@getspot/spot-widget 0.1.4 → 0.2.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @getspot/spot-widget@0.1.4 build /builds/getspot/spot-widget/packages/core
2
+ > @getspot/spot-widget@0.2.0 build /builds/getspot/spot-widget/packages/core
3
3
  > vite build
4
4
 
5
5
  The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
@@ -8,6 +8,6 @@ transforming...
8
8
  ✓ 5 modules transformed.
9
9
  rendering chunks...
10
10
  computing gzip size...
11
- dist/index.umd.js 22.00 kB │ gzip: 7.06 kB
12
- dist/index.es.js 24.07 kB │ gzip: 7.30 kB
13
- ✓ built in 152ms
11
+ dist/index.umd.js 22.08 kB │ gzip: 7.07 kB
12
+ dist/index.es.js 24.17 kB │ gzip: 7.31 kB
13
+ ✓ built in 149ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @getspot/spot-widget
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 25bba43: Making cartId required on quoteRequest
8
+
3
9
  ## 0.1.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.es.js CHANGED
@@ -48,6 +48,7 @@ function _(s) {
48
48
  "productDuration",
49
49
  "productPrice",
50
50
  "productId",
51
+ "cartId",
51
52
  "productName"
52
53
  ].forEach((c) => {
53
54
  if (!Object.prototype.hasOwnProperty.call(t, c) || t[c] === void 0 || t[c] === null)
@@ -82,6 +83,8 @@ function _(s) {
82
83
  throw new Error("productPrice must be a valid number");
83
84
  if (typeof t.productId != "string")
84
85
  throw new Error("productId must be a string");
86
+ if (typeof t.cartId != "string")
87
+ throw new Error("cartId must be a string");
85
88
  if (typeof t.productName != "string")
86
89
  throw new Error("productName must be a string");
87
90
  if ([
@@ -217,7 +220,7 @@ const q = {
217
220
  sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
218
221
  production: "https://api.getspot.com/api/v1/quote"
219
222
  };
220
- class M {
223
+ class I {
221
224
  constructor(e = {}) {
222
225
  this.options = {
223
226
  location: "body",
@@ -332,5 +335,5 @@ class M {
332
335
  }
333
336
  }
334
337
  export {
335
- M as default
338
+ I as default
336
339
  };
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(f,m){typeof exports=="object"&&typeof module<"u"?module.exports=m():typeof define=="function"&&define.amd?define(m):(f=typeof globalThis<"u"?globalThis:f||self,f.SpotWidget=m())})(this,function(){"use strict";async function f(s,e,t){try{const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(t)}),n=await o.json();if(!o.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=o.status,r.responseBody=n,r}return n}catch(o){throw o instanceof Error?o:new Error("Unknown error occurred while fetching quote")}}const m={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote"};function _(s){const{apiConfig:e={},quoteRequestData:t,callbacks:o={},location:n,theme:r}=s,{environment:a="sandbox",partnerId:p,endpoint:l}=e;if(!p||typeof p!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(l||m[a]))throw new Error(`Invalid environment in apiConfig: ${a}`);if(!t||typeof t!="object")throw new Error("quoteRequestData must be a non-null object");["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","productName"].forEach(c=>{if(!Object.prototype.hasOwnProperty.call(t,c)||t[c]===void 0||t[c]===null)throw new Error(`Missing required quoteRequestData field: '${c}'`)});const h=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!h.test(t.startDate))throw new Error("startDate must be a valid ISO8601 string");if(!h.test(t.endDate))throw new Error("endDate must be a valid ISO8601 string");if(typeof t.currencyCode!="string")throw new Error("currencyCode must be a string");if(!["USD","CAD","AUD"].includes(t.currencyCode))throw new Error(`Invalid currency code: ${t.currencyCode}`);if(typeof t.eventType!="string")throw new Error("eventType must be a string");if(typeof t.productType!="string")throw new Error("productType must be a string");const g=["Pass","Trip","Registration"];if(!g.includes(t.productType))throw new Error(`productType must be one of ${g.join(", ")}`);if(typeof t.productDuration!="string")throw new Error("productDuration must be a string");const b=["Daily","Seasonal","Trip","Event"];if(!b.includes(t.productDuration))throw new Error(`productDuration must be one of ${b.join(", ")}`);if(typeof t.productPrice!="number"||isNaN(t.productPrice))throw new Error("productPrice must be a valid number");if(typeof t.productId!="string")throw new Error("productId must be a string");if(typeof t.productName!="string")throw new Error("productName must be a string");if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const w=o[c];if(w&&typeof w!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof n=="string"&&!document.querySelector(n))throw new Error(`Invalid location selector: '${n}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function i(s,{text:e,className:t,parent:o,innerHTML:n}={}){const r=document.createElement(s);return t&&(r.className=t),e!=null&&(r.textContent=e),n!=null&&(r.innerHTML=n),o&&o.appendChild(r),r}function y(s,{name:e,description:t}){i("div",{className:"spot-header__title",text:e,parent:s}),i("div",{className:"spot-header__description",text:t,parent:s})}function C(s,e=[]){const t=i("ul",{className:"spot-benefits__list",parent:s});e.forEach(o=>{const n=i("li",{parent:t});n.innerHTML=`
1
+ (function(f,m){typeof exports=="object"&&typeof module<"u"?module.exports=m():typeof define=="function"&&define.amd?define(m):(f=typeof globalThis<"u"?globalThis:f||self,f.SpotWidget=m())})(this,function(){"use strict";async function f(s,e,t){try{const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(t)}),n=await o.json();if(!o.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=o.status,r.responseBody=n,r}return n}catch(o){throw o instanceof Error?o:new Error("Unknown error occurred while fetching quote")}}const m={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote"};function _(s){const{apiConfig:e={},quoteRequestData:t,callbacks:o={},location:n,theme:r}=s,{environment:a="sandbox",partnerId:p,endpoint:l}=e;if(!p||typeof p!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(l||m[a]))throw new Error(`Invalid environment in apiConfig: ${a}`);if(!t||typeof t!="object")throw new Error("quoteRequestData must be a non-null object");["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"].forEach(c=>{if(!Object.prototype.hasOwnProperty.call(t,c)||t[c]===void 0||t[c]===null)throw new Error(`Missing required quoteRequestData field: '${c}'`)});const h=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!h.test(t.startDate))throw new Error("startDate must be a valid ISO8601 string");if(!h.test(t.endDate))throw new Error("endDate must be a valid ISO8601 string");if(typeof t.currencyCode!="string")throw new Error("currencyCode must be a string");if(!["USD","CAD","AUD"].includes(t.currencyCode))throw new Error(`Invalid currency code: ${t.currencyCode}`);if(typeof t.eventType!="string")throw new Error("eventType must be a string");if(typeof t.productType!="string")throw new Error("productType must be a string");const g=["Pass","Trip","Registration"];if(!g.includes(t.productType))throw new Error(`productType must be one of ${g.join(", ")}`);if(typeof t.productDuration!="string")throw new Error("productDuration must be a string");const b=["Daily","Seasonal","Trip","Event"];if(!b.includes(t.productDuration))throw new Error(`productDuration must be one of ${b.join(", ")}`);if(typeof t.productPrice!="number"||isNaN(t.productPrice))throw new Error("productPrice must be a valid number");if(typeof t.productId!="string")throw new Error("productId must be a string");if(typeof t.cartId!="string")throw new Error("cartId must be a string");if(typeof t.productName!="string")throw new Error("productName must be a string");if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const w=o[c];if(w&&typeof w!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof n=="string"&&!document.querySelector(n))throw new Error(`Invalid location selector: '${n}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function i(s,{text:e,className:t,parent:o,innerHTML:n}={}){const r=document.createElement(s);return t&&(r.className=t),e!=null&&(r.textContent=e),n!=null&&(r.innerHTML=n),o&&o.appendChild(r),r}function y(s,{name:e,description:t}){i("div",{className:"spot-header__title",text:e,parent:s}),i("div",{className:"spot-header__description",text:t,parent:s})}function C(s,e=[]){const t=i("ul",{className:"spot-benefits__list",parent:s});e.forEach(o=>{const n=i("li",{parent:t});n.innerHTML=`
2
2
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
3
3
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
4
4
  stroke="#2E2E2E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -41,6 +41,7 @@ export function validateOptions(options) {
41
41
  "productDuration",
42
42
  "productPrice",
43
43
  "productId",
44
+ "cartId",
44
45
  "productName",
45
46
  ];
46
47
 
@@ -108,6 +109,10 @@ export function validateOptions(options) {
108
109
  throw new Error("productId must be a string");
109
110
  }
110
111
 
112
+ if (typeof quoteRequestData.cartId !== "string") {
113
+ throw new Error("cartId must be a string");
114
+ }
115
+
111
116
  if (typeof quoteRequestData.productName !== "string") {
112
117
  throw new Error("productName must be a string");
113
118
  }