@nextad/auction 0.1.8 → 0.1.9

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 CHANGED
@@ -26,6 +26,7 @@ type AuctionOptions = {
26
26
  };
27
27
  declare class Auction {
28
28
  private losingBids;
29
+ private winningBid?;
29
30
  private bids;
30
31
  private itemIds;
31
32
  private status;
@@ -43,6 +44,7 @@ declare class Auction {
43
44
  private setLosingBids;
44
45
  private handleLossBids;
45
46
  private handleLossBid;
47
+ private replaceMacro;
46
48
  }
47
49
 
48
50
  declare class BidNotFoundException {
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ type AuctionOptions = {
26
26
  };
27
27
  declare class Auction {
28
28
  private losingBids;
29
+ private winningBid?;
29
30
  private bids;
30
31
  private itemIds;
31
32
  private status;
@@ -43,6 +44,7 @@ declare class Auction {
43
44
  private setLosingBids;
44
45
  private handleLossBids;
45
46
  private handleLossBid;
47
+ private replaceMacro;
46
48
  }
47
49
 
48
50
  declare class BidNotFoundException {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(e,i)=>{for(var s in i)u(e,s,{get:i[s],enumerable:!0})},m=(e,i,s,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of l(i))!f.call(e,t)&&t!==s&&u(e,t,{get:()=>i[t],enumerable:!(r=h(i,t))||r.enumerable});return e};var g=e=>m(u({},"__esModule",{value:!0}),e);var y={};v(y,{AlreadyEndedAuctionException:()=>a,Auction:()=>B,BidNotFoundException:()=>o});module.exports=g(y);var c=class{static getHighestBidV26(i,s,r){return r?i.reduce((t,n)=>{let d=this.convertPrice(t,s,r);return this.convertPrice(n,s,r)>d?n:t}):i.reduce((t,n)=>{let d=t.price*100;return n.price*100>d?n:t})}static convertPrice(i,s,r){let t=i.price,n=r.conversions[s.get(i)?.currency||"USD"];if(!n)return t*100;let p=n["USD"];return t*(p||1)*100}};var o=class{name="BidNotFoundException";message="Bid is not found."},a=class{name="AlreadyEndedAuctionException";message="Auction is already ended."};var B=class{losingBids;bids;itemIds=[];status;options;bidInformation;constructor(i,s={}){this.options={lossProcessing:!0,...s},this.bids={v26:[]},this.losingBids={v26:[]},this.status="open",this.bidInformation=new WeakMap,typeof i=="string"?this.itemIds.push(i):this.itemIds.push(...i)}getStatus(){return this.status}getLosingBids(){return this.losingBids}getBidInformation(i){return this.bidInformation.get(i)}getBidInformations(){return this.bidInformation}placeBidResponseV26(i){if(i.seatbid){let s=i.seatbid.flatMap(r=>r.bid.filter(t=>this.itemIds.some(n=>n===t.impid)).map(t=>(this.bidInformation.set(t,{currency:i.cur,version:"2.6",seat:r.seat}),t)));this.bids.v26.push(...s)}return this}end(){if(this.status!=="open")throw new a;if(!this.bids.v26.length)throw new o;let i=c.getHighestBidV26(this.bids.v26,this.bidInformation,this.options.currencyConversionData);return this.setLosingBids(i),this.handleLossBids(),this.status="closed",i}setLosingBids(i){this.losingBids.v26.push(...this.bids.v26.filter(s=>s.id!==i.id))}handleLossBids(){this.losingBids.v26.forEach(i=>{this.handleLossBid(i)})}handleLossBid(i){this.options.lossProcessing&&i.lurl&&fetch(i.lurl,{keepalive:!0})}};0&&(module.exports={AlreadyEndedAuctionException,Auction,BidNotFoundException});
1
+ "use strict";var B=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var f=(n,i)=>{for(var e in i)B(n,e,{get:i[e],enumerable:!0})},m=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of g(i))!v.call(n,t)&&t!==e&&B(n,t,{get:()=>i[t],enumerable:!(s=l(i,t))||s.enumerable});return n};var y=n=>m(B({},"__esModule",{value:!0}),n);var I={};f(I,{AlreadyEndedAuctionException:()=>a,Auction:()=>u,BidNotFoundException:()=>o});module.exports=y(I);var c=class{static getHighestBidV26(i,e,s){return s?i.reduce((t,r)=>{let d=this.convertPrice(t,e,s);return this.convertPrice(r,e,s)>d?r:t}):i.reduce((t,r)=>{let d=t.price*100;return r.price*100>d?r:t})}static convertPrice(i,e,s){let t=i.price,r=s.conversions[e.get(i)?.currency||"USD"];if(!r)return t*100;let p=r["USD"];return t*(p||1)*100}};var o=class{name="BidNotFoundException";message="Bid is not found."},a=class{name="AlreadyEndedAuctionException";message="Auction is already ended."};var h=require("iab-openrtb/v26"),u=class{losingBids;winningBid;bids;itemIds=[];status;options;bidInformation;constructor(i,e={}){this.options={lossProcessing:!0,...e},this.bids={v26:[]},this.losingBids={v26:[]},this.status="open",this.bidInformation=new WeakMap,typeof i=="string"?this.itemIds.push(i):this.itemIds.push(...i)}getStatus(){return this.status}getLosingBids(){return this.losingBids}getBidInformation(i){return this.bidInformation.get(i)}getBidInformations(){return this.bidInformation}placeBidResponseV26(i){if(i.seatbid){let e=i.seatbid.flatMap(s=>s.bid.filter(t=>this.itemIds.some(r=>r===t.impid)).map(t=>(this.bidInformation.set(t,{currency:i.cur,version:"2.6",seat:s.seat}),t)));this.bids.v26.push(...e)}return this}end(){if(this.status!=="open")throw new a;if(!this.bids.v26.length)throw new o;let i=c.getHighestBidV26(this.bids.v26,this.bidInformation,this.options.currencyConversionData);return this.setLosingBids(i),this.handleLossBids(),this.status="closed",this.winningBid=i,i}setLosingBids(i){this.losingBids.v26.push(...this.bids.v26.filter(e=>e.id!==i.id))}handleLossBids(){this.losingBids.v26.forEach(i=>{this.handleLossBid(i)})}handleLossBid(i){this.options.lossProcessing&&i.lurl&&fetch(this.replaceMacro(i.lurl),{keepalive:!0})}replaceMacro(i){let e=this.winningBid?this.winningBid.price.toFixed(2):"",s=this.winningBid?(this.winningBid.price+.01).toFixed(2):"";return i=i.replaceAll("${AUCTION_PRICE}",e),i=i.replaceAll("${AUCTION_MIN_TO_WIN}}",s),i=i.replaceAll("${AUCTION_LOSS}",h.LossReasonCode.LOST_TO_HIGHER_BID.toString()),i}};0&&(module.exports={AlreadyEndedAuctionException,Auction,BidNotFoundException});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var o=class{static getHighestBidV26(i,s,r){return r?i.reduce((t,e)=>{let n=this.convertPrice(t,s,r);return this.convertPrice(e,s,r)>n?e:t}):i.reduce((t,e)=>{let n=t.price*100;return e.price*100>n?e:t})}static convertPrice(i,s,r){let t=i.price,e=r.conversions[s.get(i)?.currency||"USD"];if(!e)return t*100;let p=e["USD"];return t*(p||1)*100}};var a=class{name="BidNotFoundException";message="Bid is not found."},d=class{name="AlreadyEndedAuctionException";message="Auction is already ended."};var u=class{losingBids;bids;itemIds=[];status;options;bidInformation;constructor(i,s={}){this.options={lossProcessing:!0,...s},this.bids={v26:[]},this.losingBids={v26:[]},this.status="open",this.bidInformation=new WeakMap,typeof i=="string"?this.itemIds.push(i):this.itemIds.push(...i)}getStatus(){return this.status}getLosingBids(){return this.losingBids}getBidInformation(i){return this.bidInformation.get(i)}getBidInformations(){return this.bidInformation}placeBidResponseV26(i){if(i.seatbid){let s=i.seatbid.flatMap(r=>r.bid.filter(t=>this.itemIds.some(e=>e===t.impid)).map(t=>(this.bidInformation.set(t,{currency:i.cur,version:"2.6",seat:r.seat}),t)));this.bids.v26.push(...s)}return this}end(){if(this.status!=="open")throw new d;if(!this.bids.v26.length)throw new a;let i=o.getHighestBidV26(this.bids.v26,this.bidInformation,this.options.currencyConversionData);return this.setLosingBids(i),this.handleLossBids(),this.status="closed",i}setLosingBids(i){this.losingBids.v26.push(...this.bids.v26.filter(s=>s.id!==i.id))}handleLossBids(){this.losingBids.v26.forEach(i=>{this.handleLossBid(i)})}handleLossBid(i){this.options.lossProcessing&&i.lurl&&fetch(i.lurl,{keepalive:!0})}};export{d as AlreadyEndedAuctionException,u as Auction,a as BidNotFoundException};
1
+ var o=class{static getHighestBidV26(i,e,s){return s?i.reduce((t,n)=>{let r=this.convertPrice(t,e,s);return this.convertPrice(n,e,s)>r?n:t}):i.reduce((t,n)=>{let r=t.price*100;return n.price*100>r?n:t})}static convertPrice(i,e,s){let t=i.price,n=s.conversions[e.get(i)?.currency||"USD"];if(!n)return t*100;let p=n["USD"];return t*(p||1)*100}};var a=class{name="BidNotFoundException";message="Bid is not found."},d=class{name="AlreadyEndedAuctionException";message="Auction is already ended."};import{LossReasonCode as u}from"iab-openrtb/v26";var B=class{losingBids;winningBid;bids;itemIds=[];status;options;bidInformation;constructor(i,e={}){this.options={lossProcessing:!0,...e},this.bids={v26:[]},this.losingBids={v26:[]},this.status="open",this.bidInformation=new WeakMap,typeof i=="string"?this.itemIds.push(i):this.itemIds.push(...i)}getStatus(){return this.status}getLosingBids(){return this.losingBids}getBidInformation(i){return this.bidInformation.get(i)}getBidInformations(){return this.bidInformation}placeBidResponseV26(i){if(i.seatbid){let e=i.seatbid.flatMap(s=>s.bid.filter(t=>this.itemIds.some(n=>n===t.impid)).map(t=>(this.bidInformation.set(t,{currency:i.cur,version:"2.6",seat:s.seat}),t)));this.bids.v26.push(...e)}return this}end(){if(this.status!=="open")throw new d;if(!this.bids.v26.length)throw new a;let i=o.getHighestBidV26(this.bids.v26,this.bidInformation,this.options.currencyConversionData);return this.setLosingBids(i),this.handleLossBids(),this.status="closed",this.winningBid=i,i}setLosingBids(i){this.losingBids.v26.push(...this.bids.v26.filter(e=>e.id!==i.id))}handleLossBids(){this.losingBids.v26.forEach(i=>{this.handleLossBid(i)})}handleLossBid(i){this.options.lossProcessing&&i.lurl&&fetch(this.replaceMacro(i.lurl),{keepalive:!0})}replaceMacro(i){let e=this.winningBid?this.winningBid.price.toFixed(2):"",s=this.winningBid?(this.winningBid.price+.01).toFixed(2):"";return i=i.replaceAll("${AUCTION_PRICE}",e),i=i.replaceAll("${AUCTION_MIN_TO_WIN}}",s),i=i.replaceAll("${AUCTION_LOSS}",u.LOST_TO_HIGHER_BID.toString()),i}};export{d as AlreadyEndedAuctionException,B as Auction,a as BidNotFoundException};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextad/auction",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Kai Miyamoto",