@vcityio/cli 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +146 -145
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var ai=/\{[^{}]+\}/g,ci=()=>typeof process==="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function di(){return Math.random().toString(36).slice(2,11)}function ir(t){let{baseUrl:e="",Request:r=globalThis.Request,fetch:n=globalThis.fetch,querySerializer:i,bodySerializer:a,headers:s,requestInitExt:o=void 0,...c}={...t};o=ci()?o:void 0,e=xr(e);let u=[];async function l(w,v){let{baseUrl:R,fetch:T=n,Request:N=r,headers:F,params:D={},parseAs:X="json",querySerializer:L,bodySerializer:rt=a??gi,body:kt,...It}=v||{},rr=e;if(R)rr=xr(R)??e;let sr=typeof i==="function"?i:Sr(i);if(L)sr=typeof L==="function"?L:Sr({...typeof i==="object"?i:{},...L});let nr=kt===void 0?void 0:rt(kt,Or(s,F,D.header)),oi=Or(nr===void 0||nr instanceof FormData?{}:{"Content-Type":"application/json"},s,F,D.header),ii={redirect:"follow",...c,...It,body:nr,headers:oi},Jt,Ht,ft=new r(li(w,{baseUrl:rr,params:D,querySerializer:sr}),ii),W;for(let et in It)if(!(et in ft))ft[et]=It[et];if(u.length){Jt=di(),Ht=Object.freeze({baseUrl:rr,fetch:T,parseAs:X,querySerializer:sr,bodySerializer:rt});for(let et of u)if(et&&typeof et==="object"&&typeof et.onRequest==="function"){let K=await et.onRequest({request:ft,schemaPath:w,params:D,options:Ht,id:Jt});if(K)if(K instanceof r)ft=K;else if(K instanceof Response){W=K;break}else throw Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!W){try{W=await T(ft,o)}catch(et){let K=et;if(u.length)for(let jt=u.length-1;jt>=0;jt--){let Yt=u[jt];if(Yt&&typeof Yt==="object"&&typeof Yt.onError==="function"){let Pt=await Yt.onError({request:ft,error:K,schemaPath:w,params:D,options:Ht,id:Jt});if(Pt){if(Pt instanceof Response){K=void 0,W=Pt;break}if(Pt instanceof Error){K=Pt;continue}throw Error("onError: must return new Response() or instance of Error")}}}if(K)throw K}if(u.length)for(let et=u.length-1;et>=0;et--){let K=u[et];if(K&&typeof K==="object"&&typeof K.onResponse==="function"){let jt=await K.onResponse({request:ft,response:W,schemaPath:w,params:D,options:Ht,id:Jt});if(jt){if(!(jt instanceof Response))throw Error("onResponse: must return new Response() when modifying the response");W=jt}}}}if(W.status===204||ft.method==="HEAD"||W.headers.get("Content-Length")==="0")return W.ok?{data:void 0,response:W}:{error:void 0,response:W};if(W.ok){if(X==="stream")return{data:W.body,response:W};return{data:await W[X](),response:W}}let or=await W.text();try{or=JSON.parse(or)}catch{}return{error:or,response:W}}return{request(w,v,R){return l(v,{...R,method:w.toUpperCase()})},GET(w,v){return l(w,{...v,method:"GET"})},PUT(w,v){return l(w,{...v,method:"PUT"})},POST(w,v){return l(w,{...v,method:"POST"})},DELETE(w,v){return l(w,{...v,method:"DELETE"})},OPTIONS(w,v){return l(w,{...v,method:"OPTIONS"})},HEAD(w,v){return l(w,{...v,method:"HEAD"})},PATCH(w,v){return l(w,{...v,method:"PATCH"})},TRACE(w,v){return l(w,{...v,method:"TRACE"})},use(...w){for(let v of w){if(!v)continue;if(typeof v!=="object"||!(("onRequest"in v)||("onResponse"in v)||("onError"in v)))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(v)}},eject(...w){for(let v of w){let R=u.indexOf(v);if(R!==-1)u.splice(R,1)}}}}function Qt(t,e,r){if(e===void 0||e===null)return"";if(typeof e==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${r?.allowReserved===!0?e:encodeURIComponent(e)}`}function Ar(t,e,r){if(!e||typeof e!=="object")return"";let n=[],i={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let o in e)n.push(o,r.allowReserved===!0?e[o]:encodeURIComponent(e[o]));let s=n.join(",");switch(r.style){case"form":return`${t}=${s}`;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return s}}for(let s in e){let o=r.style==="deepObject"?`${t}[${s}]`:s;n.push(Qt(o,e[s],r))}let a=n.join(i);return r.style==="label"||r.style==="matrix"?`${i}${a}`:a}function Pr(t,e,r){if(!Array.isArray(e))return"";if(r.explode===!1){let a={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",s=(r.allowReserved===!0?e:e.map((o)=>encodeURIComponent(o))).join(a);switch(r.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return`${t}=${s}`}}let n={simple:",",label:".",matrix:";"}[r.style]||"&",i=[];for(let a of e)if(r.style==="simple"||r.style==="label")i.push(r.allowReserved===!0?a:encodeURIComponent(a));else i.push(Qt(t,a,r));return r.style==="label"||r.style==="matrix"?`${n}${i.join(n)}`:i.join(n)}function Sr(t){return function(r){let n=[];if(r&&typeof r==="object")for(let i in r){let a=r[i];if(a===void 0||a===null)continue;if(Array.isArray(a)){if(a.length===0)continue;n.push(Pr(i,a,{style:"form",explode:!0,...t?.array,allowReserved:t?.allowReserved||!1}));continue}if(typeof a==="object"){n.push(Ar(i,a,{style:"deepObject",explode:!0,...t?.object,allowReserved:t?.allowReserved||!1}));continue}n.push(Qt(i,a,t))}return n.join("&")}}function ui(t,e){let r=t;for(let n of t.match(ai)??[]){let i=n.substring(1,n.length-1),a=!1,s="simple";if(i.endsWith("*"))a=!0,i=i.substring(0,i.length-1);if(i.startsWith("."))s="label",i=i.substring(1);else if(i.startsWith(";"))s="matrix",i=i.substring(1);if(!e||e[i]===void 0||e[i]===null)continue;let o=e[i];if(Array.isArray(o)){r=r.replace(n,Pr(i,o,{style:s,explode:a}));continue}if(typeof o==="object"){r=r.replace(n,Ar(i,o,{style:s,explode:a}));continue}if(s==="matrix"){r=r.replace(n,`;${Qt(i,o)}`);continue}r=r.replace(n,s==="label"?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return r}function gi(t,e){if(t instanceof FormData)return t;if(e){if((e.get instanceof Function?e.get("Content-Type")??e.get("content-type"):e["Content-Type"]??e["content-type"])==="application/x-www-form-urlencoded")return new URLSearchParams(t).toString()}return JSON.stringify(t)}function li(t,e){let r=`${e.baseUrl}${t}`;if(e.params?.path)r=ui(r,e.params.path);let n=e.querySerializer(e.params.query??{});if(n.startsWith("?"))n=n.substring(1);if(n)r+=`?${n}`;return r}function Or(...t){let e=new Headers;for(let r of t){if(!r||typeof r!=="object")continue;let n=r instanceof Headers?r.entries():Object.entries(r);for(let[i,a]of n)if(a===null)e.delete(i);else if(Array.isArray(a))for(let s of a)e.append(i,s);else if(a!==void 0)e.set(i,a)}return e}function xr(t){if(t.endsWith("/"))return t.substring(0,t.length-1);return t}class ct extends Error{status;body;url;constructor(t,e,r,n){super(t);this.name="ApiClientError",this.status=e,this.body=r,this.url=n.split("?")[0]}}function d(t,e){if(t.error!==void 0&&t.error!==null){let r=t.response?.status??0,n=t.response?.url??"",i=typeof t.error==="object"&&t.error!==null&&"error"in t.error&&typeof t.error.error==="object"&&t.error.error?.message||`${e} failed (${r})`;throw new ct(String(i),r,t.error,n)}if(t.data===void 0)throw new ct(`${e}: empty response body`,t.response?.status??0,void 0,t.response?.url??"");return t.data}class Wt{client;constructor(t){this.client=t}async startUpload(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/uploads",{params:{path:{orgId:t}},body:e});return d(r,"media.startUpload")}async completeUpload(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/uploads/{fileId}",{params:{path:{orgId:t,fileId:e}}});return d(r,"media.completeUpload")}async upload(t,e,r=fetch){let n=await this.startUpload(t,{name:e.name,contentType:e.contentType,size:e.data.byteLength}),i=await r(n.uploadUrl,{method:n.method,headers:n.headers,body:e.data});if(!i.ok)throw new ct(`media.upload: storage refused the bytes (${i.status})`,i.status,void 0,n.uploadUrl);return this.completeUpload(t,n.fileId)}}class zt{client;constructor(t){this.client=t}async createProductDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/products/drafts",{params:{path:{orgId:t}}}),"drafts.createProductDraft")}async createEventDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/events/drafts",{params:{path:{orgId:t}}}),"drafts.createEventDraft")}async createBlogDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/blogs/drafts",{params:{path:{orgId:t}}}),"drafts.createBlogDraft")}async getProductForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}/edit",{params:{path:{orgId:t,productId:e}}}),"drafts.getProductForEdit")}async getEventForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}/edit",{params:{path:{orgId:t,eventId:e}}}),"drafts.getEventForEdit")}async getBlogForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}/edit",{params:{path:{orgId:t,blogId:e}}}),"drafts.getBlogForEdit")}async eventSlugAvailable(t,e,r){return d(await this.client.GET("/api/v1/orgs/{orgId}/events/slug-available",{params:{path:{orgId:t},query:{slug:e,eventId:r}}}),"drafts.eventSlugAvailable")}async getProductDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}/draft",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.getProductDraft")}async stageProductDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}/draft",{params:{path:{orgId:t,productId:e}},body:r});return d(n,"drafts.stageProductDraft")}async publishProduct(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products/{productId}/publish",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.publishProduct")}async discardProductDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products/{productId}/discard-draft",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.discardProductDraft")}async setProductVisibility(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}/visibility",{params:{path:{orgId:t,productId:e}},body:{visibility:r}});return d(n,"drafts.setProductVisibility")}async getEventDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}/draft",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.getEventDraft")}async stageEventDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}/draft",{params:{path:{orgId:t,eventId:e}},body:r});return d(n,"drafts.stageEventDraft")}async publishEvent(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events/{eventId}/publish",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.publishEvent")}async discardEventDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events/{eventId}/discard-draft",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.discardEventDraft")}async setEventVisibility(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}/visibility",{params:{path:{orgId:t,eventId:e}},body:{visibility:r}});return d(n,"drafts.setEventVisibility")}async getBlogDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}/draft",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.getBlogDraft")}async stageBlogDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/blogs/{blogId}/draft",{params:{path:{orgId:t,blogId:e}},body:r});return d(n,"drafts.stageBlogDraft")}async publishBlog(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs/{blogId}/publish",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.publishBlog")}async discardBlogDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs/{blogId}/discard-draft",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.discardBlogDraft")}}class Kt{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/coupons",{params:{path:{orgId:t},query:e}});return d(r,"coupons.list")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons",{params:{path:{orgId:t}},body:e});return d(r,"coupons.create")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/coupons/{couponId}",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/coupons/{couponId}",{params:{path:{orgId:t,couponId:e}},body:r});return d(n,"coupons.update")}async activate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/{couponId}/activate",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.activate")}async deactivate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/{couponId}/deactivate",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.deactivate")}async validate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/validate",{params:{path:{orgId:t}},body:e});return d(r,"coupons.validate")}}class Xt{client;constructor(t){this.client=t}async get(){let t=await this.client.GET("/api/v1/me",{});return d(t,"me.get")}async update(t){return d(await this.client.PATCH("/api/v1/me",{body:t}),"me.update")}async unread(){return d(await this.client.GET("/api/v1/me/unread",{}),"me.unread")}async teamChat(){return d(await this.client.GET("/api/v1/me/team-chat",{}),"me.teamChat")}}class Zt{client;constructor(t){this.client=t}async get(t){let e=await this.client.GET("/api/v1/orgs/{orgId}",{params:{path:{orgId:t}}});return d(e,"orgs.get")}async getSettings(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/settings",{params:{path:{orgId:t}}});return d(e,"orgs.getSettings")}async update(t,e){let r=await this.client.PATCH("/api/v1/orgs/{orgId}",{params:{path:{orgId:t}},body:e});return d(r,"orgs.update")}async listMembers(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/members",{params:{path:{orgId:t},query:e}});return d(r,"orgs.listMembers")}async overview(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/overview",{params:{path:{orgId:t},query:e}}),"orgs.overview")}async summary(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/summary",{params:{path:{orgId:t},query:e}}),"orgs.summary")}async attention(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/attention",{params:{path:{orgId:t}}}),"orgs.attention")}async addMember(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/members",{params:{path:{orgId:t}},body:e});return d(r,"orgs.addMember")}async setMemberRole(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/members/{uid}",{params:{path:{orgId:t,uid:e}},body:{role:r}});return d(n,"orgs.setMemberRole")}async removeMember(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/members/{uid}",{params:{path:{orgId:t,uid:e}}});return d(r,"orgs.removeMember")}async listInvitations(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/invitations",{params:{path:{orgId:t}}});return d(e,"orgs.listInvitations")}async revokeInvitation(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/invitations/{invitationId}",{params:{path:{orgId:t,invitationId:e}}});return d(r,"orgs.revokeInvitation")}async resendInvitation(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/invitations/{invitationId}/resend",{params:{path:{orgId:t,invitationId:e}}});return d(r,"orgs.resendInvitation")}}class te{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/products",{params:{path:{orgId:t},query:e}});return d(r,"products.list")}async get(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e},query:r}});return d(n,"products.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products",{params:{path:{orgId:t}},body:e});return d(r,"products.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e}},body:r});return d(n,"products.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e}}});return d(r,"products.delete")}}class ee{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/events",{params:{path:{orgId:t},query:e}});return d(r,"events.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}}});return d(r,"events.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events",{params:{path:{orgId:t}},body:e});return d(r,"events.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}},body:r});return d(n,"events.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}}});return d(r,"events.delete")}}class re{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/rooms",{params:{path:{orgId:t},query:e}});return d(r,"rooms.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}}});return d(r,"rooms.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/rooms",{params:{path:{orgId:t}},body:e});return d(r,"rooms.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}},body:r});return d(n,"rooms.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}}});return d(r,"rooms.delete")}}class se{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings",{params:{path:{orgId:t},query:e}});return d(r,"bookings.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}}});return d(r,"bookings.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/bookings",{params:{path:{orgId:t}},body:e});return d(r,"bookings.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}},body:r});return d(n,"bookings.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}}});return d(r,"bookings.delete")}async slots(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/slots",{params:{path:{orgId:t},query:e}});return d(r,"bookings.slots")}async listUnavailability(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/unavailability",{params:{path:{orgId:t},query:e}});return d(r,"bookings.listUnavailability")}async addUnavailability(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/bookings/unavailability",{params:{path:{orgId:t}},body:e});return d(r,"bookings.addUnavailability")}async removeUnavailability(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/bookings/unavailability/{unavailabilityId}",{params:{path:{orgId:t,unavailabilityId:e}}});return d(r,"bookings.removeUnavailability")}async getMemberHours(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/member-hours/{uid}",{params:{path:{orgId:t,uid:e}}});return d(r,"bookings.getMemberHours")}async setMemberHours(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/bookings/member-hours/{uid}",{params:{path:{orgId:t,uid:e}},body:r});return d(n,"bookings.setMemberHours")}}class ne{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/projects",{params:{path:{orgId:t},query:e}});return d(r,"projects.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}}});return d(r,"projects.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/projects",{params:{path:{orgId:t}},body:e});return d(r,"projects.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}},body:r});return d(n,"projects.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}}});return d(r,"projects.delete")}async listCards(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards",{params:{path:{orgId:t,projectId:e},query:r}});return d(n,"projects.listCards")}async getCard(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.getCard")}async createCard(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards",{params:{path:{orgId:t,projectId:e}},body:r});return d(n,"projects.createCard")}async updateCard(t,e,r,n){let i=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.updateCard")}async moveCard(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/move",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.moveCard")}async deleteCard(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.deleteCard")}async listCardComments(t,e,r,n={}){let i=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments",{params:{path:{orgId:t,projectId:e,cardId:r},query:n}});return d(i,"projects.listCardComments")}async createCardComment(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.createCardComment")}async updateCardComment(t,e,r,n,i){let a=await this.client.PATCH("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments/{commentId}",{params:{path:{orgId:t,projectId:e,cardId:r,commentId:n}},body:i});return d(a,"projects.updateCardComment")}async deleteCardComment(t,e,r,n){let i=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments/{commentId}",{params:{path:{orgId:t,projectId:e,cardId:r,commentId:n}}});return d(i,"projects.deleteCardComment")}async listCardLinks(t,e,r,n={}){let i=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/links",{params:{path:{orgId:t,projectId:e,cardId:r},query:n}});return d(i,"projects.listCardLinks")}async getCardWatch(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.getCardWatch")}async watchCard(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.watchCard")}async unwatchCard(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.unwatchCard")}}class oe{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs",{params:{path:{orgId:t},query:e}});return d(r,"blogs.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}}});return d(r,"blogs.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs",{params:{path:{orgId:t}},body:e});return d(r,"blogs.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}},body:r});return d(n,"blogs.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}}});return d(r,"blogs.delete")}}class ie{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/booking-types",{params:{path:{orgId:t},query:e}});return d(r,"bookingTypes.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}}});return d(r,"bookingTypes.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/booking-types",{params:{path:{orgId:t}},body:e});return d(r,"bookingTypes.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}},body:r});return d(n,"bookingTypes.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}}});return d(r,"bookingTypes.delete")}}class ae{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/orders",{params:{path:{orgId:t},query:e}});return d(r,"orders.list")}async listLineItems(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/line-items",{params:{path:{orgId:t},query:e}});return d(r,"orders.listLineItems")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/orders/{orderId}",{params:{path:{orgId:t,orderId:e}}});return d(r,"orders.get")}async updateLineItemShipping(t,e,r,n){let i=await this.client.PATCH("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}",{params:{path:{orgId:t,orderId:e,lineItemId:r}},body:n});return d(i,"orders.updateLineItemShipping")}async listLineItemComments(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}/comments",{params:{path:{orgId:t,orderId:e,lineItemId:r}}});return d(n,"orders.listLineItemComments")}async commentLineItem(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}/comments",{params:{path:{orgId:t,orderId:e,lineItemId:r}},body:n});return d(i,"orders.commentLineItem")}async breakdown(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/orders/breakdown",{params:{path:{orgId:t}},body:e});return d(r,"orders.breakdown")}}class ce{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/quotes",{params:{path:{orgId:t},query:e}});return d(r,"quotes.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}}});return d(r,"quotes.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/quotes",{params:{path:{orgId:t}},body:e});return d(r,"quotes.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}},body:r});return d(n,"quotes.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}}});return d(r,"quotes.delete")}}class de{client;constructor(t){this.client=t}async summary(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/summary",{params:{path:{orgId:t},query:e}});return d(r,"analytics.summary")}async overview(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/overview",{params:{path:{orgId:t},query:e}});return d(r,"analytics.overview")}async visits(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/visits",{params:{path:{orgId:t},query:e}});return d(r,"analytics.visits")}async topProducts(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/products/top",{params:{path:{orgId:t},query:e}});return d(r,"analytics.topProducts")}}class ue{client;constructor(t){this.client=t}async list(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/collections",{params:{path:{orgId:t}}});return d(e,"collections.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}}});return d(r,"collections.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/collections",{params:{path:{orgId:t}},body:e});return d(r,"collections.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}},body:r});return d(n,"collections.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}}});return d(r,"collections.delete")}}class ge{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents",{params:{path:{orgId:t},query:e}});return d(r,"agents.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/{agentId}",{params:{path:{orgId:t,agentId:e}}});return d(r,"agents.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/agents/{agentId}",{params:{path:{orgId:t,agentId:e}},body:r});return d(n,"agents.update")}async run(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/{agentId}/run",{params:{path:{orgId:t,agentId:e}}});return d(r,"agents.run")}async listRuns(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/runs",{params:{path:{orgId:t},query:e}});return d(r,"agents.listRuns")}async getRun(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/runs/{runId}",{params:{path:{orgId:t,runId:e}}});return d(r,"agents.getRun")}async cancelRun(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/runs/{runId}/cancel",{params:{path:{orgId:t,runId:e}}});return d(r,"agents.cancelRun")}async listProposals(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/proposals",{params:{path:{orgId:t},query:e}});return d(r,"agents.listProposals")}async approveProposal(t,e,r={}){let n=await this.client.POST("/api/v1/orgs/{orgId}/agents/proposals/{proposalId}/approve",{params:{path:{orgId:t,proposalId:e}},body:r});return d(n,"agents.approveProposal")}async rejectProposal(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/proposals/{proposalId}/reject",{params:{path:{orgId:t,proposalId:e}}});return d(r,"agents.rejectProposal")}}class le{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/conversations",{params:{path:{orgId:t},query:e}});return d(r,"conversations.list")}async get(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/conversations/{conversationId}",{params:{path:{orgId:t,conversationId:e},query:r}});return d(n,"conversations.get")}}class pe{client;constructor(t){this.client=t}async get(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/customer-agent",{params:{path:{orgId:t}}});return d(e,"customerAgent.get")}async listKnowledge(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/customer-agent/knowledge",{params:{path:{orgId:t}}});return d(e,"customerAgent.listKnowledge")}}class me{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts",{params:{path:{orgId:t},query:e}});return d(r,"posts.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts/{postId}",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.get")}async createDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts",{params:{path:{orgId:t}},body:e});return d(r,"posts.createDraft")}async requestVideoUpload(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/video",{params:{path:{orgId:t,postId:e}},body:{bytes:r}});return d(n,"posts.requestVideoUpload")}async finalizeVideo(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/video/finalize",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.finalizeVideo")}async videoPreview(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts/{postId}/video/preview",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.videoPreview")}async publish(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/publish",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.publish")}}class fe{client;constructor(t){this.client=t}async list(t={}){return d(await this.client.GET("/api/v1/notifications",{params:{query:t}}),"notifications.list")}async markRead(t){return d(await this.client.POST("/api/v1/notifications/read",{body:t}),"notifications.markRead")}}class ye{client;constructor(t){this.client=t}async latest(){return d(await this.client.GET("/api/v1/desk/latest",{}),"desk.latest")}async downloadUrl(t){let{response:e}=await this.client.GET("/api/v1/desk/download",{params:{query:{os:t}},parseAs:"stream",redirect:"manual"}),r=e.headers.get("Location");if(r)return new URL(r,e.url||"https://vcity.io").toString();if(e.ok&&e.url)return e.url;throw new ct(`desk.downloadUrl failed (${e.status})`,e.status,void 0,e.url)}}class he{client;constructor(t){this.client=t}async listTickets(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/tickets",{params:{path:{orgId:t},query:e}}),"support.listTickets")}async getTicket(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/tickets/{ticketId}",{params:{path:{orgId:t,ticketId:e}}}),"support.getTicket")}async updateTicket(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/support/tickets/{ticketId}",{params:{path:{orgId:t,ticketId:e}},body:r}),"support.updateTicket")}async stats(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/stats",{params:{path:{orgId:t}}}),"support.stats")}}class we{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/api-keys",{params:{path:{orgId:t},query:e}}),"apiKeys.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/api-keys",{params:{path:{orgId:t}},body:e}),"apiKeys.create")}async revoke(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/api-keys/{keyId}",{params:{path:{orgId:t,keyId:e}}}),"apiKeys.revoke")}async rotate(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/api-keys/{keyId}/rotate",{params:{path:{orgId:t,keyId:e}}}),"apiKeys.rotate")}}class ve{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns",{params:{path:{orgId:t},query:e}});return d(r,"campaigns.list")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns",{params:{path:{orgId:t}},body:e});return d(r,"campaigns.create")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}},body:r});return d(n,"campaigns.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.delete")}async activate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/activate",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.activate")}async pause(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/pause",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.pause")}async stats(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}/stats",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.stats")}async listContacts(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts",{params:{path:{orgId:t,campaignId:e},query:r}});return d(n,"campaigns.listContacts")}async addContacts(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts",{params:{path:{orgId:t,campaignId:e}},body:r});return d(n,"campaigns.addContacts")}async removeContact(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts/{contactId}",{params:{path:{orgId:t,campaignId:e,contactId:r}}});return d(n,"campaigns.removeContact")}}class be{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/comments",{params:{query:t}}),"comments.list")}async create(t){return d(await this.client.POST("/api/v1/comments",{body:t}),"comments.create")}async edit(t,e){return d(await this.client.PATCH("/api/v1/comments/{commentId}",{params:{path:{commentId:t}},body:{content:e}}),"comments.edit")}async delete(t){return d(await this.client.DELETE("/api/v1/comments/{commentId}",{params:{path:{commentId:t}}}),"comments.delete")}async pin(t){return d(await this.client.PUT("/api/v1/comments/{commentId}/pin",{params:{path:{commentId:t}}}),"comments.pin")}async unpin(t){return d(await this.client.DELETE("/api/v1/comments/{commentId}/pin",{params:{path:{commentId:t}}}),"comments.unpin")}async reactions(t){return d(await this.client.GET("/api/v1/reactions",{params:{query:{target:t}}}),"comments.reactions")}async react(t){return d(await this.client.PUT("/api/v1/reactions",{body:t}),"comments.react")}}class ke{client;constructor(t){this.client=t}async getConfig(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter",{params:{path:{orgId:t}}}),"newsletter.getConfig")}async saveSettings(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/newsletter",{params:{path:{orgId:t}},body:e}),"newsletter.saveSettings")}async publicConfig(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/public-config",{params:{path:{orgId:t}}}),"newsletter.publicConfig")}async subscribers(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/subscribers",{params:{path:{orgId:t},query:e}}),"newsletter.subscribers")}async stats(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/stats",{params:{path:{orgId:t},query:e}}),"newsletter.stats")}}class Ie{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys",{params:{path:{orgId:t},query:e}}),"surveys.list")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}}}),"surveys.get")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys",{params:{path:{orgId:t}},body:e}),"surveys.create")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}},body:r}),"surveys.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}}}),"surveys.delete")}async publish(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys/{surveyId}/publish",{params:{path:{orgId:t,surveyId:e}}}),"surveys.publish")}async close(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys/{surveyId}/close",{params:{path:{orgId:t,surveyId:e}}}),"surveys.close")}async responses(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys/{surveyId}/responses",{params:{path:{orgId:t,surveyId:e},query:r}}),"surveys.responses")}}class je{client;constructor(t){this.client=t}async get(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/storefront",{params:{path:{orgId:t}}}),"storefront.get")}async update(t,e){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/storefront",{params:{path:{orgId:t}},body:e}),"storefront.update")}async setDomain(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/storefront/domain",{params:{path:{orgId:t}},body:{domain:e}}),"storefront.setDomain")}async removeDomain(t){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/storefront/domain",{params:{path:{orgId:t}}}),"storefront.removeDomain")}async verifyDomain(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/storefront/domain/verify",{params:{path:{orgId:t}}}),"storefront.verifyDomain")}async redirects(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/storefront/redirects",{params:{path:{orgId:t}}}),"storefront.redirects")}async setRedirects(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/storefront/redirects",{params:{path:{orgId:t}},body:{redirects:e}}),"storefront.setRedirects")}async previewShopifyRedirects(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/storefront/redirects/shopify-preview",{params:{path:{orgId:t}},body:{csv:e}}),"storefront.previewShopifyRedirects")}}class Te{client;constructor(t){this.client=t}async summary(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing",{params:{path:{orgId:t}}}),"billing.summary")}async invoices(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/invoices",{params:{path:{orgId:t},query:e}}),"billing.invoices")}async usage(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/usage",{params:{path:{orgId:t}}}),"billing.usage")}async credits(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/credits",{params:{path:{orgId:t},query:e}}),"billing.credits")}}class Ee{client;constructor(t){this.client=t}async store(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}",{params:{path:{storeId:t}}}),"public.store")}async rooms(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}/rooms",{params:{path:{storeId:t}}}),"public.rooms")}async blogs(t,e={}){return d(await this.client.GET("/api/v1/public/stores/{storeId}/blogs",{params:{path:{storeId:t},query:e}}),"public.blogs")}async newsletter(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}/newsletter",{params:{path:{storeId:t}}}),"public.newsletter")}async radioStations(){return d(await this.client.GET("/api/v1/public/radio-stations",{}),"public.radioStations")}async storeRadioStations(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/radio-stations",{params:{path:{orgId:t}}}),"public.storeRadioStations")}}class Re{client;constructor(t){this.client=t}async get(t){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}",{params:{path:{roomId:t}}}),"chatRooms.get")}async messages(t,e={}){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/messages",{params:{path:{roomId:t},query:e}}),"chatRooms.messages")}async send(t,e){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/messages",{params:{path:{roomId:t}},body:e}),"chatRooms.send")}async edit(t,e,r){return d(await this.client.PATCH("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}",{params:{path:{roomId:t,messageId:e}},body:{content:r}}),"chatRooms.edit")}async delete(t,e){return d(await this.client.DELETE("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}",{params:{path:{roomId:t,messageId:e}}}),"chatRooms.delete")}async reactions(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:{roomId:t,messageId:e}}}),"chatRooms.reactions")}async react(t,e,r,n="add"){return d(await this.client.PUT("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:{roomId:t,messageId:e}},body:{emoji:r,action:n}}),"chatRooms.react")}async markRead(t){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/read",{params:{path:{roomId:t}}}),"chatRooms.markRead")}async search(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/search",{params:{path:{roomId:t},query:{q:e}}}),"chatRooms.search")}async list(t){let e=t?.length?{kind:t.join(",")}:{};return d(await this.client.GET("/api/v1/me/chat/rooms",{params:{query:e}}),"chatRooms.list")}async polls(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/polls",{params:{path:{roomId:t},query:{messageIds:e.join(",")}}}),"chatRooms.polls")}async createPoll(t,e){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/polls",{params:{path:{roomId:t}},body:e}),"chatRooms.createPoll")}async vote(t,e,r){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/polls/{messageId}",{params:{path:{roomId:t,messageId:e}},body:{optionId:r}}),"chatRooms.vote")}async linkPreview(t){return d(await this.client.GET("/api/v1/link-preview",{params:{query:{url:t}}}),"chatRooms.linkPreview")}}class Ce{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators",{params:{path:{orgId:t}}}),"configurators.list")}async seeds(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators/seeds",{params:{path:{orgId:t}}}),"configurators.seeds")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/configurators",{params:{path:{orgId:t}},body:e}),"configurators.create")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}}}),"configurators.get")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}},body:r}),"configurators.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}}}),"configurators.delete")}}class Se{client;constructor(t){this.client=t}async activeSession(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/session",{params:{path:{orgId:t}}}),"pos.activeSession")}async openSession(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sessions",{params:{path:{orgId:t}},body:e}),"pos.openSession")}async closeSession(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sessions/{sessionId}/close",{params:{path:{orgId:t,sessionId:e}},body:r}),"pos.closeSession")}async sessionSummary(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sessions/{sessionId}/summary",{params:{path:{orgId:t,sessionId:e}}}),"pos.sessionSummary")}async sales(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sales",{params:{path:{orgId:t},query:e}}),"pos.sales")}async createSale(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sales",{params:{path:{orgId:t}},body:e,...r?{headers:{"Idempotency-Key":r}}:{}}),"pos.createSale")}async sale(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sales/{saleId}",{params:{path:{orgId:t,saleId:e}}}),"pos.sale")}async favorites(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/favorites",{params:{path:{orgId:t}}}),"pos.favorites")}async setFavorites(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/pos/favorites",{params:{path:{orgId:t}},body:{productIds:e}}),"pos.setFavorites")}}class Oe{client;constructor(t){this.client=t}async connections(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/connections",{params:{path:{orgId:t}}}),"dropshipping.connections")}async products(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/products",{params:{path:{orgId:t},query:e}}),"dropshipping.products")}async import(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/dropshipping/imports",{params:{path:{orgId:t}},body:e}),"dropshipping.import")}async fulfillments(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/fulfillments",{params:{path:{orgId:t},query:{orderId:e}}}),"dropshipping.fulfillments")}async retryFulfillment(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/dropshipping/fulfillments/{fulfillmentId}/retry",{params:{path:{orgId:t,fulfillmentId:e}}}),"dropshipping.retryFulfillment")}}class xe{client;constructor(t){this.client=t}async openConversation(t,e={}){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/conversations",{params:{path:{orgId:t}},body:e}),"assistant.openConversation")}async*turn(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/assistant/conversations/{conversationId}/turns",{params:{path:{orgId:t,conversationId:e}},body:r,parseAs:"stream"}),i=d(n,"assistant.turn");if(!i)return;let a=i.getReader(),s=new TextDecoder,o="";for(;;){let{value:c,done:u}=await a.read();if(u)break;o+=s.decode(c,{stream:!0});let l=o.indexOf(`
|
|
2
|
+
var di=/\{[^{}]+\}/g,ui=()=>typeof process==="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function gi(){return Math.random().toString(36).slice(2,11)}function ir(t){let{baseUrl:e="",Request:r=globalThis.Request,fetch:n=globalThis.fetch,querySerializer:i,bodySerializer:a,headers:s,requestInitExt:o=void 0,...c}={...t};o=ui()?o:void 0,e=xr(e);let u=[];async function p(w,v){let{baseUrl:R,fetch:E=n,Request:N=r,headers:F,params:D={},parseAs:X="json",querySerializer:L,bodySerializer:rt=a??pi,body:kt,...It}=v||{},rr=e;if(R)rr=xr(R)??e;let sr=typeof i==="function"?i:Sr(i);if(L)sr=typeof L==="function"?L:Sr({...typeof i==="object"?i:{},...L});let nr=kt===void 0?void 0:rt(kt,Or(s,F,D.header)),ai=Or(nr===void 0||nr instanceof FormData?{}:{"Content-Type":"application/json"},s,F,D.header),ci={redirect:"follow",...c,...It,body:nr,headers:ai},Jt,Ht,ft=new r(mi(w,{baseUrl:rr,params:D,querySerializer:sr}),ci),W;for(let et in It)if(!(et in ft))ft[et]=It[et];if(u.length){Jt=gi(),Ht=Object.freeze({baseUrl:rr,fetch:E,parseAs:X,querySerializer:sr,bodySerializer:rt});for(let et of u)if(et&&typeof et==="object"&&typeof et.onRequest==="function"){let K=await et.onRequest({request:ft,schemaPath:w,params:D,options:Ht,id:Jt});if(K)if(K instanceof r)ft=K;else if(K instanceof Response){W=K;break}else throw Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!W){try{W=await E(ft,o)}catch(et){let K=et;if(u.length)for(let jt=u.length-1;jt>=0;jt--){let Yt=u[jt];if(Yt&&typeof Yt==="object"&&typeof Yt.onError==="function"){let Pt=await Yt.onError({request:ft,error:K,schemaPath:w,params:D,options:Ht,id:Jt});if(Pt){if(Pt instanceof Response){K=void 0,W=Pt;break}if(Pt instanceof Error){K=Pt;continue}throw Error("onError: must return new Response() or instance of Error")}}}if(K)throw K}if(u.length)for(let et=u.length-1;et>=0;et--){let K=u[et];if(K&&typeof K==="object"&&typeof K.onResponse==="function"){let jt=await K.onResponse({request:ft,response:W,schemaPath:w,params:D,options:Ht,id:Jt});if(jt){if(!(jt instanceof Response))throw Error("onResponse: must return new Response() when modifying the response");W=jt}}}}if(W.status===204||ft.method==="HEAD"||W.headers.get("Content-Length")==="0")return W.ok?{data:void 0,response:W}:{error:void 0,response:W};if(W.ok){if(X==="stream")return{data:W.body,response:W};return{data:await W[X](),response:W}}let or=await W.text();try{or=JSON.parse(or)}catch{}return{error:or,response:W}}return{request(w,v,R){return p(v,{...R,method:w.toUpperCase()})},GET(w,v){return p(w,{...v,method:"GET"})},PUT(w,v){return p(w,{...v,method:"PUT"})},POST(w,v){return p(w,{...v,method:"POST"})},DELETE(w,v){return p(w,{...v,method:"DELETE"})},OPTIONS(w,v){return p(w,{...v,method:"OPTIONS"})},HEAD(w,v){return p(w,{...v,method:"HEAD"})},PATCH(w,v){return p(w,{...v,method:"PATCH"})},TRACE(w,v){return p(w,{...v,method:"TRACE"})},use(...w){for(let v of w){if(!v)continue;if(typeof v!=="object"||!(("onRequest"in v)||("onResponse"in v)||("onError"in v)))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(v)}},eject(...w){for(let v of w){let R=u.indexOf(v);if(R!==-1)u.splice(R,1)}}}}function Qt(t,e,r){if(e===void 0||e===null)return"";if(typeof e==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${r?.allowReserved===!0?e:encodeURIComponent(e)}`}function Ar(t,e,r){if(!e||typeof e!=="object")return"";let n=[],i={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let o in e)n.push(o,r.allowReserved===!0?e[o]:encodeURIComponent(e[o]));let s=n.join(",");switch(r.style){case"form":return`${t}=${s}`;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return s}}for(let s in e){let o=r.style==="deepObject"?`${t}[${s}]`:s;n.push(Qt(o,e[s],r))}let a=n.join(i);return r.style==="label"||r.style==="matrix"?`${i}${a}`:a}function Pr(t,e,r){if(!Array.isArray(e))return"";if(r.explode===!1){let a={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",s=(r.allowReserved===!0?e:e.map((o)=>encodeURIComponent(o))).join(a);switch(r.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return`${t}=${s}`}}let n={simple:",",label:".",matrix:";"}[r.style]||"&",i=[];for(let a of e)if(r.style==="simple"||r.style==="label")i.push(r.allowReserved===!0?a:encodeURIComponent(a));else i.push(Qt(t,a,r));return r.style==="label"||r.style==="matrix"?`${n}${i.join(n)}`:i.join(n)}function Sr(t){return function(r){let n=[];if(r&&typeof r==="object")for(let i in r){let a=r[i];if(a===void 0||a===null)continue;if(Array.isArray(a)){if(a.length===0)continue;n.push(Pr(i,a,{style:"form",explode:!0,...t?.array,allowReserved:t?.allowReserved||!1}));continue}if(typeof a==="object"){n.push(Ar(i,a,{style:"deepObject",explode:!0,...t?.object,allowReserved:t?.allowReserved||!1}));continue}n.push(Qt(i,a,t))}return n.join("&")}}function li(t,e){let r=t;for(let n of t.match(di)??[]){let i=n.substring(1,n.length-1),a=!1,s="simple";if(i.endsWith("*"))a=!0,i=i.substring(0,i.length-1);if(i.startsWith("."))s="label",i=i.substring(1);else if(i.startsWith(";"))s="matrix",i=i.substring(1);if(!e||e[i]===void 0||e[i]===null)continue;let o=e[i];if(Array.isArray(o)){r=r.replace(n,Pr(i,o,{style:s,explode:a}));continue}if(typeof o==="object"){r=r.replace(n,Ar(i,o,{style:s,explode:a}));continue}if(s==="matrix"){r=r.replace(n,`;${Qt(i,o)}`);continue}r=r.replace(n,s==="label"?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return r}function pi(t,e){if(t instanceof FormData)return t;if(e){if((e.get instanceof Function?e.get("Content-Type")??e.get("content-type"):e["Content-Type"]??e["content-type"])==="application/x-www-form-urlencoded")return new URLSearchParams(t).toString()}return JSON.stringify(t)}function mi(t,e){let r=`${e.baseUrl}${t}`;if(e.params?.path)r=li(r,e.params.path);let n=e.querySerializer(e.params.query??{});if(n.startsWith("?"))n=n.substring(1);if(n)r+=`?${n}`;return r}function Or(...t){let e=new Headers;for(let r of t){if(!r||typeof r!=="object")continue;let n=r instanceof Headers?r.entries():Object.entries(r);for(let[i,a]of n)if(a===null)e.delete(i);else if(Array.isArray(a))for(let s of a)e.append(i,s);else if(a!==void 0)e.set(i,a)}return e}function xr(t){if(t.endsWith("/"))return t.substring(0,t.length-1);return t}class ct extends Error{status;body;url;constructor(t,e,r,n){super(t);this.name="ApiClientError",this.status=e,this.body=r,this.url=n.split("?")[0]}}function d(t,e){if(t.error!==void 0&&t.error!==null){let r=t.response?.status??0,n=t.response?.url??"",i=typeof t.error==="object"&&t.error!==null&&"error"in t.error&&typeof t.error.error==="object"&&t.error.error?.message||`${e} failed (${r})`;throw new ct(String(i),r,t.error,n)}if(t.data===void 0)throw new ct(`${e}: empty response body`,t.response?.status??0,void 0,t.response?.url??"");return t.data}class Wt{client;constructor(t){this.client=t}async startUpload(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/uploads",{params:{path:{orgId:t}},body:e});return d(r,"media.startUpload")}async completeUpload(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/uploads/{fileId}",{params:{path:{orgId:t,fileId:e}}});return d(r,"media.completeUpload")}async upload(t,e,r=fetch){let n=await this.startUpload(t,{name:e.name,contentType:e.contentType,size:e.data.byteLength}),i=await r(n.uploadUrl,{method:n.method,headers:n.headers,body:e.data});if(!i.ok)throw new ct(`media.upload: storage refused the bytes (${i.status})`,i.status,void 0,n.uploadUrl);return this.completeUpload(t,n.fileId)}}class zt{client;constructor(t){this.client=t}async createProductDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/products/drafts",{params:{path:{orgId:t}}}),"drafts.createProductDraft")}async createEventDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/events/drafts",{params:{path:{orgId:t}}}),"drafts.createEventDraft")}async createBlogDraft(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/blogs/drafts",{params:{path:{orgId:t}}}),"drafts.createBlogDraft")}async getProductForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}/edit",{params:{path:{orgId:t,productId:e}}}),"drafts.getProductForEdit")}async getEventForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}/edit",{params:{path:{orgId:t,eventId:e}}}),"drafts.getEventForEdit")}async getBlogForEdit(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}/edit",{params:{path:{orgId:t,blogId:e}}}),"drafts.getBlogForEdit")}async eventSlugAvailable(t,e,r){return d(await this.client.GET("/api/v1/orgs/{orgId}/events/slug-available",{params:{path:{orgId:t},query:{slug:e,eventId:r}}}),"drafts.eventSlugAvailable")}async getProductDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}/draft",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.getProductDraft")}async stageProductDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}/draft",{params:{path:{orgId:t,productId:e}},body:r});return d(n,"drafts.stageProductDraft")}async publishProduct(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products/{productId}/publish",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.publishProduct")}async discardProductDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products/{productId}/discard-draft",{params:{path:{orgId:t,productId:e}}});return d(r,"drafts.discardProductDraft")}async setProductVisibility(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}/visibility",{params:{path:{orgId:t,productId:e}},body:{visibility:r}});return d(n,"drafts.setProductVisibility")}async getEventDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}/draft",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.getEventDraft")}async stageEventDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}/draft",{params:{path:{orgId:t,eventId:e}},body:r});return d(n,"drafts.stageEventDraft")}async publishEvent(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events/{eventId}/publish",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.publishEvent")}async discardEventDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events/{eventId}/discard-draft",{params:{path:{orgId:t,eventId:e}}});return d(r,"drafts.discardEventDraft")}async setEventVisibility(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}/visibility",{params:{path:{orgId:t,eventId:e}},body:{visibility:r}});return d(n,"drafts.setEventVisibility")}async getBlogDraft(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}/draft",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.getBlogDraft")}async stageBlogDraft(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/blogs/{blogId}/draft",{params:{path:{orgId:t,blogId:e}},body:r});return d(n,"drafts.stageBlogDraft")}async publishBlog(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs/{blogId}/publish",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.publishBlog")}async discardBlogDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs/{blogId}/discard-draft",{params:{path:{orgId:t,blogId:e}}});return d(r,"drafts.discardBlogDraft")}}class Kt{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/coupons",{params:{path:{orgId:t},query:e}});return d(r,"coupons.list")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons",{params:{path:{orgId:t}},body:e});return d(r,"coupons.create")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/coupons/{couponId}",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/coupons/{couponId}",{params:{path:{orgId:t,couponId:e}},body:r});return d(n,"coupons.update")}async activate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/{couponId}/activate",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.activate")}async deactivate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/{couponId}/deactivate",{params:{path:{orgId:t,couponId:e}}});return d(r,"coupons.deactivate")}async validate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/coupons/validate",{params:{path:{orgId:t}},body:e});return d(r,"coupons.validate")}}class Xt{client;constructor(t){this.client=t}async get(){let t=await this.client.GET("/api/v1/me",{});return d(t,"me.get")}async update(t){return d(await this.client.PATCH("/api/v1/me",{body:t}),"me.update")}async unread(){return d(await this.client.GET("/api/v1/me/unread",{}),"me.unread")}async teamChat(){return d(await this.client.GET("/api/v1/me/team-chat",{}),"me.teamChat")}}class Zt{client;constructor(t){this.client=t}async get(t){let e=await this.client.GET("/api/v1/orgs/{orgId}",{params:{path:{orgId:t}}});return d(e,"orgs.get")}async getSettings(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/settings",{params:{path:{orgId:t}}});return d(e,"orgs.getSettings")}async update(t,e){let r=await this.client.PATCH("/api/v1/orgs/{orgId}",{params:{path:{orgId:t}},body:e});return d(r,"orgs.update")}async listMembers(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/members",{params:{path:{orgId:t},query:e}});return d(r,"orgs.listMembers")}async overview(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/overview",{params:{path:{orgId:t},query:e}}),"orgs.overview")}async summary(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/summary",{params:{path:{orgId:t},query:e}}),"orgs.summary")}async attention(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/attention",{params:{path:{orgId:t}}}),"orgs.attention")}async addMember(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/members",{params:{path:{orgId:t}},body:e});return d(r,"orgs.addMember")}async setMemberRole(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/members/{uid}",{params:{path:{orgId:t,uid:e}},body:{role:r}});return d(n,"orgs.setMemberRole")}async removeMember(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/members/{uid}",{params:{path:{orgId:t,uid:e}}});return d(r,"orgs.removeMember")}async listInvitations(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/invitations",{params:{path:{orgId:t}}});return d(e,"orgs.listInvitations")}async revokeInvitation(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/invitations/{invitationId}",{params:{path:{orgId:t,invitationId:e}}});return d(r,"orgs.revokeInvitation")}async resendInvitation(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/invitations/{invitationId}/resend",{params:{path:{orgId:t,invitationId:e}}});return d(r,"orgs.resendInvitation")}}class te{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/products",{params:{path:{orgId:t},query:e}});return d(r,"products.list")}async get(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e},query:r}});return d(n,"products.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/products",{params:{path:{orgId:t}},body:e});return d(r,"products.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e}},body:r});return d(n,"products.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/products/{productId}",{params:{path:{orgId:t,productId:e}}});return d(r,"products.delete")}}class ee{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/events",{params:{path:{orgId:t},query:e}});return d(r,"events.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}}});return d(r,"events.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/events",{params:{path:{orgId:t}},body:e});return d(r,"events.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}},body:r});return d(n,"events.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/events/{eventId}",{params:{path:{orgId:t,eventId:e}}});return d(r,"events.delete")}}class re{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/rooms",{params:{path:{orgId:t},query:e}});return d(r,"rooms.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}}});return d(r,"rooms.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/rooms",{params:{path:{orgId:t}},body:e});return d(r,"rooms.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}},body:r});return d(n,"rooms.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/rooms/{roomId}",{params:{path:{orgId:t,roomId:e}}});return d(r,"rooms.delete")}}class se{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings",{params:{path:{orgId:t},query:e}});return d(r,"bookings.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}}});return d(r,"bookings.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/bookings",{params:{path:{orgId:t}},body:e});return d(r,"bookings.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}},body:r});return d(n,"bookings.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/bookings/{bookingId}",{params:{path:{orgId:t,bookingId:e}}});return d(r,"bookings.delete")}async slots(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/slots",{params:{path:{orgId:t},query:e}});return d(r,"bookings.slots")}async listUnavailability(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/unavailability",{params:{path:{orgId:t},query:e}});return d(r,"bookings.listUnavailability")}async addUnavailability(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/bookings/unavailability",{params:{path:{orgId:t}},body:e});return d(r,"bookings.addUnavailability")}async removeUnavailability(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/bookings/unavailability/{unavailabilityId}",{params:{path:{orgId:t,unavailabilityId:e}}});return d(r,"bookings.removeUnavailability")}async getMemberHours(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/bookings/member-hours/{uid}",{params:{path:{orgId:t,uid:e}}});return d(r,"bookings.getMemberHours")}async setMemberHours(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/bookings/member-hours/{uid}",{params:{path:{orgId:t,uid:e}},body:r});return d(n,"bookings.setMemberHours")}}class ne{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/projects",{params:{path:{orgId:t},query:e}});return d(r,"projects.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}}});return d(r,"projects.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/projects",{params:{path:{orgId:t}},body:e});return d(r,"projects.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}},body:r});return d(n,"projects.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}",{params:{path:{orgId:t,projectId:e}}});return d(r,"projects.delete")}async listCards(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards",{params:{path:{orgId:t,projectId:e},query:r}});return d(n,"projects.listCards")}async getCard(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.getCard")}async createCard(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards",{params:{path:{orgId:t,projectId:e}},body:r});return d(n,"projects.createCard")}async updateCard(t,e,r,n){let i=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.updateCard")}async moveCard(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/move",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.moveCard")}async deleteCard(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.deleteCard")}async listCardComments(t,e,r,n={}){let i=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments",{params:{path:{orgId:t,projectId:e,cardId:r},query:n}});return d(i,"projects.listCardComments")}async createCardComment(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments",{params:{path:{orgId:t,projectId:e,cardId:r}},body:n});return d(i,"projects.createCardComment")}async updateCardComment(t,e,r,n,i){let a=await this.client.PATCH("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments/{commentId}",{params:{path:{orgId:t,projectId:e,cardId:r,commentId:n}},body:i});return d(a,"projects.updateCardComment")}async deleteCardComment(t,e,r,n){let i=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/comments/{commentId}",{params:{path:{orgId:t,projectId:e,cardId:r,commentId:n}}});return d(i,"projects.deleteCardComment")}async listCardLinks(t,e,r,n={}){let i=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/links",{params:{path:{orgId:t,projectId:e,cardId:r},query:n}});return d(i,"projects.listCardLinks")}async getCardWatch(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.getCardWatch")}async watchCard(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.watchCard")}async unwatchCard(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/projects/{projectId}/cards/{cardId}/watch",{params:{path:{orgId:t,projectId:e,cardId:r}}});return d(n,"projects.unwatchCard")}}class oe{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs",{params:{path:{orgId:t},query:e}});return d(r,"blogs.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}}});return d(r,"blogs.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/blogs",{params:{path:{orgId:t}},body:e});return d(r,"blogs.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}},body:r});return d(n,"blogs.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/blogs/{blogId}",{params:{path:{orgId:t,blogId:e}}});return d(r,"blogs.delete")}}class ie{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/booking-types",{params:{path:{orgId:t},query:e}});return d(r,"bookingTypes.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}}});return d(r,"bookingTypes.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/booking-types",{params:{path:{orgId:t}},body:e});return d(r,"bookingTypes.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}},body:r});return d(n,"bookingTypes.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/booking-types/{bookingTypeId}",{params:{path:{orgId:t,bookingTypeId:e}}});return d(r,"bookingTypes.delete")}}class ae{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/orders",{params:{path:{orgId:t},query:e}});return d(r,"orders.list")}async listLineItems(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/line-items",{params:{path:{orgId:t},query:e}});return d(r,"orders.listLineItems")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/orders/{orderId}",{params:{path:{orgId:t,orderId:e}}});return d(r,"orders.get")}async updateLineItemShipping(t,e,r,n){let i=await this.client.PATCH("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}",{params:{path:{orgId:t,orderId:e,lineItemId:r}},body:n});return d(i,"orders.updateLineItemShipping")}async listLineItemComments(t,e,r){let n=await this.client.GET("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}/comments",{params:{path:{orgId:t,orderId:e,lineItemId:r}}});return d(n,"orders.listLineItemComments")}async commentLineItem(t,e,r,n){let i=await this.client.POST("/api/v1/orgs/{orgId}/orders/{orderId}/line-items/{lineItemId}/comments",{params:{path:{orgId:t,orderId:e,lineItemId:r}},body:n});return d(i,"orders.commentLineItem")}async breakdown(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/orders/breakdown",{params:{path:{orgId:t}},body:e});return d(r,"orders.breakdown")}}class ce{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/quotes",{params:{path:{orgId:t},query:e}});return d(r,"quotes.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}}});return d(r,"quotes.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/quotes",{params:{path:{orgId:t}},body:e});return d(r,"quotes.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}},body:r});return d(n,"quotes.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/quotes/{quoteId}",{params:{path:{orgId:t,quoteId:e}}});return d(r,"quotes.delete")}}class de{client;constructor(t){this.client=t}async summary(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/summary",{params:{path:{orgId:t},query:e}});return d(r,"analytics.summary")}async overview(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/overview",{params:{path:{orgId:t},query:e}});return d(r,"analytics.overview")}async visits(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/visits",{params:{path:{orgId:t},query:e}});return d(r,"analytics.visits")}async topProducts(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/analytics/products/top",{params:{path:{orgId:t},query:e}});return d(r,"analytics.topProducts")}}class ue{client;constructor(t){this.client=t}async list(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/collections",{params:{path:{orgId:t}}});return d(e,"collections.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}}});return d(r,"collections.get")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/collections",{params:{path:{orgId:t}},body:e});return d(r,"collections.create")}async update(t,e,r){let n=await this.client.PUT("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}},body:r});return d(n,"collections.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/collections/{collectionId}",{params:{path:{orgId:t,collectionId:e}}});return d(r,"collections.delete")}}class ge{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents",{params:{path:{orgId:t},query:e}});return d(r,"agents.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/{agentId}",{params:{path:{orgId:t,agentId:e}}});return d(r,"agents.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/agents/{agentId}",{params:{path:{orgId:t,agentId:e}},body:r});return d(n,"agents.update")}async run(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/{agentId}/run",{params:{path:{orgId:t,agentId:e}}});return d(r,"agents.run")}async listRuns(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/runs",{params:{path:{orgId:t},query:e}});return d(r,"agents.listRuns")}async getRun(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/runs/{runId}",{params:{path:{orgId:t,runId:e}}});return d(r,"agents.getRun")}async cancelRun(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/runs/{runId}/cancel",{params:{path:{orgId:t,runId:e}}});return d(r,"agents.cancelRun")}async listProposals(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/agents/proposals",{params:{path:{orgId:t},query:e}});return d(r,"agents.listProposals")}async approveProposal(t,e,r={}){let n=await this.client.POST("/api/v1/orgs/{orgId}/agents/proposals/{proposalId}/approve",{params:{path:{orgId:t,proposalId:e}},body:r});return d(n,"agents.approveProposal")}async rejectProposal(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/agents/proposals/{proposalId}/reject",{params:{path:{orgId:t,proposalId:e}}});return d(r,"agents.rejectProposal")}}class le{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/conversations",{params:{path:{orgId:t},query:e}});return d(r,"conversations.list")}async get(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/conversations/{conversationId}",{params:{path:{orgId:t,conversationId:e},query:r}});return d(n,"conversations.get")}}class pe{client;constructor(t){this.client=t}async get(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/customer-agent",{params:{path:{orgId:t}}});return d(e,"customerAgent.get")}async listKnowledge(t){let e=await this.client.GET("/api/v1/orgs/{orgId}/customer-agent/knowledge",{params:{path:{orgId:t}}});return d(e,"customerAgent.listKnowledge")}}class me{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts",{params:{path:{orgId:t},query:e}});return d(r,"posts.list")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts/{postId}",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.get")}async createDraft(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts",{params:{path:{orgId:t}},body:e});return d(r,"posts.createDraft")}async requestVideoUpload(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/video",{params:{path:{orgId:t,postId:e}},body:{bytes:r}});return d(n,"posts.requestVideoUpload")}async finalizeVideo(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/video/finalize",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.finalizeVideo")}async videoPreview(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/posts/{postId}/video/preview",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.videoPreview")}async publish(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/posts/{postId}/publish",{params:{path:{orgId:t,postId:e}}});return d(r,"posts.publish")}}class fe{client;constructor(t){this.client=t}async list(t={}){return d(await this.client.GET("/api/v1/notifications",{params:{query:t}}),"notifications.list")}async markRead(t){return d(await this.client.POST("/api/v1/notifications/read",{body:t}),"notifications.markRead")}}class ye{client;constructor(t){this.client=t}async latest(){return d(await this.client.GET("/api/v1/desk/latest",{}),"desk.latest")}async downloadUrl(t){let{response:e}=await this.client.GET("/api/v1/desk/download",{params:{query:{os:t}},parseAs:"stream",redirect:"manual"}),r=e.headers.get("Location");if(r)return new URL(r,e.url||"https://vcity.io").toString();if(e.ok&&e.url)return e.url;throw new ct(`desk.downloadUrl failed (${e.status})`,e.status,void 0,e.url)}}class he{client;constructor(t){this.client=t}async listTickets(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/tickets",{params:{path:{orgId:t},query:e}}),"support.listTickets")}async getTicket(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/tickets/{ticketId}",{params:{path:{orgId:t,ticketId:e}}}),"support.getTicket")}async updateTicket(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/support/tickets/{ticketId}",{params:{path:{orgId:t,ticketId:e}},body:r}),"support.updateTicket")}async stats(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/support/stats",{params:{path:{orgId:t}}}),"support.stats")}}class we{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/api-keys",{params:{path:{orgId:t},query:e}}),"apiKeys.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/api-keys",{params:{path:{orgId:t}},body:e}),"apiKeys.create")}async revoke(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/api-keys/{keyId}",{params:{path:{orgId:t,keyId:e}}}),"apiKeys.revoke")}async rotate(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/api-keys/{keyId}/rotate",{params:{path:{orgId:t,keyId:e}}}),"apiKeys.rotate")}}class ve{client;constructor(t){this.client=t}async list(t,e={}){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns",{params:{path:{orgId:t},query:e}});return d(r,"campaigns.list")}async create(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns",{params:{path:{orgId:t}},body:e});return d(r,"campaigns.create")}async get(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.get")}async update(t,e,r){let n=await this.client.PATCH("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}},body:r});return d(n,"campaigns.update")}async delete(t,e){let r=await this.client.DELETE("/api/v1/orgs/{orgId}/campaigns/{campaignId}",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.delete")}async activate(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/activate",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.activate")}async pause(t,e){let r=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/pause",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.pause")}async stats(t,e){let r=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}/stats",{params:{path:{orgId:t,campaignId:e}}});return d(r,"campaigns.stats")}async listContacts(t,e,r={}){let n=await this.client.GET("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts",{params:{path:{orgId:t,campaignId:e},query:r}});return d(n,"campaigns.listContacts")}async addContacts(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts",{params:{path:{orgId:t,campaignId:e}},body:r});return d(n,"campaigns.addContacts")}async removeContact(t,e,r){let n=await this.client.DELETE("/api/v1/orgs/{orgId}/campaigns/{campaignId}/contacts/{contactId}",{params:{path:{orgId:t,campaignId:e,contactId:r}}});return d(n,"campaigns.removeContact")}}class be{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/comments",{params:{query:t}}),"comments.list")}async create(t){return d(await this.client.POST("/api/v1/comments",{body:t}),"comments.create")}async edit(t,e){return d(await this.client.PATCH("/api/v1/comments/{commentId}",{params:{path:{commentId:t}},body:{content:e}}),"comments.edit")}async delete(t){return d(await this.client.DELETE("/api/v1/comments/{commentId}",{params:{path:{commentId:t}}}),"comments.delete")}async pin(t){return d(await this.client.PUT("/api/v1/comments/{commentId}/pin",{params:{path:{commentId:t}}}),"comments.pin")}async unpin(t){return d(await this.client.DELETE("/api/v1/comments/{commentId}/pin",{params:{path:{commentId:t}}}),"comments.unpin")}async reactions(t){return d(await this.client.GET("/api/v1/reactions",{params:{query:{target:t}}}),"comments.reactions")}async react(t){return d(await this.client.PUT("/api/v1/reactions",{body:t}),"comments.react")}}class ke{client;constructor(t){this.client=t}async getConfig(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter",{params:{path:{orgId:t}}}),"newsletter.getConfig")}async saveSettings(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/newsletter",{params:{path:{orgId:t}},body:e}),"newsletter.saveSettings")}async publicConfig(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/public-config",{params:{path:{orgId:t}}}),"newsletter.publicConfig")}async subscribers(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/subscribers",{params:{path:{orgId:t},query:e}}),"newsletter.subscribers")}async stats(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/newsletter/stats",{params:{path:{orgId:t},query:e}}),"newsletter.stats")}}class Ie{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys",{params:{path:{orgId:t},query:e}}),"surveys.list")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}}}),"surveys.get")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys",{params:{path:{orgId:t}},body:e}),"surveys.create")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}},body:r}),"surveys.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/surveys/{surveyId}",{params:{path:{orgId:t,surveyId:e}}}),"surveys.delete")}async publish(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys/{surveyId}/publish",{params:{path:{orgId:t,surveyId:e}}}),"surveys.publish")}async close(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/surveys/{surveyId}/close",{params:{path:{orgId:t,surveyId:e}}}),"surveys.close")}async responses(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/surveys/{surveyId}/responses",{params:{path:{orgId:t,surveyId:e},query:r}}),"surveys.responses")}}class je{client;constructor(t){this.client=t}async get(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/storefront",{params:{path:{orgId:t}}}),"storefront.get")}async update(t,e){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/storefront",{params:{path:{orgId:t}},body:e}),"storefront.update")}async setDomain(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/storefront/domain",{params:{path:{orgId:t}},body:{domain:e}}),"storefront.setDomain")}async removeDomain(t){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/storefront/domain",{params:{path:{orgId:t}}}),"storefront.removeDomain")}async verifyDomain(t){return d(await this.client.POST("/api/v1/orgs/{orgId}/storefront/domain/verify",{params:{path:{orgId:t}}}),"storefront.verifyDomain")}async redirects(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/storefront/redirects",{params:{path:{orgId:t}}}),"storefront.redirects")}async setRedirects(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/storefront/redirects",{params:{path:{orgId:t}},body:{redirects:e}}),"storefront.setRedirects")}async previewShopifyRedirects(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/storefront/redirects/shopify-preview",{params:{path:{orgId:t}},body:{csv:e}}),"storefront.previewShopifyRedirects")}}class Ee{client;constructor(t){this.client=t}async summary(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing",{params:{path:{orgId:t}}}),"billing.summary")}async invoices(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/invoices",{params:{path:{orgId:t},query:e}}),"billing.invoices")}async usage(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/usage",{params:{path:{orgId:t}}}),"billing.usage")}async credits(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/billing/credits",{params:{path:{orgId:t},query:e}}),"billing.credits")}}class Te{client;constructor(t){this.client=t}async store(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}",{params:{path:{storeId:t}}}),"public.store")}async rooms(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}/rooms",{params:{path:{storeId:t}}}),"public.rooms")}async blogs(t,e={}){return d(await this.client.GET("/api/v1/public/stores/{storeId}/blogs",{params:{path:{storeId:t},query:e}}),"public.blogs")}async newsletter(t){return d(await this.client.GET("/api/v1/public/stores/{storeId}/newsletter",{params:{path:{storeId:t}}}),"public.newsletter")}async radioStations(){return d(await this.client.GET("/api/v1/public/radio-stations",{}),"public.radioStations")}async apps(){return d(await this.client.GET("/api/v1/public/apps",{}),"public.apps")}async app(t){return d(await this.client.GET("/api/v1/public/apps/{appId}",{params:{path:{appId:t}}}),"public.app")}async storeRadioStations(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/radio-stations",{params:{path:{orgId:t}}}),"public.storeRadioStations")}}class Re{client;constructor(t){this.client=t}async get(t){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}",{params:{path:{roomId:t}}}),"chatRooms.get")}async messages(t,e={}){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/messages",{params:{path:{roomId:t},query:e}}),"chatRooms.messages")}async send(t,e){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/messages",{params:{path:{roomId:t}},body:e}),"chatRooms.send")}async edit(t,e,r){return d(await this.client.PATCH("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}",{params:{path:{roomId:t,messageId:e}},body:{content:r}}),"chatRooms.edit")}async delete(t,e){return d(await this.client.DELETE("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}",{params:{path:{roomId:t,messageId:e}}}),"chatRooms.delete")}async reactions(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:{roomId:t,messageId:e}}}),"chatRooms.reactions")}async react(t,e,r,n="add"){return d(await this.client.PUT("/api/v1/me/chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:{roomId:t,messageId:e}},body:{emoji:r,action:n}}),"chatRooms.react")}async markRead(t){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/read",{params:{path:{roomId:t}}}),"chatRooms.markRead")}async search(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/search",{params:{path:{roomId:t},query:{q:e}}}),"chatRooms.search")}async list(t){let e=t?.length?{kind:t.join(",")}:{};return d(await this.client.GET("/api/v1/me/chat/rooms",{params:{query:e}}),"chatRooms.list")}async polls(t,e){return d(await this.client.GET("/api/v1/me/chat/rooms/{roomId}/polls",{params:{path:{roomId:t},query:{messageIds:e.join(",")}}}),"chatRooms.polls")}async createPoll(t,e){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/polls",{params:{path:{roomId:t}},body:e}),"chatRooms.createPoll")}async vote(t,e,r){return d(await this.client.POST("/api/v1/me/chat/rooms/{roomId}/polls/{messageId}",{params:{path:{roomId:t,messageId:e}},body:{optionId:r}}),"chatRooms.vote")}async linkPreview(t){return d(await this.client.GET("/api/v1/link-preview",{params:{query:{url:t}}}),"chatRooms.linkPreview")}}class Ce{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators",{params:{path:{orgId:t}}}),"configurators.list")}async seeds(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators/seeds",{params:{path:{orgId:t}}}),"configurators.seeds")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/configurators",{params:{path:{orgId:t}},body:e}),"configurators.create")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}}}),"configurators.get")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}},body:r}),"configurators.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/configurators/{configuratorId}",{params:{path:{orgId:t,configuratorId:e}}}),"configurators.delete")}}class Se{client;constructor(t){this.client=t}async activeSession(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/session",{params:{path:{orgId:t}}}),"pos.activeSession")}async openSession(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sessions",{params:{path:{orgId:t}},body:e}),"pos.openSession")}async closeSession(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sessions/{sessionId}/close",{params:{path:{orgId:t,sessionId:e}},body:r}),"pos.closeSession")}async sessionSummary(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sessions/{sessionId}/summary",{params:{path:{orgId:t,sessionId:e}}}),"pos.sessionSummary")}async sales(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sales",{params:{path:{orgId:t},query:e}}),"pos.sales")}async createSale(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/pos/sales",{params:{path:{orgId:t}},body:e,...r?{headers:{"Idempotency-Key":r}}:{}}),"pos.createSale")}async sale(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/sales/{saleId}",{params:{path:{orgId:t,saleId:e}}}),"pos.sale")}async favorites(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/pos/favorites",{params:{path:{orgId:t}}}),"pos.favorites")}async setFavorites(t,e){return d(await this.client.PUT("/api/v1/orgs/{orgId}/pos/favorites",{params:{path:{orgId:t}},body:{productIds:e}}),"pos.setFavorites")}}class Oe{client;constructor(t){this.client=t}async connections(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/connections",{params:{path:{orgId:t}}}),"dropshipping.connections")}async products(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/products",{params:{path:{orgId:t},query:e}}),"dropshipping.products")}async import(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/dropshipping/imports",{params:{path:{orgId:t}},body:e}),"dropshipping.import")}async fulfillments(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/dropshipping/fulfillments",{params:{path:{orgId:t},query:{orderId:e}}}),"dropshipping.fulfillments")}async retryFulfillment(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/dropshipping/fulfillments/{fulfillmentId}/retry",{params:{path:{orgId:t,fulfillmentId:e}}}),"dropshipping.retryFulfillment")}}class xe{client;constructor(t){this.client=t}async openConversation(t,e={}){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/conversations",{params:{path:{orgId:t}},body:e}),"assistant.openConversation")}async*turn(t,e,r){let n=await this.client.POST("/api/v1/orgs/{orgId}/assistant/conversations/{conversationId}/turns",{params:{path:{orgId:t,conversationId:e}},body:r,parseAs:"stream"}),i=d(n,"assistant.turn");if(!i)return;let a=i.getReader(),s=new TextDecoder,o="";for(;;){let{value:c,done:u}=await a.read();if(u)break;o+=s.decode(c,{stream:!0});let p=o.indexOf(`
|
|
3
3
|
|
|
4
|
-
`);while(
|
|
4
|
+
`);while(p>=0){let w=o.slice(0,p).split(`
|
|
5
5
|
`).filter((v)=>v.startsWith("data:")).map((v)=>v.slice(5).trimStart()).join(`
|
|
6
|
-
`);if(o=o.slice(
|
|
6
|
+
`);if(o=o.slice(p+2),w)yield JSON.parse(w);p=o.indexOf(`
|
|
7
7
|
|
|
8
|
-
`)}}}async listProposals(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/assistant/proposals",{params:{path:{orgId:t},query:e}}),"assistant.listProposals")}async approve(t,e,r={}){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/proposals/{proposalId}/approve",{params:{path:{orgId:t,proposalId:e}},body:r}),"assistant.approve")}async reject(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/proposals/{proposalId}/reject",{params:{path:{orgId:t,proposalId:e}}}),"assistant.reject")}}class Ae{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar",{params:{path:{orgId:t},query:e}}),"calendar.list")}async ics(t,e){let{data:r,error:n,response:i}=await this.client.GET("/api/v1/orgs/{orgId}/calendar.ics",{params:{path:{orgId:t},query:{token:e}},parseAs:"text"});if(n!==void 0||typeof r!=="string")throw new ct(`calendar.ics failed (${i.status})`,i.status,n,i.url);return r}async createEntry(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/entries",{params:{path:{orgId:t}},body:e}),"calendar.createEntry")}async getEntry(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e}}}),"calendar.getEntry")}async updateEntry(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e}},body:r}),"calendar.updateEntry")}async cancelEntry(t,e,r={}){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e},query:r}}),"calendar.cancelEntry")}async settings(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/settings",{params:{path:{orgId:t}}}),"calendar.settings")}async updateSettings(t,e){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/settings",{params:{path:{orgId:t}},body:e}),"calendar.updateSettings")}async staff(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/staff",{params:{path:{orgId:t}}}),"calendar.staff")}async holidays(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/holidays",{params:{path:{orgId:t},query:e}}),"calendar.holidays")}async listFeeds(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/feeds",{params:{path:{orgId:t}}}),"calendar.listFeeds")}async createFeed(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/feeds",{params:{path:{orgId:t}},body:e}),"calendar.createFeed")}async updateFeed(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/feeds/{feedId}",{params:{path:{orgId:t,feedId:e}},body:r}),"calendar.updateFeed")}async revokeFeed(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/feeds/{feedId}",{params:{path:{orgId:t,feedId:e}}}),"calendar.revokeFeed")}async listExternal(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/external",{params:{path:{orgId:t}}}),"calendar.listExternal")}async addExternal(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/external",{params:{path:{orgId:t}},body:e}),"calendar.addExternal")}async updateExternal(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/external/{calendarId}",{params:{path:{orgId:t,calendarId:e}},body:r}),"calendar.updateExternal")}async removeExternal(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/external/{calendarId}",{params:{path:{orgId:t,calendarId:e}}}),"calendar.removeExternal")}}class Pe{client;constructor(t){this.client=t}async listContacts(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts",{params:{path:{orgId:t},query:e}}),"crm.listContacts")}async createContact(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts",{params:{path:{orgId:t}},body:e}),"crm.createContact")}async getContact(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}}}),"crm.getContact")}async updateContact(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.updateContact")}async archiveContact(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}}}),"crm.archiveContact")}async restoreContact(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/restore",{params:{path:{orgId:t,contactId:e}}}),"crm.restoreContact")}async setContactTags(t,e,r){return d(await this.client.PUT("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/tags",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.setContactTags")}async contactTimeline(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/timeline",{params:{path:{orgId:t,contactId:e}}}),"crm.contactTimeline")}async contactAudiences(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/audiences",{params:{path:{orgId:t,contactId:e}}}),"crm.contactAudiences")}async addDeal(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/deals",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.addDeal")}async listTags(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/tags",{params:{path:{orgId:t}}}),"crm.listTags")}async createTag(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/tags",{params:{path:{orgId:t}},body:e}),"crm.createTag")}async listFollowUps(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/follow-ups",{params:{path:{orgId:t},query:e}}),"crm.listFollowUps")}async listAudiences(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/audiences",{params:{path:{orgId:t}}}),"crm.listAudiences")}async listAudienceContacts(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/audiences/{audienceId}/contacts",{params:{path:{orgId:t,audienceId:e},query:r}}),"crm.listAudienceContacts")}}class $e{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox",{params:{path:{orgId:t},query:e}}),"inbox.list")}async unreadCount(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/unread-count",{params:{path:{orgId:t}}}),"inbox.unreadCount")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}",{params:{path:{orgId:t,conversationId:e}}}),"inbox.get")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/inbox/{conversationId}",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.update")}async customer(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/customer",{params:{path:{orgId:t,conversationId:e}}}),"inbox.customer")}async listMessages(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages",{params:{path:{orgId:t,conversationId:e},query:r}}),"inbox.listMessages")}async reply(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.reply")}async editMessage(t,e,r,n){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}},body:n}),"inbox.editMessage")}async deleteMessage(t,e,r){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}}}),"inbox.deleteMessage")}async markRead(t,e){let r={orgId:t,conversationId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/read",{params:{path:r}}),"inbox.markRead")}async search(t,e,r){let n={orgId:t,conversationId:e};return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/search",{params:{path:n,query:{q:r}}}),"inbox.search")}async startCall(t,e){let r={orgId:t,conversationId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/calls",{params:{path:r}}),"inbox.startCall")}async createPoll(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/polls",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.createPoll")}async votePoll(t,e,r,n){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/polls/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}},body:n}),"inbox.votePoll")}async share(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/shares",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.share")}async startUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/uploads",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.startUpload")}async completeUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/uploads/{fileId}",{params:{path:{orgId:t,conversationId:e,fileId:r}}}),"inbox.completeUpload")}async shareables(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/chat/shareables",{params:{path:{orgId:t},query:e}}),"inbox.shareables")}}class De{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/quick-replies",{params:{path:{orgId:t}}}),"quickReplies.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/quick-replies",{params:{path:{orgId:t}},body:e}),"quickReplies.create")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/quick-replies/{quickReplyId}",{params:{path:{orgId:t,quickReplyId:e}},body:r}),"quickReplies.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/quick-replies/{quickReplyId}",{params:{path:{orgId:t,quickReplyId:e}}}),"quickReplies.delete")}}class Ne{client;constructor(t){this.client=t}async listRooms(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat",{params:{path:{orgId:t}}}),"teamChat.listRooms")}async createChannel(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/channels",{params:{path:{orgId:t}},body:e}),"teamChat.createChannel")}async updateChannel(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/team-chat/channels/{channelId}",{params:{path:{orgId:t,channelId:e}},body:r}),"teamChat.updateChannel")}async deleteChannel(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/channels/{channelId}",{params:{path:{orgId:t,channelId:e}}}),"teamChat.deleteChannel")}async openDm(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/dms",{params:{path:{orgId:t}},body:e}),"teamChat.openDm")}async members(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/members",{params:{path:{orgId:t}}}),"teamChat.members")}async search(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/search",{params:{path:{orgId:t},query:e}}),"teamChat.search")}async listMessages(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages",{params:{path:{orgId:t,roomId:e},query:r}}),"teamChat.listMessages")}async send(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.send")}async editMessage(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.PATCH("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}",{params:{path:i},body:n}),"teamChat.editMessage")}async deleteMessage(t,e,r){let n={orgId:t,roomId:e,messageId:r};return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}",{params:{path:n}}),"teamChat.deleteMessage")}async react(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.PUT("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:i},body:{emoji:n}}),"teamChat.react")}async unreact(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:i,query:{emoji:n}}}),"teamChat.unreact")}async thread(t,e,r){let n={orgId:t,roomId:e,messageId:r};return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/thread",{params:{path:n}}),"teamChat.thread")}async createPoll(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/polls",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.createPoll")}async votePoll(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/polls/{messageId}",{params:{path:i},body:n}),"teamChat.votePoll")}async markRead(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/read",{params:{path:r}}),"teamChat.markRead")}async typing(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/typing",{params:{path:r}}),"teamChat.typing")}async startCall(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/calls",{params:{path:r}}),"teamChat.startCall")}async share(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/shares",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.share")}async startUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/uploads",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.startUpload")}async completeUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/uploads/{fileId}",{params:{path:{orgId:t,roomId:e,fileId:r}}}),"teamChat.completeUpload")}async realtimeToken(t){return d(await this.client.POST("/api/v1/chat/realtime-token",{body:t}),"teamChat.realtimeToken")}}class Fe{client;constructor(t){this.client=t}async listNotes(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/notes",{params:{path:{orgId:t}}}),"vault.listNotes")}async createNote(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/vault/notes",{params:{path:{orgId:t}},body:e}),"vault.createNote")}async getNote(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}}}),"vault.getNote")}async saveNote(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}},body:r}),"vault.saveNote")}async deleteNote(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}}}),"vault.deleteNote")}async moveNote(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/vault/notes/{noteId}/move",{params:{path:{orgId:t,noteId:e}},body:r}),"vault.moveNote")}async search(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/search",{params:{path:{orgId:t},query:e}}),"vault.search")}async graph(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/graph",{params:{path:{orgId:t}}}),"vault.graph")}async changes(t,e){return d(await this.client.GET("/api/v1/me/vault-changes",{params:{query:{org:t,since:e}}}),"vault.changes")}}class Ue{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks",{params:{path:{orgId:t},query:e}}),"webhooks.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks",{params:{path:{orgId:t}},body:e}),"webhooks.create")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.get")}async update(t,e,r){return d(await this.client.PUT("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}},body:r}),"webhooks.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.delete")}async deliveries(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks/{webhookId}/deliveries",{params:{path:{orgId:t,webhookId:e},query:r}}),"webhooks.deliveries")}async rotateSecret(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks/{webhookId}/rotate",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.rotateSecret")}async test(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks/{webhookId}/test",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.test")}}var pi="https://vcity.io";function mi(t){let e;try{e=new URL(t)}catch{throw Error(`@vcityio/api-client: invalid baseUrl (${t.slice(0,200)})`)}if(e.protocol==="https:")return;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return;throw Error(`@vcityio/api-client: baseUrl must use https:// for non-localhost hosts (got: ${e.protocol}//${e.hostname}).`)}function fi(t,e){let r=e??globalThis.fetch;if(!r)throw Error("@vcityio/api-client: no fetch implementation found. Provide options.fetch or run on Node >=20 / a browser.");return async function(i){if(!t)return r(i);let s=i.headers.get("Authorization")?.match(/^Bearer\s+(.+)$/)?.[1]?.trim();if(s&&s!=="undefined"&&s!=="null")return r(i);let o=new Headers(i.headers);o.set("Authorization",`Bearer ${t}`);let c=new Request(i,{headers:o});return r(c)}}class ar{raw;me;orgs;drafts;coupons;media;products;events;rooms;support;agents;conversations;customerAgent;posts;collections;bookings;bookingTypes;projects;blogs;orders;analytics;apiKeys;quotes;crm;webhooks;inbox;quickReplies;teamChat;calendar;vault;assistant;notifications;desk;campaigns;comments;newsletter;surveys;configurators;pos;dropshipping;storefront;public;chatRooms;billing;constructor(t={}){let e=t.baseUrl??pi;mi(e);let r=fi(t.token,t.fetch),n={baseUrl:e,fetch:r,headers:t.headers};this.raw=ir(n),this.me=new Xt(this.raw),this.orgs=new Zt(this.raw),this.drafts=new zt(this.raw),this.coupons=new Kt(this.raw),this.media=new Wt(this.raw),this.products=new te(this.raw),this.events=new ee(this.raw),this.rooms=new re(this.raw),this.support=new he(this.raw),this.agents=new ge(this.raw),this.conversations=new le(this.raw),this.customerAgent=new pe(this.raw),this.posts=new me(this.raw),this.collections=new ue(this.raw),this.bookings=new se(this.raw),this.bookingTypes=new ie(this.raw),this.projects=new ne(this.raw),this.blogs=new oe(this.raw),this.orders=new ae(this.raw),this.analytics=new de(this.raw),this.apiKeys=new we(this.raw),this.quotes=new ce(this.raw),this.crm=new Pe(this.raw),this.webhooks=new Ue(this.raw),this.inbox=new $e(this.raw),this.quickReplies=new De(this.raw),this.teamChat=new Ne(this.raw),this.calendar=new Ae(this.raw),this.vault=new Fe(this.raw),this.assistant=new xe(this.raw),this.notifications=new fe(this.raw),this.desk=new ye(this.raw),this.campaigns=new ve(this.raw),this.comments=new be(this.raw),this.newsletter=new ke(this.raw),this.surveys=new Ie(this.raw),this.configurators=new Ce(this.raw),this.pos=new Se(this.raw),this.dropshipping=new Oe(this.raw),this.storefront=new je(this.raw),this.public=new Ee(this.raw),this.chatRooms=new Re(this.raw),this.billing=new Te(this.raw)}}function cr(t={}){return new ar(t)}import lt from"node:fs";import vi from"node:os";import Be from"node:path";var yi=/\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[P_^X][^\x07\x1b]*(?:\x07|\x1b\\)|[^[\]P_^X])/g,hi=/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g,wi=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;function E(t){return t.replace(yi,"").replace(hi,"").replace(wi,"")}function Dr(t){let e;try{e=new URL(t)}catch{throw Error(`Refusing to open malformed URL: ${E(t).slice(0,100)}`)}if(e.protocol==="https:")return e;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return e;throw Error(`Refusing to open URL with unsafe protocol: ${e.protocol}`)}var $r=512;function O(t,e){let r=t.trim();if(!r)throw Error(`${e} must not be empty.`);if(r.length>$r)throw Error(`${e} must be at most ${$r} characters.`);if(/[\x00-\x1f\x7f]/.test(r))throw Error(`${e} must not contain control characters.`);return r}function St(t){let e;try{e=new URL(t)}catch{throw Error(`Invalid api base URL: ${t.slice(0,200)}`)}if(e.protocol==="https:")return e;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return e;throw Error(`api base URL must use https:// (got: ${e.protocol}//${e.hostname}).`)}function gt(){if(process.env.VCITY_CONFIG_DIR)return Be.resolve(process.env.VCITY_CONFIG_DIR);return Be.join(vi.homedir(),".vcity")}function Me(){return Be.join(gt(),"auth.json")}function dr(){return Be.join(gt(),"config.json")}function Le(){let t=process.env.VCITY_API_BASE_URL||"https://vcity.io";return St(t),t}import dt from"node:fs";function Ot(t,e,r=384){if(process.platform==="win32"){dt.writeFileSync(t,e,{mode:r});try{dt.chmodSync(t,r)}catch{}return}let n=dt.constants.O_WRONLY|dt.constants.O_CREAT|dt.constants.O_TRUNC|dt.constants.O_NOFOLLOW,i=dt.openSync(t,n,r);try{dt.writeSync(i,e),dt.fchmodSync(i,r)}finally{dt.closeSync(i)}}function bi(){let t=gt();lt.mkdirSync(t,{recursive:!0,mode:448});try{lt.chmodSync(t,448)}catch{}if(process.platform!=="win32"){let e;try{e=lt.statSync(t)}catch{return}if((e.mode&63)!==0)throw Error(`Refusing to write CLI credentials: ${t} is group- or world-accessible (mode ${(e.mode&511).toString(8)}). Tighten its permissions (\`chmod 700 ${t}\`) or set VCITY_CONFIG_DIR to a directory you own.`)}}function ki(t){if(!t||typeof t!=="object")return!1;let e=t;return typeof e.api_base_url==="string"&&typeof e.access_token==="string"&&typeof e.refresh_token==="string"&&typeof e.access_expires_at==="number"&&typeof e.refresh_expires_at==="number"&&!!e.user&&typeof e.user==="object"}function xt(){let t=Me();if(!lt.existsSync(t))return;try{let e=JSON.parse(lt.readFileSync(t,"utf-8"));if(!ki(e))return;if(St(e.api_base_url),new URL(e.api_base_url).origin!==new URL(Le()).origin)return;return e}catch{return}}function Ii(t){let e;try{e=lt.lstatSync(t)}catch{return}if(e.isSymbolicLink()||e.isFile()&&e.nlink>1)lt.rmSync(t,{force:!0})}function qe(t){bi();let e=Me();Ii(e),Ot(e,JSON.stringify(t,null,2),384)}function $t(){let t=Me();if(lt.existsSync(t))lt.rmSync(t)}function _e(){let t=xt();if(!t)throw Error("Not logged in. Run `vcity login` first.");return t}var ur={name:"@vcityio/cli",version:"0.10.1",type:"module",description:"vcity command-line interface for org owners",main:"./dist/index.js",bin:{vcity:"./dist/index.js"},files:["dist","README.md","LICENSE"],engines:{node:">=20"},publishConfig:{access:"public"},optionalDependencies:{open:"^10.0.0"},keywords:["vcity","cli"],author:"Otherwise SAS",license:"MIT",homepage:"https://vcity.io",bugs:{email:"support@owsas.com"}};var nt=ur.version,Tt=ur.name;var gr=60000,Mr=`vcity-cli/${nt} (${process.platform} ${process.arch})`,Nr=2048;class Dt extends Error{status;body;constructor(t,e,r){super(r??`HTTP ${t}`);this.status=t;this.body=e;this.name="ApiError"}}function Lr(t,e,r){if(e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e))throw Error(`Refusing to build URL with non-relative path: ${e.slice(0,100)}`);let n=new URL(t),i=new URL(e.startsWith("/")?e:`/${e}`,t);if(i.origin!==n.origin)throw Error(`Refusing to build URL outside base origin: ${i.origin}`);if(r){for(let[a,s]of Object.entries(r))if(s!==void 0&&s!==null&&!Number.isNaN(s))i.searchParams.set(a,String(s))}return i.toString()}var Fr=(t,e)=>typeof t==="string"&&t.length>0&&t.length<=e,Ge=Symbol("transient"),Ur=(t)=>typeof t==="number"&&Number.isFinite(t);async function Ti(t){try{let e=await fetch(Lr(t.api_base_url,"/api/cli/auth/refresh"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.refresh_token}`},body:JSON.stringify({refresh_token:t.refresh_token}),signal:AbortSignal.timeout(gr),redirect:"error"});if(e.status===429||e.status>=500)return Ge;if(!e.ok)return;let r=await e.json();if(!Fr(r.access_token,Nr)||!Fr(r.refresh_token,Nr)||!Ur(r.access_expires_at)||!Ur(r.refresh_expires_at)||r.access_expires_at<=Date.now()||r.refresh_expires_at<=Date.now())return;let n={...t,access_token:r.access_token,refresh_token:r.refresh_token,access_expires_at:r.access_expires_at,refresh_expires_at:r.refresh_expires_at};return qe(n),n}catch{return Ge}}async function Br(t){let e=()=>new Dt(401,void 0,"Session expired. Run `vcity login` again."),r=xt();if(r&&r.refresh_token!==t.refresh_token)return r;let n=await Ti(t);if(n&&n!==Ge)return n;let i=xt();if(i&&i.refresh_token!==t.refresh_token)return i;if(n===Ge)throw new Dt(503,void 0,"Could not refresh the session. Check your connection and try again.");throw $t(),e()}async function Nt(t,e={}){let{authed:r=!0,method:n="GET",body:i,query:a,baseUrl:s,headers:o}=e,c=r?_e():void 0,u=s??c?.api_base_url??"https://vcity.io",l={"content-type":"application/json","user-agent":Mr};if(c)l.authorization=`Bearer ${c.access_token}`;if(o)for(let[T,N]of Object.entries(o))l[T]=N;let w=await fetch(Lr(u,t,a),{method:n,headers:l,body:i===void 0?void 0:JSON.stringify(i),signal:AbortSignal.timeout(gr),redirect:"error"}),R=(w.headers.get("content-type")??"").includes("application/json")?await w.json().catch(()=>{return}):await w.text().catch(()=>{return});if(!w.ok){let T=(R&&typeof R==="object"&&"error"in R?String(R.error):void 0)??`Request failed (${w.status})`;throw new Dt(w.status,R,T)}return R}function Ei(t,e){let r=new URL(t).origin;if(r!==e)throw Error(`Refusing to attach Bearer token to cross-origin SDK request: ${r}`)}var Ri=3,Ci=60000;function Si(t,e){let r=t.headers.get("retry-after"),n=r!==null&&/^\d+$/.test(r)?Number(r)*1000:r?Date.parse(r)-Date.now():Number.NaN,i=Number.isFinite(n)?n:1000*2**e;return Math.min(Math.max(i,0),Ci)}async function Oi(t){for(let e=0;;e++){let r=await t();if(r.status!==429||e>=Ri)return r;await new Promise((n)=>setTimeout(n,Si(r,e)))}}function xi(){let t=async(e,r,n)=>{Ei(e.url,n);let i=new Headers(e.headers);i.set("authorization",`Bearer ${r}`),i.set("user-agent",Mr);let a=new Request(e,{headers:i,signal:AbortSignal.timeout(gr),redirect:e.redirect==="manual"?"manual":"error"});return globalThis.fetch(a)};return async function(r){let n=_e(),i=new URL(n.api_base_url).origin;if(Date.now()>=n.access_expires_at){if(Date.now()>=n.refresh_expires_at)throw $t(),new Dt(401,void 0,"Session expired. Run `vcity login` again.");n=await Br(n)}let a=await Oi(()=>t(r.clone(),n.access_token,i));if(a.status!==401)return a;return n=await Br(n),t(r,n.access_token,i)}}function p(){let t=_e();return cr({baseUrl:t.api_base_url,fetch:xi()})}import Et from"node:fs";import Ai from"node:path";var lr=16777216;function Pi(t){let e=new Uint8Array(t+1),r=0;while(r<e.length){let n=Et.readSync(0,e,r,e.length-r,null);if(n===0)break;r+=n}if(r>t)throw Error(`--data: stdin body exceeds the ${t}-byte cap.`);return Buffer.from(e.buffer,e.byteOffset,r).toString("utf-8")}function P(t){if(t===void 0)return;let e;if(t==="-"){if(process.stdin.isTTY)throw Error("--data: reading from stdin (-) but nothing is piped in");try{e=Pi(lr)}catch(r){let n=r instanceof Error?r.message:String(r);if(n.startsWith("--data:"))throw r;throw Error(`--data: could not read stdin: ${n}`)}}else if(t.startsWith("@")){let r=t.slice(1);if(r.length===0)throw Error("--data: missing file path after `@`");if(!/\.json$/i.test(r))throw Error(`--data: @file path must point to a .json file (got: ${r})`);let n;try{n=Et.realpathSync(r)}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not read ${r}: ${o}`)}if(!/\.json$/i.test(n))throw Error(`--data: @file path must point to a .json file (got: ${r} → ${n})`);let i;try{i=Et.realpathSync(process.cwd())}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not resolve cwd: ${o}`)}if(n!==i&&!n.startsWith(i+Ai.sep))throw Error(`--data: @file path must be inside the current working directory (got: ${r}). To send a file from elsewhere, pipe it: cat <file> | vcity ... --data -`);let a;try{a=Et.openSync(n,"r")}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not read ${r}: ${o}`)}try{let s;try{s=Et.fstatSync(a)}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`--data: could not read ${r}: ${c}`)}if(s.nlink>1)throw Error(`--data: @file path must not be a hard link (got: ${r})`);if(s.size>lr)throw Error(`--data: ${r} exceeds the ${lr}-byte body cap (got ${s.size} bytes).`);try{e=Et.readFileSync(a,"utf-8")}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`--data: could not read ${r}: ${c}`)}}finally{try{Et.closeSync(a)}catch{}}}else e=t;try{return JSON.parse(e)}catch{throw Error("--data: invalid JSON")}}import Rt from"node:fs";function $i(){let t=gt();Rt.mkdirSync(t,{recursive:!0,mode:448});try{Rt.chmodSync(t,448)}catch{}if(process.platform!=="win32"){let e;try{e=Rt.statSync(t)}catch{return}if((e.mode&63)!==0)throw Error(`Refusing to write CLI config: ${t} is group- or world-accessible (mode ${(e.mode&511).toString(8)}). Tighten its permissions (\`chmod 700 ${t}\`) or set VCITY_CONFIG_DIR to a directory you own.`)}}function Di(t){if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;if(e.active_org!==void 0&&typeof e.active_org!=="string")return!1;if(e.default_format!==void 0&&e.default_format!=="pretty"&&e.default_format!=="json")return!1;return!0}function Ct(){let t=dr();if(!Rt.existsSync(t))return{};try{let e=JSON.parse(Rt.readFileSync(t,"utf-8"));return Di(e)?e:{}}catch{return{}}}function Ni(t){let e;try{e=Rt.lstatSync(t)}catch{return}if(e.isSymbolicLink()||e.isFile()&&e.nlink>1)Rt.rmSync(t,{force:!0})}function qr(t){$i();let r={...Ct(),...t},n=dr();return Ni(n),Ot(n,JSON.stringify(r,null,2),384),r}function h(t){if(t)return t;let e=Ct();if(!e.active_org)throw Error("No active org. Run `vcity org use <slug>` or pass --org <slug>.");return e.active_org}function f(t){if(t)return"json";if(!process.stdout.isTTY)return"json";return"pretty"}function g(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function k(t,e){process.stdout.write(`${
|
|
11
|
-
`)}function j(t){for(let[e,r]of Object.entries(t)){if(r===void 0||r===null)continue;let n=typeof r==="object"?JSON.stringify(r):String(r);process.stdout.write(`${
|
|
12
|
-
`)}}import
|
|
13
|
-
`),j(u)}async function Wr(t,e={}){let r=f(e.json),n=h(e.org),i=pr(e.visibility),a=Vr(e.type),s=P(e.data),o=s&&typeof s==="object"?{...s}:{};if(e.title!==void 0)o.title=e.title;if(e.slug!==void 0)o.slug=e.slug;if(e.summary!==void 0)o.summary=e.summary;if(e.content!==void 0)o.content=e.content;if(i!==void 0)o.visibility=i;if(a!==void 0)o.type=a;let c=Jr(e.tags);if(c!==void 0)o.tags=c;if(Object.keys(o).length===0)throw Error("blogs update: nothing to update (pass at least one field or --data)");let
|
|
14
|
-
`),j(
|
|
15
|
-
`);return}}let a=await
|
|
16
|
-
`)}async function Kr(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;if(t.enabled!==void 0)n.enabled=t.enabled;let a=await
|
|
17
|
-
`),j(a)}async function es(t,e={}){let r=f(e.json),n=h(e.org),i=Zr(e);if(Object.keys(i).length===0)throw Error("booking-types update: nothing to update (pass at least one field or --data)");let s=await
|
|
8
|
+
`)}}}async listProposals(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/assistant/proposals",{params:{path:{orgId:t},query:e}}),"assistant.listProposals")}async approve(t,e,r={}){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/proposals/{proposalId}/approve",{params:{path:{orgId:t,proposalId:e}},body:r}),"assistant.approve")}async reject(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/assistant/proposals/{proposalId}/reject",{params:{path:{orgId:t,proposalId:e}}}),"assistant.reject")}}class Ae{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar",{params:{path:{orgId:t},query:e}}),"calendar.list")}async ics(t,e){let{data:r,error:n,response:i}=await this.client.GET("/api/v1/orgs/{orgId}/calendar.ics",{params:{path:{orgId:t},query:{token:e}},parseAs:"text"});if(n!==void 0||typeof r!=="string")throw new ct(`calendar.ics failed (${i.status})`,i.status,n,i.url);return r}async createEntry(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/entries",{params:{path:{orgId:t}},body:e}),"calendar.createEntry")}async getEntry(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e}}}),"calendar.getEntry")}async updateEntry(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e}},body:r}),"calendar.updateEntry")}async cancelEntry(t,e,r={}){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/entries/{entryId}",{params:{path:{orgId:t,entryId:e},query:r}}),"calendar.cancelEntry")}async settings(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/settings",{params:{path:{orgId:t}}}),"calendar.settings")}async updateSettings(t,e){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/settings",{params:{path:{orgId:t}},body:e}),"calendar.updateSettings")}async staff(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/staff",{params:{path:{orgId:t}}}),"calendar.staff")}async holidays(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/holidays",{params:{path:{orgId:t},query:e}}),"calendar.holidays")}async listFeeds(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/feeds",{params:{path:{orgId:t}}}),"calendar.listFeeds")}async createFeed(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/feeds",{params:{path:{orgId:t}},body:e}),"calendar.createFeed")}async updateFeed(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/feeds/{feedId}",{params:{path:{orgId:t,feedId:e}},body:r}),"calendar.updateFeed")}async revokeFeed(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/feeds/{feedId}",{params:{path:{orgId:t,feedId:e}}}),"calendar.revokeFeed")}async listExternal(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/calendar/external",{params:{path:{orgId:t}}}),"calendar.listExternal")}async addExternal(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/calendar/external",{params:{path:{orgId:t}},body:e}),"calendar.addExternal")}async updateExternal(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/calendar/external/{calendarId}",{params:{path:{orgId:t,calendarId:e}},body:r}),"calendar.updateExternal")}async removeExternal(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/calendar/external/{calendarId}",{params:{path:{orgId:t,calendarId:e}}}),"calendar.removeExternal")}}class Pe{client;constructor(t){this.client=t}async listContacts(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts",{params:{path:{orgId:t},query:e}}),"crm.listContacts")}async createContact(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts",{params:{path:{orgId:t}},body:e}),"crm.createContact")}async getContact(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}}}),"crm.getContact")}async updateContact(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.updateContact")}async archiveContact(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/crm/contacts/{contactId}",{params:{path:{orgId:t,contactId:e}}}),"crm.archiveContact")}async restoreContact(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/restore",{params:{path:{orgId:t,contactId:e}}}),"crm.restoreContact")}async setContactTags(t,e,r){return d(await this.client.PUT("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/tags",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.setContactTags")}async contactTimeline(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/timeline",{params:{path:{orgId:t,contactId:e}}}),"crm.contactTimeline")}async contactAudiences(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/audiences",{params:{path:{orgId:t,contactId:e}}}),"crm.contactAudiences")}async addDeal(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/contacts/{contactId}/deals",{params:{path:{orgId:t,contactId:e}},body:r}),"crm.addDeal")}async listTags(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/tags",{params:{path:{orgId:t}}}),"crm.listTags")}async createTag(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/crm/tags",{params:{path:{orgId:t}},body:e}),"crm.createTag")}async listFollowUps(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/follow-ups",{params:{path:{orgId:t},query:e}}),"crm.listFollowUps")}async listAudiences(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/audiences",{params:{path:{orgId:t}}}),"crm.listAudiences")}async listAudienceContacts(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/crm/audiences/{audienceId}/contacts",{params:{path:{orgId:t,audienceId:e},query:r}}),"crm.listAudienceContacts")}}class $e{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox",{params:{path:{orgId:t},query:e}}),"inbox.list")}async unreadCount(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/unread-count",{params:{path:{orgId:t}}}),"inbox.unreadCount")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}",{params:{path:{orgId:t,conversationId:e}}}),"inbox.get")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/inbox/{conversationId}",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.update")}async customer(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/customer",{params:{path:{orgId:t,conversationId:e}}}),"inbox.customer")}async listMessages(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages",{params:{path:{orgId:t,conversationId:e},query:r}}),"inbox.listMessages")}async reply(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.reply")}async editMessage(t,e,r,n){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}},body:n}),"inbox.editMessage")}async deleteMessage(t,e,r){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/inbox/{conversationId}/messages/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}}}),"inbox.deleteMessage")}async markRead(t,e){let r={orgId:t,conversationId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/read",{params:{path:r}}),"inbox.markRead")}async search(t,e,r){let n={orgId:t,conversationId:e};return d(await this.client.GET("/api/v1/orgs/{orgId}/inbox/{conversationId}/search",{params:{path:n,query:{q:r}}}),"inbox.search")}async startCall(t,e){let r={orgId:t,conversationId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/calls",{params:{path:r}}),"inbox.startCall")}async createPoll(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/polls",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.createPoll")}async votePoll(t,e,r,n){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/polls/{messageId}",{params:{path:{orgId:t,conversationId:e,messageId:r}},body:n}),"inbox.votePoll")}async share(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/shares",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.share")}async startUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/uploads",{params:{path:{orgId:t,conversationId:e}},body:r}),"inbox.startUpload")}async completeUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/inbox/{conversationId}/uploads/{fileId}",{params:{path:{orgId:t,conversationId:e,fileId:r}}}),"inbox.completeUpload")}async shareables(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/chat/shareables",{params:{path:{orgId:t},query:e}}),"inbox.shareables")}}class De{client;constructor(t){this.client=t}async list(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/quick-replies",{params:{path:{orgId:t}}}),"quickReplies.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/quick-replies",{params:{path:{orgId:t}},body:e}),"quickReplies.create")}async update(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/quick-replies/{quickReplyId}",{params:{path:{orgId:t,quickReplyId:e}},body:r}),"quickReplies.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/quick-replies/{quickReplyId}",{params:{path:{orgId:t,quickReplyId:e}}}),"quickReplies.delete")}}class Ne{client;constructor(t){this.client=t}async listRooms(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat",{params:{path:{orgId:t}}}),"teamChat.listRooms")}async createChannel(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/channels",{params:{path:{orgId:t}},body:e}),"teamChat.createChannel")}async updateChannel(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/team-chat/channels/{channelId}",{params:{path:{orgId:t,channelId:e}},body:r}),"teamChat.updateChannel")}async deleteChannel(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/channels/{channelId}",{params:{path:{orgId:t,channelId:e}}}),"teamChat.deleteChannel")}async openDm(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/dms",{params:{path:{orgId:t}},body:e}),"teamChat.openDm")}async members(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/members",{params:{path:{orgId:t}}}),"teamChat.members")}async search(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/search",{params:{path:{orgId:t},query:e}}),"teamChat.search")}async listMessages(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages",{params:{path:{orgId:t,roomId:e},query:r}}),"teamChat.listMessages")}async send(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.send")}async editMessage(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.PATCH("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}",{params:{path:i},body:n}),"teamChat.editMessage")}async deleteMessage(t,e,r){let n={orgId:t,roomId:e,messageId:r};return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}",{params:{path:n}}),"teamChat.deleteMessage")}async react(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.PUT("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:i},body:{emoji:n}}),"teamChat.react")}async unreact(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.DELETE("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/reactions",{params:{path:i,query:{emoji:n}}}),"teamChat.unreact")}async thread(t,e,r){let n={orgId:t,roomId:e,messageId:r};return d(await this.client.GET("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/messages/{messageId}/thread",{params:{path:n}}),"teamChat.thread")}async createPoll(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/polls",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.createPoll")}async votePoll(t,e,r,n){let i={orgId:t,roomId:e,messageId:r};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/polls/{messageId}",{params:{path:i},body:n}),"teamChat.votePoll")}async markRead(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/read",{params:{path:r}}),"teamChat.markRead")}async typing(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/typing",{params:{path:r}}),"teamChat.typing")}async startCall(t,e){let r={orgId:t,roomId:e};return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/calls",{params:{path:r}}),"teamChat.startCall")}async share(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/shares",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.share")}async startUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/uploads",{params:{path:{orgId:t,roomId:e}},body:r}),"teamChat.startUpload")}async completeUpload(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/team-chat/rooms/{roomId}/uploads/{fileId}",{params:{path:{orgId:t,roomId:e,fileId:r}}}),"teamChat.completeUpload")}async realtimeToken(t){return d(await this.client.POST("/api/v1/chat/realtime-token",{body:t}),"teamChat.realtimeToken")}}class Fe{client;constructor(t){this.client=t}async listNotes(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/notes",{params:{path:{orgId:t}}}),"vault.listNotes")}async createNote(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/vault/notes",{params:{path:{orgId:t}},body:e}),"vault.createNote")}async getNote(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}}}),"vault.getNote")}async saveNote(t,e,r){return d(await this.client.PATCH("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}},body:r}),"vault.saveNote")}async deleteNote(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/vault/notes/{noteId}",{params:{path:{orgId:t,noteId:e}}}),"vault.deleteNote")}async moveNote(t,e,r){return d(await this.client.POST("/api/v1/orgs/{orgId}/vault/notes/{noteId}/move",{params:{path:{orgId:t,noteId:e}},body:r}),"vault.moveNote")}async search(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/search",{params:{path:{orgId:t},query:e}}),"vault.search")}async graph(t){return d(await this.client.GET("/api/v1/orgs/{orgId}/vault/graph",{params:{path:{orgId:t}}}),"vault.graph")}async changes(t,e){return d(await this.client.GET("/api/v1/me/vault-changes",{params:{query:{org:t,since:e}}}),"vault.changes")}}class Ue{client;constructor(t){this.client=t}async list(t,e={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks",{params:{path:{orgId:t},query:e}}),"webhooks.list")}async create(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks",{params:{path:{orgId:t}},body:e}),"webhooks.create")}async get(t,e){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.get")}async update(t,e,r){return d(await this.client.PUT("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}},body:r}),"webhooks.update")}async delete(t,e){return d(await this.client.DELETE("/api/v1/orgs/{orgId}/webhooks/{webhookId}",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.delete")}async deliveries(t,e,r={}){return d(await this.client.GET("/api/v1/orgs/{orgId}/webhooks/{webhookId}/deliveries",{params:{path:{orgId:t,webhookId:e},query:r}}),"webhooks.deliveries")}async rotateSecret(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks/{webhookId}/rotate",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.rotateSecret")}async test(t,e){return d(await this.client.POST("/api/v1/orgs/{orgId}/webhooks/{webhookId}/test",{params:{path:{orgId:t,webhookId:e}}}),"webhooks.test")}}var fi="https://vcity.io";function yi(t){let e;try{e=new URL(t)}catch{throw Error(`@vcityio/api-client: invalid baseUrl (${t.slice(0,200)})`)}if(e.protocol==="https:")return;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return;throw Error(`@vcityio/api-client: baseUrl must use https:// for non-localhost hosts (got: ${e.protocol}//${e.hostname}).`)}function hi(t,e){let r=e??globalThis.fetch;if(!r)throw Error("@vcityio/api-client: no fetch implementation found. Provide options.fetch or run on Node >=20 / a browser.");return async function(i){if(!t)return r(i);let s=i.headers.get("Authorization")?.match(/^Bearer\s+(.+)$/)?.[1]?.trim();if(s&&s!=="undefined"&&s!=="null")return r(i);let o=new Headers(i.headers);o.set("Authorization",`Bearer ${t}`);let c=new Request(i,{headers:o});return r(c)}}class ar{raw;me;orgs;drafts;coupons;media;products;events;rooms;support;agents;conversations;customerAgent;posts;collections;bookings;bookingTypes;projects;blogs;orders;analytics;apiKeys;quotes;crm;webhooks;inbox;quickReplies;teamChat;calendar;vault;assistant;notifications;desk;campaigns;comments;newsletter;surveys;configurators;pos;dropshipping;storefront;public;chatRooms;billing;constructor(t={}){let e=t.baseUrl??fi;yi(e);let r=hi(t.token,t.fetch),n={baseUrl:e,fetch:r,headers:t.headers};this.raw=ir(n),this.me=new Xt(this.raw),this.orgs=new Zt(this.raw),this.drafts=new zt(this.raw),this.coupons=new Kt(this.raw),this.media=new Wt(this.raw),this.products=new te(this.raw),this.events=new ee(this.raw),this.rooms=new re(this.raw),this.support=new he(this.raw),this.agents=new ge(this.raw),this.conversations=new le(this.raw),this.customerAgent=new pe(this.raw),this.posts=new me(this.raw),this.collections=new ue(this.raw),this.bookings=new se(this.raw),this.bookingTypes=new ie(this.raw),this.projects=new ne(this.raw),this.blogs=new oe(this.raw),this.orders=new ae(this.raw),this.analytics=new de(this.raw),this.apiKeys=new we(this.raw),this.quotes=new ce(this.raw),this.crm=new Pe(this.raw),this.webhooks=new Ue(this.raw),this.inbox=new $e(this.raw),this.quickReplies=new De(this.raw),this.teamChat=new Ne(this.raw),this.calendar=new Ae(this.raw),this.vault=new Fe(this.raw),this.assistant=new xe(this.raw),this.notifications=new fe(this.raw),this.desk=new ye(this.raw),this.campaigns=new ve(this.raw),this.comments=new be(this.raw),this.newsletter=new ke(this.raw),this.surveys=new Ie(this.raw),this.configurators=new Ce(this.raw),this.pos=new Se(this.raw),this.dropshipping=new Oe(this.raw),this.storefront=new je(this.raw),this.public=new Te(this.raw),this.chatRooms=new Re(this.raw),this.billing=new Ee(this.raw)}}function cr(t={}){return new ar(t)}import lt from"node:fs";import ki from"node:os";import Be from"node:path";var wi=/\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[P_^X][^\x07\x1b]*(?:\x07|\x1b\\)|[^[\]P_^X])/g,vi=/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g,bi=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;function T(t){return t.replace(wi,"").replace(vi,"").replace(bi,"")}function Dr(t){let e;try{e=new URL(t)}catch{throw Error(`Refusing to open malformed URL: ${T(t).slice(0,100)}`)}if(e.protocol==="https:")return e;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return e;throw Error(`Refusing to open URL with unsafe protocol: ${e.protocol}`)}var $r=512;function O(t,e){let r=t.trim();if(!r)throw Error(`${e} must not be empty.`);if(r.length>$r)throw Error(`${e} must be at most ${$r} characters.`);if(/[\x00-\x1f\x7f]/.test(r))throw Error(`${e} must not contain control characters.`);return r}function St(t){let e;try{e=new URL(t)}catch{throw Error(`Invalid api base URL: ${t.slice(0,200)}`)}if(e.protocol==="https:")return e;if(e.protocol==="http:"&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"))return e;throw Error(`api base URL must use https:// (got: ${e.protocol}//${e.hostname}).`)}function gt(){if(process.env.VCITY_CONFIG_DIR)return Be.resolve(process.env.VCITY_CONFIG_DIR);return Be.join(ki.homedir(),".vcity")}function Me(){return Be.join(gt(),"auth.json")}function dr(){return Be.join(gt(),"config.json")}function Le(){let t=process.env.VCITY_API_BASE_URL||"https://vcity.io";return St(t),t}import dt from"node:fs";function Ot(t,e,r=384){if(process.platform==="win32"){dt.writeFileSync(t,e,{mode:r});try{dt.chmodSync(t,r)}catch{}return}let n=dt.constants.O_WRONLY|dt.constants.O_CREAT|dt.constants.O_TRUNC|dt.constants.O_NOFOLLOW,i=dt.openSync(t,n,r);try{dt.writeSync(i,e),dt.fchmodSync(i,r)}finally{dt.closeSync(i)}}function Ii(){let t=gt();lt.mkdirSync(t,{recursive:!0,mode:448});try{lt.chmodSync(t,448)}catch{}if(process.platform!=="win32"){let e;try{e=lt.statSync(t)}catch{return}if((e.mode&63)!==0)throw Error(`Refusing to write CLI credentials: ${t} is group- or world-accessible (mode ${(e.mode&511).toString(8)}). Tighten its permissions (\`chmod 700 ${t}\`) or set VCITY_CONFIG_DIR to a directory you own.`)}}function ji(t){if(!t||typeof t!=="object")return!1;let e=t;return typeof e.api_base_url==="string"&&typeof e.access_token==="string"&&typeof e.refresh_token==="string"&&typeof e.access_expires_at==="number"&&typeof e.refresh_expires_at==="number"&&!!e.user&&typeof e.user==="object"}function xt(){let t=Me();if(!lt.existsSync(t))return;try{let e=JSON.parse(lt.readFileSync(t,"utf-8"));if(!ji(e))return;if(St(e.api_base_url),new URL(e.api_base_url).origin!==new URL(Le()).origin)return;return e}catch{return}}function Ei(t){let e;try{e=lt.lstatSync(t)}catch{return}if(e.isSymbolicLink()||e.isFile()&&e.nlink>1)lt.rmSync(t,{force:!0})}function qe(t){Ii();let e=Me();Ei(e),Ot(e,JSON.stringify(t,null,2),384)}function $t(){let t=Me();if(lt.existsSync(t))lt.rmSync(t)}function _e(){let t=xt();if(!t)throw Error("Not logged in. Run `vcity login` first.");return t}var ur={name:"@vcityio/cli",version:"0.10.3",type:"module",description:"vcity command-line interface for org owners",main:"./dist/index.js",bin:{vcity:"./dist/index.js"},files:["dist","README.md","LICENSE"],engines:{node:">=20"},publishConfig:{access:"public"},optionalDependencies:{open:"^10.0.0"},keywords:["vcity","cli"],author:"Otherwise SAS",license:"MIT",homepage:"https://vcity.io",bugs:{email:"support@owsas.com"}};var nt=ur.version,Et=ur.name;var gr=60000,Mr=`vcity-cli/${nt} (${process.platform} ${process.arch})`,Nr=2048;class Dt extends Error{status;body;constructor(t,e,r){super(r??`HTTP ${t}`);this.status=t;this.body=e;this.name="ApiError"}}function Lr(t,e,r){if(e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e))throw Error(`Refusing to build URL with non-relative path: ${e.slice(0,100)}`);let n=new URL(t),i=new URL(e.startsWith("/")?e:`/${e}`,t);if(i.origin!==n.origin)throw Error(`Refusing to build URL outside base origin: ${i.origin}`);if(r){for(let[a,s]of Object.entries(r))if(s!==void 0&&s!==null&&!Number.isNaN(s))i.searchParams.set(a,String(s))}return i.toString()}var Fr=(t,e)=>typeof t==="string"&&t.length>0&&t.length<=e,Ge=Symbol("transient"),Ur=(t)=>typeof t==="number"&&Number.isFinite(t);async function Ri(t){try{let e=await fetch(Lr(t.api_base_url,"/api/cli/auth/refresh"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.refresh_token}`},body:JSON.stringify({refresh_token:t.refresh_token}),signal:AbortSignal.timeout(gr),redirect:"error"});if(e.status===429||e.status>=500)return Ge;if(!e.ok)return;let r=await e.json();if(!Fr(r.access_token,Nr)||!Fr(r.refresh_token,Nr)||!Ur(r.access_expires_at)||!Ur(r.refresh_expires_at)||r.access_expires_at<=Date.now()||r.refresh_expires_at<=Date.now())return;let n={...t,access_token:r.access_token,refresh_token:r.refresh_token,access_expires_at:r.access_expires_at,refresh_expires_at:r.refresh_expires_at};return qe(n),n}catch{return Ge}}async function Br(t){let e=()=>new Dt(401,void 0,"Session expired. Run `vcity login` again."),r=xt();if(r&&r.refresh_token!==t.refresh_token)return r;let n=await Ri(t);if(n&&n!==Ge)return n;let i=xt();if(i&&i.refresh_token!==t.refresh_token)return i;if(n===Ge)throw new Dt(503,void 0,"Could not refresh the session. Check your connection and try again.");throw $t(),e()}async function Nt(t,e={}){let{authed:r=!0,method:n="GET",body:i,query:a,baseUrl:s,headers:o}=e,c=r?_e():void 0,u=s??c?.api_base_url??"https://vcity.io",p={"content-type":"application/json","user-agent":Mr};if(c)p.authorization=`Bearer ${c.access_token}`;if(o)for(let[E,N]of Object.entries(o))p[E]=N;let w=await fetch(Lr(u,t,a),{method:n,headers:p,body:i===void 0?void 0:JSON.stringify(i),signal:AbortSignal.timeout(gr),redirect:"error"}),R=(w.headers.get("content-type")??"").includes("application/json")?await w.json().catch(()=>{return}):await w.text().catch(()=>{return});if(!w.ok){let E=(R&&typeof R==="object"&&"error"in R?String(R.error):void 0)??`Request failed (${w.status})`;throw new Dt(w.status,R,E)}return R}function Ci(t,e){let r=new URL(t).origin;if(r!==e)throw Error(`Refusing to attach Bearer token to cross-origin SDK request: ${r}`)}var Si=3,Oi=60000;function xi(t,e){let r=t.headers.get("retry-after"),n=r!==null&&/^\d+$/.test(r)?Number(r)*1000:r?Date.parse(r)-Date.now():Number.NaN,i=Number.isFinite(n)?n:1000*2**e;return Math.min(Math.max(i,0),Oi)}async function Ai(t){for(let e=0;;e++){let r=await t();if(r.status!==429||e>=Si)return r;await new Promise((n)=>setTimeout(n,xi(r,e)))}}function Pi(){let t=async(e,r,n)=>{Ci(e.url,n);let i=new Headers(e.headers);i.set("authorization",`Bearer ${r}`),i.set("user-agent",Mr);let a=new Request(e,{headers:i,signal:AbortSignal.timeout(gr),redirect:e.redirect==="manual"?"manual":"error"});return globalThis.fetch(a)};return async function(r){let n=_e(),i=new URL(n.api_base_url).origin;if(Date.now()>=n.access_expires_at){if(Date.now()>=n.refresh_expires_at)throw $t(),new Dt(401,void 0,"Session expired. Run `vcity login` again.");n=await Br(n)}let a=await Ai(()=>t(r.clone(),n.access_token,i));if(a.status!==401)return a;return n=await Br(n),t(r,n.access_token,i)}}function l(){let t=_e();return cr({baseUrl:t.api_base_url,fetch:Pi()})}import Tt from"node:fs";import $i from"node:path";var lr=16777216;function Di(t){let e=new Uint8Array(t+1),r=0;while(r<e.length){let n=Tt.readSync(0,e,r,e.length-r,null);if(n===0)break;r+=n}if(r>t)throw Error(`--data: stdin body exceeds the ${t}-byte cap.`);return Buffer.from(e.buffer,e.byteOffset,r).toString("utf-8")}function P(t){if(t===void 0)return;let e;if(t==="-"){if(process.stdin.isTTY)throw Error("--data: reading from stdin (-) but nothing is piped in");try{e=Di(lr)}catch(r){let n=r instanceof Error?r.message:String(r);if(n.startsWith("--data:"))throw r;throw Error(`--data: could not read stdin: ${n}`)}}else if(t.startsWith("@")){let r=t.slice(1);if(r.length===0)throw Error("--data: missing file path after `@`");if(!/\.json$/i.test(r))throw Error(`--data: @file path must point to a .json file (got: ${r})`);let n;try{n=Tt.realpathSync(r)}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not read ${r}: ${o}`)}if(!/\.json$/i.test(n))throw Error(`--data: @file path must point to a .json file (got: ${r} → ${n})`);let i;try{i=Tt.realpathSync(process.cwd())}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not resolve cwd: ${o}`)}if(n!==i&&!n.startsWith(i+$i.sep))throw Error(`--data: @file path must be inside the current working directory (got: ${r}). To send a file from elsewhere, pipe it: cat <file> | vcity ... --data -`);let a;try{a=Tt.openSync(n,"r")}catch(s){let o=s instanceof Error?s.message:String(s);throw Error(`--data: could not read ${r}: ${o}`)}try{let s;try{s=Tt.fstatSync(a)}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`--data: could not read ${r}: ${c}`)}if(s.nlink>1)throw Error(`--data: @file path must not be a hard link (got: ${r})`);if(s.size>lr)throw Error(`--data: ${r} exceeds the ${lr}-byte body cap (got ${s.size} bytes).`);try{e=Tt.readFileSync(a,"utf-8")}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`--data: could not read ${r}: ${c}`)}}finally{try{Tt.closeSync(a)}catch{}}}else e=t;try{return JSON.parse(e)}catch{throw Error("--data: invalid JSON")}}import Rt from"node:fs";function Ni(){let t=gt();Rt.mkdirSync(t,{recursive:!0,mode:448});try{Rt.chmodSync(t,448)}catch{}if(process.platform!=="win32"){let e;try{e=Rt.statSync(t)}catch{return}if((e.mode&63)!==0)throw Error(`Refusing to write CLI config: ${t} is group- or world-accessible (mode ${(e.mode&511).toString(8)}). Tighten its permissions (\`chmod 700 ${t}\`) or set VCITY_CONFIG_DIR to a directory you own.`)}}function Fi(t){if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;if(e.active_org!==void 0&&typeof e.active_org!=="string")return!1;if(e.default_format!==void 0&&e.default_format!=="pretty"&&e.default_format!=="json")return!1;return!0}function Ct(){let t=dr();if(!Rt.existsSync(t))return{};try{let e=JSON.parse(Rt.readFileSync(t,"utf-8"));return Fi(e)?e:{}}catch{return{}}}function Ui(t){let e;try{e=Rt.lstatSync(t)}catch{return}if(e.isSymbolicLink()||e.isFile()&&e.nlink>1)Rt.rmSync(t,{force:!0})}function qr(t){Ni();let r={...Ct(),...t},n=dr();return Ui(n),Ot(n,JSON.stringify(r,null,2),384),r}function h(t){if(t)return t;let e=Ct();if(!e.active_org)throw Error("No active org. Run `vcity org use <slug>` or pass --org <slug>.");return e.active_org}function f(t){if(t)return"json";if(!process.stdout.isTTY)return"json";return"pretty"}function g(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
9
|
+
`)}function Bi(t,e){if(t.length===0)return"(no rows)";let r=t.map((o)=>e.map((c)=>T(c.get(o)??""))),n=e.map((o,c)=>Math.max(o.header.length,...r.map((u)=>u[c].length))),i=n.map((o)=>"-".repeat(o)).join(" "),a=e.map((o,c)=>o.header.padEnd(n[c])).join(" "),s=r.map((o)=>o.map((c,u)=>c.padEnd(n[u])).join(" "));return[a,i,...s].join(`
|
|
10
|
+
`)}function k(t,e){process.stdout.write(`${Bi(t,e)}
|
|
11
|
+
`)}function j(t){for(let[e,r]of Object.entries(t)){if(r===void 0||r===null)continue;let n=typeof r==="object"?JSON.stringify(r):String(r);process.stdout.write(`${T(e).padEnd(20)} ${T(n)}
|
|
12
|
+
`)}}import Mi from"node:readline";function _(t){let e=Mi.createInterface({input:process.stdin,output:process.stdout});return new Promise((r)=>{e.question(`${T(t)} `,(n)=>{e.close();let i=n.trim().toLowerCase();r(i==="y"||i==="yes")})})}var _r=["draft","public","hidden"];function pr(t){if(t===void 0)return;if(!_r.includes(t))throw Error(`invalid --visibility: ${t}. Allowed: ${_r.join(", ")}`);return t}var Gr=["blog","news"];function Vr(t){if(t===void 0)return;if(!Gr.includes(t))throw Error(`invalid --type: ${t}. Allowed: ${Gr.join(", ")}`);return t}function Jr(t){if(t===void 0)return;return t.split(",").map((e)=>e.trim()).filter((e)=>e.length>0)}async function Hr(t={}){let e=f(t.json),r=h(t.org),n=pr(t.visibility),i={};if(t.limit!==void 0)i.limit=t.limit;if(t.search!==void 0)i.search=t.search;if(n!==void 0)i.visibility=n;let s=await l().blogs.list(r,i),o=s.data??[];if(e==="json"){g({org:r,blogs:o,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});return}k(o,[{header:"ID",get:(c)=>c.id},{header:"TITLE",get:(c)=>c.title??""},{header:"SLUG",get:(c)=>c.slug??""},{header:"VISIBILITY",get:(c)=>c.visibility??""},{header:"TYPE",get:(c)=>c.type??"blog"},{header:"UPDATED",get:(c)=>c.updatedAt!==void 0?new Date(c.updatedAt).toISOString():""}])}async function Yr(t,e={}){let r=f(e.json),n=h(e.org),a=await l().blogs.get(n,t);if(r==="json"){g(a);return}j(a)}async function Qr(t={}){let e=f(t.json),r=h(t.org),n=pr(t.visibility),i=Vr(t.type),a=P(t.data),s=a&&typeof a==="object"?{...a}:{};if(t.title!==void 0)s.title=t.title;if(t.slug!==void 0)s.slug=t.slug;if(t.summary!==void 0)s.summary=t.summary;if(t.content!==void 0)s.content=t.content;if(n!==void 0)s.visibility=n;if(i!==void 0)s.type=i;let o=Jr(t.tags);if(o!==void 0)s.tags=o;if(s.title===void 0)throw Error("blogs create: --title is required (or supply it via --data)");let u=await l().blogs.create(r,s);if(e==="json"){g(u);return}process.stdout.write(`Created blog:
|
|
13
|
+
`),j(u)}async function Wr(t,e={}){let r=f(e.json),n=h(e.org),i=pr(e.visibility),a=Vr(e.type),s=P(e.data),o=s&&typeof s==="object"?{...s}:{};if(e.title!==void 0)o.title=e.title;if(e.slug!==void 0)o.slug=e.slug;if(e.summary!==void 0)o.summary=e.summary;if(e.content!==void 0)o.content=e.content;if(i!==void 0)o.visibility=i;if(a!==void 0)o.type=a;let c=Jr(e.tags);if(c!==void 0)o.tags=c;if(Object.keys(o).length===0)throw Error("blogs update: nothing to update (pass at least one field or --data)");let p=await l().blogs.update(n,t,o);if(r==="json"){g(p);return}process.stdout.write(`Updated blog:
|
|
14
|
+
`),j(p)}async function zr(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("blogs delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete blog ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
15
|
+
`);return}}let a=await l().blogs.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted blog ${t}.
|
|
16
|
+
`)}async function Kr(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;if(t.enabled!==void 0)n.enabled=t.enabled;let a=await l().bookingTypes.list(r,n),s=a.data??[];if(e==="json"){g({org:r,bookingTypes:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"NAME",get:(o)=>o.name??""},{header:"SLUG",get:(o)=>o.slug??""},{header:"DURATION",get:(o)=>o.duration!==void 0?String(o.duration):""},{header:"ENABLED",get:(o)=>o.enabled!==void 0?String(o.enabled):""}])}async function Xr(t,e={}){let r=f(e.json),n=h(e.org),a=await l().bookingTypes.get(n,t);if(r==="json"){g(a);return}j(a)}function Zr(t){let e=P(t.data),r=e&&typeof e==="object"?{...e}:{};if(t.name!==void 0)r.name=t.name;if(t.duration!==void 0)r.duration=t.duration;if(t.description!==void 0)r.description=t.description;if(t.bufferBefore!==void 0)r.bufferBefore=t.bufferBefore;if(t.bufferAfter!==void 0)r.bufferAfter=t.bufferAfter;if(t.color!==void 0)r.color=t.color;if(t.assignee!==void 0)r.assignees=[t.assignee];if(t.roundRobin!==void 0)r.roundRobin=t.roundRobin;if(t.enabled!==void 0)r.enabled=t.enabled;if(t.sortOrder!==void 0)r.sortOrder=t.sortOrder;return r}async function ts(t={}){let e=f(t.json),r=h(t.org),n=Zr(t);if(n.name===void 0)throw Error("booking-types create: --name is required (or supply it via --data)");if(n.duration===void 0)throw Error("booking-types create: --duration is required (or supply it via --data)");let a=await l().bookingTypes.create(r,n);if(e==="json"){g(a);return}process.stdout.write(`Created booking type:
|
|
17
|
+
`),j(a)}async function es(t,e={}){let r=f(e.json),n=h(e.org),i=Zr(e);if(Object.keys(i).length===0)throw Error("booking-types update: nothing to update (pass at least one field or --data)");let s=await l().bookingTypes.update(n,t,i);if(r==="json"){g(s);return}process.stdout.write(`Updated booking type:
|
|
18
18
|
`),j(s)}async function rs(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("booking-types delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete booking type ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
19
|
-
`);return}}let a=await
|
|
20
|
-
`)}function x(t){if(t==null)return"";return new Date(t).toISOString().replace("T"," ").slice(0,16)}async function ut(t,e=Number.POSITIVE_INFINITY){let r=[],n=new Set;for(let i=0;r.length<e;){let a=await t(i,Math.min(200,e-r.length)),s=a.data??[];for(let o of s){let c=o.id;if(c!==void 0&&n.has(c))continue;if(c!==void 0)n.add(c);r.push(o)}if(i+=s.length,!a.hasMore||s.length===0)break}return r}var Ve=new Set(["PENDING","APPROVED","REJECTED","CANCELED","COMPLETED","NO_SHOW"]);async function ns(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&!Ve.has(t.status))throw Error(`Invalid booking status: ${t.status}. Allowed: ${[...Ve].join(", ")}`);let n={};if(t.limit!==void 0)n.limit=t.limit;if(t.status!==void 0)n.status=t.status;if(t.fromTs!==void 0)n.fromTs=t.fromTs;if(t.toTs!==void 0)n.toTs=t.toTs;let a=await
|
|
21
|
-
`),j(s)}async function as(t,e={}){let r=f(e.json),n=h(e.org);if(e.status!==void 0&&!Ve.has(e.status))throw Error(`Invalid booking status: ${e.status}. Allowed: ${[...Ve].join(", ")}`);let i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.status!==void 0)a.status=e.status;if(e.assignee!==void 0)a.assigneeUid=e.assignee;if(Object.keys(a).length===0)throw Error("bookings update: nothing to update (pass --status and/or --assignee)");let o=await
|
|
19
|
+
`);return}}let a=await l().bookingTypes.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted booking type ${t}.
|
|
20
|
+
`)}function x(t){if(t==null)return"";return new Date(t).toISOString().replace("T"," ").slice(0,16)}async function ut(t,e=Number.POSITIVE_INFINITY){let r=[],n=new Set;for(let i=0;r.length<e;){let a=await t(i,Math.min(200,e-r.length)),s=a.data??[];for(let o of s){let c=o.id;if(c!==void 0&&n.has(c))continue;if(c!==void 0)n.add(c);r.push(o)}if(i+=s.length,!a.hasMore||s.length===0)break}return r}var Ve=new Set(["PENDING","APPROVED","REJECTED","CANCELED","COMPLETED","NO_SHOW"]);async function ns(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&!Ve.has(t.status))throw Error(`Invalid booking status: ${t.status}. Allowed: ${[...Ve].join(", ")}`);let n={};if(t.limit!==void 0)n.limit=t.limit;if(t.status!==void 0)n.status=t.status;if(t.fromTs!==void 0)n.fromTs=t.fromTs;if(t.toTs!==void 0)n.toTs=t.toTs;let a=await l().bookings.list(r,n),s=a.data??[];if(e==="json"){g({org:r,bookings:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"NAME",get:(o)=>o.name??""},{header:"EMAIL",get:(o)=>o.email??""},{header:"REQUESTED",get:(o)=>x(o.requestedDate)},{header:"STATUS",get:(o)=>o.status??""}])}async function os(t,e={}){let r=f(e.json),n=h(e.org),a=await l().bookings.get(n,t);if(r==="json"){g(a);return}j(a)}function ss(t,e){if(/^-?\d+$/.test(t)){let n=Number(t);if(Number.isFinite(n))return n}let r=Date.parse(t);if(Number.isFinite(r))return r;throw Error(`${e}: expected ISO 8601 or epoch ms (got: ${t})`)}async function is(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.name!==void 0)i.name=t.name;if(t.email!==void 0)i.email=t.email;if(t.start!==void 0)i.requestedDate=ss(t.start,"--start");if(t.end!==void 0)i.requestedEndDate=ss(t.end,"--end");if(t.timezone!==void 0)i.timezone=t.timezone;if(t.phone!==void 0)i.telephone=t.phone;if(t.company!==void 0)i.company=t.company;if(t.note!==void 0)i.note=t.note;if(t.bookingType!==void 0)i.bookingTypeId=t.bookingType;if(t.assignee!==void 0)i.assigneeUid=t.assignee;for(let[o,c]of[["name","--name"],["email","--email"],["requestedDate","--start"],["requestedEndDate","--end"],["timezone","--timezone"]])if(i[o]===void 0)throw Error(`bookings create: ${c} is required (or supply it via --data)`);let s=await l().bookings.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created booking:
|
|
21
|
+
`),j(s)}async function as(t,e={}){let r=f(e.json),n=h(e.org);if(e.status!==void 0&&!Ve.has(e.status))throw Error(`Invalid booking status: ${e.status}. Allowed: ${[...Ve].join(", ")}`);let i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.status!==void 0)a.status=e.status;if(e.assignee!==void 0)a.assigneeUid=e.assignee;if(Object.keys(a).length===0)throw Error("bookings update: nothing to update (pass --status and/or --assignee)");let o=await l().bookings.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated booking:
|
|
22
22
|
`),j(o)}async function cs(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("bookings cancel: --yes is required in JSON / non-interactive mode");if(!await _(`Cancel booking ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
23
|
-
`);return}}let a=await
|
|
24
|
-
`)}var
|
|
25
|
-
`);return}k(s,[{header:"TIME",get:(o)=>o.requestedDate?new Date(o.requestedDate).toTimeString().slice(0,5):""},{header:"NAME",get:(o)=>o.name??""},{header:"STATUS",get:(o)=>o.status??""},{header:"EMAIL",get:(o)=>o.email??""},{header:"ID",get:(o)=>o.id}])}import pt from"node:fs";class y extends Error{constructor(t){super(t);this.name="UsageError"}}function m(t,e){return typeof t[e]==="string"?t[e]:void 0}function At(t,e){let r=m(t,e);return r===void 0?void 0:O(r,`--${e}`)}function C(t,e,{min:r=0,max:n=Number.MAX_SAFE_INTEGER}={}){let i=m(t,e);if(i===void 0)return;if(!/^\d+$/.test(i)||Number(i)<r||Number(i)>n)throw new y(`--${e} must be an integer between ${r} and ${n} (got: ${i})`);return Number(i)}function A(t,e,r){let n=m(t,e);if(n===void 0)return;if(!r.includes(n))throw new y(`--${e} must be one of ${r.join(", ")} (got: ${n})`);return n}var
|
|
26
|
-
`);return r}function q(t,e){let r=m(t,e);return r===void 0?void 0:r.split(",").map((n)=>n.trim()).filter(Boolean)}function yt(t,e=!1){if(t===void 0)return"";let r=new Date(t),n=(a)=>String(a).padStart(2,"0"),i=`${r.getFullYear()}-${n(r.getMonth()+1)}-${n(r.getDate())}`;return e?i:`${i} ${n(r.getHours())}:${n(r.getMinutes())}`}var us=86400000;function mr(t){let e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}function
|
|
23
|
+
`);return}}let a=await l().bookings.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Canceled booking ${t}.
|
|
24
|
+
`)}var Li=new Set(["CANCELED","REJECTED"]);async function ds(t={}){let e=f(t.json),r=h(t.org),n=new Date(t.now??Date.now());n.setHours(0,0,0,0);let i=new Date(n);i.setDate(i.getDate()+1);let a=l(),s=(await ut(async(o,c)=>{let u=await a.bookings.list(r,{skip:o,limit:c,fromTs:n.getTime(),toTs:i.getTime()-1});return{data:u.data??[],hasMore:u.hasMore}})).filter((o)=>!Li.has(o.status??"")).sort((o,c)=>(o.requestedDate??0)-(c.requestedDate??0));if(e==="json"){g({org:r,from:n.getTime(),to:i.getTime(),bookings:s});return}if(s.length===0){process.stdout.write(`No bookings today.
|
|
25
|
+
`);return}k(s,[{header:"TIME",get:(o)=>o.requestedDate?new Date(o.requestedDate).toTimeString().slice(0,5):""},{header:"NAME",get:(o)=>o.name??""},{header:"STATUS",get:(o)=>o.status??""},{header:"EMAIL",get:(o)=>o.email??""},{header:"ID",get:(o)=>o.id}])}import pt from"node:fs";class y extends Error{constructor(t){super(t);this.name="UsageError"}}function m(t,e){return typeof t[e]==="string"?t[e]:void 0}function At(t,e){let r=m(t,e);return r===void 0?void 0:O(r,`--${e}`)}function C(t,e,{min:r=0,max:n=Number.MAX_SAFE_INTEGER}={}){let i=m(t,e);if(i===void 0)return;if(!/^\d+$/.test(i)||Number(i)<r||Number(i)>n)throw new y(`--${e} must be an integer between ${r} and ${n} (got: ${i})`);return Number(i)}function A(t,e,r){let n=m(t,e);if(n===void 0)return;if(!r.includes(n))throw new y(`--${e} must be one of ${r.join(", ")} (got: ${n})`);return n}var qi=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?)?$/,_i=/^(\d{4})-(\d{2})-(\d{2})$/;function M(t,e){let r=m(t,e);if(r===void 0)return;let n=r.match(_i),i=/^\d+$/.test(r)?Number(r):n?new Date(Number(n[1]),Number(n[2])-1,Number(n[3])).getTime():qi.test(r)?Date.parse(r):Number.NaN;if(!Number.isFinite(i)||i<0)throw new y(`--${e} must be unix-ms or a date like 2026-11-01 (got: ${r})`);return i}function I(t,e,r){if(!t)throw new y(`usage: ${e}`);return O(t,r)}function G(t,e){if(t===void 0||t.trim()==="")throw new y(`usage: ${e}`);return t}var Gi=16777216;function st(t){let e;try{e=pt.statSync(t)}catch{throw new y(`cannot read ${t}: no such file`)}if(!e.isFile())throw new y(`${t} is not a regular file`);if(e.size>Gi)throw new y(`${t} is larger than 16 MiB`);return pt.readFileSync(t,"utf8")}function Z(t,e){let r=pt.constants.O_WRONLY|pt.constants.O_CREAT|pt.constants.O_TRUNC|(pt.constants.O_NOFOLLOW??0),n=pt.openSync(t,r,420);try{pt.writeSync(n,e)}finally{pt.closeSync(n)}}async function B(t,e){if(e.yes)return!0;if(f(e.json)==="json")throw new y("--yes is required in JSON / non-interactive mode");let r=await _(`${t} [y/N]`);if(!r)process.stdout.write(`Aborted.
|
|
26
|
+
`);return r}function q(t,e){let r=m(t,e);return r===void 0?void 0:r.split(",").map((n)=>n.trim()).filter(Boolean)}function yt(t,e=!1){if(t===void 0)return"";let r=new Date(t),n=(a)=>String(a).padStart(2,"0"),i=`${r.getFullYear()}-${n(r.getMonth()+1)}-${n(r.getDate())}`;return e?i:`${i} ${n(r.getHours())}:${n(r.getMinutes())}`}var us=86400000;function mr(t){let e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}function Vi(t){k([...t].sort((e,r)=>e.startMillis-r.startMillis),[{header:"START",get:(e)=>e.allDay?`${yt(e.startMillis,!0)} (all day)`:yt(e.startMillis)},{header:"END",get:(e)=>e.allDay?"":yt(e.endMillis)},{header:"TYPE",get:(e)=>e.type},{header:"TITLE",get:(e)=>e.title??""},{header:"WHERE",get:(e)=>e.locationLabel??e.calendarName??""},{header:"ID",get:(e)=>e.id}])}var Ji="vcity calendar list [--from <date>] [--to <date>] [--days <n>] | ics [<feedId>] [--output <file>] | feeds list|create|rotate|revoke | add --title <s> --start <date> --end <date> | cancel <entryId> | holidays | external list|add|refresh|remove | settings | staff";async function Hi(t,e,r,n,i){let a=l().calendar;switch(e){case void 0:case"list":{let{data:s}=await a.listFeeds(t);if(i)g({org:t,feeds:s});else k(s,[{header:"ID",get:(o)=>String(o.id)},{header:"SCOPE",get:(o)=>String(o.scope??"")},{header:"NAMES",get:(o)=>o.showCustomerNames?"shown":"hidden"},{header:"LAST USED",get:(o)=>x(o.lastAccessedAt)},{header:"SUBSCRIBE (keep private)",get:(o)=>String(o.webcalUrl??o.url??"")}]);return}case"create":{let s=await a.createFeed(t,{scope:A(n,"scope",["org","member"])??"org",...n["show-names"]===!0&&{showCustomerNames:!0},...n["hide-names"]===!0&&{showCustomerNames:!1}});if(i)g(s);else process.stdout.write(T(`Subscribe in any calendar app (anyone with this link can read the calendar):
|
|
27
27
|
${String(s.webcalUrl??"")}
|
|
28
|
-
`));return}case"rotate":{let s=I(r[0],"vcity calendar feeds rotate <feedId>","feed id"),o=await a.updateFeed(t,s,{rotate:!0});if(i)g(o);else process.stdout.write(
|
|
28
|
+
`));return}case"rotate":{let s=I(r[0],"vcity calendar feeds rotate <feedId>","feed id"),o=await a.updateFeed(t,s,{rotate:!0});if(i)g(o);else process.stdout.write(T(`New link (the old one stops working):
|
|
29
29
|
${String(o.webcalUrl??"")}
|
|
30
30
|
`));return}case"revoke":{let s=I(r[0],"vcity calendar feeds revoke <feedId> [--yes]","feed id");if(!await B(`Revoke calendar link ${s}? Subscribed apps stop updating.`,{yes:n.yes===!0,json:i}))return;let o=await a.revokeFeed(t,s);if(i)g(o);else process.stdout.write(`Revoked.
|
|
31
|
-
`);return}default:throw new y("usage: vcity calendar feeds list|create [--scope org|member] [--show-names]|rotate <id>|revoke <id>")}}async function
|
|
31
|
+
`);return}default:throw new y("usage: vcity calendar feeds list|create [--scope org|member] [--show-names]|rotate <id>|revoke <id>")}}async function Yi(t,e,r,n,i){let a=l().calendar;switch(e){case void 0:case"list":{let{data:s}=await a.listExternal(t);if(i)g({org:t,calendars:s});else k(s,[{header:"ID",get:(o)=>String(o.id)},{header:"NAME",get:(o)=>String(o.name??"")},{header:"BLOCKS",get:(o)=>o.blockAvailability?"yes":"no"},{header:"LAST SYNC",get:(o)=>x(o.lastSyncedAt??o.lastFetchedAt)},{header:"ERROR",get:(o)=>String(o.lastError??"")}]);return}case"add":{let s=G(m(n,"url"),"vcity calendar external add --name <s> --url <ics url> [--block]"),o=G(m(n,"name"),"vcity calendar external add --name <s> --url <ics url> [--block]"),c=await a.addExternal(t,{name:o,url:s,blockAvailability:n.block===!0});if(i)g(c);else process.stdout.write(`Imported ${T(o)}.
|
|
32
32
|
`);return}case"refresh":{let s=I(r[0],"vcity calendar external refresh <id>","calendar id"),o=await a.updateExternal(t,s,{refresh:!0});if(i)g(o);else process.stdout.write(`Refreshed.
|
|
33
33
|
`);return}case"remove":{let s=I(r[0],"vcity calendar external remove <id> [--yes]","calendar id");if(!await B(`Remove imported calendar ${s}?`,{yes:n.yes===!0,json:i}))return;let o=await a.removeExternal(t,s);if(i)g(o);else process.stdout.write(`Removed.
|
|
34
|
-
`);return}default:throw new y("usage: vcity calendar external list|add --name <s> --url <ics url> [--block]|refresh <id>|remove <id>")}}async function gs(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=
|
|
35
|
-
`);else process.stdout.write(process.stdout.isTTY?
|
|
34
|
+
`);return}default:throw new y("usage: vcity calendar external list|add --name <s> --url <ics url> [--block]|refresh <id>|remove <id>")}}async function gs(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().calendar;switch(t){case"list":{let s=M(r,"from")??mr(Date.now()),o=C(r,"days",{min:1,max:62})??7,c=M(r,"to")??s+o*us;if(c<=s)throw new y("--to must be after --from");if(c-s>62*us)throw new y("the calendar shows at most 62 days at a time");let{data:u}=await a.list(i,{from:s,to:c,...r["no-overlays"]===!0&&{overlays:"false"}});if(n)g({org:i,from:s,to:c,items:u});else Vi(u);return}case"ics":{let{data:s}=await a.listFeeds(i),o=s,c=e[0]?o.find((v)=>v.id===e[0]):o[0];if(!c?.url)throw new y(e[0]?`no calendar link ${e[0]}`:"this store has no calendar link yet; create one with `vcity calendar feeds create`");let u=new URL(c.url).searchParams.get("token");if(!u)throw Error("calendar link has no token");let p=await a.ics(i,u),w=m(r,"output");if(w)Z(w,p),process.stderr.write(`Wrote ${T(w)}
|
|
35
|
+
`);else process.stdout.write(process.stdout.isTTY?T(p):p);return}case"feeds":return Hi(i,e[0],e.slice(1),r,n);case"external":return Yi(i,e[0],e.slice(1),r,n);case"add":{let c={...P(m(r,"data"))??{}};if(m(r,"title")!==void 0)c.title=m(r,"title");if(m(r,"description")!==void 0)c.description=m(r,"description");let u=M(r,"start"),p=M(r,"end");if(u!==void 0)c.startMillis=u;if(p!==void 0)c.endMillis=p;if(r["all-day"]===!0)c.allDay=!0;c.category=A(r,"category",["custom","timeoff","meeting","holiday"])??c.category??"custom";let w=A(r,"location",["virtual","physical"]);if(w)c.locationType=w;if(c.category==="meeting"&&c.locationType===void 0)throw new y("a meeting needs --location virtual|physical");if(typeof c.title!=="string"||typeof c.startMillis!=="number"||typeof c.endMillis!=="number")throw new y("usage: vcity calendar add --title <s> --start <date|ms> --end <date|ms> [--all-day] [--category custom|timeoff|meeting --location virtual|physical] [--description <s>] [--data <json>]");if(c.timezone===void 0)c.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone;let v=await a.createEntry(i,c);if(n)g(v);else process.stdout.write(`Added ${T(String(c.title))}.
|
|
36
36
|
`);return}case"cancel":{let s=I(e[0],"vcity calendar cancel <entryId> [--scope single|following|all] [--yes]","entry id");if(!await B(`Cancel calendar entry ${s}?`,{yes:r.yes===!0,json:n}))return;let o=A(r,"scope",["single","following","all"]),c=await a.cancelEntry(i,s,o?{scope:o}:{});if(n)g(c);else process.stdout.write(`Cancelled.
|
|
37
|
-
`);return}case"holidays":{let s=A(r,"country",["CO","US","MX","ES","BR","AR","CL","PE"]),o=C(r,"year",{min:1970,max:2100}),c=await a.holidays(i,{...s&&{country:s},...o!==void 0&&{year:o}});if(n)g(c);else k(c.data,[{header:"DATE",get:(u)=>u.date},{header:"HOLIDAY",get:(u)=>u.name}]);return}case"settings":{let s=await a.settings(i);g(s);return}case"staff":{let s=await a.staff(i);if(n)g(s);else k(s.data??[],[{header:"UID",get:(o)=>String(o.uid??o.id??"")},{header:"NAME",get:(o)=>String(o.name??"")}]);return}default:throw new y(`usage: ${
|
|
38
|
-
`);return}k(s,[{header:"START",get:(o)=>yt(o.start)},{header:"END",get:(o)=>yt(o.end).slice(11)}])}async function ps(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=
|
|
37
|
+
`);return}case"holidays":{let s=A(r,"country",["CO","US","MX","ES","BR","AR","CL","PE"]),o=C(r,"year",{min:1970,max:2100}),c=await a.holidays(i,{...s&&{country:s},...o!==void 0&&{year:o}});if(n)g(c);else k(c.data,[{header:"DATE",get:(u)=>u.date},{header:"HOLIDAY",get:(u)=>u.name}]);return}case"settings":{let s=await a.settings(i);g(s);return}case"staff":{let s=await a.staff(i);if(n)g(s);else k(s.data??[],[{header:"UID",get:(o)=>String(o.uid??o.id??"")},{header:"NAME",get:(o)=>String(o.name??"")}]);return}default:throw new y(`usage: ${Ji}`)}}var Qi=86400000,Wi=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];async function ls(t){let e=h(m(t,"org")),r=M(t,"from")??mr(Date.now()),n=M(t,"to")??r+(C(t,"days",{min:1,max:62})??7)*Qi;if(n<=r)throw new y("--to must be after --from");let i=At(t,"type"),a=await l().bookings.slots(e,{from:r,to:n,...i!==void 0&&{bookingTypeId:i}});if(f(!!t.json)==="json"){g({org:e,from:r,to:n,...a});return}let s=a.slots;if(s.length===0){process.stdout.write(`No free slots in that range.
|
|
38
|
+
`);return}k(s,[{header:"START",get:(o)=>yt(o.start)},{header:"END",get:(o)=>yt(o.end).slice(11)}])}async function ps(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().bookings;switch(t){case void 0:case"list":{let s=At(r,"uid"),o=M(r,"from"),c=M(r,"to"),{data:u}=await a.listUnavailability(i,{...s!==void 0&&{uid:s},...o!==void 0&&{from:o},...c!==void 0&&{to:c}});if(n)g({org:i,timeOff:u});else k(u,[{header:"ID",get:(p)=>p.id},{header:"MEMBER",get:(p)=>p.uid},{header:"FROM",get:(p)=>yt(p.startDate,p.allDay)},{header:"TO",get:(p)=>yt(p.endDate,p.allDay)},{header:"REASON",get:(p)=>`${p.reason??""}${p.recurring?" (yearly)":""}`}]);return}case"add":{let o=At(r,"uid"),c=M(r,"from"),u=M(r,"to");if(o===void 0||c===void 0||u===void 0)throw new y("usage: vcity bookings time-off add --uid <uid> --from <date|ms> --to <date|ms> [--reason <s>] [--all-day] [--recurring]");if(u<=c)throw new y("--to must be after --from");let p=await a.addUnavailability(i,{uid:o,startDate:c,endDate:u,...m(r,"reason")!==void 0&&{reason:m(r,"reason")},...r["all-day"]===!0&&{allDay:!0},...r.recurring===!0&&{recurring:!0}});if(n)g(p);else process.stdout.write(`Added time off ${p.id}.
|
|
39
39
|
`);return}case"remove":{let s=I(e[0],"vcity bookings time-off remove <id> [--yes]","time off id");if(!await B(`Remove time off ${s}?`,{yes:r.yes===!0,json:n}))return;let o=await a.removeUnavailability(i,s);if(n)g(o);else process.stdout.write(`Removed.
|
|
40
|
-
`);return}default:throw new y("usage: vcity bookings time-off list [--uid] [--from] [--to] | add --uid --from --to | remove <id>")}}async function ms(t,e){let r=f(!!e.json)==="json",n=h(m(e,"org")),i=I(t[0],"vcity bookings hours <uid> [--data <json|@file|->]","uid"),a=
|
|
41
|
-
`);return}k(c,[{header:"DAY",get:(u)=>
|
|
42
|
-
`),j(o)}async function ks(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"update");hs(e.priority);let a=P(e.data),s=a&&typeof a==="object"?{...a}:{};if(e.title!==void 0)s.title=e.title;if(e.column!==void 0)s.columnId=e.column;if(e.description!==void 0)s.description=e.description;if(e.priority!==void 0)s.priority=e.priority;if(e.due!==void 0)s.dueDate=ys(e.due,"--due");if(e.assignee!==void 0)s.assignees=[e.assignee];if(e.archived!==void 0)s.archived=e.archived;if(Object.keys(s).length===0)throw Error("cards update: nothing to update (pass at least one field or --data)");let c=await
|
|
43
|
-
`),j(c)}async function Is(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"move");if(!e.column)throw Error("cards move: --column <columnId> is required");let a={columnId:e.column};if(e.order!==void 0)a.order=e.order;let o=await
|
|
40
|
+
`);return}default:throw new y("usage: vcity bookings time-off list [--uid] [--from] [--to] | add --uid --from --to | remove <id>")}}async function ms(t,e){let r=f(!!e.json)==="json",n=h(m(e,"org")),i=I(t[0],"vcity bookings hours <uid> [--data <json|@file|->]","uid"),a=l().bookings,s=P(m(e,"data")),o;if(s!==void 0){let u=Array.isArray(s)?{workingHours:s}:s;if(typeof u!=="object"||u===null)throw new y('--data must be a workingHours array or {"workingHours":[…]}');o=await a.setMemberHours(n,i,u)}else o=await a.getMemberHours(n,i);if(r){g(o);return}let c=o.workingHours;if(!c){process.stdout.write(`Uses the store hours (no personal schedule).
|
|
41
|
+
`);return}k(c,[{header:"DAY",get:(u)=>Wi[u.dayOfWeek]??String(u.dayOfWeek)},{header:"HOURS",get:(u)=>u.isWorkingDay?`${u.startTime}–${u.endTime}`:"off"}])}var fs=new Set(["urgent-important","not-urgent-important","urgent-not-important","not-urgent-not-important"]);function ys(t,e){if(/^-?\d+$/.test(t)){let n=Number(t);if(Number.isFinite(n))return n}let r=Date.parse(t);if(Number.isFinite(r))return r;throw Error(`${e}: expected ISO 8601 or epoch ms (got: ${t})`)}function ht(t,e){if(!t)throw Error(`cards ${e}: --project <id> is required`);return t}function hs(t){if(t!==void 0&&!fs.has(t))throw Error(`Invalid priority: ${t}. Allowed: ${[...fs].join(", ")}`)}async function ws(t={}){let e=f(t.json),r=h(t.org),n=ht(t.project,"list"),i={};if(t.limit!==void 0)i.limit=t.limit;if(t.column!==void 0)i.columnId=t.column;if(t.assignee!==void 0)i.assignee=t.assignee;if(t.archived)i.includeArchived=!0;let s=await l().projects.listCards(r,n,i),o=s.data??[];if(e==="json"){g({org:r,project:n,cards:o,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});return}k(o,[{header:"CODE",get:(c)=>c.code??""},{header:"TITLE",get:(c)=>c.title??""},{header:"COLUMN",get:(c)=>c.columnId??""},{header:"PRIORITY",get:(c)=>c.priority??""},{header:"ASSIGNEES",get:(c)=>(c.assignees??[]).join(",")},{header:"DUE",get:(c)=>c.dueDate!==void 0?new Date(c.dueDate).toISOString().slice(0,10):""},{header:"ID",get:(c)=>c.id}])}async function vs(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"get"),s=await l().projects.getCard(n,i,t);if(r==="json"){g(s);return}j(s)}async function bs(t={}){let e=f(t.json),r=h(t.org),n=ht(t.project,"create");hs(t.priority);let i=P(t.data),a=i&&typeof i==="object"?{...i}:{};if(t.title!==void 0)a.title=t.title;if(t.column!==void 0)a.columnId=t.column;if(t.description!==void 0)a.description=t.description;if(t.priority!==void 0)a.priority=t.priority;if(t.due!==void 0)a.dueDate=ys(t.due,"--due");if(t.assignee!==void 0)a.assignees=[t.assignee];if(t.order!==void 0)a.order=t.order;if(a.title===void 0)throw Error("cards create: --title is required (or supply it via --data)");if(a.columnId===void 0)throw Error("cards create: --column is required (or supply it via --data)");let o=await l().projects.createCard(r,n,a);if(e==="json"){g(o);return}process.stdout.write(`Created card:
|
|
42
|
+
`),j(o)}async function ks(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"update");hs(e.priority);let a=P(e.data),s=a&&typeof a==="object"?{...a}:{};if(e.title!==void 0)s.title=e.title;if(e.column!==void 0)s.columnId=e.column;if(e.description!==void 0)s.description=e.description;if(e.priority!==void 0)s.priority=e.priority;if(e.due!==void 0)s.dueDate=ys(e.due,"--due");if(e.assignee!==void 0)s.assignees=[e.assignee];if(e.archived!==void 0)s.archived=e.archived;if(Object.keys(s).length===0)throw Error("cards update: nothing to update (pass at least one field or --data)");let c=await l().projects.updateCard(n,i,t,s);if(r==="json"){g(c);return}process.stdout.write(`Updated card:
|
|
43
|
+
`),j(c)}async function Is(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"move");if(!e.column)throw Error("cards move: --column <columnId> is required");let a={columnId:e.column};if(e.order!==void 0)a.order=e.order;let o=await l().projects.moveCard(n,i,t,a);if(r==="json"){g(o);return}process.stdout.write(`Moved card to ${e.column}:
|
|
44
44
|
`),j(o)}async function js(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"delete");if(!e.yes){if(r==="json")throw Error("cards delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete card ${t} in project ${i}? [y/N]`)){process.stdout.write(`Aborted.
|
|
45
|
-
`);return}}let s=await
|
|
46
|
-
`)}async function
|
|
47
|
-
`),j(s)}async function Rs(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;if(t.search!==void 0)n.search=t.search;if(t.status!==void 0)n.status=t.status;let a=await
|
|
48
|
-
`),j(s)}async function Os(t,e={}){let r=f(e.json),n=h(e.org),i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.name!==void 0)a.name=e.name;if(e.slug!==void 0)a.slug=e.slug;if(e.status!==void 0)a.status=e.status;if(e.startsAt!==void 0)a.startsAt=Je(e.startsAt,"--starts-at");if(e.endsAt!==void 0)a.endsAt=Je(e.endsAt,"--ends-at");if(Object.keys(a).length===0)throw Error("events update: nothing to update (pass at least one field or --data)");let o=await
|
|
45
|
+
`);return}}let s=await l().projects.deleteCard(n,i,t);if(r==="json"){g(s);return}process.stdout.write(`Deleted card ${t}.
|
|
46
|
+
`)}async function Es(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"comments"),s=await l().projects.listCardComments(n,i,t,e.limit!==void 0?{limit:e.limit}:{}),o=s.data??[];if(r==="json"){g({org:n,project:i,card:t,comments:o,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});return}k(o,[{header:"AUTHOR",get:(c)=>c.authorName||(c.authorUid??"")},{header:"COMMENT",get:(c)=>c.content??""},{header:"AT",get:(c)=>c.createdAt!==void 0?new Date(c.createdAt).toISOString():""},{header:"ID",get:(c)=>c.id}])}async function Ts(t,e={}){let r=f(e.json),n=h(e.org),i=ht(e.project,"comment");if(!e.message)throw Error("cards comment: --message <text> is required");let s=await l().projects.createCardComment(n,i,t,{content:e.message});if(r==="json"){g(s);return}process.stdout.write(`Posted comment:
|
|
47
|
+
`),j(s)}async function Rs(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;if(t.search!==void 0)n.search=t.search;if(t.status!==void 0)n.status=t.status;let a=await l().events.list(r,n),s=a.data??[];if(e==="json"){g({org:r,events:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"NAME",get:(o)=>o.name??""},{header:"STARTS_AT",get:(o)=>o.startsAt!==void 0?new Date(o.startsAt).toISOString():""},{header:"STATUS",get:(o)=>o.status??""},{header:"CATEGORIES",get:(o)=>(o.categories??[]).join(",")}])}async function Cs(t,e={}){let r=f(e.json),n=h(e.org),a=await l().events.get(n,t);if(r==="json"){g(a);return}j(a)}function Je(t,e){if(/^-?\d+$/.test(t)){let n=Number(t);if(Number.isFinite(n))return n}let r=Date.parse(t);if(Number.isFinite(r))return r;throw Error(`${e}: expected ISO 8601 or epoch ms (got: ${t})`)}async function Ss(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.name!==void 0)i.name=t.name;if(t.slug!==void 0)i.slug=t.slug;if(t.startsAt!==void 0)i.startsAt=Je(t.startsAt,"--starts-at");if(t.endsAt!==void 0)i.endsAt=Je(t.endsAt,"--ends-at");if(i.name===void 0)throw Error("events create: --name is required (or supply it via --data)");let s=await l().events.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created event:
|
|
48
|
+
`),j(s)}async function Os(t,e={}){let r=f(e.json),n=h(e.org),i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.name!==void 0)a.name=e.name;if(e.slug!==void 0)a.slug=e.slug;if(e.status!==void 0)a.status=e.status;if(e.startsAt!==void 0)a.startsAt=Je(e.startsAt,"--starts-at");if(e.endsAt!==void 0)a.endsAt=Je(e.endsAt,"--ends-at");if(Object.keys(a).length===0)throw Error("events update: nothing to update (pass at least one field or --data)");let o=await l().events.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated event:
|
|
49
49
|
`),j(o)}async function xs(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("events delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete event ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
50
|
-
`);return}}let a=await
|
|
51
|
-
`)}function wt(t){return[...t].sort((e,r)=>(e.createdAt??0)-(r.createdAt??0)).map((e)=>{let r=e.mine?"you":e.sender?.name??"customer",n=e.deleted?"(deleted)":e.content??"",i=(e.files??[]).map((a)=>` [file: ${a.name??a.url??""}]`).join("");return
|
|
52
|
-
`)}var
|
|
50
|
+
`);return}}let a=await l().events.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted event ${t}.
|
|
51
|
+
`)}function wt(t){return[...t].sort((e,r)=>(e.createdAt??0)-(r.createdAt??0)).map((e)=>{let r=e.mine?"you":e.sender?.name??"customer",n=e.deleted?"(deleted)":e.content??"",i=(e.files??[]).map((a)=>` [file: ${a.name??a.url??""}]`).join("");return T(`${x(e.createdAt)} ${r}: ${n}${i}`)}).join(`
|
|
52
|
+
`)}var zi="vcity inbox list|show|search|reply|assign|close|reopen|read|customer|unread (reply: vcity inbox reply <id> --message <s> | --quick-reply <shortcut>)";function He(t){return t.trim().replace(/^\//,"").toLowerCase()}async function Ki(t,e){let{data:r}=await l().quickReplies.list(t),n=He(e),i=r.find((a)=>a.id===e||a.shortcut&&He(a.shortcut)===n);if(!i)throw new y(`no quick reply with id or shortcut "${e}" (see \`vcity quick-replies list\`)`);return i.body}async function As(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"list":{let s=await a.inbox.list(i,{...A(r,"status",["open","closed","all"])&&{status:A(r,"status",["open","closed","all"])},...m(r,"assigned-to")!==void 0&&{assignedTo:m(r,"assigned-to")},...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...C(r,"skip")!==void 0&&{skip:C(r,"skip")}});if(n)g({org:i,conversations:s.data,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});else k(s.data,[{header:"ID",get:(o)=>o.id},{header:"",get:(o)=>o.unread?"●":""},{header:"STATUS",get:(o)=>o.status??""},{header:"CUSTOMER",get:(o)=>o.contactName??o.contactEmail??""},{header:"CHANNEL",get:(o)=>o.messagingChannel??""},{header:"UPDATED",get:(o)=>x(o.updatedAt)},{header:"LAST MESSAGE",get:(o)=>String(o.lastMessage?.content??"").slice(0,60)}]);return}case"show":{let s=I(e[0],"vcity inbox show <conversationId> [--limit <n>]","conversation id"),[{conversation:o},c]=await Promise.all([a.inbox.get(i,s),a.inbox.listMessages(i,s,{...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")}})]);if(n)g({conversation:o,messages:c.data,hasMore:c.hasMore});else{let u=o;process.stdout.write(T(`${String(u.contactName??u.contactEmail??s)} · ${String(u.status??"")}
|
|
53
53
|
|
|
54
54
|
`)+`${wt(c.data)}
|
|
55
55
|
`)}return}case"search":{let s=I(e[0],"vcity inbox search <conversationId> --query <text>","conversation id"),o=m(r,"query")??e.slice(1).join(" ");if(!o||o.trim().length<2)throw new y("usage: vcity inbox search <conversationId> --query <text> (2+ characters)");let c=await a.inbox.search(i,s,o);if(n)g(c);else process.stdout.write(`${wt(c.data)}
|
|
56
|
-
`);return}case"reply":{let s=I(e[0],"vcity inbox reply <conversationId> --message <s>","conversation id"),o=m(r,"quick-reply"),c=o?await
|
|
56
|
+
`);return}case"reply":{let s=I(e[0],"vcity inbox reply <conversationId> --message <s>","conversation id"),o=m(r,"quick-reply"),c=o?await Ki(i,o):G(m(r,"message"),"vcity inbox reply <conversationId> --message <s> | --quick-reply <shortcut>"),u=await a.inbox.reply(i,s,{content:c,...m(r,"reply-to")&&{replyToId:m(r,"reply-to")}});if(n)g(u);else process.stdout.write(`Sent.
|
|
57
57
|
`);return}case"assign":{let s=I(e[0],"vcity inbox assign <conversationId> <uid|me> | --unassign","conversation id"),o=r.unassign===!0?null:I(e[1],"vcity inbox assign <conversationId> <uid>","uid"),c=await a.inbox.update(i,s,{assignedTo:o});if(n)g(c);else process.stdout.write(o?`Assigned to ${o}.
|
|
58
58
|
`:`Unassigned.
|
|
59
59
|
`);return}case"close":case"reopen":{let s=I(e[0],`vcity inbox ${t} <conversationId>`,"conversation id"),o=await a.inbox.update(i,s,{status:t==="close"?"closed":"open"});if(n)g(o);else process.stdout.write(t==="close"?`Closed.
|
|
60
60
|
`:`Reopened.
|
|
61
61
|
`);return}case"read":{let s=I(e[0],"vcity inbox read <conversationId>","conversation id"),o=await a.inbox.markRead(i,s);if(n)g(o);else process.stdout.write(`Marked read.
|
|
62
62
|
`);return}case"customer":{let s=I(e[0],"vcity inbox customer <conversationId>","conversation id"),o=await a.inbox.customer(i,s);if(n)g(o);else j(o);return}case"unread":{let{count:s}=await a.inbox.unreadCount(i);if(n)g({org:i,count:s});else process.stdout.write(`${s}
|
|
63
|
-
`);return}default:throw new y(`usage: ${
|
|
63
|
+
`);return}default:throw new y(`usage: ${zi}`)}}async function Ps(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().quickReplies,s=m(r,"shortcut");switch(t){case"list":{let{data:o}=await a.list(i);if(n)g({org:i,quickReplies:o});else k(o,[{header:"ID",get:(c)=>c.id},{header:"SHORTCUT",get:(c)=>c.shortcut??""},{header:"TITLE",get:(c)=>c.title},{header:"BODY",get:(c)=>c.body.replace(/\s+/g," ").slice(0,60)}]);return}case"create":{let o=G(m(r,"title"),"vcity quick-replies create --title <s> --body <s> [--shortcut <s>]"),c=G(m(r,"body"),"vcity quick-replies create --title <s> --body <s> [--shortcut <s>]"),u=await a.create(i,{title:o,body:c,...s!==void 0&&{shortcut:s}});if(n)g(u);else process.stdout.write(`Created quick reply ${T(String(u.id??""))}.
|
|
64
64
|
`);return}case"update":{let o=I(e[0],"vcity quick-replies update <id> [--title] [--body] [--shortcut]","quick reply id"),c={...m(r,"title")!==void 0&&{title:m(r,"title")},...m(r,"body")!==void 0&&{body:m(r,"body")},...s!==void 0&&{shortcut:s===""?null:s}};if(Object.keys(c).length===0)throw new y("quick-replies update: nothing to change");let u=await a.update(i,o,c);if(n)g(u);else process.stdout.write(`Updated quick reply ${o}.
|
|
65
65
|
`);return}case"delete":{let o=I(e[0],"vcity quick-replies delete <id> [--yes]","quick reply id");if(!await B(`Delete quick reply ${o}?`,{yes:r.yes===!0,json:n}))return;let c=await a.delete(i,o);if(n)g(c);else process.stdout.write(`Deleted quick reply ${o}.
|
|
66
|
-
`);return}case"export":{let{data:o}=await a.list(i);g(o.map((c)=>({title:c.title,body:c.body,shortcut:c.shortcut??null})));return}case"import":{let o=e[0];if(!o)throw new y("usage: vcity quick-replies import <file.json> (the output of `quick-replies export`)");let c;try{c=JSON.parse(st(o))}catch(
|
|
66
|
+
`);return}case"export":{let{data:o}=await a.list(i);g(o.map((c)=>({title:c.title,body:c.body,shortcut:c.shortcut??null})));return}case"import":{let o=e[0];if(!o)throw new y("usage: vcity quick-replies import <file.json> (the output of `quick-replies export`)");let c;try{c=JSON.parse(st(o))}catch(E){if(E instanceof y)throw E;throw new y(`${o}: invalid JSON`)}if(!Array.isArray(c))throw new y(`${o}: expected a JSON array`);let u=(await a.list(i)).data,p=new Set(u.flatMap((E)=>E.shortcut?[He(E.shortcut)]:[])),w=new Set(u.map((E)=>E.title.trim().toLowerCase())),v=[];for(let E of c){if(typeof E?.title!=="string"||typeof E.body!=="string"){v.push({title:String(E?.title??""),action:"error",error:"needs title and body"});continue}let N=E.shortcut?He(E.shortcut):void 0,F=E.title.trim().toLowerCase();if(N?p.has(N):w.has(F)){v.push({title:E.title,action:"skip"});continue}try{await a.create(i,{title:E.title,body:E.body,...N&&{shortcut:N}}),v.push({title:E.title,action:"create"})}catch(D){if(D.status===409)v.push({title:E.title,action:"skip"});else v.push({title:E.title,action:"error",error:D.message})}if(N)p.add(N);w.add(F)}if(n)g({org:i,results:v});else k(v,[{header:"TITLE",get:(E)=>E.title},{header:"RESULT",get:(E)=>E.action},{header:"ERROR",get:(E)=>E.error??""}]);let R=v.filter((E)=>E.action==="error").length;if(R>0)throw Error(`${R} of ${v.length} quick replies failed`);return}default:throw new y("usage: vcity quick-replies list|create|update|delete|export|import")}}var $s="vcity chat rooms|members|messages <room>|send <room> --message <s>|thread <room> <messageId>|react|unreact <room> <messageId> <emoji>|search <text>|read <room>|channel create --name <s>|channel rename|delete <channelId>|dm <uid> (<room> is a room id or #channel-slug)";async function Ft(t,e){if(!e)throw new y(`usage: ${$s}`);if(!e.startsWith("#"))return O(e,"room id");let r=e.slice(1),{channels:n}=await l().teamChat.listRooms(t),i=n.find((a)=>a.slug===r||a.name===r);if(!i)throw new y(`no channel #${r} (see \`vcity chat rooms\`)`);return i.id}async function Ds(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().teamChat;switch(t){case"rooms":{let s=await a.listRooms(i);if(n)g(s);else k([...s.channels.map((o)=>({...o,name:`#${o.slug??o.name}`})),...s.dms],[{header:"ID",get:(o)=>o.id},{header:"ROOM",get:(o)=>o.name??""},{header:"UNREAD",get:(o)=>String(o.unreadCount??0)},{header:"@",get:(o)=>String(o.mentionCount??0)}]);return}case"members":{let{data:s}=await a.members(i);if(n)g({org:i,members:s});else k(s,[{header:"UID",get:(o)=>o.uid},{header:"NAME",get:(o)=>o.name??""},{header:"ROLE",get:(o)=>o.role??""}]);return}case"messages":{let s=await Ft(i,e[0]),o=C(r,"before"),c=m(r,"before-id");if(o===void 0!==(c===void 0))throw new y("--before <ms> and --before-id <messageId> go together (the oldest message you have)");let u=await a.listMessages(i,s,{...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...o!==void 0&&c!==void 0&&{beforeTs:o,beforeId:c}});if(n)g({roomId:s,messages:u.data,hasMore:u.hasMore});else process.stdout.write(`${wt(u.data)}
|
|
67
67
|
`);return}case"send":{let s=await Ft(i,e[0]),o=G(m(r,"message"),"vcity chat send <room> --message <s> [--reply-to <id>] [--mention uid,uid]"),c=q(r,"mention"),u=await a.send(i,s,{content:o,...m(r,"reply-to")!==void 0&&{replyToId:m(r,"reply-to")},...c&&{mentionIds:c}});if(n)g(u);else process.stdout.write(`Sent.
|
|
68
68
|
`);return}case"thread":{let s=await Ft(i,e[0]),o=I(e[1],"vcity chat thread <room> <messageId>","message id"),c=await a.thread(i,s,o);if(n)g(c);else{let u=c;process.stdout.write(`${wt([u.root,...u.replies??[]].filter(Boolean))}
|
|
69
69
|
`)}return}case"react":case"unreact":{let s=await Ft(i,e[0]),o=I(e[1],`vcity chat ${t} <room> <messageId> <emoji>`,"message id"),c=G(e[2],`vcity chat ${t} <room> <messageId> <emoji>`),u=t==="unreact"?await a.unreact(i,s,o,c):await a.react(i,s,o,c);if(n)g(u);else process.stdout.write(t==="unreact"?`Reaction removed.
|
|
@@ -71,160 +71,160 @@ var ai=/\{[^{}]+\}/g,ci=()=>typeof process==="object"&&Number.parseInt(process?.
|
|
|
71
71
|
`);return}case"search":{let s=G(e.join(" ")||m(r,"q"),"vcity chat search <text>"),{data:o}=await a.search(i,{q:s});if(n)g({org:i,results:o});else k(o,[{header:"ROOM",get:(c)=>c.roomId},{header:"WHEN",get:(c)=>x(c.message.createdAt)},{header:"FROM",get:(c)=>String(c.message.sender?.name??"")},{header:"MESSAGE",get:(c)=>String(c.message.content??"").slice(0,80)}]);return}case"read":{let s=await Ft(i,e[0]),o=await a.markRead(i,s);if(n)g(o);else process.stdout.write(`Marked read.
|
|
72
72
|
`);return}case"channel":{if(e[0]==="rename"||e[0]==="delete"){let c=I(e[1],`vcity chat channel ${e[0]} <channelId>`,"channel id"),u=e[0]==="delete"?await a.deleteChannel(i,c):await a.updateChannel(i,c,{...m(r,"name")!==void 0&&{name:m(r,"name")},...m(r,"description")!==void 0&&{description:m(r,"description")}});if(n)g(u);else process.stdout.write(e[0]==="delete"?`Deleted.
|
|
73
73
|
`:`Updated.
|
|
74
|
-
`);return}if(e[0]!=="create")throw new y("usage: vcity chat channel create --name <s> [--description <s>] | rename <channelId> [--name <s>] [--description <s>] | delete <channelId>");let s=G(m(r,"name"),"vcity chat channel create --name <s> [--description <s>]"),o=await a.createChannel(i,{name:s,...m(r,"description")!==void 0&&{description:m(r,"description")}});if(n)g(o);else process.stdout.write(`Created #${
|
|
75
|
-
`);return}case"dm":{let s=I(e[0],"vcity chat dm <uid>","uid"),o=await a.openDm(i,{memberId:s});if(n)g(o);else process.stdout.write(`DM room ${
|
|
76
|
-
`);return}default:throw new y(`usage: ${$s}`)}}function
|
|
74
|
+
`);return}if(e[0]!=="create")throw new y("usage: vcity chat channel create --name <s> [--description <s>] | rename <channelId> [--name <s>] [--description <s>] | delete <channelId>");let s=G(m(r,"name"),"vcity chat channel create --name <s> [--description <s>]"),o=await a.createChannel(i,{name:s,...m(r,"description")!==void 0&&{description:m(r,"description")}});if(n)g(o);else process.stdout.write(`Created #${T(s)}.
|
|
75
|
+
`);return}case"dm":{let s=I(e[0],"vcity chat dm <uid>","uid"),o=await a.openDm(i,{memberId:s});if(n)g(o);else process.stdout.write(`DM room ${T(String(o.id??""))}. Send with \`vcity chat send ${T(String(o.id??""))} --message …\`
|
|
76
|
+
`);return}default:throw new y(`usage: ${$s}`)}}function Xi(t){let e=[],r=[],n="",i=!1,a=1,s=1,o=t.charCodeAt(0)===65279?1:0;for(;o<t.length;o++){let c=t[o];if(c===`
|
|
77
77
|
`)a++;if(i){if(c==='"'&&t[o+1]==='"')n+='"',o++;else if(c==='"')i=!1;else n+=c;continue}if(c==='"'&&n==="")i=!0;else if(c===",")r.push(n),n="";else if(c===`
|
|
78
78
|
`||c==="\r"){if(c==="\r"&&t[o+1]===`
|
|
79
|
-
`)o++,a++;else if(c==="\r")a++;r.push(n),e.push({line:s,cells:r}),r=[],n="",s=a}else n+=c}if(i)throw Error("CSV: unterminated quoted field");if(n!==""||r.length>0)r.push(n),e.push({line:s,cells:r});return e.filter((c)=>c.cells.some((u)=>u.trim()!==""))}function Ye(t){let[e,...r]=
|
|
79
|
+
`)o++,a++;else if(c==="\r")a++;r.push(n),e.push({line:s,cells:r}),r=[],n="",s=a}else n+=c}if(i)throw Error("CSV: unterminated quoted field");if(n!==""||r.length>0)r.push(n),e.push({line:s,cells:r});return e.filter((c)=>c.cells.some((u)=>u.trim()!==""))}function Ye(t){let[e,...r]=Xi(t);if(!e)return[];let n=e.cells.map((i)=>i.trim());return r.map(({line:i,cells:a})=>({line:i,record:Object.fromEntries(n.map((s,o)=>[s,Zi(a[o]??"")]))}))}var Ns=/^[=+\-@\t\r]/;function Zi(t){return t.startsWith("'")&&Ns.test(t.slice(1))?t.slice(1):t}function ta(t){if(t===void 0||t===null)return"";if(typeof t==="number"||typeof t==="boolean")return String(t);let e=typeof t==="object"?JSON.stringify(t):String(t);if(Ns.test(e))e=`'${e}`;return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Qe(t,e){return[t,...e].map((r)=>r.map(ta).join(",")).join(`\r
|
|
80
80
|
`)+`\r
|
|
81
|
-
`}var hr=["name","email","phone","company","jobTitle","website","address","whatsapp","facebook","twitter","linkedin","instagram","notes","tags","source","lang"],Fs=["lastInteraction","totalInteractions","score","name"],Bs="vcity crm contacts list|get|create|update|archive|restore|tag|timeline|export|import · vcity crm tags list|create · vcity crm follow-ups · vcity crm audiences [<id>]";function Us(t){let e=P(m(t,"data"));if(e!==void 0&&(typeof e!=="object"||e===null||Array.isArray(e)))throw new y("--data must be a JSON object");let r={...e},n={jobTitle:"job-title"};for(let a of hr){if(a==="tags")continue;let s=m(t,n[a]??a);if(s!==void 0)r[a]=s}let i=q(t,"tags");if(i)r.tags=i;return r}function yr(t){k(t,[{header:"ID",get:(e)=>e.id},{header:"NAME",get:(e)=>e.name??""},{header:"EMAIL",get:(e)=>e.email??""},{header:"COMPANY",get:(e)=>e.company??""},{header:"TAGS",get:(e)=>(e.tags??[]).join(",")},{header:"LAST SEEN",get:(e)=>x(e.lastInteraction)}])}function fr(t){return{...m(t,"q")!==void 0&&{q:m(t,"q")},...q(t,"tags")&&{tags:q(t,"tags")?.join(",")},...A(t,"sort",Fs)&&{sort:A(t,"sort",Fs)},...t.archived===!0&&{includeArchived:"true"}}}function
|
|
82
|
-
`);if(n)g({...v,rows:
|
|
83
|
-
`),w.length>0)k(w,[{header:"ROW",get:(
|
|
81
|
+
`}var hr=["name","email","phone","company","jobTitle","website","address","whatsapp","facebook","twitter","linkedin","instagram","notes","tags","source","lang"],Fs=["lastInteraction","totalInteractions","score","name"],Bs="vcity crm contacts list|get|create|update|archive|restore|tag|timeline|export|import · vcity crm tags list|create · vcity crm follow-ups · vcity crm audiences [<id>]";function Us(t){let e=P(m(t,"data"));if(e!==void 0&&(typeof e!=="object"||e===null||Array.isArray(e)))throw new y("--data must be a JSON object");let r={...e},n={jobTitle:"job-title"};for(let a of hr){if(a==="tags")continue;let s=m(t,n[a]??a);if(s!==void 0)r[a]=s}let i=q(t,"tags");if(i)r.tags=i;return r}function yr(t){k(t,[{header:"ID",get:(e)=>e.id},{header:"NAME",get:(e)=>e.name??""},{header:"EMAIL",get:(e)=>e.email??""},{header:"COMPANY",get:(e)=>e.company??""},{header:"TAGS",get:(e)=>(e.tags??[]).join(",")},{header:"LAST SEEN",get:(e)=>x(e.lastInteraction)}])}function fr(t){return{...m(t,"q")!==void 0&&{q:m(t,"q")},...q(t,"tags")&&{tags:q(t,"tags")?.join(",")},...A(t,"sort",Fs)&&{sort:A(t,"sort",Fs)},...t.archived===!0&&{includeArchived:"true"}}}function ea(t){let e=["id",...hr,"createdAt","lastInteraction","totalInteractions"];return Qe(e,t.map((r)=>e.map((n)=>{let i=r[n];if(Array.isArray(i))return i.join("|");if((n==="createdAt"||n==="lastInteraction")&&typeof i==="number")return new Date(i).toISOString();return i})))}function ra(t){let e={};for(let[r,n]of Object.entries(t)){let i=n.trim();if(i===""||r==="id"||r==="createdAt"||r==="lastInteraction"||r==="totalInteractions")continue;if(!hr.includes(r))throw Error(`unknown column "${r}"`);e[r]=r==="tags"?i.split("|").map((a)=>a.trim()).filter(Boolean):i}return e}function sa(t){let e=[];for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;for(let i of n){let a=[i.registerDate,i.createdAt,i.at,i.date].find((o)=>typeof o==="number"),s=Object.entries(i).filter(([o,c])=>!["registerDate","createdAt","at","date"].includes(o)&&c!==void 0&&c!==null).map(([o,c])=>`${o}=${typeof c==="object"?JSON.stringify(c):String(c)}`).join(" ");e.push({kind:r,at:a,detail:s})}}return e.sort((r,n)=>(n.at??0)-(r.at??0))}async function na(t){let{data:e}=await l().crm.listTags(t);return(r)=>{let n=r.toLowerCase(),i=e.find((a)=>a.id===r||a.slug?.toLowerCase()===n||a.name?.toLowerCase()===n);if(!i)throw new y(`no CRM tag "${r}" (see \`vcity crm tags list\`)`);return i.id}}async function oa(t,e,r,n){let i=Ye(st(e));if(i.length===0)throw new y(`${e}: no contact rows`);let a=l(),s=new Map,o=new Set,c=new Set;for(let E of await ut(async(N,F)=>{let D=await a.crm.listContacts(t,{skip:N,limit:F,includeArchived:"true"});return{data:D.data,hasMore:D.hasMore}})){if(E.isCustom===!1){if(E.email)c.add(E.email.toLowerCase());continue}if(o.add(E.id),E.email)s.set(E.email.toLowerCase(),E.id)}let u=r["dry-run"]===!0,p=[];for(let{line:E,record:N}of i){let F;try{F=ra(N)}catch(kt){p.push({row:E,action:"error",error:kt.message});continue}let D=typeof F.email==="string"?F.email:void 0,X=N.id?.trim(),L=X&&o.has(X)?X:D?s.get(D.toLowerCase()):void 0;if(!L&&D&&c.has(D.toLowerCase())){p.push({row:E,email:D,action:"skip",error:"matches a platform contact, which cannot be edited"});continue}if(!L&&typeof F.name!=="string"){p.push({row:E,email:D,action:"error",error:"a new contact needs a name"});continue}let rt=L?"update":"create";if(u){if(D&&!L)s.set(D.toLowerCase(),"(new)");p.push({row:E,email:D,action:rt,id:L==="(new)"?void 0:L});continue}try{let It=(L?await a.crm.updateContact(t,L,F):await a.crm.createContact(t,{source:"csv",...F})).id??L;if(D&&It)s.set(D.toLowerCase(),It);p.push({row:E,email:D,action:rt,id:It})}catch(kt){p.push({row:E,email:D,action:"error",error:kt.message})}}let w=p.filter((E)=>E.action==="error"),v={org:t,dryRun:u,total:p.length,created:p.filter((E)=>E.action==="create").length,updated:p.filter((E)=>E.action==="update").length,skipped:p.filter((E)=>E.action==="skip").length,failed:w.length},R=m(r,"report");if(R)Z(R,`${JSON.stringify({...v,rows:p},null,2)}
|
|
82
|
+
`);if(n)g({...v,rows:p});else if(process.stdout.write(`${u?"Dry run: ":""}created ${v.created}, updated ${v.updated}, skipped ${v.skipped}, failed ${v.failed} of ${v.total}.
|
|
83
|
+
`),w.length>0)k(w,[{header:"ROW",get:(E)=>String(E.row)},{header:"EMAIL",get:(E)=>E.email??""},{header:"ERROR",get:(E)=>E.error??""}]);if(w.length>0)throw Error(`${w.length} of ${p.length} rows failed`)}async function ia(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"list":{if(r.all===!0){let o=await ut(async(c,u)=>{let p=await a.crm.listContacts(i,{...fr(r),skip:c,limit:u});return{data:p.data,hasMore:p.hasMore}});if(n)g({org:i,contacts:o,total:o.length});else yr(o);return}let s=await a.crm.listContacts(i,{...fr(r),...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...C(r,"skip")!==void 0&&{skip:C(r,"skip")}});if(n)g({org:i,contacts:s.data,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});else yr(s.data);return}case"get":{let s=I(e[0],"vcity crm contacts get <id>","contact id"),o=await a.crm.getContact(i,s);if(n)g(o);else j(o);return}case"create":{let s=Us(r);if(typeof s.name!=="string")throw new y("usage: vcity crm contacts create --name <s> [--email …]");let o=await a.crm.createContact(i,s);if(n)g(o);else process.stdout.write(`Created contact ${T(String(o.id))}.
|
|
84
84
|
`);return}case"update":{let s=I(e[0],"vcity crm contacts update <id> [--name …]","contact id"),o=Us(r);if(Object.keys(o).length===0)throw new y("crm contacts update: nothing to change");let c=await a.crm.updateContact(i,s,o);if(n)g(c);else process.stdout.write(`Updated contact ${s}.
|
|
85
85
|
`);return}case"archive":{let s=I(e[0],"vcity crm contacts archive <id> [--yes]","contact id");if(!await B(`Archive contact ${s} in ${i}?`,{yes:r.yes===!0,json:n}))return;let o=await a.crm.archiveContact(i,s);if(n)g(o);else process.stdout.write(`Archived contact ${s} (restore with \`vcity crm contacts restore ${s}\`).
|
|
86
86
|
`);return}case"restore":{let s=I(e[0],"vcity crm contacts restore <id>","contact id"),o=await a.crm.restoreContact(i,s);if(n)g(o);else process.stdout.write(`Restored contact ${s}.
|
|
87
|
-
`);return}case"tag":{let s=I(e[0],"vcity crm contacts tag <id> [--add a,b] [--remove c]","contact id"),o=q(r,"add"),c=q(r,"remove");if(!o&&!c)throw new y("usage: vcity crm contacts tag <id> [--add a,b] [--remove c]");let u=await
|
|
88
|
-
`:
|
|
89
|
-
`);else process.stdout.write(process.stdout.isTTY?
|
|
90
|
-
`);return}if(e[0]===void 0||e[0]==="list"){let s=await a.crm.listTags(i);if(n)g(s);else k(s.data??[],[{header:"ID",get:(o)=>String(o.id??"")},{header:"SLUG",get:(o)=>String(o.slug??"")},{header:"NAME",get:(o)=>String(o.name??"")},{header:"CONTACTS",get:(o)=>String(o.contactCount??"")}]);return}}if(t==="follow-ups"){let s=M(r,"due-before"),o=await a.crm.listFollowUps(i,{...s!==void 0&&{dueBefore:s},...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")}});if(n)g(o);else k(o.data,[{header:"DUE",get:(c)=>x(c.dueDate)},{header:"CARD",get:(c)=>c.code},{header:"TITLE",get:(c)=>c.title},{header:"CONTACTS",get:(c)=>c.contacts.map((u)=>u.name).join(", ")}]);return}if(t==="audiences"){if(e[0]){let o=I(e[0],"vcity crm audiences <id>","audience id"),c=await a.crm.listAudienceContacts(i,o,{});if(n)g(c);else yr(c.data);return}let s=await a.crm.listAudiences(i);if(n)g(s);else k(s.data??[],[{header:"ID",get:(o)=>String(o.id??"")},{header:"NAME",get:(o)=>String(o.name??"")},{header:"TYPE",get:(o)=>String(o.type??"")},{header:"CONTACTS",get:(o)=>String(o.contactCount??"")}]);return}throw new y(`usage: ${Bs}`)}var
|
|
91
|
-
`);return}throw new y("usage: vcity desk latest | vcity desk download [--os mac|windows|linux]")}import{setTimeout as
|
|
87
|
+
`);return}case"tag":{let s=I(e[0],"vcity crm contacts tag <id> [--add a,b] [--remove c]","contact id"),o=q(r,"add"),c=q(r,"remove");if(!o&&!c)throw new y("usage: vcity crm contacts tag <id> [--add a,b] [--remove c]");let u=await na(i),p=o?.map(u),w=c?.map(u),v=await a.crm.setContactTags(i,s,{...p&&{add:p},...w&&{remove:w}});if(n)g(v);else j(v);return}case"timeline":{let s=I(e[0],"vcity crm contacts timeline <id>","contact id"),o=await a.crm.contactTimeline(i,s);if(n)g(o);else k(sa(o),[{header:"WHEN",get:(c)=>x(c.at)},{header:"KIND",get:(c)=>c.kind},{header:"DETAIL",get:(c)=>c.detail}]);return}case"export":{let s=await ut(async(u,p)=>{let w=await a.crm.listContacts(i,{...fr(r),skip:u,limit:p});return{data:w.data,hasMore:w.hasMore}}),o=A(r,"format",["csv","json"])==="json"?`${JSON.stringify(s,null,2)}
|
|
88
|
+
`:ea(s),c=m(r,"output");if(c)Z(c,o),process.stderr.write(`Wrote ${s.length} contacts to ${T(c)}
|
|
89
|
+
`);else process.stdout.write(process.stdout.isTTY?T(o):o);return}case"import":{let s=e[0];if(!s)throw new y("usage: vcity crm contacts import <file.csv> [--dry-run] [--report <file>]");return oa(i,s,r,n)}default:throw new y(`usage: ${Bs}`)}}async function Ms(t,e,r){if(t==="contacts")return ia(e[0],e.slice(1),r);let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();if(t==="tags"){if(e[0]==="create"){let s=m(r,"name")??e[1];if(!s)throw new y("usage: vcity crm tags create --name <s> [--color <hex>]");let o=m(r,"color"),c=await a.crm.createTag(i,{name:s,...o!==void 0&&{color:o}});if(n)g(c);else process.stdout.write(`Created tag ${T(s)}.
|
|
90
|
+
`);return}if(e[0]===void 0||e[0]==="list"){let s=await a.crm.listTags(i);if(n)g(s);else k(s.data??[],[{header:"ID",get:(o)=>String(o.id??"")},{header:"SLUG",get:(o)=>String(o.slug??"")},{header:"NAME",get:(o)=>String(o.name??"")},{header:"CONTACTS",get:(o)=>String(o.contactCount??"")}]);return}}if(t==="follow-ups"){let s=M(r,"due-before"),o=await a.crm.listFollowUps(i,{...s!==void 0&&{dueBefore:s},...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")}});if(n)g(o);else k(o.data,[{header:"DUE",get:(c)=>x(c.dueDate)},{header:"CARD",get:(c)=>c.code},{header:"TITLE",get:(c)=>c.title},{header:"CONTACTS",get:(c)=>c.contacts.map((u)=>u.name).join(", ")}]);return}if(t==="audiences"){if(e[0]){let o=I(e[0],"vcity crm audiences <id>","audience id"),c=await a.crm.listAudienceContacts(i,o,{});if(n)g(c);else yr(c.data);return}let s=await a.crm.listAudiences(i);if(n)g(s);else k(s.data??[],[{header:"ID",get:(o)=>String(o.id??"")},{header:"NAME",get:(o)=>String(o.name??"")},{header:"TYPE",get:(o)=>String(o.type??"")},{header:"CONTACTS",get:(o)=>String(o.contactCount??"")}]);return}throw new y(`usage: ${Bs}`)}var Ls="usage: vcity apps list [--json] | vcity apps get <appId> [--json]";async function qs(t,e,r){let n=f(!!r.json)==="json",i=l();if(t==="list"){let{data:a}=await i.public.apps();if(n){g(a);return}k(a,[{header:"ID",get:(s)=>s.id},{header:"NAME",get:(s)=>s.name},{header:"PLATFORMS",get:(s)=>s.platforms.join(",")},{header:"CHANNELS",get:(s)=>s.channels.join(",")}]);return}if(t==="get"){let a=e[0];if(!a)throw new y(Ls);let s=await i.public.app(a);if(n)g(s);else j(s);return}throw new y(Ls)}var aa=["mac","windows","linux"];function ca(){if(process.platform==="darwin")return"mac";if(process.platform==="win32")return"windows";return"linux"}async function _s(t,e){let r=f(!!e.json)==="json",n=l();if(t==="latest"){let i=await n.desk.latest();if(r)g(i);else j(i);return}if(t==="download"){let i=A(e,"os",aa)??ca(),a=await n.desk.downloadUrl(i);if(r)g({os:i,url:a});else process.stdout.write(`${T(a)}
|
|
91
|
+
`);return}throw new y("usage: vcity desk latest | vcity desk download [--os mac|windows|linux]")}import{setTimeout as da}from"node:timers/promises";var ua=1,ga=30,la=900,pa=64,ma=512,Gs=2048,wr=512;function fa(t){if(t===!1)return!1;if(process.env.VCITY_NO_OPEN_BROWSER)return!1;if(!process.stdout.isTTY)return!1;return!0}function vr(t,e,r){if(typeof t!=="string"||t.length===0||t.length>e)throw Error(`Invalid device flow response: ${r} is missing, empty, or too long.`);return t}var ya=60000;function Vs(t,e){if(typeof t!=="number"||!Number.isFinite(t))throw Error(`Invalid device flow response: ${e} is missing or non-finite.`);if(t<=Date.now()-ya)throw Error(`Invalid device flow response: ${e} is already expired.`);return t}function ha(t){if(vr(t.access_token,Gs,"access_token"),vr(t.refresh_token,Gs,"refresh_token"),Vs(t.access_expires_at,"access_expires_at"),Vs(t.refresh_expires_at,"refresh_expires_at"),!t.user||typeof t.user!=="object")throw Error("Invalid device flow response: user object is missing.");if(vr(t.user.id,wr,"user.id"),t.user.email!==void 0){if(typeof t.user.email!=="string"||t.user.email.length>wr)throw Error("Invalid device flow response: user.email is invalid.")}if(t.user.name!==void 0){if(typeof t.user.name!=="string"||t.user.name.length>wr)throw Error("Invalid device flow response: user.name is invalid.")}}function wa(t){if(t&&typeof t==="object"&&"status"in t){let e=t.status;if(typeof e==="number")return e}return}async function va(t){try{let e=(await import("open")).default;await e(t)}catch{}}async function Js(t={}){let e=t.apiBaseUrl??Le(),r=St(e),n=await Nt("/api/cli/auth/device/code",{method:"POST",body:{},authed:!1,baseUrl:r.toString()});if(typeof n.user_code!=="string"||n.user_code.length===0||n.user_code.length>pa)throw Error("Invalid device flow response: user_code is missing or too long.");if(typeof n.device_code!=="string"||n.device_code.length===0||n.device_code.length>ma)throw Error("Invalid device flow response: device_code is missing or too long.");let i=new URL("/cli-auth",r),a=new URL(i);if(a.searchParams.set("user_code",n.user_code),process.stdout.write(`
|
|
92
92
|
Open this URL to approve the session:
|
|
93
93
|
${i.toString()}
|
|
94
94
|
Enter this code:
|
|
95
|
-
${
|
|
95
|
+
${T(n.user_code)}
|
|
96
96
|
|
|
97
97
|
Only enter this code if you just ran \`vcity login\` yourself. Never paste a code someone else sent you.
|
|
98
98
|
|
|
99
99
|
`),process.stdout.write(`Waiting for approval…
|
|
100
|
-
`),
|
|
101
|
-
Logged in as ${
|
|
102
|
-
`);return}throw Error(`Login ${w.status}. Run \`vcity login\` again.`)}if(
|
|
100
|
+
`),fa(t.openBrowser))await va(Dr(a.toString()).toString());let s=(w)=>{let v=typeof w==="number"&&Number.isFinite(w)?w:0;return Math.max(v,ua)},o=Math.min(Math.max(typeof n.expires_in==="number"&&Number.isFinite(n.expires_in)?n.expires_in:0,ga),la),c=Date.now()+o*1000,u=s(n.interval),p=0;while(Date.now()<c){await da(u*1000);let w;try{w=await Nt("/api/cli/auth/device/token",{method:"POST",body:{device_code:n.device_code},authed:!1,baseUrl:r.toString()})}catch(v){let R=wa(v);if(R===400)w=v.body;else if(R!==void 0)throw v;else{p++;continue}}if(!w)continue;if(w.status==="pending"){u=s(w.interval);continue}if(w.status==="approved"){ha(w),qe({api_base_url:r.toString(),access_token:w.access_token,refresh_token:w.refresh_token,access_expires_at:w.access_expires_at,refresh_expires_at:w.refresh_expires_at,user:w.user});let v=w.user.email??w.user.name??w.user.id;process.stdout.write(`
|
|
101
|
+
Logged in as ${T(v)}.
|
|
102
|
+
`);return}throw Error(`Login ${w.status}. Run \`vcity login\` again.`)}if(p>0)throw Error(`Login timed out after ${p} network error${p===1?"":"s"} while polling. Check your connection and run \`vcity login\` again.`);throw Error("Login timed out. Run `vcity login` again.")}async function Hs(){let t=xt();if(!t){process.stdout.write(`Not logged in.
|
|
103
103
|
`);return}try{await Nt("/api/cli/auth/logout",{method:"POST",body:{refresh_token:t.refresh_token},headers:{"x-refresh-token":t.refresh_token}})}catch{}$t(),process.stdout.write(`Logged out.
|
|
104
|
-
`)}var
|
|
105
|
-
`)}async function
|
|
106
|
-
`);return}if(t==="read"){let c=r.all===!0,u=c?void 0:I(e[0],"vcity notifications read <id> | --all [--org <slug>]","notification id"),
|
|
107
|
-
`);return}if(t==="unread"){let c=await i.me.unread();if(n)g(c);else k(c.orgs,[{header:"STORE",get:(u)=>u.slug??u.orgId},{header:"INBOX",get:(u)=>String(u.inboxUnread??0)},{header:"NOTIFICATIONS",get:(u)=>String(u.notificationsUnread??0)}]);return}throw new y("usage: vcity notifications [list] [--unread] [--org <slug>] [--all-stores] [--limit <n>] | read <id>|--all | unread")}var We=new Set(["ACCEPTED","REJECTED","PENDING","FAILED","REVERSED","RETAINED","STARTED","EXPIRED","ABANDONED","CANCELED","ANTIFRAUD"]);async function
|
|
108
|
-
`:Qe([...
|
|
109
|
-
`);else process.stdout.write(i)}var
|
|
110
|
-
`)}async function
|
|
111
|
-
`)}import{readFileSync as
|
|
112
|
-
`),j(u)}async function
|
|
113
|
-
`),j(a)}async function
|
|
114
|
-
`),j(s)}async function
|
|
115
|
-
`);return}}let i=await
|
|
116
|
-
`)}import{closeSync as
|
|
117
|
-
Retry with: vcity posts attach-video ${String(o.id)} --video <file>`)}if(e==="json"){g(c??o);return}let u=c?" with its video":"";process.stdout.write(`Draft ${
|
|
118
|
-
`)}var
|
|
119
|
-
`)}async function
|
|
120
|
-
`),j(i)}async function
|
|
121
|
-
`);return}}let i=await
|
|
122
|
-
`)}function Ir(t,e,r){if(t===void 0)return;if(!e.includes(t))throw Error(`products list: ${r} must be one of ${e.join(", ")} (got: ${t})`);return t}var
|
|
123
|
-
`),j(s)}async function
|
|
124
|
-
`),j(o)}async function
|
|
125
|
-
`);return}}let a=await
|
|
126
|
-
`)}import
|
|
127
|
-
`)}async function
|
|
104
|
+
`)}var ba=/^\d{4}-\d{2}-\d{2}$/;function Ys(t,e){if(t===void 0)return;if(!ba.test(t))throw Error(`${e} must be a date, YYYY-MM-DD (UTC). Got: ${t}`);return t}function br(t){let e={},r=Ys(t.from,"--from"),n=Ys(t.to,"--to");if(r)e.from=r;if(n)e.to=n;return e}function kr(t,e){let r=t.clamped?` (shortened to the ${e} plan limit)`:"";process.stderr.write(`${T(`${t.from} to ${t.to}, ${t.days} days${r}`)}
|
|
105
|
+
`)}async function Qs(t={}){let e=f(t.json),r=h(t.org),n=await l().analytics.summary(r,br(t));if(e==="json"){g({org:r,...n});return}kr(n.range,n.plan),j({totalVisits:n.totalVisits,productViews:n.productViews}),k(n.visitsByType,[{header:"PAGE TYPE",get:(i)=>i.value},{header:"VISITS",get:(i)=>String(i.count)}])}async function Ws(t={}){let e=f(t.json),r=h(t.org);if(t.groupBy!==void 0&&t.groupBy!=="day"&&t.groupBy!=="type")throw Error(`--group-by must be day or type. Got: ${t.groupBy}`);let n=await l().analytics.visits(r,{...br(t),groupBy:t.groupBy});if(e==="json"){g({org:r,...n});return}kr(n.range,n.plan),k(n.data,[{header:n.groupBy==="day"?"DAY":"PAGE TYPE",get:(i)=>i.value},{header:"VISITS",get:(i)=>String(i.count)}])}async function zs(t={}){let e=f(t.json),r=h(t.org),n=await l().analytics.topProducts(r,{...br(t),limit:t.limit});if(e==="json"){g({org:r,...n});return}kr(n.range,n.plan),k(n.data,[{header:"PRODUCT",get:(i)=>i.name??"(unknown)"},{header:"ID",get:(i)=>i.productId},{header:"VIEWS",get:(i)=>String(i.views)}])}async function Ks(t,e,r){let n=f(!!r.json)==="json",i=l(),a=At(r,"org"),s=a===void 0?void 0:String((await i.orgs.get(a)).id),o=r["all-stores"]===!0?"stores":void 0;if(t===void 0||t==="list"){let c=await i.notifications.list({...r.unread===!0&&{status:"unread"},...s!==void 0&&{orgId:s},...o&&{include:o},...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...C(r,"skip")!==void 0&&{skip:C(r,"skip")}});if(n)g(c);else k(c.data,[{header:"ID",get:(u)=>u.id},{header:"",get:(u)=>u.read?"":"●"},{header:"WHEN",get:(u)=>x(u.createdAt)},{header:"TYPE",get:(u)=>u.type??""},{header:"MESSAGE",get:(u)=>(u.message??"").slice(0,80)}]),process.stdout.write(`${c.unreadCount} unread
|
|
106
|
+
`);return}if(t==="read"){let c=r.all===!0,u=c?void 0:I(e[0],"vcity notifications read <id> | --all [--org <slug>]","notification id"),p=await i.notifications.markRead({...u!==void 0&&{id:u},...c&&{all:!0},...s!==void 0&&{orgId:s},...o&&{include:o}});if(n)g(p);else process.stdout.write(`Marked read.
|
|
107
|
+
`);return}if(t==="unread"){let c=await i.me.unread();if(n)g(c);else k(c.orgs,[{header:"STORE",get:(u)=>u.slug??u.orgId},{header:"INBOX",get:(u)=>String(u.inboxUnread??0)},{header:"NOTIFICATIONS",get:(u)=>String(u.notificationsUnread??0)}]);return}throw new y("usage: vcity notifications [list] [--unread] [--org <slug>] [--all-stores] [--limit <n>] | read <id>|--all | unread")}var We=new Set(["ACCEPTED","REJECTED","PENDING","FAILED","REVERSED","RETAINED","STARTED","EXPIRED","ABANDONED","CANCELED","ANTIFRAUD"]);async function tn(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&!We.has(t.status))throw Error(`Invalid order status: ${t.status}. Allowed: ${[...We].join(", ")}`);let n={};if(t.limit!==void 0)n.limit=t.limit;if(t.status!==void 0)n.status=t.status;let a=await l().orders.list(r,n),s=a.data??[];if(e==="json"){g({org:r,orders:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"STATUS",get:(o)=>o.status??""},{header:"TOTAL",get:(o)=>o.total!==void 0?`${o.total.toLocaleString()} ${o.currencyCode??""}`.trim():""},{header:"CREATED",get:(o)=>x(o.createdAt)}])}async function en(t,e={}){let r=f(e.json),n=h(e.org),a=await l().orders.get(n,t);if(r==="json"){g(a);return}j(a)}var Xs=["id","status","createdAt","currencyCode","subtotal","taxes","shipping","discount","total","processed","paymentIntentId"];async function rn(t={}){let e=h(t.org);if(t.status!==void 0&&!We.has(t.status))throw new y(`Invalid order status: ${t.status}. Allowed: ${[...We].join(", ")}`);let r=l(),n=await ut(async(a,s)=>{let o=await r.orders.list(e,{skip:a,limit:s,...t.status!==void 0&&{status:t.status},...t.fromTs!==void 0&&{fromTs:t.fromTs},...t.toTs!==void 0&&{toTs:t.toTs}});return{data:o.data??[],hasMore:o.hasMore}}),i=(t.format??"csv")==="json"?`${JSON.stringify(n,null,2)}
|
|
108
|
+
`:Qe([...Xs],n.map((a)=>Xs.map((s)=>s==="createdAt"&&typeof a.createdAt==="number"?new Date(a.createdAt).toISOString():a[s])));if(t.output)Z(t.output,i),process.stderr.write(`Wrote ${n.length} orders to ${T(t.output)}
|
|
109
|
+
`);else process.stdout.write(i)}var Zs=["pending","shipped","delivered"];async function sn(t,e,r={}){let n=f(r.json),i=h(r.org),a=r.status??"shipped";if(a!=="shipped"&&a!=="delivered")throw new y("--status must be shipped or delivered");let s=l(),o=[],c=e;if(c.length===0){let w=((await s.orders.get(i,t)).lineItems??[]).filter((R)=>typeof R.id==="string");if(w.length===0)throw Error(`Order ${t} has no line items`);let v=Zs.indexOf(a);c=[];for(let R of w)if(Zs.indexOf(R.shippingStatus??"pending")>=v)o.push({lineItemId:R.id,shippingStatus:R.shippingStatus,skipped:!0});else c.push(R.id)}for(let p of c)try{await s.orders.updateLineItemShipping(i,t,p,{shippingStatus:a}),o.push({lineItemId:p,shippingStatus:a})}catch(w){o.push({lineItemId:p,error:w.message})}if(n==="json")g({org:i,orderId:t,results:o});else k(o,[{header:"LINE ITEM",get:(p)=>p.lineItemId},{header:"SHIPPING",get:(p)=>`${p.shippingStatus??""}${p.skipped?" (unchanged)":""}`},{header:"ERROR",get:(p)=>p.error??""}]);let u=o.filter((p)=>p.error).length;if(u>0)throw Error(`${u} of ${o.length} line items failed`)}var ka=128,Ia=/^[a-z0-9_-]+$/i;function ja(t){if(!t||t.length>ka||!Ia.test(t))throw Error("Server returned an unexpected org slug format. Run `vcity org list` to see valid orgs.")}async function nn(){let e=await l().me.get();if(e&&typeof e==="object"&&"orgs"in e){let r=e.orgs;return Array.isArray(r)?r:[]}return[]}function Ea(t){if(!t)return"";let e=[];if(t.admin)e.push("admin");if(t.admins?.create||t.admins?.update||t.admins?.delete)e.push("admins");if(t.products?.create||t.products?.update||t.products?.delete)e.push("products");if(t.orders?.retrieve||t.orders?.update)e.push("orders");if(t.quotes?.retrieve||t.quotes?.update)e.push("quotes");if(t.surveys?.create||t.surveys?.update||t.surveys?.delete||t.surveys?.retrieve)e.push("surveys");return e.join(",")}async function on(t={}){let e=f(t.json),r=await nn(),n=Ct().active_org;if(e==="json"){g({orgs:r,active_org:n??null});return}k(r,[{header:"*",get:(i)=>i.slug===n?"*":" "},{header:"SLUG",get:(i)=>i.slug},{header:"NAME",get:(i)=>i.name??""},{header:"ID",get:(i)=>i.id}])}async function an(t){let r=(await nn()).find((n)=>n.slug===t||n.id===t);if(!r)throw Error(`No accessible org matches "${t}". Run \`vcity org list\` to see options.`);ja(r.slug),qr({active_org:r.slug}),process.stdout.write(`Active org set to ${T(r.slug)} (${T(r.name??r.id)}).
|
|
110
|
+
`)}async function cn(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;let a=await l().orgs.listMembers(r,n),s=a.data??[];if(e==="json"){g({org:r,members:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"PROFILE_ID",get:(o)=>o.profileId??""},{header:"ACTIVE",get:(o)=>o.active?"yes":"no"},{header:"PERMISSIONS",get:(o)=>Ea(o.permissions)}])}async function dn(t,e={}){let r=f(e.json),i=await l().orgs.get(t);if(r==="json"){g(i);return}j(i)}var un=["name","slug","description","website","contactEmail","billingEmail","email","telephone","whatsapp","instagram","facebook","linkedin","youtube","locale","timezone","countryCode","seoTitle","seoDescription","colorMain"],gn=(t)=>t.replace(/[A-Z]/g,(e)=>`-${e.toLowerCase()}`);async function ln(t={}){let e=h(t.org),r=await l().orgs.getSettings(e);if(f(t.json)==="json")g(r);else j(r)}function Ta(t){let e=P(m(t,"data"));if(e!==void 0&&(typeof e!=="object"||e===null||Array.isArray(e)))throw new y("--data must be a JSON object");let r={...e};for(let n of un){let i=m(t,gn(n));if(i!==void 0)r[n]=i}if(m(t,"phone")!==void 0)r.telephone=m(t,"phone");return r}async function pn(t){let e=h(m(t,"org")),r=Ta(t);if(Object.keys(r).length===0)throw new y(`usage: vcity org set [--org <slug>] ${un.map((i)=>`--${gn(i)} <s>`).slice(0,6).join(" ")} … [--data <json|@file|->]`);let n=await l().orgs.update(e,r);if(f(!!t.json)==="json")g(n);else process.stdout.write(`Updated ${Object.keys(r).map(T).join(", ")} on ${e}.
|
|
111
|
+
`)}import{readFileSync as Ra}from"node:fs";async function mn(t={}){let e=f(t.json),r=h(t.org),i=await l().agents.list(r,t.limit!==void 0?{limit:t.limit}:{}),a=i.data??[];if(e==="json"){g({org:r,agents:a,total:i.total,skip:i.skip,limit:i.limit,hasMore:i.hasMore});return}k(a,[{header:"ID",get:(s)=>s.id},{header:"NAME",get:(s)=>s.name??""},{header:"KIND",get:(s)=>s.kind??""},{header:"ENABLED",get:(s)=>s.enabled?"yes":"no"},{header:"AUTONOMY",get:(s)=>s.autonomy??""},{header:"TRIGGER",get:(s)=>s.trigger?.type??""}])}async function fn(t,e={}){let r=f(e.json),n=h(e.org),a=await l().agents.get(n,t);if(r==="json"){g(a);return}j(a)}async function yn(t,e={}){let r=f(e.json),n=h(e.org);if(e.instructions!==void 0&&e.instructionsFile!==void 0)throw Error("agents update: pass --instructions or --instructions-file, not both");let i=e.instructionsFile!==void 0?Ra(e.instructionsFile,"utf8"):e.instructions,a={name:e.name,description:e.description,emoji:e.emoji,avatar:e.avatar,instructions:i,enabled:e.disable?!1:void 0},s=Object.fromEntries(Object.entries(a).filter(([,p])=>p!==void 0));if(Object.keys(s).length===0)throw Error("agents update: nothing to update (pass --name, --description, --emoji, --avatar, --instructions, --instructions-file or --disable)");let o=l(),c=await o.agents.get(n,t);if(typeof c.updatedAt!=="number")throw Error("agents update: the agent has no updatedAt to edit against");let u=await o.agents.update(n,t,{...s,expectedUpdatedAt:c.updatedAt});if(r==="json"){g(u);return}process.stdout.write(`Updated agent:
|
|
112
|
+
`),j(u)}async function hn(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&t.status!=="open"&&t.status!=="all")throw Error('conversations list: --status must be "open" or "all"');let i=await l().conversations.list(r,{...t.status?{status:t.status}:{},...t.awaitingReply?{awaitingReply:"true"}:{}}),a=i.data??[];if(e==="json"){g({org:r,conversations:a,notice:i.notice});return}k(a,[{header:"ID",get:(s)=>s.id},{header:"VISITOR",get:(s)=>s.visitor??""},{header:"STATUS",get:(s)=>s.status??""},{header:"WAITING",get:(s)=>s.awaitingReply?"yes":"no"},{header:"LAST",get:(s)=>s.lastMessageExcerpt??""}])}async function wn(t,e={}){let r=f(e.json),n=h(e.org),a=await l().conversations.get(n,t,e.limit!==void 0?{limit:e.limit}:{});if(r==="json"){g(a);return}j(a.conversation),k(a.messages??[],[{header:"FROM",get:(s)=>s.from},{header:"AT",get:(s)=>s.at!==void 0?new Date(s.at).toISOString():""},{header:"TEXT",get:(s)=>s.text}])}async function vn(t={}){let e=f(t.json),r=h(t.org),n=await l().customerAgent.get(r);if(e==="json"){g(n);return}j(n)}async function bn(t={}){let e=f(t.json),r=h(t.org),i=(await l().customerAgent.listKnowledge(r)).data??[];if(e==="json"){g({org:r,documents:i});return}k(i,[{header:"ID",get:(a)=>a.id},{header:"NAME",get:(a)=>a.name},{header:"CHUNKS",get:(a)=>String(a.chunks)},{header:"EXCERPT",get:(a)=>a.excerpt}])}function kn(t){let e=P(t.data),r=e&&typeof e==="object"?{...e}:{};if(t.name!==void 0)r.name=t.name;if(t.description!==void 0)r.description=t.description;if(t.slug!==void 0)r.slug=t.slug;if(t.seoTitle!==void 0)r.seoTitle=t.seoTitle;if(t.seoDescription!==void 0)r.seoDescription=t.seoDescription;return r}async function In(t={}){let e=f(t.json),r=h(t.org),n=await l().collections.list(r),i=n.data??[];if(e==="json"){g({org:r,collections:i,total:n.total});return}k(i,[{header:"ID",get:(a)=>a.id},{header:"NAME",get:(a)=>a.name??""},{header:"SLUG",get:(a)=>a.slug??""},{header:"DESCRIPTION",get:(a)=>a.description??""}])}async function jn(t,e={}){let r=f(e.json),n=h(e.org),i=await l().collections.get(n,t);if(r==="json"){g(i);return}j(i)}async function En(t={}){let e=f(t.json),r=h(t.org),n=kn(t);if(n.name===void 0)throw Error("collections create: --name is required (or supply it via --data)");let a=await l().collections.create(r,n);if(e==="json"){g(a);return}process.stdout.write(`Created collection:
|
|
113
|
+
`),j(a)}async function Tn(t,e={}){let r=f(e.json),n=h(e.org),i=kn(e);if(Object.keys(i).length===0)throw Error("collections update: nothing to update (pass at least one field or --data)");let s=await l().collections.update(n,t,i);if(r==="json"){g(s);return}process.stdout.write(`Updated collection:
|
|
114
|
+
`),j(s)}async function Rn(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("collections delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete collection ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
115
|
+
`);return}}let i=await l().collections.delete(n,t);if(r==="json"){g(i);return}process.stdout.write(`Deleted collection ${t}.
|
|
116
|
+
`)}import{closeSync as Ca,existsSync as Cn,openSync as Sa,readFileSync as Oa,readSync as xa,statSync as Ut}from"node:fs";var Sn=["draft","published","all"];async function xn(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&!Sn.includes(t.status))throw Error(`posts list: --status must be one of ${Sn.join(", ")} (got: ${t.status})`);let n=await l().posts.list(r,{...t.limit!==void 0?{limit:t.limit}:{},...t.status?{status:t.status}:{}}),i=n.data??[];if(e==="json"){g({org:r,posts:i,total:n.total,skip:n.skip,limit:n.limit,hasMore:n.hasMore});return}k(i,[{header:"ID",get:(a)=>a.id},{header:"STATUS",get:(a)=>a.status??""},{header:"FILES",get:(a)=>String(a.files?.length??0)},{header:"TEXT",get:(a)=>(a.comment??"").replace(/\s+/g," ").slice(0,60)}])}async function An(t,e={}){let r=f(e.json),n=h(e.org),i=await l().posts.get(n,t);if(r==="json"){g(i);return}j(i)}async function Pn(t={}){let e=f(t.json),r=h(t.org),n=t.video!==void 0?$n(t.video,t.poster):void 0,i=P(t.data),a=i&&typeof i==="object"?{...i}:{};if(t.comment!==void 0)a.comment=t.comment;if(t.file!==void 0)a.files=[...a.files??[],t.file];if(a.comment===void 0)throw Error("posts create: --comment is required (or supply it via --data)");let o=await l().posts.createDraft(r,a),c;if(n)try{c=await Dn(r,String(o.id),n)}catch(p){let w=p instanceof Error?p.message:String(p);throw Error(`Draft ${String(o.id)} was filed, but the video was not attached: ${w}
|
|
117
|
+
Retry with: vcity posts attach-video ${String(o.id)} --video <file>`)}if(e==="json"){g(c??o);return}let u=c?" with its video":"";process.stdout.write(`Draft ${T(String(o.id))} filed${u}. An org admin must publish it from the proposals inbox.
|
|
118
|
+
`)}var Aa=26214400,Pa=2097152;function $n(t,e){if(!Cn(t)||!Ut(t).isFile())throw Error(`--video: file not found: ${t}`);if(!/\.mp4$/i.test(t))throw Error("--video: only .mp4 (H.264 + AAC) is accepted.");let r=Ut(t).size;if(r<1||r>Aa)throw Error("--video: the file must be between 1 byte and 25 MB.");if(String.fromCharCode(...$a(t,8).subarray(4,8))!=="ftyp")throw Error("--video: this does not look like an MP4 file.");if(e!==void 0){if(!Cn(e)||!Ut(e).isFile())throw Error(`--poster: file not found: ${e}`);if(!/\.jpe?g$/i.test(e))throw Error("--poster: only JPEG images are accepted.");if(Ut(e).size>Pa)throw Error("--poster: the file must be at most 2 MB.")}return{video:t,...e!==void 0?{poster:e}:{}}}function $a(t,e){let r=Sa(t,"r");try{let n=new Uint8Array(e),i=xa(r,n,0,e,0);return n.subarray(0,i)}finally{Ca(r)}}var Da=/(^|\.)storage\.googleapis\.com$/;function Na(t,e){let r;try{r=new URL(t)}catch{throw Error(`the ${e} upload URL from the API is not valid`)}if(r.protocol!=="https:"||!Da.test(r.hostname))throw Error(`refusing to upload the ${e}: the API returned a URL outside Google Cloud Storage`)}async function On(t,e,r,n){Na(t,n);let i;try{let a=await fetch(t,{method:"PUT",headers:e,body:new Uint8Array(Oa(r)),redirect:"error"});if(a.ok)return;i=a.status}catch{throw Error(`uploading the ${n} failed (network error)`)}throw Error(`uploading the ${n} failed (HTTP ${i})`)}async function Dn(t,e,r){let n=l(),i=await n.posts.requestVideoUpload(t,e,Ut(r.video).size);if(await On(i.videoUploadUrl,i.videoHeaders,r.video,"video"),r.poster)await On(i.posterUploadUrl,i.posterHeaders,r.poster,"poster");return await n.posts.finalizeVideo(t,e)}async function Nn(t,e={}){let r=f(e.json),n=h(e.org);if(e.video===void 0)throw Error("posts attach-video: --video <file.mp4> is required");let i=await Dn(n,t,$n(e.video,e.poster));if(r==="json"){g(i);return}process.stdout.write(`Video attached to draft ${t}. It stays private until an org admin publishes the post.
|
|
119
|
+
`)}async function Fn(t,e={}){let r=f(e.json),n=h(e.org),i=await l().posts.videoPreview(n,t);if(r==="json"){g(i);return}process.stdout.write(`Short-lived private links (do not share):
|
|
120
|
+
`),j(i)}async function Un(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("posts publish: --yes is required in JSON / non-interactive mode");if(!await _(`Publish post ${t} to the public feed of ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
121
|
+
`);return}}let i=await l().posts.publish(n,t);if(r==="json"){g(i);return}process.stdout.write(`Published post ${t}.
|
|
122
|
+
`)}function Ir(t,e,r){if(t===void 0)return;if(!e.includes(t))throw Error(`products list: ${r} must be one of ${e.join(", ")} (got: ${t})`);return t}var Fa=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?)?$/;function Bn(t,e){if(t===void 0)return;let r=/^\d+$/.test(t)?Number(t):Fa.test(t)?Date.parse(t):Number.NaN;if(!Number.isFinite(r)||r<0)throw Error(`products list: ${e} must be unix-ms or a date like 2026-10-01 (got: ${t})`);return r}async function Mn(t={}){let e=f(t.json),r=h(t.org),n={search:t.search,limit:t.limit,skip:t.skip,visibility:Ir(t.visibility,["public","draft","hidden"],"--visibility"),createdFrom:Bn(t.createdFrom,"--created-from"),updatedFrom:Bn(t.updatedFrom,"--updated-from"),collection:t.collection,sort:Ir(t.sort,["createdAt","updatedAt"],"--sort"),order:Ir(t.order,["asc","desc"],"--order"),lang:t.lang},a=await l().products.list(r,Object.fromEntries(Object.entries(n).filter(([,o])=>o!==void 0))),s=a.data??[];if(e==="json"){g({org:r,products:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"NAME",get:(o)=>o.name??""},{header:"PRICE",get:(o)=>o.price!==void 0?`${o.price.toLocaleString()} ${o.currencyCode??""}`.trim():""},{header:"SKU",get:(o)=>o.sku??""},{header:"VISIBILITY",get:(o)=>o.visibility??""},{header:"STOCK",get:(o)=>o.availability!==void 0?String(o.availability):""}])}async function Ln(t,e={}){let r=f(e.json),n=h(e.org),a=await l().products.get(n,t,e.lang!==void 0?{lang:e.lang}:{});if(r==="json"){g(a);return}j(a)}async function qn(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.name!==void 0)i.name=t.name;if(t.price!==void 0)i.price=t.price;if(t.currency!==void 0)i.currencyCode=t.currency;if(t.sku!==void 0)i.sku=t.sku;if(i.name===void 0)throw Error("products create: --name is required (or supply it via --data)");let s=await l().products.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created product:
|
|
123
|
+
`),j(s)}async function _n(t,e={}){let r=f(e.json),n=h(e.org),i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.name!==void 0)a.name=e.name;if(e.price!==void 0)a.price=e.price;if(e.currency!==void 0)a.currencyCode=e.currency;if(e.sku!==void 0)a.sku=e.sku;if(e.visibility!==void 0)a.visibility=e.visibility;if(e.availability!==void 0)a.availability=e.availability;if(Object.keys(a).length===0)throw Error("products update: nothing to update (pass at least one field or --data)");let o=await l().products.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated product:
|
|
124
|
+
`),j(o)}async function Gn(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("products delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete product ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
125
|
+
`);return}}let a=await l().products.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted product ${t}.
|
|
126
|
+
`)}import Jn from"node:fs";import Vn from"node:path";var mt=1048576,Ua={".png":{contentType:"image/png",max:10*mt},".jpg":{contentType:"image/jpeg",max:10*mt},".jpeg":{contentType:"image/jpeg",max:10*mt},".gif":{contentType:"image/gif",max:10*mt},".webp":{contentType:"image/webp",max:10*mt},".pdf":{contentType:"application/pdf",max:25*mt},".mp4":{contentType:"video/mp4",max:100*mt},".mov":{contentType:"video/quicktime",max:100*mt}};function Bt(t){let e=Ua[Vn.extname(t).toLowerCase()];if(!e)throw new y(`${t}: unsupported file type (PNG, JPEG, GIF, WebP, PDF, MP4 or MOV)`);let r;try{r=Jn.statSync(t)}catch{throw new y(`${t}: no such file`)}if(!r.isFile())throw new y(`${t} is not a regular file`);if(r.size>e.max)throw new y(`${t} is larger than ${e.max/mt} MB`);return{name:Vn.basename(t),contentType:e.contentType,size:r.size}}async function ze(t,e,r){let{name:n,contentType:i}=Bt(r),a=new Uint8Array(Jn.readFileSync(r)),s=await t.media.upload(e,{name:n,contentType:i,data:a});return{url:s.url,id:s.id,kind:s.kind}}var Hn=(t)=>/^https?:\/\//i.test(t);async function Yn(t,e,r){if(t!=="upload"||e.length===0)throw new y("usage: vcity media upload <file> [file…] [--org <slug>] [--json] (PNG/JPEG/GIF/WebP ≤10 MB, PDF ≤25 MB, MP4/MOV ≤100 MB)");for(let o of e)Bt(o);let n=h(m(r,"org")),i=l(),a=[];for(let o of e)try{a.push({file:o,...await ze(i,n,o)})}catch(c){a.push({file:o,error:c.message})}if(f(!!r.json)==="json")g({org:n,files:a});else k(a,[{header:"FILE",get:(o)=>o.file},{header:"URL",get:(o)=>o.url??""},{header:"ERROR",get:(o)=>o.error??""}]);let s=a.filter((o)=>o.error).length;if(s>0)throw Error(`${s} of ${a.length} uploads failed`)}import{randomUUID as Ba}from"node:crypto";import jr from"node:path";var Ma=new Set(["price","availability"]),La=new Set(["tags","categories","collections"]),qa=new Set(["name","price","currencyCode","sku","visibility","availability","cta","type","slug","description","tags","categories","collections","thumbnail","gallery"]),_a={currency:"currencyCode",stock:"availability",image:"thumbnail"};function Ga(t){let e={};for(let[r,n]of Object.entries(t)){let i=_a[r]??r,a=n.trim();if(a==="")continue;if(!qa.has(i))throw Error(`unknown column "${r}"`);if(Ma.has(i)){let s=Number(a);if(!Number.isFinite(s))throw Error(`${i} must be a number (got: ${a})`);e[i]=s}else if(La.has(i))e[i]=a.split("|").map((s)=>s.trim()).filter(Boolean);else if(i==="thumbnail")e.thumbnail={url:a};else if(i==="gallery")e.gallery=a.split("|").map((s)=>({url:s.trim()})).filter((s)=>s.url);else e[i]=a}return e}function Va(t,e){if(jr.extname(t).toLowerCase()===".json"){let r;try{r=JSON.parse(e)}catch(n){throw new y(`${t}: invalid JSON (${n.message})`)}if(!Array.isArray(r)||r.some((n)=>typeof n!=="object"||n===null||Array.isArray(n)))throw new y(`${t}: expected a JSON array of product objects`);return r.map((n,i)=>({row:i+1,json:n}))}return Ye(e).map(({line:r,record:n})=>({row:r,csv:n}))}async function Ja(t,e,r){let n=async(o)=>{if(Hn(o))return{url:o};let c=jr.resolve(e,o);if(!r)return Bt(c),{url:o};let u=r.cache.get(c);if(u)return u;let{url:p,id:w}=await ze(r.sdk,r.org,c);return r.cache.set(c,{url:p,id:w}),{url:p,id:w}},i=async(o)=>{if(!o.url)return o;let{url:c,id:u}=await n(o.url);return{...o,url:c,id:o.id||u||Ba()}},a={...t},s=a.thumbnail;if(s?.url)a.thumbnail=await i(s);if(Array.isArray(a.gallery))a.gallery=await Promise.all(a.gallery.map(i));return a}function Qn(t){if(process.stderr.isTTY)process.stderr.write(`${T(t)}
|
|
127
|
+
`)}async function Wn(t,e={}){let r=f(e.json),n=h(e.org),i=Va(t,st(t));if(i.length===0)throw new y(`${t}: no product rows`);let a=(e.upsertBy??"sku")==="sku",s=l(),o=new Map;if(a){let v=await ut(async(R,E)=>{let N=await s.products.list(n,{skip:R,limit:E,sort:"createdAt",order:"asc"});return{data:N.data??[],hasMore:N.hasMore}});for(let R of v)if(R.sku)o.set(R.sku,R.id)}let c=[],u=new Map;for(let[v,R]of i.entries()){let{row:E}=R,N;try{N=R.csv?Ga(R.csv):R.json??{}}catch(L){c.push({row:E,action:"error",error:L.message});continue}let F=typeof N.sku==="string"?N.sku:void 0,D=a&&F?o.get(F):void 0,X=D?"update":"create";if(X==="create"&&(N.name===void 0||N.price===void 0||N.currencyCode===void 0)){c.push({row:E,sku:F,action:"error",error:"a new product needs name, price and currencyCode"});continue}try{N=await Ja(N,e.images??jr.dirname(t),e.dryRun?void 0:{sdk:s,org:n,cache:u})}catch(L){c.push({row:E,sku:F,action:"error",error:L.message});continue}if(e.dryRun){if(F&&!D)o.set(F,"(new)");c.push({row:E,sku:F,action:X,id:D==="(new)"?void 0:D});continue}try{let rt=(D?await s.products.update(n,D,N):await s.products.create(n,N)).id??D;if(F&&rt)o.set(F,rt);c.push({row:E,sku:F,action:X,id:rt}),Qn(`[${v+1}/${i.length}] ${X}d ${F??rt??""}`)}catch(L){c.push({row:E,sku:F,action:"error",error:L.message}),Qn(`[${v+1}/${i.length}] row ${E} failed: ${L.message}`)}}let p=c.filter((v)=>v.action==="error"),w={org:n,dryRun:!!e.dryRun,total:c.length,created:c.filter((v)=>v.action==="create").length,updated:c.filter((v)=>v.action==="update").length,failed:p.length};if(e.report)Z(e.report,`${JSON.stringify({...w,rows:c},null,2)}
|
|
128
128
|
`);if(r==="json")g({...w,rows:c});else if(process.stdout.write(`${w.dryRun?"Dry run: would create":"Created"} ${w.created}, ${w.dryRun?"update":"updated"} ${w.updated}, failed ${w.failed} of ${w.total} rows.
|
|
129
|
-
`),
|
|
130
|
-
`),j(s)}async function
|
|
131
|
-
`),j(o)}async function
|
|
132
|
-
`);return}}let a=await
|
|
133
|
-
`)}var Ke=new Set(["PENDING","IN_PROGRESS","SUBMITTED","CANCELED","ORDERED"]);async function
|
|
134
|
-
`),j(s)}async function
|
|
135
|
-
`),j(o)}async function
|
|
136
|
-
`);return}}let a=await
|
|
137
|
-
`)}async function
|
|
138
|
-
`),j(s)}async function
|
|
139
|
-
`),j(o)}async function
|
|
140
|
-
`);return}}let a=await
|
|
141
|
-
`)}var
|
|
129
|
+
`),p.length>0)k(p,[{header:"ROW",get:(v)=>String(v.row)},{header:"SKU",get:(v)=>v.sku??""},{header:"ERROR",get:(v)=>v.error??""}]);if(p.length>0)throw Error(`${p.length} of ${c.length} rows failed`)}async function zn(t={}){let e=f(t.json),r=h(t.org),i=await l().projects.list(r,t.limit!==void 0?{limit:t.limit}:{}),a=i.data??[];if(e==="json"){g({org:r,projects:a,total:i.total,skip:i.skip,limit:i.limit,hasMore:i.hasMore});return}k(a,[{header:"ID",get:(s)=>s.id},{header:"NAME",get:(s)=>s.name??""},{header:"PREFIX",get:(s)=>s.prefix??""},{header:"DESCRIPTION",get:(s)=>s.description??""}])}async function Kn(t,e={}){let r=f(e.json),n=h(e.org),a=await l().projects.get(n,t);if(r==="json"){g(a);return}j(a)}async function Xn(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.name!==void 0)i.name=t.name;if(t.prefix!==void 0)i.prefix=t.prefix;if(t.description!==void 0)i.description=t.description;if(i.name===void 0)throw Error("projects create: --name is required (or supply it via --data)");if(i.prefix===void 0)throw Error("projects create: --prefix is required (or supply it via --data)");let s=await l().projects.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created project:
|
|
130
|
+
`),j(s)}async function Zn(t,e={}){let r=f(e.json),n=h(e.org),i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.name!==void 0)a.name=e.name;if(e.description!==void 0)a.description=e.description;if(Object.keys(a).length===0)throw Error("projects update: nothing to update (pass at least one field or --data)");let o=await l().projects.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated project:
|
|
131
|
+
`),j(o)}async function to(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("projects delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete project ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
132
|
+
`);return}}let a=await l().projects.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted project ${t}.
|
|
133
|
+
`)}var Ke=new Set(["PENDING","IN_PROGRESS","SUBMITTED","CANCELED","ORDERED"]);async function eo(t={}){let e=f(t.json),r=h(t.org);if(t.status!==void 0&&!Ke.has(t.status))throw Error(`Invalid quote status: ${t.status}. Allowed: ${[...Ke].join(", ")}`);let n={};if(t.limit!==void 0)n.limit=t.limit;if(t.status!==void 0)n.status=t.status;let a=await l().quotes.list(r,n),s=a.data??[];if(e==="json"){g({org:r,quotes:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"NAME",get:(o)=>o.name??""},{header:"PRODUCT",get:(o)=>o.productId??""},{header:"QTY",get:(o)=>o.quantity!==void 0?String(o.quantity):""},{header:"STATUS",get:(o)=>o.status??""},{header:"CREATED",get:(o)=>x(o.createdAt)}])}async function ro(t,e={}){let r=f(e.json),n=h(e.org),a=await l().quotes.get(n,t);if(r==="json"){g(a);return}j(a)}async function so(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.name!==void 0)i.name=t.name;if(t.email!==void 0)i.email=t.email;if(t.product!==void 0)i.productId=t.product;if(t.quantity!==void 0)i.quantity=t.quantity;if(t.phone!==void 0)i.telephone=t.phone;if(t.variation!==void 0)i.selectedVariation=t.variation;if(t.company!==void 0)i.company=t.company;if(t.note!==void 0)i.note=t.note;if(i.name===void 0||i.email===void 0||i.productId===void 0)throw Error("quotes create: --name, --email and --product are required (or supply them via --data)");let s=await l().quotes.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created quote:
|
|
134
|
+
`),j(s)}async function no(t,e={}){let r=f(e.json),n=h(e.org);if(e.status!==void 0&&!Ke.has(e.status))throw Error(`Invalid quote status: ${e.status}. Allowed: ${[...Ke].join(", ")}`);let i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.name!==void 0)a.name=e.name;if(e.email!==void 0)a.email=e.email;if(e.product!==void 0)a.productId=e.product;if(e.quantity!==void 0)a.quantity=e.quantity;if(e.phone!==void 0)a.telephone=e.phone;if(e.variation!==void 0)a.selectedVariation=e.variation;if(e.status!==void 0)a.status=e.status;if(e.company!==void 0)a.company=e.company;if(e.note!==void 0)a.note=e.note;if(e.assignee!==void 0)a.assigneeUid=e.assignee;if(Object.keys(a).length===0)throw Error("quotes update: nothing to update (pass at least one field or --data)");let o=await l().quotes.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated quote:
|
|
135
|
+
`),j(o)}async function oo(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("quotes delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete quote ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
136
|
+
`);return}}let a=await l().quotes.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted quote ${t}.
|
|
137
|
+
`)}async function io(t={}){let e=f(t.json),r=h(t.org),n={};if(t.limit!==void 0)n.limit=t.limit;let a=await l().rooms.list(r,n),s=a.data??[];if(e==="json"){g({org:r,rooms:s,total:a.total,skip:a.skip,limit:a.limit,hasMore:a.hasMore});return}k(s,[{header:"ID",get:(o)=>o.id},{header:"TITLE",get:(o)=>o.title??""},{header:"DISABLED",get:(o)=>o.disabled?"yes":"no"},{header:"TYPE",get:(o)=>o.type??""}])}async function ao(t,e={}){let r=f(e.json),n=h(e.org),a=await l().rooms.get(n,t);if(r==="json"){g(a);return}j(a)}async function co(t={}){let e=f(t.json),r=h(t.org),n=P(t.data),i=n&&typeof n==="object"?{...n}:{};if(t.title!==void 0)i.title=t.title;if(t.description!==void 0)i.description=t.description;if(t.type!==void 0)i.type=t.type;if(i.title===void 0)throw Error("rooms create: --title is required (or supply it via --data)");let s=await l().rooms.create(r,i);if(e==="json"){g(s);return}process.stdout.write(`Created room:
|
|
138
|
+
`),j(s)}async function uo(t,e={}){let r=f(e.json),n=h(e.org),i=P(e.data),a=i&&typeof i==="object"?{...i}:{};if(e.title!==void 0)a.title=e.title;if(e.description!==void 0)a.description=e.description;if(e.type!==void 0)a.type=e.type;if(e.disabled!==void 0)a.disabled=e.disabled;if(Object.keys(a).length===0)throw Error("rooms update: nothing to update (pass at least one field or --data)");let o=await l().rooms.update(n,t,a);if(r==="json"){g(o);return}process.stdout.write(`Updated room:
|
|
139
|
+
`),j(o)}async function go(t,e={}){let r=f(e.json),n=h(e.org);if(!e.yes){if(r==="json")throw Error("rooms delete: --yes is required in JSON / non-interactive mode");if(!await _(`Delete room ${t} in org ${n}? [y/N]`)){process.stdout.write(`Aborted.
|
|
140
|
+
`);return}}let a=await l().rooms.delete(n,t);if(r==="json"){g(a);return}process.stdout.write(`Deleted room ${t}.
|
|
141
|
+
`)}var lo=["today","week","month","quarter","year","all"];async function po(t={}){let e=f(t.json),r=h(t.org),n=l(),[i,a,s]=await Promise.all([n.orgs.summary(r),n.orgs.overview(r,{timeframe:t.timeframe??"week"}),n.orgs.attention(r)]);if(e==="json"){g({org:r,summary:i,overview:a,attention:s});return}let o=a.sales;if(process.stdout.write(T([`${r} — ${a.timeframe}`,` inbox ${i.inboxUnread} unread · ${i.openConversations} open · ${i.unassignedConversations} unassigned`,` orders ${i.pendingOrders} pending · ${a.totalOrders} in ${a.timeframe}`,` bookings ${i.pendingBookings} pending`,` sales ${o?`${o.revenue.toLocaleString()} ${o.currencyCode} from ${o.orders} paid orders`:"none"}`,` visits ${a.totalVisits}`,""].join(`
|
|
142
142
|
`))),s.tasks.length>0)process.stdout.write(`Needs attention:
|
|
143
|
-
`),k(s.tasks,[{header:"KIND",get:(c)=>c.kind},{header:"WHEN",get:(c)=>x(c.at)},{header:"DETAIL",get:(c)=>c.detail}])}import{spawn as
|
|
143
|
+
`),k(s.tasks,[{header:"KIND",get:(c)=>c.kind},{header:"WHEN",get:(c)=>x(c.at)},{header:"DETAIL",get:(c)=>c.detail}])}import{spawn as wo}from"node:child_process";import Mt from"node:path";var mo="https://vcity.io/cli/install.sh",fo=1e4,vo=64,Ha=/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function Ya(t){return t.length>0&&t.length<=vo&&Ha.test(t)}function Qa(){return typeof process.versions.bun==="string"?"binary":"npm"}async function Wa(){let t=`https://registry.npmjs.org/${Et}/latest`,e;try{e=await fetch(t,{headers:{accept:"application/json"},signal:AbortSignal.timeout(fo)})}catch(n){if(n instanceof Error&&n.name==="TimeoutError")throw Error(`npm registry did not respond within ${fo/1000}s. Try again later.`,{cause:n});throw Error("Could not reach the npm registry. Check your internet connection.",{cause:n})}if(!e.ok)throw Error(`Failed to fetch latest version from npm (HTTP ${e.status})`);let r=await e.json();if(!r.version||typeof r.version!=="string"||r.version.length>vo)throw Error("Latest version response from npm is missing or invalid `version` field");return r.version}function yo(t){let[e,...r]=t.split("-"),[n,i,a]=e.split(".").map((s)=>parseInt(s,10));return{major:Number.isFinite(n)?n:0,minor:Number.isFinite(i)?i:0,patch:Number.isFinite(a)?a:0,prerelease:r.join("-")}}function Er(t,e){let r=yo(t),n=yo(e);if(r.major!==n.major)return r.major-n.major;if(r.minor!==n.minor)return r.minor-n.minor;if(r.patch!==n.patch)return r.patch-n.patch;if(r.prerelease===n.prerelease)return 0;if(r.prerelease==="")return 1;if(n.prerelease==="")return-1;return r.prerelease<n.prerelease?-1:1}function za(t,e){return new Promise((r,n)=>{let i=wo(t,e,{stdio:"inherit",shell:!1});i.on("error",n),i.on("exit",(a)=>r({exitCode:a??1}))})}function Ka(t,e=["--version"]){return new Promise((r)=>{let n=wo(t,e,{stdio:"ignore",shell:!1});n.on("error",()=>r(!1)),n.on("exit",(i)=>r(i===0))})}async function Xa(){let t=Mt.dirname(process.execPath),e=process.platform==="win32"?[Mt.join(t,"npm.cmd"),Mt.join(t,"npm")]:[Mt.join(t,"npm")];for(let r of e)if(await Ka(r))return r;return}function ho(){process.stdout.write(`Download, inspect, then run (recommended):
|
|
144
144
|
`),process.stdout.write(` f=$(mktemp)
|
|
145
|
-
`),process.stdout.write(` curl -fsSL ${
|
|
145
|
+
`),process.stdout.write(` curl -fsSL ${mo} -o "$f"
|
|
146
146
|
`),process.stdout.write(` less "$f"
|
|
147
147
|
`),process.stdout.write(` bash "$f"
|
|
148
148
|
`),process.stdout.write(`
|
|
149
149
|
Or, if you trust the origin (no signature verification is performed):
|
|
150
|
-
`),process.stdout.write(` curl -fsSL ${
|
|
151
|
-
`)}async function
|
|
150
|
+
`),process.stdout.write(` curl -fsSL ${mo} | bash
|
|
151
|
+
`)}async function bo(t={}){let e=f(t.json),r=Qa(),n=await Wa(),i=T(n),s=Er(nt,i)<0;if(e==="json"){if(g({current:nt,latest:i,outdated:s,installMethod:r}),t.check||!s)return}else{if(process.stdout.write(`current: ${nt}
|
|
152
152
|
`),process.stdout.write(`latest: ${i}
|
|
153
153
|
`),!s){process.stdout.write(`vcity is up to date.
|
|
154
154
|
`);return}process.stdout.write(`install: ${r==="binary"?"standalone binary":"npm global"}
|
|
155
155
|
`)}if(t.check)return;if(!t.yes&&e!=="json"){if(process.stdout.write(`
|
|
156
156
|
Run with --yes to apply the update, or use the command below:
|
|
157
|
-
`),r==="binary")
|
|
157
|
+
`),r==="binary")ho();else process.stdout.write(` npm install -g ${Et}@latest
|
|
158
158
|
`);return}if(r==="binary"){if(e!=="json")process.stdout.write(`
|
|
159
159
|
This CLI was installed from a standalone binary.
|
|
160
|
-
`),
|
|
161
|
-
npm install -g ${
|
|
160
|
+
`),ho();return}if(!Ya(i))throw Error(`Refusing to install: registry returned a non-semver \`latest\` value. Expected MAJOR.MINOR.PATCH; got: ${i.slice(0,100)}`);let o=await Xa();if(!o)throw Error(`Could not find \`npm\` alongside the current Node.js binary (${Mt.dirname(process.execPath)}). Run this yourself with a trusted npm:
|
|
161
|
+
npm install -g ${Et}@${i}`);process.stdout.write(`
|
|
162
162
|
Installing latest from npm…
|
|
163
|
-
`);let{exitCode:c}=await
|
|
163
|
+
`);let{exitCode:c}=await za(o,["install","-g",`${Et}@${i}`]);if(c!==0)throw Error(`npm install exited with code ${c}`);process.stdout.write(`
|
|
164
164
|
Updated to ${i}. Run \`vcity --version\` to confirm.
|
|
165
|
-
`)}import Lt from"node:fs";import ot from"node:path";var Xe=".vcity-vault.json",
|
|
165
|
+
`)}import Lt from"node:fs";import ot from"node:path";var Xe=".vcity-vault.json",Za=/^---\n([\s\S]*?)\n---\n?/;function Tr(t){return["---",`id: ${t.id}`,`title: ${JSON.stringify(t.title)}`,`tags: ${JSON.stringify(t.tags??[])}`,"---",t.content??""].join(`
|
|
166
166
|
`)}function qt(t){let e=t.replace(/\r\n/g,`
|
|
167
|
-
`),r=e.match(
|
|
168
|
-
`)){let s=a.indexOf(":");if(s>0)n[a.slice(0,s).trim()]=a.slice(s+1).trim()}let i=(a)=>{if(a===void 0)return;try{return JSON.parse(a)}catch{return a}};return{id:n.id||void 0,title:i(n.title),tags:i(n.tags),content:e.slice(r[0].length)}}function
|
|
169
|
-
`);let
|
|
170
|
-
`),
|
|
171
|
-
`))}async function
|
|
172
|
-
`);if(n)g({org:t,dir:e,dryRun:s,results:o});else k(o.filter((v)=>v.action!=="unchanged"),[{header:"FILE",get:(v)=>v.file},{header:"RESULT",get:(v)=>v.action==="merged"?"merged with newer server edits (file updated)":v.action},{header:"NOTE",get:(v)=>v.error??""}]);let w=o.filter((v)=>v.action==="error").length;if(w>0)throw Error(`${w} of ${o.length} pages failed`)}function
|
|
167
|
+
`),r=e.match(Za);if(!r)return{content:e};let n={};for(let a of r[1].split(`
|
|
168
|
+
`)){let s=a.indexOf(":");if(s>0)n[a.slice(0,s).trim()]=a.slice(s+1).trim()}let i=(a)=>{if(a===void 0)return;try{return JSON.parse(a)}catch{return a}};return{id:n.id||void 0,title:i(n.title),tags:i(n.tags),content:e.slice(r[0].length)}}function tc(t,e){let r=(t.slug||t.title||t.id).toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||t.id,n=`${r.slice(0,80)}.md`;if(e.has(n))n=`${r.slice(0,60)}-${t.id.replace(/[^a-zA-Z0-9_-]/g,"")}.md`;return e.add(n),n}function Cr(t){let e=ot.join(t,Xe);if(!Lt.existsSync(e))return;return JSON.parse(st(e))}function Rr(t,e){return{file:e,version:t.version??0,content:t.content??"",title:t.title,tags:t.tags??[]}}function ko(t,e){let r=ot.join(t,e.file);if(!Lt.existsSync(r))return!1;let n=qt(st(r));return n.content!==e.content||n.title!==void 0&&n.title!==e.title||n.tags!==void 0&&JSON.stringify(n.tags)!==JSON.stringify(e.tags)}async function ec(t,e,r,n){let i=l().vault,a=Cr(e);if(a&&a.org!==t)throw new y(`${e} was pulled from ${a.org}, not ${t}`);let s=a?Object.values(a.notes).filter((w)=>ko(e,w)):[];if(s.length>0&&r.force!==!0)throw new y(`${s.length} page(s) have local edits that were not pushed (${s.map((w)=>w.file).slice(0,5).join(", ")}). Run \`vcity vault push\` first, or pass --force to overwrite them.`);Lt.mkdirSync(e,{recursive:!0});let{data:o}=await i.listNotes(t),c=new Set,u={org:t,notes:{}};for(let w of o){let{note:v}=await i.getNote(t,w.id),R=tc(v,c);Z(ot.join(e,R),Tr(v)),u.notes[v.id]=Rr(v,R)}Z(ot.join(e,Xe),`${JSON.stringify(u,null,2)}
|
|
169
|
+
`);let p=Lt.readdirSync(e).filter((w)=>w.endsWith(".md")&&!c.has(w)).filter((w)=>{let v=qt(st(ot.join(e,w))).id;return v!==void 0&&!u.notes[v]});if(n)g({org:t,dir:e,pulled:Object.keys(u.notes).length,orphans:p});else if(process.stdout.write(`Pulled ${Object.keys(u.notes).length} pages into ${T(e)}.
|
|
170
|
+
`),p.length>0)process.stdout.write(T(`Not on the server any more (left untouched; push ignores them): ${p.join(", ")}
|
|
171
|
+
`))}async function rc(t,e,r,n){let i=Cr(e);if(!i)throw new y(`${e} has no ${Xe}; run \`vcity vault pull ${e}\` first`);if(i.org!==t)throw new y(`${e} was pulled from ${i.org}, not ${t}`);let a=l().vault,s=r["dry-run"]===!0,o=[],u=Lt.readdirSync(e).filter((v)=>v.endsWith(".md")).sort().map((v)=>({file:v,parsed:qt(st(ot.join(e,v)))})),p=new Map;for(let{file:v,parsed:R}of u){if(!R.id)continue;let E=p.get(R.id);if(E)throw new y(`${E} and ${v} both carry id ${R.id}; keep one (or delete the id line to create a new page)`);p.set(R.id,v)}for(let{file:v,parsed:R}of u){let E=R.id?i.notes[R.id]:void 0;try{if(R.id&&(!E||E.file!==v)){o.push({file:v,action:"skip",id:R.id,error:E?`page now lives in ${E.file}`:"page was deleted or renamed on the server since the last pull"});continue}if(!R.id||!E){let D=R.title??v.replace(/\.md$/,"");if(!s){let X=await a.createNote(t,{title:D,content:R.content,tags:R.tags??[]}),L=X.note??X,rt={...L,content:R.content};i.notes[L.id]=Rr(rt,v),Z(ot.join(e,v),Tr(rt)),o.push({file:v,action:"create",id:L.id})}else o.push({file:v,action:"create"});continue}if(!ko(e,E)){o.push({file:v,action:"unchanged",id:R.id});continue}if(s){o.push({file:v,action:"save",id:R.id});continue}let N=await a.saveNote(t,R.id,{content:R.content,...R.title!==void 0&&{title:R.title},...R.tags!==void 0&&{tags:R.tags},baseVersion:E.version,baseContent:E.content}),F=N.note;if(i.notes[R.id]=Rr({...F,content:F.content??R.content},v),N.merged)Z(ot.join(e,v),Tr(F));o.push({file:v,action:N.merged?"merged":"save",id:R.id})}catch(N){o.push({file:v,action:"error",id:R.id,error:N.message})}}if(!s)Z(ot.join(e,Xe),`${JSON.stringify(i,null,2)}
|
|
172
|
+
`);if(n)g({org:t,dir:e,dryRun:s,results:o});else k(o.filter((v)=>v.action!=="unchanged"),[{header:"FILE",get:(v)=>v.file},{header:"RESULT",get:(v)=>v.action==="merged"?"merged with newer server edits (file updated)":v.action},{header:"NOTE",get:(v)=>v.error??""}]);let w=o.filter((v)=>v.action==="error").length;if(w>0)throw Error(`${w} of ${o.length} pages failed`)}function sc(t,e){let n=Cr(ot.dirname(ot.resolve(t)))?.notes[e];return n&&n.file===ot.basename(t)?n:void 0}var nc="vcity vault list|get <id>|create --title <s> [--file <f.md>|--content <s>]|save <id> --file <f.md>|delete <id>|move <id> --parent <id|root> [--order n]|search <text>|pull <dir>|push <dir> [--dry-run]";async function Io(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().vault;switch(t){case"list":{let{data:s}=await a.listNotes(i);if(n)g({org:i,notes:s});else k(s,[{header:"ID",get:(o)=>o.id},{header:"TITLE",get:(o)=>o.title},{header:"PARENT",get:(o)=>o.parentId??""},{header:"TAGS",get:(o)=>(o.tags??[]).join(",")},{header:"UPDATED",get:(o)=>x(o.updatedAt)}]);return}case"get":{let s=I(e[0],"vcity vault get <id>","note id"),o=await a.getNote(i,s);if(n)g(o);else process.stdout.write(`${T(`# ${o.note.title}
|
|
173
173
|
|
|
174
174
|
${o.note.content??""}`)}
|
|
175
|
-
`);return}case"create":{let s=G(m(r,"title"),"vcity vault create --title <s> [--file <f.md>|--content <s>] [--parent <id>] [--tags a,b]"),o=m(r,"file"),c=o?qt(st(o)).content:m(r,"content")??"",u=await a.createNote(i,{title:s,content:c,tags:q(r,"tags")??[],...m(r,"parent")!==void 0&&{parentId:m(r,"parent")}});if(n)g(u);else process.stdout.write(`Created page ${
|
|
176
|
-
`);return}case"save":{let s=I(e[0],"vcity vault save <id> --file <f.md> | --content <s>","note id"),o=m(r,"file"),u=(o?qt(st(o)):void 0)?.content??G(m(r,"content"),"vcity vault save <id> --file <f.md> | --content <s>"),
|
|
175
|
+
`);return}case"create":{let s=G(m(r,"title"),"vcity vault create --title <s> [--file <f.md>|--content <s>] [--parent <id>] [--tags a,b]"),o=m(r,"file"),c=o?qt(st(o)).content:m(r,"content")??"",u=await a.createNote(i,{title:s,content:c,tags:q(r,"tags")??[],...m(r,"parent")!==void 0&&{parentId:m(r,"parent")}});if(n)g(u);else process.stdout.write(`Created page ${T(s)}.
|
|
176
|
+
`);return}case"save":{let s=I(e[0],"vcity vault save <id> --file <f.md> | --content <s>","note id"),o=m(r,"file"),u=(o?qt(st(o)):void 0)?.content??G(m(r,"content"),"vcity vault save <id> --file <f.md> | --content <s>"),p=o?sc(o,s):void 0,w=p?.version??(await a.getNote(i,s)).note.version??0,v=await a.saveNote(i,s,{content:u,...m(r,"title")!==void 0&&{title:m(r,"title")},baseVersion:w,...p&&{baseContent:p.content}});if(n)g(v);else process.stdout.write(v.merged?`Saved (merged with newer edits).
|
|
177
177
|
`:`Saved.
|
|
178
178
|
`);return}case"delete":{let s=I(e[0],"vcity vault delete <id> [--yes]","note id");if(!await B(`Delete vault page ${s}?`,{yes:r.yes===!0,json:n}))return;let o=await a.deleteNote(i,s);if(n)g(o);else process.stdout.write(`Deleted.
|
|
179
179
|
`);return}case"move":{let s=I(e[0],"vcity vault move <id> --parent <id|root> [--order <n>]","note id"),o=G(m(r,"parent"),"vcity vault move <id> --parent <id|root> [--order <n>]"),c=await a.moveNote(i,s,{parentId:o==="root"?null:o,order:C(r,"order")??0});if(n)g(c);else process.stdout.write(`Moved.
|
|
180
|
-
`);return}case"search":{let s=G(e.join(" ")||m(r,"q"),"vcity vault search <text>"),o=await a.search(i,{q:s});if(n)g(o);else k(o.data??[],[{header:"ID",get:(c)=>String(c.id??"")},{header:"TITLE",get:(c)=>String(c.title??"")},{header:"MATCH",get:(c)=>String(c.snippet??c.excerpt??"").replace(/\s+/g," ").slice(0,80)}]);return}case"pull":return
|
|
181
|
-
${
|
|
180
|
+
`);return}case"search":{let s=G(e.join(" ")||m(r,"q"),"vcity vault search <text>"),o=await a.search(i,{q:s});if(n)g(o);else k(o.data??[],[{header:"ID",get:(c)=>String(c.id??"")},{header:"TITLE",get:(c)=>String(c.title??"")},{header:"MATCH",get:(c)=>String(c.snippet??c.excerpt??"").replace(/\s+/g," ").slice(0,80)}]);return}case"pull":return ec(i,G(e[0],"vcity vault pull <dir> [--force]"),r,n);case"push":return rc(i,G(e[0],"vcity vault push <dir> [--dry-run]"),r,n);default:throw new y(`usage: ${nc}`)}}var jo=["order.created","product.created","booking.created"],oc="vcity webhooks list|get|create|update|delete|test|deliveries|rotate (create: --url <https://…> --events order.created,booking.created)";function ic(t){let e=q(t,"events");if(!e)return;let r=e.filter((n)=>!jo.includes(n));if(r.length>0)throw new y(`unknown event ${r.join(", ")}. Allowed: ${jo.join(", ")}`);return e}function ac(t,e){let r=m(t,"header");if(r===void 0)return;if(e)throw new y(`an update replaces every custom header, so --header would drop the others; pass them all with --data '{"headers":{…}}'`);let n=r.indexOf(":");if(n<=0)throw new y('--header must look like "Name: value"');return{[r.slice(0,n).trim()]:r.slice(n+1).trim()}}function Eo(t,e=!1){let r=P(m(t,"data"));if(r!==void 0&&(typeof r!=="object"||r===null||Array.isArray(r)))throw new y("--data must be a JSON object");let n={...r},i=m(t,"url");if(i!==void 0){if(!i.startsWith("https://"))throw new y("--url must be an https:// URL");n.url=i}let a=ic(t);if(a)n.events=a;let s=ac(t,e);if(s)n.headers={...n.headers,...s};let o=m(t,"description");if(o!==void 0)n.description=o;let c=A(t,"status",["active","paused"]);if(c)n.status=c;return n}function To(t){process.stdout.write(`Signing secret (shown once — store it now):
|
|
181
|
+
${T(String(t))}
|
|
182
182
|
Verify the X-Vcity-Signature header of each delivery with it.
|
|
183
|
-
`)}async function
|
|
184
|
-
`),
|
|
183
|
+
`)}async function Ro(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"list":{let s=await a.webhooks.list(i,{...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...C(r,"skip")!==void 0&&{skip:C(r,"skip")}});if(n)g({org:i,webhooks:s.data,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});else k(s.data,[{header:"ID",get:(o)=>o.id},{header:"STATUS",get:(o)=>o.status},{header:"EVENTS",get:(o)=>o.events.join(",")},{header:"URL",get:(o)=>o.url},{header:"FAILURES",get:(o)=>String(o.consecutiveFailures??0)}]);return}case"get":{let s=I(e[0],"vcity webhooks get <id>","webhook id"),o=await a.webhooks.get(i,s);if(n)g(o);else j(o);return}case"create":{let s=Eo(r);if(typeof s.url!=="string"||!Array.isArray(s.events))throw new y('usage: vcity webhooks create --url <https://…> --events order.created[,…] [--header "X-Key: v"] [--description <s>]');let o=await a.webhooks.create(i,s);if(n)g(o);else process.stdout.write(`Created webhook ${T(o.id)}.
|
|
184
|
+
`),To(o.signingSecret);return}case"update":{let s=I(e[0],"vcity webhooks update <id> [--url …] [--events …] [--status active|paused]","webhook id"),o=Eo(r,!0);if(Object.keys(o).length===0)throw new y("webhooks update: nothing to change");let c=await a.webhooks.update(i,s,o);if(n)g(c);else process.stdout.write(`Updated webhook ${s}.
|
|
185
185
|
`);return}case"delete":{let s=I(e[0],"vcity webhooks delete <id> [--yes]","webhook id");if(!await B(`Delete webhook ${s} in ${i}?`,{yes:r.yes===!0,json:n}))return;let o=await a.webhooks.delete(i,s);if(n)g(o);else process.stdout.write(`Deleted webhook ${s}.
|
|
186
|
-
`);return}case"test":{let s=I(e[0],"vcity webhooks test <id>","webhook id"),o=await a.webhooks.test(i,s);if(n)g(o);else process.stdout.write(
|
|
186
|
+
`);return}case"test":{let s=I(e[0],"vcity webhooks test <id>","webhook id"),o=await a.webhooks.test(i,s);if(n)g(o);else process.stdout.write(T(`${o.ok?"OK":"FAILED"} — receiver answered ${o.status??"nothing"} in ${o.durationMs} ms${o.error?` (${o.error})`:""}
|
|
187
187
|
${o.responseBody?`${o.responseBody}
|
|
188
188
|
`:""}`));if(!o.ok)throw Error("test delivery failed");return}case"deliveries":{let s=I(e[0],"vcity webhooks deliveries <id> [--failed] [--limit n] [--before <ms>]","webhook id"),o=await a.webhooks.deliveries(i,s,{...C(r,"limit",{min:1,max:200})!==void 0&&{limit:C(r,"limit")},...C(r,"before")!==void 0&&{beforeTs:C(r,"before")},...r.failed===!0&&{success:"false"}});if(n)g(o);else if(k(o.data,[{header:"WHEN",get:(c)=>x(c.createdAt)},{header:"EVENT",get:(c)=>c.eventName},{header:"OK",get:(c)=>c.success?"yes":"no"},{header:"STATUS",get:(c)=>String(c.responseStatus??"")},{header:"TRY",get:(c)=>String(c.attempt??"")},{header:"ERROR",get:(c)=>c.error??""}]),o.nextCursor)process.stdout.write(`More: --before ${o.nextCursor}
|
|
189
|
-
`);return}case"rotate":{let s=I(e[0],"vcity webhooks rotate <id> [--yes]","webhook id");if(!await B(`Rotate the signing secret of ${s}? The old secret stops working immediately.`,{yes:r.yes===!0,json:n}))return;let o=await a.webhooks.rotateSecret(i,s);if(n)g(o);else
|
|
189
|
+
`);return}case"rotate":{let s=I(e[0],"vcity webhooks rotate <id> [--yes]","webhook id");if(!await B(`Rotate the signing secret of ${s}? The old secret stops working immediately.`,{yes:r.yes===!0,json:n}))return;let o=await a.webhooks.rotateSecret(i,s);if(n)g(o);else To(o.signingSecret);return}default:throw new y(`usage: ${oc}`)}}function V(t){let e=P(m(t,"data"));if(e===void 0)return{};if(typeof e!=="object"||e===null||Array.isArray(e))throw new y("--data must be a JSON object");return{...e}}function it(t,e){let r=m(t,e);if(r===void 0)return;let n=Number(r);if(r.trim()===""||!Number.isFinite(n))throw new y(`--${e} must be a number (got: ${r})`);return n}function U(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}var Ze=["run","runs","run-get","cancel-run","proposals","approve","reject"];async function Co(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"run":{let s=I(e[0],"vcity agents run <agentId>","agent id"),o=await a.agents.run(i,s);if(n)g(o);else process.stdout.write(`Queued a run of ${s}${o.run?.id?` (${T(o.run.id)})`:""}. The reply lands in conversation ${T(o.roomId??"?")}.
|
|
190
190
|
`);return}case"runs":{let o=(await a.agents.listRuns(i,U({agentId:m(r,"agent"),limit:C(r,"limit",{min:1,max:200})}))).data??[];if(n)g({org:i,runs:o});else k(o,[{header:"ID",get:(c)=>c.id},{header:"AGENT",get:(c)=>c.agentId??""},{header:"STATUS",get:(c)=>c.status??""},{header:"TRIGGER",get:(c)=>c.trigger??""},{header:"STARTED",get:(c)=>c.startedAt?x(c.startedAt):""},{header:"ERROR",get:(c)=>c.error??""}]);return}case"run-get":{let s=I(e[0],"vcity agents run-get <runId>","run id"),o=await a.agents.getRun(i,s);if(n)g(o);else j(o);return}case"cancel-run":{let s=I(e[0],"vcity agents cancel-run <runId>","run id"),o=await a.agents.cancelRun(i,s);if(n)g(o);else process.stdout.write(`Cancelled run ${s}.
|
|
191
191
|
`);return}case"proposals":{let o=(await a.agents.listProposals(i,U({status:A(r,"status",["pending","approved","rejected"]),agentId:m(r,"agent"),limit:C(r,"limit",{min:1,max:200})}))).data??[];if(n)g({org:i,proposals:o});else k(o,[{header:"ID",get:(c)=>c.id},{header:"AGENT",get:(c)=>c.agentId??""},{header:"KIND",get:(c)=>c.kind??""},{header:"CONCEPT",get:(c)=>c.concept??""},{header:"STATUS",get:(c)=>c.status??""},{header:"CREATED",get:(c)=>c.createdAt?x(c.createdAt):""}]);return}case"approve":{let s=I(e[0],"vcity agents approve <proposalId> [--confirm-destructive] [--notify-customer]","proposal id");if(!await B(`Approve proposal ${s}? Its change is applied to the store.`,{yes:r.yes===!0,json:n}))return;let o=await a.agents.approveProposal(i,s,U({confirmDestructive:r["confirm-destructive"]===!0?!0:void 0,notifyCustomer:r["notify-customer"]===!0?!0:void 0}));if(n)g(o);else process.stdout.write(`Approved proposal ${s}.
|
|
192
192
|
`);return}case"reject":{let s=I(e[0],"vcity agents reject <proposalId>","proposal id"),o=await a.agents.rejectProposal(i,s);if(n)g(o);else process.stdout.write(`Rejected proposal ${s}.
|
|
193
|
-
`);return}default:throw new y(`usage: vcity agents list|get|${Ze.join("|")}`)}}var
|
|
194
|
-
`);return}case"update":{let o=s("vcity campaigns update <id> [--name …] [--subject …] [--data <json>]"),c=
|
|
193
|
+
`);return}default:throw new y(`usage: vcity agents list|get|${Ze.join("|")}`)}}var cc="vcity campaigns list|get|create|update|delete|activate|pause|stats|contacts|add-contacts|remove-contact",dc=["event","product","room","custom"],uc=["invitation-link","pre-register","product-launch","product-reminder","scene-invitation","broadcast"],gc=["event-cadence","scheduled","immediate"];function So(t){return{...V(t),...U({name:m(t,"name"),resourceType:A(t,"resource-type",dc),resourceId:m(t,"resource"),mode:A(t,"mode",uc),sendType:A(t,"send",gc),scheduledAt:M(t,"at"),emailSubject:m(t,"subject"),emailBody:m(t,"body")})}}function lc(t){let e=V(t),r=q(t,"emails");if(r)e.contacts=[...e.contacts??[],...r.map((n)=>({email:n}))];return e}async function Oo(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l(),s=(o)=>I(e[0],o,"campaign id");switch(t){case"list":{let o=await a.campaigns.list(i,U({status:m(r,"status"),search:m(r,"search"),limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),c=o.data??[];if(n)g({org:i,campaigns:c,total:o.total,skip:o.skip,limit:o.limit,hasMore:o.hasMore});else k(c,[{header:"ID",get:(u)=>u.id},{header:"NAME",get:(u)=>u.name??""},{header:"STATUS",get:(u)=>u.status??""},{header:"MODE",get:(u)=>u.mode??""},{header:"SEND",get:(u)=>u.sendType??""}]);return}case"get":case"stats":{let o=s(`vcity campaigns ${t} <id>`),c=t==="get"?await a.campaigns.get(i,o):await a.campaigns.stats(i,o);if(n)g(c);else j(c);return}case"create":{let o=So(r);for(let u of["name","resourceType","mode","emailSubject","emailBody"])if(o[u]===void 0)throw new y("usage: vcity campaigns create --name <s> --resource-type event|product|room|custom [--resource <id>] --mode <mode> --subject <s> --body <html> [--send immediate|scheduled|event-cadence] [--at <date>] [--data <json>]");let c=await a.campaigns.create(i,o);if(n)g(c);else process.stdout.write(`Created campaign ${T(c.id)} (draft). Add recipients with \`vcity campaigns add-contacts\`.
|
|
194
|
+
`);return}case"update":{let o=s("vcity campaigns update <id> [--name …] [--subject …] [--data <json>]"),c=So(r);if(Object.keys(c).length===0)throw new y("campaigns update: nothing to change");let u=await a.campaigns.update(i,o,c);if(n)g(u);else process.stdout.write(`Updated campaign ${o}.
|
|
195
195
|
`);return}case"delete":{let o=s("vcity campaigns delete <id> [--yes]");if(!await B(`Delete campaign ${o} in ${i}?`,{yes:r.yes===!0,json:n}))return;let c=await a.campaigns.delete(i,o);if(n)g(c);else process.stdout.write(`Deleted campaign ${o}.
|
|
196
196
|
`);return}case"activate":case"pause":{let o=s(`vcity campaigns ${t} <id>`);if(t==="activate"&&!await B(`Activate campaign ${o}? Emails start going out to its recipients.`,{yes:r.yes===!0,json:n}))return;let c=t==="activate"?await a.campaigns.activate(i,o):await a.campaigns.pause(i,o);if(n)g(c);else process.stdout.write(`${t==="activate"?"Activated":"Paused"} campaign ${o}.
|
|
197
|
-
`);return}case"contacts":{let o=s("vcity campaigns contacts <id> [--limit n] [--skip n]"),c=await a.campaigns.listContacts(i,o,U({limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),u=c.data??[];if(n)g({org:i,campaign:o,contacts:u,total:c.total,hasMore:c.hasMore});else k(u,[{header:"ID",get:(
|
|
198
|
-
`);return}default:throw new y(`usage: ${
|
|
199
|
-
`);return}case"update":{let s=I(e[0],"vcity coupons update <id> [--percent …] [--until …] [--data <json>]","coupon id"),o=
|
|
197
|
+
`);return}case"contacts":{let o=s("vcity campaigns contacts <id> [--limit n] [--skip n]"),c=await a.campaigns.listContacts(i,o,U({limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),u=c.data??[];if(n)g({org:i,campaign:o,contacts:u,total:c.total,hasMore:c.hasMore});else k(u,[{header:"ID",get:(p)=>p.id},{header:"EMAIL",get:(p)=>p.email??""},{header:"NAME",get:(p)=>p.name??""},{header:"STATUS",get:(p)=>p.status??""}]);return}case"add-contacts":{let o=s(`vcity campaigns add-contacts <id> --emails a@b.com,c@d.com | --data '{"contacts":[…]}'`),c=lc(r);if(!Array.isArray(c.contacts)||c.contacts.length===0)throw new y("campaigns add-contacts: pass --emails or --data with contacts");let u=await a.campaigns.addContacts(i,o,c);if(n)g(u);else j(u);return}case"remove-contact":{let o=s("vcity campaigns remove-contact <id> <contactId>"),c=I(e[1],"vcity campaigns remove-contact <id> <contactId>","contact id"),u=await a.campaigns.removeContact(i,o,c);if(n)g(u);else process.stdout.write(`Removed ${c} from campaign ${o}.
|
|
198
|
+
`);return}default:throw new y(`usage: ${cc}`)}}var pc="vcity coupons list|get|create|update|activate|deactivate|validate",mc=["percentage","fixed","free-shipping","bxgy"];function xo(t){let e=it(t,"percent"),r=it(t,"amount"),n=A(t,"type",mc);if(!n&&e!==void 0)n="percentage";if(!n&&r!==void 0)n="fixed";return{...V(t),...U({code:m(t,"code"),discountType:n,percentageOff:e,fixedAmountOff:r,currencyCode:A(t,"currency",["USD","COP"]),maxDiscountAmount:it(t,"max-discount"),minOrderAmount:it(t,"min-order"),maxTotalUses:C(t,"max-uses",{min:1}),maxUsesPerUser:C(t,"max-uses-per-user",{min:1}),startDate:M(t,"from"),endDate:M(t,"until"),productIds:q(t,"products"),collectionIds:q(t,"collections")})}}function fc(t){if(t.discountType==="percentage")return`${t.percentageOff??"?"}%`;if(t.discountType==="fixed")return`${t.fixedAmountOff??"?"} ${t.currencyCode??""}`.trim();return t.discountType??""}async function Ao(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"list":{let s=await a.coupons.list(i,U({active:r.active===!0?"true":void 0,limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),o=s.data??[];if(n)g({org:i,coupons:o,total:s.total,skip:s.skip,limit:s.limit,hasMore:s.hasMore});else k(o,[{header:"ID",get:(c)=>c.id},{header:"CODE",get:(c)=>c.code??""},{header:"DISCOUNT",get:fc},{header:"ACTIVE",get:(c)=>c.active?"yes":"no"},{header:"ENDS",get:(c)=>c.endDate?x(c.endDate):""}]);return}case"get":{let s=I(e[0],"vcity coupons get <id>","coupon id"),o=await a.coupons.get(i,s);if(n)g(o);else j(o);return}case"create":{let s=xo(r);if(typeof s.code!=="string"||typeof s.discountType!=="string")throw new y("usage: vcity coupons create --code <CODE> (--percent <n> | --amount <n> --currency USD|COP | --type free-shipping) [--until <date>] [--max-uses <n>] [--min-order <n>] [--data <json>]");let o=await a.coupons.create(i,s);if(n)g(o);else process.stdout.write(`Created coupon ${T(o.code??"")} (${T(o.id)}).
|
|
199
|
+
`);return}case"update":{let s=I(e[0],"vcity coupons update <id> [--percent …] [--until …] [--data <json>]","coupon id"),o=xo(r);if(Object.keys(o).length===0)throw new y("coupons update: nothing to change");let c=await a.coupons.update(i,s,o);if(n)g(c);else process.stdout.write(`Updated coupon ${s}.
|
|
200
200
|
`);return}case"activate":case"deactivate":{let s=I(e[0],`vcity coupons ${t} <id>`,"coupon id"),o=t==="activate"?await a.coupons.activate(i,s):await a.coupons.deactivate(i,s);if(n)g(o);else process.stdout.write(`${t==="activate"?"Activated":"Deactivated"} coupon ${s}.
|
|
201
|
-
`);return}case"validate":{let s=I(e[0]??m(r,"code"),`vcity coupons validate <CODE> [--data '{"cart":{…}}']`,"coupon code"),o=await a.coupons.validate(i,{...V(r),code:s});if(n)g(o);else j(o);return}default:throw new y(`usage: ${
|
|
201
|
+
`);return}case"validate":{let s=I(e[0]??m(r,"code"),`vcity coupons validate <CODE> [--data '{"cart":{…}}']`,"coupon code"),o=await a.coupons.validate(i,{...V(r),code:s});if(n)g(o);else j(o);return}default:throw new y(`usage: ${pc}`)}}var at=(t)=>t===void 0||t===null?"":String(t),Po="vcity dropshipping connections | products | import --connection <id> --products a,b (--markup-percent <n> | --markup-fixed <n> [--currency COP]) | fulfillments <orderId> | retry <fulfillmentId>";function _t(t,e,r){if(f(!!t.json)==="json"||!r)g(e);else r()}async function $o(t,e,r){let n=h(m(r,"org")),i=l().dropshipping;switch(t){case"connections":{let a=await i.connections(n);return _t(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>at(s.id)},{header:"PROVIDER",get:(s)=>at(s.provider)}]))}case"products":{let a=await i.products(n,{...C(r,"limit",{min:1,max:100})!==void 0&&{limit:C(r,"limit")}});return _t(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>at(s.id)},{header:"NAME",get:(s)=>at(s.name)},{header:"PRICE",get:(s)=>`${at(s.price)} ${at(s.currencyCode)}`},{header:"SOURCE",get:(s)=>at(s.dropshippingSource?.externalProductId)}]))}case"import":{let a=m(r,"connection"),s=q(r,"products")??[],o=it(r,"markup-percent"),c=it(r,"markup-fixed");if(!a||s.length===0||o===void 0&&c===void 0)throw new y(`usage: ${Po}`);let u=o!==void 0?{type:"percentage",value:o}:{type:"fixed",value:c,...m(r,"currency")!==void 0&&{currencyCode:m(r,"currency")}};return _t(r,await i.import(n,{connectionId:a,externalProductIds:s,markup:u}))}case"fulfillments":{let a=I(e[0],"vcity dropshipping fulfillments <orderId>","order id"),s=await i.fulfillments(n,a);return _t(r,s,()=>k(s.data??[],[{header:"ID",get:(o)=>at(o.id)},{header:"STATUS",get:(o)=>at(o.status)},{header:"TRACKING",get:(o)=>at(o.trackingNumber)},{header:"SUPPLIER ORDER",get:(o)=>at(o.externalOrderId)}]))}case"retry":{let a=I(e[0],"vcity dropshipping retry <fulfillmentId>","fulfillment id");return _t(r,await i.retryFulfillment(n,a))}default:throw new y(`usage: ${Po}`)}}var tr=(t)=>t===void 0||t===null?"":String(t),yc="vcity pos session | open --cash <n> --currency USD|COP | close <sessionId> --cash <n> [--notes <s>] | summary <sessionId> | sales [--session <id>] [--method cash|epayco] [--from <date>] [--to <date>] | sale <saleId> | sell --data <json|@file> | favorites [--set a,b]";function vt(t,e,r){if(f(!!t.json)==="json"||!r)g(e);else r()}async function Do(t,e,r){let n=h(m(r,"org")),i=l().pos;switch(t){case"session":{let a=await i.activeSession(n);return vt(r,a,()=>a.session?j(a.session):process.stdout.write(`No register session is open.
|
|
202
202
|
`))}case"open":{let a=it(r,"cash"),s=A(r,"currency",["USD","COP"]);if(a===void 0||!s)throw new y("usage: vcity pos open --cash <n> --currency USD|COP");return vt(r,await i.openSession(n,{openingCash:a,currencyCode:s}))}case"close":{let a=I(e[0],"vcity pos close <sessionId> --cash <n>","session id"),s=it(r,"cash");if(s===void 0)throw new y("usage: vcity pos close <sessionId> --cash <n> [--notes <s>]");let o=await i.closeSession(n,a,U({closingCash:s,notes:m(r,"notes")}));return vt(r,o,()=>j({status:o.status,expectedCash:o.expectedCash,closingCash:o.closingCash,discrepancy:o.discrepancy}))}case"summary":{let a=I(e[0],"vcity pos summary <sessionId>","session id"),s=await i.sessionSummary(n,a);return vt(r,s,()=>j(s))}case"sales":{let a=await i.sales(n,U({sessionId:m(r,"session"),paymentMethod:A(r,"method",["cash","epayco"]),startDate:M(r,"from"),endDate:M(r,"to"),limit:C(r,"limit",{min:1,max:100}),skip:C(r,"skip")}));return vt(r,a,()=>k(a.data??[],[{header:"RECEIPT",get:(s)=>tr(s.receiptNumber)},{header:"TOTAL",get:(s)=>`${tr(s.total)} ${tr(s.currencyCode)}`},{header:"WHEN",get:(s)=>typeof s.createdAt==="number"?x(s.createdAt):""},{header:"ID",get:(s)=>tr(s.id)}]))}case"sale":{let a=I(e[0],"vcity pos sale <saleId>","sale id");return vt(r,await i.sale(n,a))}case"sell":{let a=V(r);if(!a.sessionId||!a.lineItems)throw new y(`usage: vcity pos sell --data '{"sessionId":…,"lineItems":[…],"payments":[…]}' [--idempotency-key <k>]`);return vt(r,await i.createSale(n,a,m(r,"idempotency-key")))}case"favorites":{let a=m(r,"set"),s=a!==void 0?await i.setFavorites(n,a.split(",").map((o)=>o.trim()).filter(Boolean)):await i.favorites(n);return vt(r,s,()=>process.stdout.write(`${(s.productIds??[]).join(`
|
|
203
203
|
`)}
|
|
204
|
-
`))}default:throw new y(`usage: ${
|
|
204
|
+
`))}default:throw new y(`usage: ${yc}`)}}var Gt=(t)=>t===void 0||t===null?"":String(t);function J(t,e,r){if(f(!!t.json)==="json"||!r)g(e);else r()}async function No(t,e,r){let n=h(m(r,"org")),i=l().configurators;switch(t){case"list":{let a=await i.list(n);return J(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>Gt(s.id)},{header:"NAME",get:(s)=>Gt(s.name)},{header:"VERSION",get:(s)=>Gt(s.version)}]))}case"seeds":{let a=await i.seeds(n);return J(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>Gt(s.id)},{header:"NAME",get:(s)=>Gt(s.name)}]))}case"get":{let a=I(e[0],"vcity configurators get <id>","configurator id");return J(r,await i.get(n,a))}case"create":{let a=m(r,"seed"),s=r.data!==void 0?V(r):void 0;if(!a&&!s)throw new y("usage: vcity configurators create --seed <seedId> | --data <json|@file|->");return J(r,await i.create(n,a?{seedId:a}:{definition:s}))}case"update":{let a=I(e[0],"vcity configurators update <id> --data <patch json> [--bump-version]","configurator id");return J(r,await i.update(n,a,{patch:V(r),...r["bump-version"]===!0&&{bumpVersion:!0}}))}case"delete":{let a=I(e[0],"vcity configurators delete <id>","configurator id");return J(r,await i.delete(n,a))}default:throw new y("usage: vcity configurators list|seeds|get|create|update|delete")}}async function Fo(t,e,r){let n=l().chatRooms,i="usage: vcity rooms show|messages|send|search|read <roomId> … (user login only)",a=I(e[0],"usage: vcity rooms show|messages|send|search|read <roomId> … (user login only)","room id");switch(t){case"show":{let s=await n.get(a);return J(r,s,()=>j(s))}case"messages":{let s=await n.messages(a,U({limit:C(r,"limit",{min:1,max:200}),around:m(r,"around")}));return J(r,s,()=>process.stdout.write(`${wt(s.data)}
|
|
205
205
|
`))}case"send":{let s=m(r,"message");if(!s)throw new y("usage: vcity rooms send <roomId> --message <text> [--reply-to <messageId>] [--as-org]");return J(r,await n.send(a,U({content:s,replyToId:m(r,"reply-to"),asOrg:r["as-org"]===!0?!0:void 0})))}case"search":{let s=m(r,"query")??e.slice(1).join(" ");if(!s)throw new y("usage: vcity rooms search <roomId> --query <text>");let o=await n.search(a,s);return J(r,o,()=>process.stdout.write(`${wt(o.data)}
|
|
206
|
-
`))}case"read":return J(r,await n.markRead(a));default:throw new y("usage: vcity rooms show|messages|send|search|read <roomId> … (user login only)")}}async function
|
|
207
|
-
`)}var
|
|
208
|
-
${
|
|
209
|
-
`)}async function
|
|
210
|
-
`),
|
|
211
|
-
`);return}case"rotate":{let s=I(e[0],"vcity keys rotate <id> [--yes]","key id");if(!await B(`Rotate API key ${s}? A new token is issued; the old one keeps working for a grace period.`,{yes:r.yes===!0,json:n}))return;let o=await a.apiKeys.rotate(i,s);if(n)g(o);else{if(o.newId)process.stdout.write(`New key ${
|
|
212
|
-
`);if(
|
|
213
|
-
`)}return}default:throw new y(`usage: ${
|
|
206
|
+
`))}case"read":return J(r,await n.markRead(a));default:throw new y("usage: vcity rooms show|messages|send|search|read <roomId> … (user login only)")}}async function Uo(t,e,r){let n=h(m(r,"org")),i=l().surveys;if(t==="create"){let s=m(r,"title");if(!s)throw new y("usage: vcity surveys create --title <s> [--data <json with questions…>]");return J(r,await i.create(n,{questions:[],...V(r),title:s}))}let a=I(e[0],`vcity surveys ${t} <surveyId>`,"survey id");if(t==="update")return J(r,await i.update(n,a,{...V(r),...U({title:m(r,"title")})}));if(t==="publish")return J(r,await i.publish(n,a));if(t==="close")return J(r,await i.close(n,a));if(t==="delete")return J(r,await i.delete(n,a));throw new y("usage: vcity surveys create|update|publish|close|delete")}async function Bo(t,e,r){let n=l().comments,i=I(e[0],`vcity comments ${t} <commentId>`,"comment id");if(t==="edit"){let a=m(r,"message");if(!a)throw new y("usage: vcity comments edit <commentId> --message <text>");return J(r,await n.edit(i,a))}if(t==="delete")return J(r,await n.delete(i));if(t==="pin")return J(r,await n.pin(i));if(t==="unpin")return J(r,await n.unpin(i));throw new y("usage: vcity comments edit|delete|pin|unpin <commentId>")}var H=(t)=>t===void 0||t===null?"":String(t),Mo=(t)=>typeof t==="number"?x(t):"";function Y(t,e,r){if(f(!!t.json)==="json"||!r)g(e);else r()}var Vt=(t)=>U({limit:C(t,"limit",{min:1,max:200}),skip:C(t,"skip")});async function Lo(t,e,r){let n=h(m(r,"org")),i=l();switch(t){case"config":return Y(r,await i.newsletter.getConfig(n));case"subscribers":{let a=await i.newsletter.subscribers(n,Vt(r)),s=a.data??[];return Y(r,a,()=>k(s,[{header:"EMAIL",get:(o)=>H(o.email)},{header:"STATUS",get:(o)=>H(o.status)},{header:"SOURCE",get:(o)=>H(o.source)},{header:"SINCE",get:(o)=>Mo(o.createdAt)}]))}case"stats":{let a=await i.newsletter.stats(n,U({days:C(r,"days",{min:1,max:365})}));return Y(r,a,()=>j(a))}default:throw new y("usage: vcity newsletter config|subscribers|stats [--org <slug>] [--json]")}}async function qo(t,e,r){let n=h(m(r,"org")),i=l();switch(t){case"list":{let a=await i.surveys.list(n,{...Vt(r),...U({status:A(r,"status",["draft","active","closed"])})});return Y(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>H(s.id)},{header:"TITLE",get:(s)=>H(s.title)},{header:"STATUS",get:(s)=>H(s.status)},{header:"RESPONSES",get:(s)=>H(s.responseCount)}]))}case"get":{let a=I(e[0],"vcity surveys get <surveyId>","survey id"),s=await i.surveys.get(n,a);return Y(r,s,()=>j(s))}case"responses":{let a=I(e[0],"vcity surveys responses <surveyId>","survey id");return Y(r,await i.surveys.responses(n,a,Vt(r)))}case"create":case"update":case"publish":case"close":case"delete":return Uo(t,e,r);default:throw new y("usage: vcity surveys list|get|responses|create|update|publish|close|delete [--status draft|active|closed] [--json]")}}async function _o(t,e,r){let n=l();switch(t){case"list":{let i=I(e[0],"vcity comments list <table:id>","target"),a=await n.comments.list({target:i,...Vt(r)});return Y(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>H(s.id)},{header:"AUTHOR",get:(s)=>H(s.author?.name)},{header:"WHEN",get:(s)=>Mo(s.createdAt)},{header:"COMMENT",get:(s)=>H(s.content).slice(0,80)}]))}case"add":{let i=I(e[0],"vcity comments add <table:id> --message <text>","target"),a=m(r,"message");if(!a)throw new y("usage: vcity comments add <table:id> --message <text> [--parent <commentId>]");return Y(r,await n.comments.create(U({target:i,content:a,parent:m(r,"parent")})))}case"reactions":{let i=I(e[0],"vcity comments reactions <table:id>","target");return Y(r,await n.comments.reactions(i))}case"react":{let i=I(e[0],"vcity comments react <table:id> <emoji> [--remove]","target"),a=I(e[1],"vcity comments react <table:id> <emoji> [--remove]","emoji");return Y(r,await n.comments.react({target:i,emoji:a,action:r.remove===!0?"remove":"add"}))}case"edit":case"delete":case"pin":case"unpin":return Bo(t,e,r);default:throw new y("usage: vcity comments list|add|reactions|react <table:id> … | edit|delete|pin|unpin <commentId> [--json] (user login only)")}}async function Go(t,e,r){let n=h(m(r,"org")),i=l();switch(t??"summary"){case"summary":{let a=await i.billing.summary(n);return Y(r,a,()=>k(a.plan?.modules??[],[{header:"MODULE",get:(s)=>H(s.module)},{header:"PLAN",get:(s)=>H(s.plan)},{header:"NEXT",get:(s)=>H(s.pendingPlan)},{header:"SUSPENDED",get:(s)=>s.suspended?"yes":""}]))}case"invoices":{let a=await i.billing.invoices(n,Vt(r));return Y(r,a,()=>k(a.data??[],[{header:"ID",get:(s)=>H(s.id)},{header:"PERIOD",get:(s)=>H(s.billingPeriod)},{header:"AMOUNT",get:(s)=>`${H(s.amount)} ${H(s.currencyCode)}`},{header:"STATUS",get:(s)=>s.voided?"void":s.processed?"paid":"open"}]))}case"usage":return Y(r,await i.billing.usage(n));case"credits":return Y(r,await i.billing.credits(n,U({limit:C(r,"limit",{min:1,max:200})})));default:throw new y("usage: vcity billing [summary|invoices|usage|credits] [--org <slug>] [--json]")}}async function Vo(t,e,r){let n=h(m(r,"org")),i=l();switch(t??"get"){case"get":{let a=await i.storefront.get(n);return Y(r,a,()=>{j({domain:a.domain?.customDomain??"(none)",status:a.domain?.status??"",error:a.domain?.error??""});let s=[...a.dnsRecords?.host??[],...a.dnsRecords?.txt??[]];if(s.length)k(s,[{header:"TYPE",get:(o)=>H(o.type)},{header:"NAME",get:(o)=>H(o.name)},{header:"VALUE",get:(o)=>H(o.value)}])})}case"domain":{let a=I(e[0],"vcity storefront domain <host>","domain");return Y(r,await i.storefront.setDomain(n,a))}case"verify":return Y(r,await i.storefront.verifyDomain(n));case"remove-domain":return Y(r,await i.storefront.removeDomain(n));case"redirects":return Y(r,await i.storefront.redirects(n));default:throw new y("usage: vcity storefront [get|domain <host>|verify|remove-domain|redirects] [--org <slug>] [--json]")}}var bt=["draft","stage","publish","discard-draft","visibility"],hc={products:"product",events:"event",blogs:"blog post"};async function er(t,e,r,n){let i=f(!!n.json)==="json",a=h(m(n,"org")),s=l().drafts,o=hc[t],c=I(r[0],`vcity ${t} ${e} <id>`,`${o} id`),u;switch(e){case"draft":u=t==="products"?await s.getProductDraft(a,c):t==="events"?await s.getEventDraft(a,c):await s.getBlogDraft(a,c);break;case"stage":{let p=V(n);if(Object.keys(p).length===0)throw new y(`usage: vcity ${t} stage <id> --data <json|@file|->`);u=t==="products"?await s.stageProductDraft(a,c,p):t==="events"?await s.stageEventDraft(a,c,p):await s.stageBlogDraft(a,c,p);break}case"publish":u=t==="products"?await s.publishProduct(a,c):t==="events"?await s.publishEvent(a,c):await s.publishBlog(a,c);break;case"discard-draft":if(!await B(`Discard the unpublished changes of ${o} ${c}?`,{yes:n.yes===!0,json:i}))return;u=t==="products"?await s.discardProductDraft(a,c):t==="events"?await s.discardEventDraft(a,c):await s.discardBlogDraft(a,c);break;case"visibility":{if(t==="blogs")throw new y("blogs have no visibility switch; publish or discard the draft instead");let p=r[1];if(p!=="public"&&p!=="hidden")throw new y(`usage: vcity ${t} visibility <id> public|hidden`);u=t==="products"?await s.setProductVisibility(a,c,p):await s.setEventVisibility(a,c,p);break}default:throw new y(`usage: vcity ${t} ${bt.join("|")} <id>`)}if(i)g(u);else if(e==="draft")j(u??{});else process.stdout.write(`${e==="publish"?"Published":e==="discard-draft"?"Discarded the draft of":e==="stage"?"Staged changes to":"Updated"} ${o} ${c}.
|
|
207
|
+
`)}var wc="vcity keys list|create|revoke|rotate (store API keys; needs a signed-in admin)";function Jo(t){process.stdout.write(`API key (shown once — store it now):
|
|
208
|
+
${T(String(t))}
|
|
209
|
+
`)}async function Ho(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"list":{let s=await a.apiKeys.list(i,U({revoked:r.revoked===!0?"true":void 0,limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),o=s.data??[];if(n)g({org:i,keys:o,total:s.total,hasMore:s.hasMore});else k(o,[{header:"ID",get:(c)=>c.id},{header:"LABEL",get:(c)=>c.label??""},{header:"SCOPES",get:(c)=>(c.scopes??[]).join(",")},{header:"LAST USED",get:(c)=>c.lastUsedAt?x(c.lastUsedAt):""},{header:"REVOKED",get:(c)=>c.revokedAt?x(c.revokedAt):""},{header:"EXPIRES",get:(c)=>c.expiresAt?x(c.expiresAt):""}]);return}case"create":{let s=m(r,"label"),o=q(r,"scopes")??q(r,"scope");if(!s||!o||o.length===0)throw new y("usage: vcity keys create --label <name> --scopes products:read,orders:read");let c=await a.apiKeys.create(i,{label:s,scopes:o});if(n)g(c);else process.stdout.write(`Created API key ${T(c.id)}.
|
|
210
|
+
`),Jo(c.token);return}case"revoke":{let s=I(e[0],"vcity keys revoke <id> [--yes]","key id");if(!await B(`Revoke API key ${s} in ${i}? Integrations using it stop working.`,{yes:r.yes===!0,json:n}))return;let o=await a.apiKeys.revoke(i,s);if(n)g(o);else process.stdout.write(`Revoked API key ${s}.
|
|
211
|
+
`);return}case"rotate":{let s=I(e[0],"vcity keys rotate <id> [--yes]","key id");if(!await B(`Rotate API key ${s}? A new token is issued; the old one keeps working for a grace period.`,{yes:r.yes===!0,json:n}))return;let o=await a.apiKeys.rotate(i,s);if(n)g(o);else{if(o.newId)process.stdout.write(`New key ${T(o.newId)}.
|
|
212
|
+
`);if(Jo(o.token),o.oldExpiresAt)process.stdout.write(`The old token stops working at ${x(o.oldExpiresAt)}.
|
|
213
|
+
`)}return}default:throw new y(`usage: ${wc}`)}}var vc=["admin","member"];async function Yo(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().orgs;switch(t){case"add":{let s=I(e[0],"vcity org members add <email|uid> [--role admin|member]","email or user id"),o=A(r,"role",vc),c=await a.addMember(i,{userIdOrEmail:s,...o&&{role:o}});if(n)g(c);else if(c.invited)process.stdout.write(`Invited ${s} to ${i}.
|
|
214
214
|
`);else process.stdout.write(`Added ${s} to ${i}.
|
|
215
215
|
`);return}case"role":{let o=I(e[0],"vcity org members role <uid> admin|member","user id"),c=e[1];if(c!=="admin"&&c!=="member")throw new y("usage: vcity org members role <uid> admin|member");let u=await a.setMemberRole(i,o,c);if(n)g(u);else process.stdout.write(`${o} is now ${c} of ${i}.
|
|
216
216
|
`);return}case"remove":{let s=I(e[0],"vcity org members remove <uid> [--yes]","user id");if(!await B(`Remove ${s} from ${i}?`,{yes:r.yes===!0,json:n}))return;let o=await a.removeMember(i,s);if(n)g(o);else process.stdout.write(`Removed ${s} from ${i}.
|
|
217
|
-
`);return}default:throw new y("usage: vcity org members list|add|role|remove")}}async function
|
|
218
|
-
`);return}case"resend":{let s=I(e[0],"vcity org invitations resend <id>","invitation id"),o=await a.resendInvitation(i,s);if(n)g(o);else j({resent:s,...o});return}default:throw new y("usage: vcity org invitations list|revoke|resend")}}async function
|
|
219
|
-
`);return}case"breakdown":{let s=V(r),o=q(r,"products");if(o)s.lineItems=o.map((u)=>{let[
|
|
220
|
-
`);return}throw new y("usage: vcity profile [get] | set …")}var
|
|
221
|
-
`);return}case"stats":{let s=await a.support.stats(i);if(n)g(s);else j(s);return}default:throw new y(`usage: ${
|
|
222
|
-
`),process.stdout.write(`User ID: ${
|
|
223
|
-
`),process.stdout.write(`Active org: ${s.active_org?
|
|
224
|
-
`)}var
|
|
225
|
-
→ vcity ${
|
|
226
|
-
`)}function S(t){process.stderr.write(`error: ${
|
|
227
|
-
`),process.exit(2)}function
|
|
217
|
+
`);return}default:throw new y("usage: vcity org members list|add|role|remove")}}async function Qo(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l().orgs;switch(t){case"list":{let o=(await a.listInvitations(i)).data??[];if(n)g({org:i,invitations:o});else k(o,[{header:"ID",get:(c)=>c.id},{header:"EMAIL",get:(c)=>c.email??""},{header:"INVITED BY",get:(c)=>c.invitedBy??""},{header:"STATUS",get:(c)=>c.status??""},{header:"EXPIRES",get:(c)=>c.expiresAt?x(c.expiresAt):""}]);return}case"revoke":{let s=I(e[0],"vcity org invitations revoke <id> [--yes]","invitation id");if(!await B(`Revoke invitation ${s}?`,{yes:r.yes===!0,json:n}))return;let o=await a.revokeInvitation(i,s);if(n)g(o);else process.stdout.write(`Revoked invitation ${s}.
|
|
218
|
+
`);return}case"resend":{let s=I(e[0],"vcity org invitations resend <id>","invitation id"),o=await a.resendInvitation(i,s);if(n)g(o);else j({resent:s,...o});return}default:throw new y("usage: vcity org invitations list|revoke|resend")}}async function Wo(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"comments":{let o=I(e[0],"vcity orders comments <orderId> <lineItemId>","order id"),c=I(e[1],"vcity orders comments <orderId> <lineItemId>","line item id"),p=(await a.orders.listLineItemComments(i,o,c)).data??[];if(n)g({org:i,orderId:o,lineItemId:c,comments:p});else k(p,[{header:"ID",get:(w)=>w.id},{header:"WHEN",get:(w)=>w.createdAt?x(w.createdAt):""},{header:"BY",get:(w)=>w.uid??""},{header:"COMMENT",get:(w)=>w.content??""}]);return}case"comment":{let o=I(e[0],'vcity orders comment <orderId> <lineItemId> --text "…" [--parent <commentId>]',"order id"),c=I(e[1],'vcity orders comment <orderId> <lineItemId> --text "…" [--parent <commentId>]',"line item id"),u=G(m(r,"text")??e.slice(2).join(" "),'vcity orders comment <orderId> <lineItemId> --text "…" [--parent <commentId>]'),p=m(r,"parent"),w=await a.orders.commentLineItem(i,o,c,{content:u,...p&&{parent:p}});if(n)g(w);else process.stdout.write(`Comment added.
|
|
219
|
+
`);return}case"breakdown":{let s=V(r),o=q(r,"products");if(o)s.lineItems=o.map((u)=>{let[p,w="1"]=u.split(":"),v=Number(w);if(!p||!Number.isFinite(v)||v<=0)throw new y(`--products expects id:qty pairs (got: ${u})`);return{type:"product",targetId:p,quantity:v}});if(!Array.isArray(s.lineItems)||s.lineItems.length===0)throw new y(`usage: vcity orders breakdown --products <id:qty,…> | --data '{"lineItems":[…],"shippingAddress":{…}}'`);let c=await a.orders.breakdown(i,s);if(n)g(c);else j(c);return}default:throw new y("usage: vcity orders comments|comment|breakdown")}}var bc=["en","de","el","es","fr","it","pt","ru","zh"];async function zo(t,e){let r=f(!!e.json)==="json",n=l().me;if(t===void 0||t==="get"){let i=await n.get();if(r)g(i.user??i);else j(i.user??i);return}if(t==="set"){let i=m(e,"company"),a={...V(e),...U({firstName:m(e,"first-name"),lastName:m(e,"last-name"),company:i===""?null:i,lang:A(e,"lang",bc)})};if(Object.keys(a).length===0)throw new y("usage: vcity profile set [--first-name <s>] [--last-name <s>] [--company <s>] [--lang en|es|…]");let s=await n.update(a);if(r)g(s.user??s);else process.stdout.write(`Profile updated.
|
|
220
|
+
`);return}throw new y("usage: vcity profile [get] | set …")}var kc="vcity support tickets|get|update|stats",Ko=["open","in_progress","waiting_on_customer","resolved","closed"],Xo=["low","medium","high","urgent"];async function Zo(t,e,r){let n=f(!!r.json)==="json",i=h(m(r,"org")),a=l();switch(t){case"tickets":case"list":{let s=await a.support.listTickets(i,U({status:A(r,"status",Ko),priority:A(r,"priority",Xo),category:m(r,"category"),limit:C(r,"limit",{min:1,max:200}),skip:C(r,"skip")})),o=s.data??[];if(n)g({org:i,tickets:o,total:s.total,hasMore:s.hasMore});else k(o,[{header:"ID",get:(c)=>c.id},{header:"SUBJECT",get:(c)=>c.subject??""},{header:"STATUS",get:(c)=>c.status??""},{header:"PRIORITY",get:(c)=>c.priority??""},{header:"ASSIGNED",get:(c)=>c.assignedTo??""},{header:"UPDATED",get:(c)=>c.updatedAt?x(c.updatedAt):""}]);return}case"get":{let s=I(e[0],"vcity support get <ticketId>","ticket id"),o=await a.support.getTicket(i,s);if(n)g(o);else j(o);return}case"update":{let s=I(e[0],"vcity support update <ticketId> [--status …] [--priority …] [--assign <uid>] [--category <s>] [--tags a,b]","ticket id"),o={...V(r),...U({status:A(r,"status",Ko),priority:A(r,"priority",Xo),assignedTo:m(r,"assign"),category:m(r,"category"),tags:q(r,"tags")})};if(Object.keys(o).length===0)throw new y("support update: nothing to change");let c=await a.support.updateTicket(i,s,o);if(n)g(c);else process.stdout.write(`Updated ticket ${s}.
|
|
221
|
+
`);return}case"stats":{let s=await a.support.stats(i);if(n)g(s);else j(s);return}default:throw new y(`usage: ${kc}`)}}function Ic(t){if(t&&typeof t==="object"&&"user"in t){let e=t;return{user:e.user,orgs:e.orgs??[]}}throw Error("Logged-in token is an API key, not a CLI user token. `vcity whoami` is only valid for CLI sessions.")}async function ti(t={}){let e=f(t.json),n=await l().me.get(),{user:i,orgs:a}=Ic(n),s=Ct();if(e==="json"){g({user:i,orgs:a,active_org:s.active_org??null});return}let o=T(i.email??i.name??i.id);process.stdout.write(`User: ${o}
|
|
222
|
+
`),process.stdout.write(`User ID: ${T(i.id)}
|
|
223
|
+
`),process.stdout.write(`Active org: ${s.active_org?T(s.active_org):"(none — run `vcity org use <slug>`)"}
|
|
224
|
+
`)}var jc=new Set(["json","yes","check","no-browser","disabled","dry-run","all","failed","unassign","unread","all-stores","no-overlays","show-names","hide-names","force","all-day","block","recurring"]);function ei(t){let e=[],r={};for(let n=0;n<t.length;n++){let i=t[n];if(i==="--"){e.push(...t.slice(n+1));break}if(!i.startsWith("--")){e.push(i);continue}let a=i.indexOf("=");if(a>=0){r[i.slice(2,a)]=i.slice(a+1);continue}let s=i.slice(2),o=t[n+1];if(jc.has(s)||o===void 0||o.startsWith("--"))r[s]=!0;else r[s]=o,n++}return{positional:e,flags:r}}import{chmodSync as Ec,lstatSync as Tc,mkdirSync as Rc,readFileSync as Cc,rmSync as Sc}from"node:fs";import Oc from"node:path";var xc=86400000,Ac=1500,ri=64;function si(){return Oc.join(gt(),"update-check.json")}function Pc(){try{let t=Cc(si(),"utf8"),e=JSON.parse(t);if(typeof e.latest==="string"&&e.latest.length>0&&e.latest.length<=ri&&typeof e.checkedAt==="number")return e;return}catch{return}}function $c(t){try{let e=gt();Rc(e,{recursive:!0,mode:448});try{Ec(e,448)}catch{}let r=si();try{let n=Tc(r);if(n.isSymbolicLink()||n.isFile()&&n.nlink>1)Sc(r,{force:!0})}catch{}Ot(r,JSON.stringify(t,null,2),384)}catch{}}async function Dc(){let t=new AbortController,e=setTimeout(()=>t.abort(),Ac);try{let r=await fetch(`https://registry.npmjs.org/${Et}/latest`,{headers:{accept:"application/json"},signal:t.signal});if(!r.ok)return;let i=(await r.json()).version;return typeof i==="string"&&i.length>0&&i.length<=ri?i:void 0}catch{return}finally{clearTimeout(e)}}function ni(t){if(process.env.VCITY_NO_UPDATE_CHECK==="1")return!1;if(!process.stderr.isTTY)return!1;if(t.includes("--json"))return!1;if(t[0]==="update")return!1;return!0}function oi(){let t=Pc(),e=Date.now();if(t&&e-t.checkedAt<xc)return Promise.resolve(t.latest);return Dc().then((r)=>{if(r)$c({latest:r,checkedAt:e});return r??t?.latest})}function ii(t){if(!t)return;if(Er(nt,t)>=0)return;process.stderr.write(`
|
|
225
|
+
→ vcity ${T(t)} available (you have ${nt}). Run \`vcity update\` to upgrade.
|
|
226
|
+
`)}function S(t){process.stderr.write(`error: ${T(t)}
|
|
227
|
+
`),process.exit(2)}function Nc(){process.stdout.write(`vcity ${nt}
|
|
228
228
|
|
|
229
229
|
Usage:
|
|
230
230
|
vcity login [--api-base-url <url>] [--no-browser]
|
|
@@ -415,6 +415,7 @@ Usage:
|
|
|
415
415
|
vcity vault move <id> --parent <id|root> [--order <n>] · delete <id> [--yes]
|
|
416
416
|
vcity vault pull <dir> [--force] · vcity vault push <dir> [--dry-run] (the vault as a folder of Markdown files)
|
|
417
417
|
vcity desk latest | vcity desk download [--os mac|windows|linux] (Vcity Desk, the desktop admin app)
|
|
418
|
+
vcity apps list | vcity apps get <appId> [--json] (the Otherwise app catalogue)
|
|
418
419
|
vcity update [--check] [--yes] [--json]
|
|
419
420
|
|
|
420
421
|
The --data flag:
|
|
@@ -437,7 +438,7 @@ Exit codes:
|
|
|
437
438
|
0 success
|
|
438
439
|
1 runtime error (no active org, not logged in, request failed)
|
|
439
440
|
2 usage error (unknown command, bad flag, missing argument)
|
|
440
|
-
`)}function
|
|
441
|
-
`);return}let[e,r,...n]=t,i=t.slice(1),{positional:a,flags:s}=Zo(i),o=a.slice(r&&!r.startsWith("--")?1:0);switch(e){case"login":return Gs({apiBaseUrl:typeof s["api-base-url"]==="string"?s["api-base-url"]:void 0,openBrowser:s["no-browser"]===!0?!1:void 0});case"logout":return Vs();case"whoami":return Xo({json:!!s.json});case"org":{if(r==="list")return sn({json:!!s.json});if(r==="use"){let c=o[0];if(!c)S("usage: vcity org use <slug>");return nn(c)}if(r==="get"){let c=o[0];if(!c)S("usage: vcity org get <id>");return an(O(c,"org id"))}if(r==="members"){let c=z(s),u=o[0];if(u==="list")return on({org:c.org,limit:c.limit,json:c.json});if(u==="add"||u==="role"||u==="remove")return Jo(u,o.slice(1),s);S("usage: vcity org members list|add|role|remove")}if(r==="invitations")return Ho(o[0],o.slice(1),s);if(r==="settings")return un({org:Q(s,"org","--org"),json:!!s.json});if(r==="set")return gn(s);S("usage: vcity org list | use <slug> | get <id> | members list|add|role|remove | invitations | settings | set --name <s> …")}case"products":{let c=z(s);if(r==="list")return Un({org:c.org,search:b(s,"search"),limit:c.limit,skip:Nc(s.skip),visibility:b(s,"visibility"),createdFrom:b(s,"created-from"),updatedFrom:b(s,"updated-from"),collection:b(s,"collection"),sort:b(s,"sort"),order:b(s,"order"),lang:b(s,"lang"),json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity products get <id>");return Bn(O(u,"product id"),{org:c.org,lang:b(s,"lang"),json:c.json})}if(r==="create")return Mn({org:c.org,name:b(s,"name"),price:tt(s.price,"--price"),currency:b(s,"currency"),sku:b(s,"sku"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity products update <id>");return Ln(O(u,"product id"),{org:c.org,name:b(s,"name"),price:tt(s.price,"--price"),currency:b(s,"currency"),sku:b(s,"sku"),visibility:b(s,"visibility"),availability:tt(s.availability,"--availability"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity products delete <id>");return qn(O(u,"product id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(r==="import"){let u=o[0];if(!u)S("usage: vcity products import <file.csv|file.json>");return Yn(u,{org:c.org,upsertBy:A(s,"upsert-by",["sku","none"]),dryRun:s["dry-run"]===!0,report:m(s,"report"),images:m(s,"images"),json:c.json})}if(bt.includes(r??""))return er("products",r,o,s);S(`usage: vcity products list|get|create|update|delete|import|${bt.join("|")}`)}case"events":{let c=z(s);if(r==="list"){let u=c.status;if(u!==void 0&&u!=="active"&&u!=="disabled")S(`invalid --status: ${u}. Allowed: active, disabled`);return Rs({org:c.org,limit:c.limit,status:u,search:b(s,"search"),json:c.json})}if(r==="get"){let u=o[0];if(!u)S("usage: vcity events get <id>");return Cs(O(u,"event id"),{org:c.org,json:c.json})}if(r==="create")return Ss({org:c.org,name:b(s,"name"),startsAt:b(s,"starts-at"),endsAt:b(s,"ends-at"),slug:b(s,"slug"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity events update <id>");return Os(O(u,"event id"),{org:c.org,name:b(s,"name"),startsAt:b(s,"starts-at"),endsAt:b(s,"ends-at"),slug:b(s,"slug"),status:b(s,"status"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity events delete <id>");return xs(O(u,"event id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(bt.includes(r??""))return er("events",r,o,s);S(`usage: vcity events list|get|create|update|delete|${bt.join("|")}`)}case"collections":{let c=z(s),u={org:c.org,name:b(s,"name"),description:b(s,"description"),slug:b(s,"slug"),seoTitle:b(s,"seo-title"),seoDescription:b(s,"seo-description"),data:b(s,"data"),json:c.json};if(r==="list")return bn({org:c.org,json:c.json});if(r==="create")return In(u);if(r==="get"||r==="update"||r==="delete"){let l=o[0];if(!l)S(`usage: vcity collections ${r} <id>`);let w=O(l,"collection id");if(r==="get")return kn(w,{org:c.org,json:c.json});if(r==="update")return jn(w,u);return Tn(w,{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity collections list|get|create|update|delete")}case"agents":{let c=z(s);if(r==="list")return ln({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity agents get <id>");return pn(O(u,"agent id"),{org:c.org,json:c.json})}if(r==="update"){let u=o[0];if(!u)S("usage: vcity agents update <id> [--name ..] [--instructions ..] [--disable]");return mn(O(u,"agent id"),{org:c.org,json:c.json,name:b(s,"name"),description:b(s,"description"),emoji:b(s,"emoji"),avatar:b(s,"avatar"),instructions:b(s,"instructions"),instructionsFile:b(s,"instructions-file"),disable:s.disable===!0})}if(Ze.includes(r??""))return Eo(r,o,s);S(`usage: vcity agents list|get|update|${Ze.join("|")}`)}case"customer-agent":{let c=z(s);if(r==="get")return hn({org:c.org,json:c.json});if(r==="knowledge")return wn({org:c.org,json:c.json});S("usage: vcity customer-agent get|knowledge")}case"conversations":{let c=z(s);if(r==="list")return fn({org:c.org,status:c.status,awaitingReply:s["awaiting-reply"]===!0,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity conversations get <id>");return yn(O(u,"conversation id"),{org:c.org,limit:c.limit,json:c.json})}S("usage: vcity conversations list|get")}case"posts":{let c=z(s);if(r==="list")return Sn({org:c.org,limit:c.limit,status:c.status,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity posts get <id>");return On(O(u,"post id"),{org:c.org,json:c.json})}if(r==="create")return xn({org:c.org,comment:b(s,"comment"),file:b(s,"file"),video:b(s,"video"),poster:b(s,"poster"),data:b(s,"data"),json:c.json});if(r==="attach-video"){let u=o[0];if(!u)S("usage: vcity posts attach-video <id> --video <file.mp4>");return $n(O(u,"post id"),{org:c.org,video:b(s,"video"),poster:b(s,"poster"),json:c.json})}if(r==="preview"){let u=o[0];if(!u)S("usage: vcity posts preview <id>");return Dn(O(u,"post id"),{org:c.org,json:c.json})}if(r==="publish"){let u=o[0];if(!u)S("usage: vcity posts publish <id>");return Nn(O(u,"post id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity posts list|get|create|attach-video|preview|publish")}case"rooms":{if(r==="show"||r==="messages"||r==="send"||r==="search"||r==="read")return Do(r,o,s);let c=z(s);if(r==="list")return no({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity rooms get <id>");return oo(O(u,"room id"),{org:c.org,json:c.json})}if(r==="create")return io({org:c.org,title:b(s,"title"),description:b(s,"description"),type:b(s,"type"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity rooms update <id>");return ao(O(u,"room id"),{org:c.org,title:b(s,"title"),description:b(s,"description"),type:b(s,"type"),disabled:s.disabled===!0?!0:void 0,data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity rooms delete <id>");return co(O(u,"room id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity rooms list|get|create|update|delete|show|messages|send|search|read")}case"bookings":{let c=z(s);if(r==="list")return ns({...c,fromTs:M(s,"from"),toTs:M(s,"to")});if(r==="today")return ds({org:c.org,json:c.json});if(r==="slots")return ls(s);if(r==="time-off")return ps(o[0],o.slice(1),s);if(r==="hours")return ms(o,s);if(r==="get"){let u=o[0];if(!u)S("usage: vcity bookings get <id>");return os(O(u,"booking id"),{org:c.org,json:c.json})}if(r==="create")return is({org:c.org,name:b(s,"name"),email:b(s,"email"),start:b(s,"start"),end:b(s,"end"),timezone:b(s,"timezone"),phone:b(s,"phone"),company:b(s,"company"),note:b(s,"note"),bookingType:Q(s,"booking-type","--booking-type"),assignee:Q(s,"assignee","--assignee"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity bookings update <id>");return as(O(u,"booking id"),{org:c.org,status:b(s,"status"),assignee:Q(s,"assignee","--assignee"),data:b(s,"data"),json:c.json})}if(r==="cancel"||r==="delete"){let u=o[0];if(!u)S(`usage: vcity bookings ${r} <id>`);return cs(O(u,"booking id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity bookings list|get|create|update|cancel")}case"booking-types":{let c=z(s);if(r==="list")return Kr({org:c.org,limit:c.limit,enabled:s.enabled===!0?!0:void 0,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity booking-types get <id>");return Xr(O(u,"booking type id"),{org:c.org,json:c.json})}if(r==="create")return ts({org:c.org,name:b(s,"name"),duration:tt(s.duration,"--duration"),description:b(s,"description"),bufferBefore:tt(s["buffer-before"],"--buffer-before"),bufferAfter:tt(s["buffer-after"],"--buffer-after"),color:b(s,"color"),assignee:Q(s,"assignee","--assignee"),roundRobin:s["round-robin"]===!0?!0:void 0,sortOrder:tt(s["sort-order"],"--sort-order"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity booking-types update <id>");let l=s.disabled===!0?!1:s.enabled===!0?!0:void 0;return es(O(u,"booking type id"),{org:c.org,name:b(s,"name"),duration:tt(s.duration,"--duration"),description:b(s,"description"),bufferBefore:tt(s["buffer-before"],"--buffer-before"),bufferAfter:tt(s["buffer-after"],"--buffer-after"),color:b(s,"color"),assignee:Q(s,"assignee","--assignee"),roundRobin:s["round-robin"]===!0?!0:void 0,enabled:l,sortOrder:tt(s["sort-order"],"--sort-order"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity booking-types delete <id>");return rs(O(u,"booking type id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity booking-types list|get|create|update|delete")}case"projects":{let c=z(s);if(r==="list")return Qn({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity projects get <id>");return Wn(O(u,"project id"),{org:c.org,json:c.json})}if(r==="create")return zn({org:c.org,name:b(s,"name"),prefix:b(s,"prefix"),description:b(s,"description"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity projects update <id>");return Kn(O(u,"project id"),{org:c.org,name:b(s,"name"),description:b(s,"description"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity projects delete <id>");return Xn(O(u,"project id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity projects list|get|create|update|delete")}case"blogs":{let c=z(s);if(r==="list")return Hr({org:c.org,limit:c.limit,visibility:b(s,"visibility"),search:b(s,"search"),json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity blogs get <id|slug>");return Yr(O(u,"blog id"),{org:c.org,json:c.json})}if(r==="create")return Qr({org:c.org,title:b(s,"title"),slug:b(s,"slug"),summary:b(s,"summary"),content:b(s,"content"),visibility:b(s,"visibility"),type:b(s,"type"),tags:b(s,"tags"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity blogs update <id|slug>");return Wr(O(u,"blog id"),{org:c.org,title:b(s,"title"),slug:b(s,"slug"),summary:b(s,"summary"),content:b(s,"content"),visibility:b(s,"visibility"),type:b(s,"type"),tags:b(s,"tags"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity blogs delete <id|slug>");return zr(O(u,"blog id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(bt.includes(r??""))return er("blogs",r,o,s);S(`usage: vcity blogs list|get|create|update|delete|${bt.join("|")}`)}case"cards":{let c=z(s),u=Q(s,"project","--project");if(r==="list")return ws({org:c.org,project:u,column:Q(s,"column","--column"),assignee:Q(s,"assignee","--assignee"),archived:s.archived===!0,limit:c.limit,json:c.json});if(r==="get"){let l=o[0];if(!l)S("usage: vcity cards get <id|CODE-n> --project <id>");return vs(O(l,"card id"),{org:c.org,project:u,json:c.json})}if(r==="create")return bs({org:c.org,project:u,title:b(s,"title"),column:Q(s,"column","--column"),description:b(s,"description"),priority:b(s,"priority"),due:b(s,"due"),assignee:Q(s,"assignee","--assignee"),order:tt(s.order,"--order"),data:b(s,"data"),json:c.json});if(r==="update"){let l=o[0];if(!l)S("usage: vcity cards update <id|CODE-n> --project <id>");return ks(O(l,"card id"),{org:c.org,project:u,title:b(s,"title"),column:Q(s,"column","--column"),description:b(s,"description"),priority:b(s,"priority"),due:b(s,"due"),assignee:Q(s,"assignee","--assignee"),archived:s.archived===!0?!0:void 0,data:b(s,"data"),json:c.json})}if(r==="move"){let l=o[0];if(!l)S("usage: vcity cards move <id|CODE-n> --project <id> --column <col>");return Is(O(l,"card id"),{org:c.org,project:u,column:Q(s,"column","--column"),order:tt(s.order,"--order"),json:c.json})}if(r==="delete"){let l=o[0];if(!l)S("usage: vcity cards delete <id|CODE-n> --project <id>");return js(O(l,"card id"),{org:c.org,project:u,yes:s.yes===!0,json:c.json})}if(r==="comments"){let l=o[0];if(!l)S("usage: vcity cards comments <id|CODE-n> --project <id>");return Ts(O(l,"card id"),{org:c.org,project:u,limit:c.limit,json:c.json})}if(r==="comment"){let l=o[0];if(!l)S("usage: vcity cards comment <id|CODE-n> --project <id> --message <text>");return Es(O(l,"card id"),{org:c.org,project:u,message:b(s,"message"),json:c.json})}S("usage: vcity cards list|get|create|update|move|delete|comments|comment")}case"analytics":{let c=z(s),u={org:c.org,from:b(s,"from"),to:b(s,"to"),json:c.json};if(r==="summary")return Hs(u);if(r==="visits")return Ys({...u,groupBy:b(s,"group-by")});if(r==="top-products")return Qs({...u,limit:c.limit});S("usage: vcity analytics summary | vcity analytics visits | vcity analytics top-products")}case"orders":{let c=z(s);if(r==="list")return Xs(c);if(r==="get"){let u=o[0];if(!u)S("usage: vcity orders get <id>");return Zs(O(u,"order id"),{org:c.org,json:c.json})}if(r==="export")return tn({org:c.org,status:c.status,fromTs:M(s,"from"),toTs:M(s,"to"),format:A(s,"format",["csv","json"]),output:m(s,"output")});if(r==="ship"){let[u,...l]=o;if(!u)S("usage: vcity orders ship <orderId> [lineItemId...]");return en(O(u,"order id"),l.map((w)=>O(w,"line item id")),{org:c.org,status:A(s,"status",["shipped","delivered"]),json:c.json})}if(r==="comments"||r==="comment"||r==="breakdown")return Yo(r,o,s);S("usage: vcity orders list|get|export|ship|comments|comment|breakdown")}case"media":return Jn(r,o,s);case"status":return go({org:Q(s,"org","--org"),timeframe:A(s,"timeframe",uo),json:!!s.json});case"quotes":{let c=z(s);if(r==="list")return Zn(c);if(r==="get"){let u=o[0];if(!u)S("usage: vcity quotes get <id>");return to(O(u,"quote id"),{org:c.org,json:c.json})}if(r==="create")return eo({org:c.org,name:b(s,"name"),email:b(s,"email"),product:Q(s,"product","--product"),quantity:tt(s.quantity,"--quantity"),phone:b(s,"phone"),variation:b(s,"variation"),company:b(s,"company"),note:b(s,"note"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity quotes update <id>");return ro(O(u,"quote id"),{org:c.org,status:b(s,"status"),assignee:Q(s,"assignee","--assignee"),name:b(s,"name"),email:b(s,"email"),product:Q(s,"product","--product"),quantity:tt(s.quantity,"--quantity"),phone:b(s,"phone"),variation:b(s,"variation"),company:b(s,"company"),note:b(s,"note"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity quotes delete <id>");return so(O(u,"quote id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity quotes list|get|create|update|delete")}case"crm":return Ms(r,o,s);case"inbox":return As(r,o,s);case"quick-replies":return Ps(r,o,s);case"chat":return Ds(r,o,s);case"notifications":return Ws(r&&!r.startsWith("--")?r:void 0,o,s);case"webhooks":return To(r,o,s);case"configurators":return $o(r,o,s);case"billing":return qo(r&&!r.startsWith("--")?r:void 0,o,s);case"storefront":return _o(r&&!r.startsWith("--")?r:void 0,o,s);case"newsletter":return Bo(r,o,s);case"surveys":return Mo(r,o,s);case"comments":return Lo(r,o,s);case"dropshipping":return Ao(r,o,s);case"pos":return Po(r,o,s);case"coupons":return Oo(r,o,s);case"campaigns":return Co(r,o,s);case"keys":return Vo(r,o,s);case"support":return Ko(r,o,s);case"profile":return Qo(r,s);case"calendar":return gs(r,o,s);case"vault":return bo(r,o,s);case"desk":return Ls(r,s);case"update":return wo({check:s.check===!0,yes:s.yes===!0,json:!!s.json});default:S(`unknown command: ${e}. Run \`vcity --help\`.`)}}async function Uc(){let t=process.argv.slice(2),e=ri(t)?si():void 0;try{await Fc(t)}finally{if(e)ni(await e)}}Uc().catch((t)=>{if(t instanceof y)S(t.message);let e=t instanceof Error?t.message:String(t);if(process.stderr.write(`error: ${E(e)}
|
|
442
|
-
`),process.env.VCITY_DEBUG&&t instanceof Error&&t.stack)process.stderr.write(`${
|
|
441
|
+
`)}function Fc(t){if(typeof t!=="string")return;let e=parseInt(t,10);if(Number.isNaN(e)||e<0)S(`--limit must be a non-negative integer (got: ${t})`);return e}function Uc(t){if(typeof t!=="string")return;if(!/^\d+$/.test(t))S(`--skip must be a non-negative integer (got: ${t})`);return Number(t)}function tt(t,e){if(t===void 0)return;if(typeof t!=="string")return;let r=Number(t);if(!Number.isFinite(r))S(`${e} must be a number (got: ${t})`);return r}function b(t,e){return typeof t[e]==="string"?t[e]:void 0}function Q(t,e,r){let n=b(t,e);if(n===void 0)return;return O(n,r)}function z(t){return{org:Q(t,"org","--org"),limit:Fc(t.limit),status:typeof t.status==="string"?t.status:void 0,json:!!t.json}}async function Bc(t){if(t.length===0||t[0]==="--help"||t[0]==="-h"||t[0]==="help"){Nc();return}if(t[0]==="--version"||t[0]==="-v"){process.stdout.write(`${nt}
|
|
442
|
+
`);return}let[e,r,...n]=t,i=t.slice(1),{positional:a,flags:s}=ei(i),o=a.slice(r&&!r.startsWith("--")?1:0);switch(e){case"login":return Js({apiBaseUrl:typeof s["api-base-url"]==="string"?s["api-base-url"]:void 0,openBrowser:s["no-browser"]===!0?!1:void 0});case"logout":return Hs();case"whoami":return ti({json:!!s.json});case"org":{if(r==="list")return on({json:!!s.json});if(r==="use"){let c=o[0];if(!c)S("usage: vcity org use <slug>");return an(c)}if(r==="get"){let c=o[0];if(!c)S("usage: vcity org get <id>");return dn(O(c,"org id"))}if(r==="members"){let c=z(s),u=o[0];if(u==="list")return cn({org:c.org,limit:c.limit,json:c.json});if(u==="add"||u==="role"||u==="remove")return Yo(u,o.slice(1),s);S("usage: vcity org members list|add|role|remove")}if(r==="invitations")return Qo(o[0],o.slice(1),s);if(r==="settings")return ln({org:Q(s,"org","--org"),json:!!s.json});if(r==="set")return pn(s);S("usage: vcity org list | use <slug> | get <id> | members list|add|role|remove | invitations | settings | set --name <s> …")}case"products":{let c=z(s);if(r==="list")return Mn({org:c.org,search:b(s,"search"),limit:c.limit,skip:Uc(s.skip),visibility:b(s,"visibility"),createdFrom:b(s,"created-from"),updatedFrom:b(s,"updated-from"),collection:b(s,"collection"),sort:b(s,"sort"),order:b(s,"order"),lang:b(s,"lang"),json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity products get <id>");return Ln(O(u,"product id"),{org:c.org,lang:b(s,"lang"),json:c.json})}if(r==="create")return qn({org:c.org,name:b(s,"name"),price:tt(s.price,"--price"),currency:b(s,"currency"),sku:b(s,"sku"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity products update <id>");return _n(O(u,"product id"),{org:c.org,name:b(s,"name"),price:tt(s.price,"--price"),currency:b(s,"currency"),sku:b(s,"sku"),visibility:b(s,"visibility"),availability:tt(s.availability,"--availability"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity products delete <id>");return Gn(O(u,"product id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(r==="import"){let u=o[0];if(!u)S("usage: vcity products import <file.csv|file.json>");return Wn(u,{org:c.org,upsertBy:A(s,"upsert-by",["sku","none"]),dryRun:s["dry-run"]===!0,report:m(s,"report"),images:m(s,"images"),json:c.json})}if(bt.includes(r??""))return er("products",r,o,s);S(`usage: vcity products list|get|create|update|delete|import|${bt.join("|")}`)}case"events":{let c=z(s);if(r==="list"){let u=c.status;if(u!==void 0&&u!=="active"&&u!=="disabled")S(`invalid --status: ${u}. Allowed: active, disabled`);return Rs({org:c.org,limit:c.limit,status:u,search:b(s,"search"),json:c.json})}if(r==="get"){let u=o[0];if(!u)S("usage: vcity events get <id>");return Cs(O(u,"event id"),{org:c.org,json:c.json})}if(r==="create")return Ss({org:c.org,name:b(s,"name"),startsAt:b(s,"starts-at"),endsAt:b(s,"ends-at"),slug:b(s,"slug"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity events update <id>");return Os(O(u,"event id"),{org:c.org,name:b(s,"name"),startsAt:b(s,"starts-at"),endsAt:b(s,"ends-at"),slug:b(s,"slug"),status:b(s,"status"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity events delete <id>");return xs(O(u,"event id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(bt.includes(r??""))return er("events",r,o,s);S(`usage: vcity events list|get|create|update|delete|${bt.join("|")}`)}case"collections":{let c=z(s),u={org:c.org,name:b(s,"name"),description:b(s,"description"),slug:b(s,"slug"),seoTitle:b(s,"seo-title"),seoDescription:b(s,"seo-description"),data:b(s,"data"),json:c.json};if(r==="list")return In({org:c.org,json:c.json});if(r==="create")return En(u);if(r==="get"||r==="update"||r==="delete"){let p=o[0];if(!p)S(`usage: vcity collections ${r} <id>`);let w=O(p,"collection id");if(r==="get")return jn(w,{org:c.org,json:c.json});if(r==="update")return Tn(w,u);return Rn(w,{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity collections list|get|create|update|delete")}case"agents":{let c=z(s);if(r==="list")return mn({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity agents get <id>");return fn(O(u,"agent id"),{org:c.org,json:c.json})}if(r==="update"){let u=o[0];if(!u)S("usage: vcity agents update <id> [--name ..] [--instructions ..] [--disable]");return yn(O(u,"agent id"),{org:c.org,json:c.json,name:b(s,"name"),description:b(s,"description"),emoji:b(s,"emoji"),avatar:b(s,"avatar"),instructions:b(s,"instructions"),instructionsFile:b(s,"instructions-file"),disable:s.disable===!0})}if(Ze.includes(r??""))return Co(r,o,s);S(`usage: vcity agents list|get|update|${Ze.join("|")}`)}case"customer-agent":{let c=z(s);if(r==="get")return vn({org:c.org,json:c.json});if(r==="knowledge")return bn({org:c.org,json:c.json});S("usage: vcity customer-agent get|knowledge")}case"conversations":{let c=z(s);if(r==="list")return hn({org:c.org,status:c.status,awaitingReply:s["awaiting-reply"]===!0,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity conversations get <id>");return wn(O(u,"conversation id"),{org:c.org,limit:c.limit,json:c.json})}S("usage: vcity conversations list|get")}case"posts":{let c=z(s);if(r==="list")return xn({org:c.org,limit:c.limit,status:c.status,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity posts get <id>");return An(O(u,"post id"),{org:c.org,json:c.json})}if(r==="create")return Pn({org:c.org,comment:b(s,"comment"),file:b(s,"file"),video:b(s,"video"),poster:b(s,"poster"),data:b(s,"data"),json:c.json});if(r==="attach-video"){let u=o[0];if(!u)S("usage: vcity posts attach-video <id> --video <file.mp4>");return Nn(O(u,"post id"),{org:c.org,video:b(s,"video"),poster:b(s,"poster"),json:c.json})}if(r==="preview"){let u=o[0];if(!u)S("usage: vcity posts preview <id>");return Fn(O(u,"post id"),{org:c.org,json:c.json})}if(r==="publish"){let u=o[0];if(!u)S("usage: vcity posts publish <id>");return Un(O(u,"post id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity posts list|get|create|attach-video|preview|publish")}case"rooms":{if(r==="show"||r==="messages"||r==="send"||r==="search"||r==="read")return Fo(r,o,s);let c=z(s);if(r==="list")return io({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity rooms get <id>");return ao(O(u,"room id"),{org:c.org,json:c.json})}if(r==="create")return co({org:c.org,title:b(s,"title"),description:b(s,"description"),type:b(s,"type"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity rooms update <id>");return uo(O(u,"room id"),{org:c.org,title:b(s,"title"),description:b(s,"description"),type:b(s,"type"),disabled:s.disabled===!0?!0:void 0,data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity rooms delete <id>");return go(O(u,"room id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity rooms list|get|create|update|delete|show|messages|send|search|read")}case"bookings":{let c=z(s);if(r==="list")return ns({...c,fromTs:M(s,"from"),toTs:M(s,"to")});if(r==="today")return ds({org:c.org,json:c.json});if(r==="slots")return ls(s);if(r==="time-off")return ps(o[0],o.slice(1),s);if(r==="hours")return ms(o,s);if(r==="get"){let u=o[0];if(!u)S("usage: vcity bookings get <id>");return os(O(u,"booking id"),{org:c.org,json:c.json})}if(r==="create")return is({org:c.org,name:b(s,"name"),email:b(s,"email"),start:b(s,"start"),end:b(s,"end"),timezone:b(s,"timezone"),phone:b(s,"phone"),company:b(s,"company"),note:b(s,"note"),bookingType:Q(s,"booking-type","--booking-type"),assignee:Q(s,"assignee","--assignee"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity bookings update <id>");return as(O(u,"booking id"),{org:c.org,status:b(s,"status"),assignee:Q(s,"assignee","--assignee"),data:b(s,"data"),json:c.json})}if(r==="cancel"||r==="delete"){let u=o[0];if(!u)S(`usage: vcity bookings ${r} <id>`);return cs(O(u,"booking id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity bookings list|get|create|update|cancel")}case"booking-types":{let c=z(s);if(r==="list")return Kr({org:c.org,limit:c.limit,enabled:s.enabled===!0?!0:void 0,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity booking-types get <id>");return Xr(O(u,"booking type id"),{org:c.org,json:c.json})}if(r==="create")return ts({org:c.org,name:b(s,"name"),duration:tt(s.duration,"--duration"),description:b(s,"description"),bufferBefore:tt(s["buffer-before"],"--buffer-before"),bufferAfter:tt(s["buffer-after"],"--buffer-after"),color:b(s,"color"),assignee:Q(s,"assignee","--assignee"),roundRobin:s["round-robin"]===!0?!0:void 0,sortOrder:tt(s["sort-order"],"--sort-order"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity booking-types update <id>");let p=s.disabled===!0?!1:s.enabled===!0?!0:void 0;return es(O(u,"booking type id"),{org:c.org,name:b(s,"name"),duration:tt(s.duration,"--duration"),description:b(s,"description"),bufferBefore:tt(s["buffer-before"],"--buffer-before"),bufferAfter:tt(s["buffer-after"],"--buffer-after"),color:b(s,"color"),assignee:Q(s,"assignee","--assignee"),roundRobin:s["round-robin"]===!0?!0:void 0,enabled:p,sortOrder:tt(s["sort-order"],"--sort-order"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity booking-types delete <id>");return rs(O(u,"booking type id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity booking-types list|get|create|update|delete")}case"projects":{let c=z(s);if(r==="list")return zn({org:c.org,limit:c.limit,json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity projects get <id>");return Kn(O(u,"project id"),{org:c.org,json:c.json})}if(r==="create")return Xn({org:c.org,name:b(s,"name"),prefix:b(s,"prefix"),description:b(s,"description"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity projects update <id>");return Zn(O(u,"project id"),{org:c.org,name:b(s,"name"),description:b(s,"description"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity projects delete <id>");return to(O(u,"project id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity projects list|get|create|update|delete")}case"blogs":{let c=z(s);if(r==="list")return Hr({org:c.org,limit:c.limit,visibility:b(s,"visibility"),search:b(s,"search"),json:c.json});if(r==="get"){let u=o[0];if(!u)S("usage: vcity blogs get <id|slug>");return Yr(O(u,"blog id"),{org:c.org,json:c.json})}if(r==="create")return Qr({org:c.org,title:b(s,"title"),slug:b(s,"slug"),summary:b(s,"summary"),content:b(s,"content"),visibility:b(s,"visibility"),type:b(s,"type"),tags:b(s,"tags"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity blogs update <id|slug>");return Wr(O(u,"blog id"),{org:c.org,title:b(s,"title"),slug:b(s,"slug"),summary:b(s,"summary"),content:b(s,"content"),visibility:b(s,"visibility"),type:b(s,"type"),tags:b(s,"tags"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity blogs delete <id|slug>");return zr(O(u,"blog id"),{org:c.org,yes:s.yes===!0,json:c.json})}if(bt.includes(r??""))return er("blogs",r,o,s);S(`usage: vcity blogs list|get|create|update|delete|${bt.join("|")}`)}case"cards":{let c=z(s),u=Q(s,"project","--project");if(r==="list")return ws({org:c.org,project:u,column:Q(s,"column","--column"),assignee:Q(s,"assignee","--assignee"),archived:s.archived===!0,limit:c.limit,json:c.json});if(r==="get"){let p=o[0];if(!p)S("usage: vcity cards get <id|CODE-n> --project <id>");return vs(O(p,"card id"),{org:c.org,project:u,json:c.json})}if(r==="create")return bs({org:c.org,project:u,title:b(s,"title"),column:Q(s,"column","--column"),description:b(s,"description"),priority:b(s,"priority"),due:b(s,"due"),assignee:Q(s,"assignee","--assignee"),order:tt(s.order,"--order"),data:b(s,"data"),json:c.json});if(r==="update"){let p=o[0];if(!p)S("usage: vcity cards update <id|CODE-n> --project <id>");return ks(O(p,"card id"),{org:c.org,project:u,title:b(s,"title"),column:Q(s,"column","--column"),description:b(s,"description"),priority:b(s,"priority"),due:b(s,"due"),assignee:Q(s,"assignee","--assignee"),archived:s.archived===!0?!0:void 0,data:b(s,"data"),json:c.json})}if(r==="move"){let p=o[0];if(!p)S("usage: vcity cards move <id|CODE-n> --project <id> --column <col>");return Is(O(p,"card id"),{org:c.org,project:u,column:Q(s,"column","--column"),order:tt(s.order,"--order"),json:c.json})}if(r==="delete"){let p=o[0];if(!p)S("usage: vcity cards delete <id|CODE-n> --project <id>");return js(O(p,"card id"),{org:c.org,project:u,yes:s.yes===!0,json:c.json})}if(r==="comments"){let p=o[0];if(!p)S("usage: vcity cards comments <id|CODE-n> --project <id>");return Es(O(p,"card id"),{org:c.org,project:u,limit:c.limit,json:c.json})}if(r==="comment"){let p=o[0];if(!p)S("usage: vcity cards comment <id|CODE-n> --project <id> --message <text>");return Ts(O(p,"card id"),{org:c.org,project:u,message:b(s,"message"),json:c.json})}S("usage: vcity cards list|get|create|update|move|delete|comments|comment")}case"analytics":{let c=z(s),u={org:c.org,from:b(s,"from"),to:b(s,"to"),json:c.json};if(r==="summary")return Qs(u);if(r==="visits")return Ws({...u,groupBy:b(s,"group-by")});if(r==="top-products")return zs({...u,limit:c.limit});S("usage: vcity analytics summary | vcity analytics visits | vcity analytics top-products")}case"orders":{let c=z(s);if(r==="list")return tn(c);if(r==="get"){let u=o[0];if(!u)S("usage: vcity orders get <id>");return en(O(u,"order id"),{org:c.org,json:c.json})}if(r==="export")return rn({org:c.org,status:c.status,fromTs:M(s,"from"),toTs:M(s,"to"),format:A(s,"format",["csv","json"]),output:m(s,"output")});if(r==="ship"){let[u,...p]=o;if(!u)S("usage: vcity orders ship <orderId> [lineItemId...]");return sn(O(u,"order id"),p.map((w)=>O(w,"line item id")),{org:c.org,status:A(s,"status",["shipped","delivered"]),json:c.json})}if(r==="comments"||r==="comment"||r==="breakdown")return Wo(r,o,s);S("usage: vcity orders list|get|export|ship|comments|comment|breakdown")}case"media":return Yn(r,o,s);case"status":return po({org:Q(s,"org","--org"),timeframe:A(s,"timeframe",lo),json:!!s.json});case"quotes":{let c=z(s);if(r==="list")return eo(c);if(r==="get"){let u=o[0];if(!u)S("usage: vcity quotes get <id>");return ro(O(u,"quote id"),{org:c.org,json:c.json})}if(r==="create")return so({org:c.org,name:b(s,"name"),email:b(s,"email"),product:Q(s,"product","--product"),quantity:tt(s.quantity,"--quantity"),phone:b(s,"phone"),variation:b(s,"variation"),company:b(s,"company"),note:b(s,"note"),data:b(s,"data"),json:c.json});if(r==="update"){let u=o[0];if(!u)S("usage: vcity quotes update <id>");return no(O(u,"quote id"),{org:c.org,status:b(s,"status"),assignee:Q(s,"assignee","--assignee"),name:b(s,"name"),email:b(s,"email"),product:Q(s,"product","--product"),quantity:tt(s.quantity,"--quantity"),phone:b(s,"phone"),variation:b(s,"variation"),company:b(s,"company"),note:b(s,"note"),data:b(s,"data"),json:c.json})}if(r==="delete"){let u=o[0];if(!u)S("usage: vcity quotes delete <id>");return oo(O(u,"quote id"),{org:c.org,yes:s.yes===!0,json:c.json})}S("usage: vcity quotes list|get|create|update|delete")}case"crm":return Ms(r,o,s);case"inbox":return As(r,o,s);case"quick-replies":return Ps(r,o,s);case"chat":return Ds(r,o,s);case"notifications":return Ks(r&&!r.startsWith("--")?r:void 0,o,s);case"webhooks":return Ro(r,o,s);case"configurators":return No(r,o,s);case"billing":return Go(r&&!r.startsWith("--")?r:void 0,o,s);case"storefront":return Vo(r&&!r.startsWith("--")?r:void 0,o,s);case"newsletter":return Lo(r,o,s);case"surveys":return qo(r,o,s);case"comments":return _o(r,o,s);case"dropshipping":return $o(r,o,s);case"pos":return Do(r,o,s);case"coupons":return Ao(r,o,s);case"campaigns":return Oo(r,o,s);case"keys":return Ho(r,o,s);case"support":return Zo(r,o,s);case"profile":return zo(r,s);case"calendar":return gs(r,o,s);case"vault":return Io(r,o,s);case"desk":return _s(r,s);case"apps":return qs(r,o,s);case"update":return bo({check:s.check===!0,yes:s.yes===!0,json:!!s.json});default:S(`unknown command: ${e}. Run \`vcity --help\`.`)}}async function Mc(){let t=process.argv.slice(2),e=ni(t)?oi():void 0;try{await Bc(t)}finally{if(e)ii(await e)}}Mc().catch((t)=>{if(t instanceof y)S(t.message);let e=t instanceof Error?t.message:String(t);if(process.stderr.write(`error: ${T(e)}
|
|
443
|
+
`),process.env.VCITY_DEBUG&&t instanceof Error&&t.stack)process.stderr.write(`${T(t.stack)}
|
|
443
444
|
`);process.exit(1)});
|