@cohostvip/cohost-node 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -957,7 +957,7 @@ interface OrderItem {
|
|
|
957
957
|
options: any | null;
|
|
958
958
|
offering: OrderItemOffering;
|
|
959
959
|
}
|
|
960
|
-
interface OrderItemOffering extends Pick<Offering, "id" | "name" | "type" | "includes" | "status" | "description" | "options" | "sorting"> {
|
|
960
|
+
interface OrderItemOffering extends Pick<Offering, "id" | "name" | "type" | "includes" | "status" | "description" | "options" | "maximumQuantity" | "minimumQuantity" | "sorting"> {
|
|
961
961
|
costs?: OfferingCosts;
|
|
962
962
|
/**
|
|
963
963
|
* doc assicated with this offering in the DB.
|
|
@@ -1219,7 +1219,7 @@ interface OrderContext$1 {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
type CartSessionItem = Pick<OrderItem, "id" | "details" | "offeringId" | "quantity" | "options" | "tableCommitmentId"> & {
|
|
1221
1221
|
costs?: OrderItemCosts;
|
|
1222
|
-
offering: OrderItemOffering
|
|
1222
|
+
offering: OrderItemOffering;
|
|
1223
1223
|
};
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Represents a temporary or persisted cart before order placement.
|
|
@@ -1278,9 +1278,13 @@ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" |
|
|
|
1278
1278
|
* Partner-forwarded data (e.g. utm, session metadata).
|
|
1279
1279
|
*/
|
|
1280
1280
|
forwarded?: any;
|
|
1281
|
+
/**
|
|
1282
|
+
* Customer answers
|
|
1283
|
+
*/
|
|
1284
|
+
customerAnswers?: any;
|
|
1281
1285
|
status: "started" | "completed" | "abandoned" | "cancelled";
|
|
1282
1286
|
}
|
|
1283
|
-
type UpdatableCartSession = Pick<CartSession, "customer" | "items">;
|
|
1287
|
+
type UpdatableCartSession = Pick<CartSession, "customer" | "items" | "customerAnswers" | "forwarded">;
|
|
1284
1288
|
|
|
1285
1289
|
/**
|
|
1286
1290
|
* Pagination parameters for a paginated API request.
|
package/dist/index.d.ts
CHANGED
|
@@ -957,7 +957,7 @@ interface OrderItem {
|
|
|
957
957
|
options: any | null;
|
|
958
958
|
offering: OrderItemOffering;
|
|
959
959
|
}
|
|
960
|
-
interface OrderItemOffering extends Pick<Offering, "id" | "name" | "type" | "includes" | "status" | "description" | "options" | "sorting"> {
|
|
960
|
+
interface OrderItemOffering extends Pick<Offering, "id" | "name" | "type" | "includes" | "status" | "description" | "options" | "maximumQuantity" | "minimumQuantity" | "sorting"> {
|
|
961
961
|
costs?: OfferingCosts;
|
|
962
962
|
/**
|
|
963
963
|
* doc assicated with this offering in the DB.
|
|
@@ -1219,7 +1219,7 @@ interface OrderContext$1 {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
type CartSessionItem = Pick<OrderItem, "id" | "details" | "offeringId" | "quantity" | "options" | "tableCommitmentId"> & {
|
|
1221
1221
|
costs?: OrderItemCosts;
|
|
1222
|
-
offering: OrderItemOffering
|
|
1222
|
+
offering: OrderItemOffering;
|
|
1223
1223
|
};
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Represents a temporary or persisted cart before order placement.
|
|
@@ -1278,9 +1278,13 @@ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" |
|
|
|
1278
1278
|
* Partner-forwarded data (e.g. utm, session metadata).
|
|
1279
1279
|
*/
|
|
1280
1280
|
forwarded?: any;
|
|
1281
|
+
/**
|
|
1282
|
+
* Customer answers
|
|
1283
|
+
*/
|
|
1284
|
+
customerAnswers?: any;
|
|
1281
1285
|
status: "started" | "completed" | "abandoned" | "cancelled";
|
|
1282
1286
|
}
|
|
1283
|
-
type UpdatableCartSession = Pick<CartSession, "customer" | "items">;
|
|
1287
|
+
type UpdatableCartSession = Pick<CartSession, "customer" | "items" | "customerAnswers" | "forwarded">;
|
|
1284
1288
|
|
|
1285
1289
|
/**
|
|
1286
1290
|
* Pagination parameters for a paginated API request.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var D=(n,e,t)=>e in n?l(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e)=>{for(var t in e)l(n,t,{get:e[t],enumerable:!0})},z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of w(e))!U.call(n,s)&&s!==t&&l(n,s,{get:()=>e[s],enumerable:!(r=E(e,s))||r.enumerable});return n};var B=n=>z(l({},"__esModule",{value:!0}),n);var o=(n,e,t)=>D(n,typeof e!="symbol"?e+"":e,t);var L={};$(L,{CohostClient:()=>p,createCohostClient:()=>_});module.exports=B(L);var d=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var g="https://api.cohost.com/v1";var m=class n extends Error{constructor(t,r){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=r?.errorCode,this.statusCode=r?.statusCode}static fromError(t,r){return new n(t.message,{...r,errorCode:r?.errorCode||t.name})}};var v={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},O={};var R=(n,e)=>{let{pagination:t,...r}=n;return{query:r,pagination:t,...e}},V=n=>{if(!n)return"";let e=new URLSearchParams;for(let[t,r]of Object.entries(n))r!==void 0&&(Array.isArray(r)?r.forEach(s=>e.append(t,String(s))):e.set(t,String(r)));return e.toString()?`?${e.toString()}`:""},P=({token:n,baseUrl:e=g,debug:t=!1})=>async function(r,s={}){let{method:i="GET",data:c,query:q,pagination:I,headers:A={}}=s,T={...q,...I},k=V(T),x=`${O.baseUrl??e}${r}${k}`,h={...v.headers,...O.headers,...A};n&&(h.Authorization=`Bearer ${n}`);let b=c&&i!=="GET"?JSON.stringify(c):void 0;t&&(console.log(`[Cohost SDK] Request: ${i} ${x}`),b&&console.log("[Cohost SDK] Body:",b),console.log("[Cohost SDK] Headers:",h));let u=await fetch(x,{method:i,headers:h,body:b}),a=u.headers.get("content-type")?.includes("application/json")?await u.json():await u.text();if(!u.ok){let S=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error: ${S}`,{url:x}),new m(S||u.statusText,{errorCode:u.statusText||"API_ERROR",statusCode:u.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var f=class extends d{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,R(t))}};var y=class extends d{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var C=class extends d{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async findTables(e,t){return this.request(`/cart/tables/find-tables/${e}`,{query:{...t}})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}};var p=class n{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:r,settings:s={}}=e,i=t??P({token:r,baseUrl:s.apiUrl||g,debug:s.debug});this.events=new f(i,s),this.orders=new y(i,s),this.cart=new C(i,s)}requestWithOverrides(e){let{token:t,settings:r={}}=this.baseOptions,s=(i,c={})=>P({token:e.token??t,baseUrl:e.baseUrl??r.apiUrl??g,debug:r.debug})(i,{...c,headers:{...e.headers||{},...c.headers||{}}});return new n({token:e.token??t,settings:{...r,apiUrl:e.baseUrl??r.apiUrl}},s)}};function _(n){return new p(n)}0&&(module.exports={CohostClient,createCohostClient});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var E=(n,e,t)=>e in n?k(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var o=(n,e,t)=>E(n,typeof e!="symbol"?e+"":e,t);var d=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var g="https://api.cohost.com/v1";var p=class n extends Error{constructor(t,r){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=r?.errorCode,this.statusCode=r?.statusCode}static fromError(t,r){return new n(t.message,{...r,errorCode:r?.errorCode||t.name})}};var S={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},b={};var v=(n,e)=>{let{pagination:t,...r}=n;return{query:r,pagination:t,...e}},w=n=>{if(!n)return"";let e=new URLSearchParams;for(let[t,r]of Object.entries(n))r!==void 0&&(Array.isArray(r)?r.forEach(s=>e.append(t,String(s))):e.set(t,String(r)));return e.toString()?`?${e.toString()}`:""},O=({token:n,baseUrl:e=g,debug:t=!1})=>async function(r,s={}){let{method:i="GET",data:c,query:R,pagination:q,headers:I={}}=s,A={...R,...q},T=w(A),C=`${b.baseUrl??e}${r}${T}`,x={...S.headers,...b.headers,...I};n&&(x.Authorization=`Bearer ${n}`);let h=c&&i!=="GET"?JSON.stringify(c):void 0;t&&(console.log(`[Cohost SDK] Request: ${i} ${C}`),h&&console.log("[Cohost SDK] Body:",h),console.log("[Cohost SDK] Headers:",x));let u=await fetch(C,{method:i,headers:x,body:h}),a=u.headers.get("content-type")?.includes("application/json")?await u.json():await u.text();if(!u.ok){let P=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error: ${P}`,{url:C}),new p(P||u.statusText,{errorCode:u.statusText||"API_ERROR",statusCode:u.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var l=class extends d{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,v(t))}};var m=class extends d{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var f=class extends d{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async findTables(e,t){return this.request(`/cart/tables/find-tables/${e}`,{query:{...t}})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}};var y=class n{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:r,settings:s={}}=e,i=t??O({token:r,baseUrl:s.apiUrl||g,debug:s.debug});this.events=new l(i,s),this.orders=new m(i,s),this.cart=new f(i,s)}requestWithOverrides(e){let{token:t,settings:r={}}=this.baseOptions,s=(i,c={})=>O({token:e.token??t,baseUrl:e.baseUrl??r.apiUrl??g,debug:r.debug})(i,{...c,headers:{...e.headers||{},...c.headers||{}}});return new n({token:e.token??t,settings:{...r,apiUrl:e.baseUrl??r.apiUrl}},s)}};function ue(n){return new y(n)}export{y as CohostClient,ue as createCohostClient};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|