@topsort/sdk
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| var E=require("node:module");var{defineProperty:a,getOwnPropertyNames:x,getOwnPropertyDescriptor:A}=Object,C=Object.prototype.hasOwnProperty;var m=new WeakMap,b=(t)=>{var r=m.get(t),o;if(r)return r;if(r=a({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")x(t).map((e)=>!C.call(r,e)&&a(r,e,{get:()=>t[e],enumerable:!(o=A(t,e))||o.enumerable}));return m.set(t,r),r};var k=(t,r)=>{for(var o in r)a(t,o,{get:r[o],enumerable:!0,configurable:!0,set:(e)=>r[o]=()=>e})};var T={};k(T,{TopsortClient:()=>v});module.exports=b(T);var u="https://api.topsort.com",n={auctions:"v2/auctions",events:"v2/events"};var c="0.3.8";class d{status;statusText;body;retry;constructor(t,r,o,e=!1){this.status=t,this.statusText=r,this.body=o,this.retry=e}}var i=d;class f{async handleResponse(t){let r;if(t.status!==204)r=await t.json();if(!t.ok){let o=t.status===429||t.status>=500;throw new i(t.status,t.statusText,r,o)}return r}async request(t,r){try{let o=this.sanitizeUrl(t),e=await fetch(o,r);return this.handleResponse(e)}catch(o){let e=o instanceof Error?o.message:"Unknown error";throw new i(500,"Internal Server Error",e)}}setupTimeoutSignal(t){if(t.timeout!=null){let r=new AbortController;return setTimeout(()=>r.abort(),t.timeout),r.signal}}async post(t,r,o){let e=this.setupTimeoutSignal(o),w=o.fetchOptions??{keepalive:!0};return this.request(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-UA":o.userAgent?`@topsort/sdk ${c} ${o.userAgent}`:`@topsort/sdk ${c}`,Authorization:`Bearer ${o.apiKey}`},body:JSON.stringify(r),signal:e,...w})}sanitizeUrl(t){try{return new URL(t).href.replace(/\/+$/,"")}catch(r){throw new i(400,"Invalid URL",{error:`Invalid URL: ${r}`})}}}var s=new f;function l(t){if(!t?.apiKey?.length)throw new i(401,"API Key is required.",{})}function p(t){return async(...r)=>{let o=r[r.length-1];return l(o),t(...r)}}async function U(t,r){let o=`${r.host}/${n.auctions}`;return await s.post(o.toString(),t,r)}var g=p(U);async function j(t,r){try{let o=`${r.host}/${n.events}`;return await s.post(o,t,r),{ok:!0,retry:!1}}catch(o){if(o instanceof i&&o.retry)return{ok:!1,retry:!0};throw o}}var h=p(j);class y{config;constructor(t){this.config=t,this.config.host=this.config.host??u}async reportEvent(t){return h(t,this.config)}async createAuction(t){return g(t,this.config)}}var v=y; | ||
| var E=require("node:module");var{defineProperty:a,getOwnPropertyNames:x,getOwnPropertyDescriptor:A}=Object,C=Object.prototype.hasOwnProperty;var m=new WeakMap,b=(t)=>{var r=m.get(t),o;if(r)return r;if(r=a({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")x(t).map((e)=>!C.call(r,e)&&a(r,e,{get:()=>t[e],enumerable:!(o=A(t,e))||o.enumerable}));return m.set(t,r),r};var k=(t,r)=>{for(var o in r)a(t,o,{get:r[o],enumerable:!0,configurable:!0,set:(e)=>r[o]=()=>e})};var T={};k(T,{TopsortClient:()=>v});module.exports=b(T);var u="https://api.topsort.com",n={auctions:"v2/auctions",events:"v2/events"};var c="0.3.9";class d{status;statusText;body;retry;constructor(t,r,o,e=!1){this.status=t,this.statusText=r,this.body=o,this.retry=e}}var i=d;class f{async handleResponse(t){let r;if(t.status!==204)r=await t.json();if(!t.ok){let o=t.status===429||t.status>=500;throw new i(t.status,t.statusText,r,o)}return r}async request(t,r){try{let o=this.sanitizeUrl(t),e=await fetch(o,r);return this.handleResponse(e)}catch(o){let e=o instanceof Error?o.message:"Unknown error";throw new i(500,"Internal Server Error",e)}}setupTimeoutSignal(t){if(t.timeout!=null){let r=new AbortController;return setTimeout(()=>r.abort(),t.timeout),r.signal}}async post(t,r,o){let e=this.setupTimeoutSignal(o),w=o.fetchOptions??{keepalive:!0};return this.request(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-UA":o.userAgent?`@topsort/sdk ${c} ${o.userAgent}`:`@topsort/sdk ${c}`,Authorization:`Bearer ${o.apiKey}`},body:JSON.stringify(r),signal:e,...w})}sanitizeUrl(t){try{return new URL(t).href.replace(/\/+$/,"")}catch(r){throw new i(400,"Invalid URL",{error:`Invalid URL: ${r}`})}}}var s=new f;function l(t){if(!t?.apiKey?.length)throw new i(401,"API Key is required.",{})}function p(t){return async(...r)=>{let o=r[r.length-1];return l(o),t(...r)}}async function U(t,r){let o=`${r.host}/${n.auctions}`;return await s.post(o.toString(),t,r)}var g=p(U);async function j(t,r){try{let o=`${r.host}/${n.events}`;return await s.post(o,t,r),{ok:!0,retry:!1}}catch(o){if(o instanceof i&&o.retry)return{ok:!1,retry:!0};throw o}}var h=p(j);class y{config;constructor(t){this.config=t,this.config.host=this.config.host??u}async reportEvent(t){return h(t,this.config)}async createAuction(t){return g(t,this.config)}}var v=y; |
+127
-12
@@ -271,17 +271,17 @@ /** | ||
| url: string; | ||
| /** | ||
| * Additional content metadata for the asset. | ||
| * This is an open object that can contain any additional properties. | ||
| * @type {Record<string, any>} | ||
| * @optional | ||
| * @example { "headingText": "Summer Sale", "bannerText": "50% off", "bannerTextColour": "#FFFFFF", "heroImage": "hero.jpg", "heroImageAltText": "Hero" } | ||
| */ | ||
| content?: Record<string, any>; | ||
| } | ||
| /** | ||
| * Represents an auction winner. | ||
| * @interface Winner | ||
| * Base interface for auction winners. | ||
| * @interface BaseWinner | ||
| */ | ||
| interface Winner { | ||
| interface BaseWinner { | ||
| /** | ||
| * The list of available sources for a banner. | ||
| * Only present for banner auction winners. | ||
| * @type {Asset[]} | ||
| * @required | ||
| * @minItems 1 | ||
| */ | ||
| asset: Asset[]; | ||
| /** | ||
| * The marketplace's ID of the winning entity, depending on the target of the campaign. | ||
@@ -319,4 +319,36 @@ * @type {string} | ||
| type: string; | ||
| /** | ||
| * The ID of the campaign that won the auction. | ||
| * @type {string} | ||
| * @example "82588593-85c5-47c0-b125-07e315b7f2b3" | ||
| */ | ||
| campaignId: string; | ||
| } | ||
| /** | ||
| * Represents a sponsored listing auction winner. | ||
| * @interface SponsoredListingWinner | ||
| * @extends {BaseWinner} | ||
| */ | ||
| interface SponsoredListingWinner extends BaseWinner {} | ||
| /** | ||
| * Represents a banner auction winner with asset information. | ||
| * @interface BannerWinner | ||
| * @extends {BaseWinner} | ||
| */ | ||
| interface BannerWinner extends BaseWinner { | ||
| /** | ||
| * The list of available sources for a banner. | ||
| * Only present for banner auction winners. | ||
| * @type {Asset[]} | ||
| * @required | ||
| * @minItems 1 | ||
| */ | ||
| asset: Asset[]; | ||
| } | ||
| /** | ||
| * Union type for all winner types. | ||
| * @typedef {(SponsoredListingWinner|BannerWinner)} Winner | ||
| */ | ||
| type Winner = SponsoredListingWinner | BannerWinner; | ||
| /** | ||
| * Result for a single auction. | ||
@@ -335,2 +367,3 @@ * @interface Result | ||
| * The type of auction result. | ||
| * Discriminator for the result type. | ||
| * @type {AuctionType} | ||
@@ -345,2 +378,4 @@ * @required | ||
| * It may contain fewer or no entries at all if there aren't enough products with usable bids. | ||
| * Winners for listings auctions will be SponsoredListingWinner objects. | ||
| * Winners for banner auctions will be BannerWinner objects with asset information. | ||
| * @type {Winner[]} | ||
@@ -439,2 +474,8 @@ * @required | ||
| resolvedBidId?: string; | ||
| /** | ||
| * Page information describing which page the event occurred on. | ||
| * @type {Page} | ||
| * @optional | ||
| */ | ||
| page?: Page; | ||
| } | ||
@@ -448,2 +489,7 @@ /** | ||
| /** | ||
| * Index signature to allow additional properties. | ||
| * Placement supports additional custom properties beyond the standard fields. | ||
| */ | ||
| [key: string]: any; | ||
| /** | ||
| * An array of IDs of the categories associated to the page in which this event occurred, if applicable. | ||
@@ -529,2 +575,29 @@ * These IDs must match the IDs provided through the catalog service. | ||
| /** | ||
| * Information regarding an organic or non-sponsored event. | ||
| * Describes the type of object that was interacted with. | ||
| * @interface InteractionObject | ||
| */ | ||
| interface InteractionObject { | ||
| /** | ||
| * The type of object that is being reported on the interaction. | ||
| * @type {"listing" | "banner"} | ||
| * @required | ||
| * @example "listing" | ||
| */ | ||
| type: "listing" | "banner"; | ||
| /** | ||
| * When type is `banner`, signals the ID of the asset of the banner. | ||
| * @type {string} | ||
| * @optional | ||
| * @example "asset-123" | ||
| */ | ||
| assetId?: string; | ||
| /** | ||
| * When type is `listing`, signals the specific interaction flavor with the listing. | ||
| * @type {"image" | "add_to_cart" | "purchase_now"} | ||
| * @optional | ||
| */ | ||
| clickType?: "image" | "add_to_cart" | "purchase_now"; | ||
| } | ||
| /** | ||
| * An impression means a promotable has become visible to the consumer. | ||
@@ -564,2 +637,20 @@ * For promoted entities, include the `resolvedBidId` field from the `/v2/auctions` response. | ||
| placement?: Placement; | ||
| /** | ||
| * Information regarding an organic or non-sponsored event. | ||
| * @type {InteractionObject} | ||
| * @optional | ||
| */ | ||
| object?: InteractionObject; | ||
| /** | ||
| * Marketplace provided ID for a campaign. | ||
| * @type {string} | ||
| * @optional | ||
| */ | ||
| externalCampaignId?: string; | ||
| /** | ||
| * Marketplace provided ID for a vendor. | ||
| * @type {string} | ||
| * @optional | ||
| */ | ||
| externalVendorId?: string; | ||
| } | ||
@@ -600,2 +691,26 @@ /** | ||
| placement?: Placement; | ||
| /** | ||
| * Information regarding an organic or non-sponsored event. | ||
| * @type {InteractionObject} | ||
| * @optional | ||
| */ | ||
| object?: InteractionObject; | ||
| /** | ||
| * For sponsored events only, signals the specific interaction flavor with the listing. | ||
| * @type {"image" | "add_to_cart" | "purchase_now"} | ||
| * @optional | ||
| */ | ||
| clickType?: "image" | "add_to_cart" | "purchase_now"; | ||
| /** | ||
| * Marketplace provided ID for a campaign. | ||
| * @type {string} | ||
| * @optional | ||
| */ | ||
| externalCampaignId?: string; | ||
| /** | ||
| * Marketplace provided ID for a vendor. | ||
| * @type {string} | ||
| * @optional | ||
| */ | ||
| externalVendorId?: string; | ||
| } | ||
@@ -832,2 +947,2 @@ /** | ||
| } | ||
| export { TopsortClient, Purchase, Placement, PageView, Page, Item, Impression, EventResult, Event, Entity, DeviceType, Config, Click, ChannelType, AuctionResult, Auction }; | ||
| export { TopsortClient, Purchase, Placement, PageView, Page, Item, InteractionObject, Impression, EventResult, Event, Entity, DeviceType, Config, Click, ChannelType, AuctionResult, Auction }; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| var c="https://api.topsort.com",n={auctions:"v2/auctions",events:"v2/events"};var a="0.3.8";class m{status;statusText;body;retry;constructor(t,r,o,e=!1){this.status=t,this.statusText=r,this.body=o,this.retry=e}}var i=m;class u{async handleResponse(t){let r;if(t.status!==204)r=await t.json();if(!t.ok){let o=t.status===429||t.status>=500;throw new i(t.status,t.statusText,r,o)}return r}async request(t,r){try{let o=this.sanitizeUrl(t),e=await fetch(o,r);return this.handleResponse(e)}catch(o){let e=o instanceof Error?o.message:"Unknown error";throw new i(500,"Internal Server Error",e)}}setupTimeoutSignal(t){if(t.timeout!=null){let r=new AbortController;return setTimeout(()=>r.abort(),t.timeout),r.signal}}async post(t,r,o){let e=this.setupTimeoutSignal(o),h=o.fetchOptions??{keepalive:!0};return this.request(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-UA":o.userAgent?`@topsort/sdk ${a} ${o.userAgent}`:`@topsort/sdk ${a}`,Authorization:`Bearer ${o.apiKey}`},body:JSON.stringify(r),signal:e,...h})}sanitizeUrl(t){try{return new URL(t).href.replace(/\/+$/,"")}catch(r){throw new i(400,"Invalid URL",{error:`Invalid URL: ${r}`})}}}var s=new u;function d(t){if(!t?.apiKey?.length)throw new i(401,"API Key is required.",{})}function p(t){return async(...r)=>{let o=r[r.length-1];return d(o),t(...r)}}async function v(t,r){let o=`${r.host}/${n.auctions}`;return await s.post(o.toString(),t,r)}var f=p(v);async function w(t,r){try{let o=`${r.host}/${n.events}`;return await s.post(o,t,r),{ok:!0,retry:!1}}catch(o){if(o instanceof i&&o.retry)return{ok:!1,retry:!0};throw o}}var l=p(w);class g{config;constructor(t){this.config=t,this.config.host=this.config.host??c}async reportEvent(t){return l(t,this.config)}async createAuction(t){return f(t,this.config)}}var x=g;export{x as TopsortClient}; | ||
| var c="https://api.topsort.com",n={auctions:"v2/auctions",events:"v2/events"};var a="0.3.9";class m{status;statusText;body;retry;constructor(t,r,o,e=!1){this.status=t,this.statusText=r,this.body=o,this.retry=e}}var i=m;class u{async handleResponse(t){let r;if(t.status!==204)r=await t.json();if(!t.ok){let o=t.status===429||t.status>=500;throw new i(t.status,t.statusText,r,o)}return r}async request(t,r){try{let o=this.sanitizeUrl(t),e=await fetch(o,r);return this.handleResponse(e)}catch(o){let e=o instanceof Error?o.message:"Unknown error";throw new i(500,"Internal Server Error",e)}}setupTimeoutSignal(t){if(t.timeout!=null){let r=new AbortController;return setTimeout(()=>r.abort(),t.timeout),r.signal}}async post(t,r,o){let e=this.setupTimeoutSignal(o),h=o.fetchOptions??{keepalive:!0};return this.request(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-UA":o.userAgent?`@topsort/sdk ${a} ${o.userAgent}`:`@topsort/sdk ${a}`,Authorization:`Bearer ${o.apiKey}`},body:JSON.stringify(r),signal:e,...h})}sanitizeUrl(t){try{return new URL(t).href.replace(/\/+$/,"")}catch(r){throw new i(400,"Invalid URL",{error:`Invalid URL: ${r}`})}}}var s=new u;function d(t){if(!t?.apiKey?.length)throw new i(401,"API Key is required.",{})}function p(t){return async(...r)=>{let o=r[r.length-1];return d(o),t(...r)}}async function v(t,r){let o=`${r.host}/${n.auctions}`;return await s.post(o.toString(),t,r)}var f=p(v);async function w(t,r){try{let o=`${r.host}/${n.events}`;return await s.post(o,t,r),{ok:!0,retry:!1}}catch(o){if(o instanceof i&&o.retry)return{ok:!1,retry:!0};throw o}}var l=p(w);class g{config;constructor(t){this.config=t,this.config.host=this.config.host??c}async reportEvent(t){return l(t,this.config)}async createAuction(t){return f(t,this.config)}}var x=g;export{x as TopsortClient}; |
+7
-7
| { | ||
| "name": "@topsort/sdk", | ||
| "version": "0.3.8", | ||
| "version": "0.3.9", | ||
| "description": "The official Topsort SDK for TypeScript and JavaScript", | ||
| "packageManager": "bun@1.3.1", | ||
| "packageManager": "bun@1.3.3", | ||
| "main": "dist/index.cjs", | ||
@@ -50,8 +50,8 @@ "module": "dist/index.js", | ||
| "devDependencies": { | ||
| "@biomejs/biome": "2.3.3", | ||
| "@biomejs/biome": "2.3.7", | ||
| "@playwright/test": "1.56.1", | ||
| "@types/bun": "1.3.1", | ||
| "bunup": "0.15.12", | ||
| "lefthook": "2.0.2", | ||
| "msw": "2.11.2", | ||
| "@types/bun": "1.3.3", | ||
| "bunup": "0.16.10", | ||
| "lefthook": "2.0.4", | ||
| "msw": "2.12.3", | ||
| "typescript": "5.9.3" | ||
@@ -58,0 +58,0 @@ }, |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
41068
8.33%954
13.71%4
-20%