@sellout/utils 0.0.384 → 1.0.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.
Files changed (76) hide show
  1. package/{src/CSV.ts → CSV.ts} +1 -1
  2. package/{src/GoogleTimezoneAPI.ts → GoogleTimezoneAPI.ts} +1 -1
  3. package/{src/IPStack.ts → IPStack.ts} +1 -2
  4. package/MongoConnectionManager.ts +49 -0
  5. package/package.json +4 -17
  6. package/price.ts +5 -0
  7. package/query.ts +31 -0
  8. package/time.ts +33 -0
  9. package/wait.ts +5 -0
  10. package/.dist/CSV.d.ts +0 -1
  11. package/.dist/CSV.js +0 -24
  12. package/.dist/CSV.js.map +0 -1
  13. package/.dist/ClientTrackingUtil.d.ts +0 -9
  14. package/.dist/ClientTrackingUtil.js +0 -37
  15. package/.dist/ClientTrackingUtil.js.map +0 -1
  16. package/.dist/FacebookUtil.d.ts +0 -8
  17. package/.dist/FacebookUtil.js +0 -77
  18. package/.dist/FacebookUtil.js.map +0 -1
  19. package/.dist/GoogleTimezoneAPI.d.ts +0 -1
  20. package/.dist/GoogleTimezoneAPI.js +0 -27
  21. package/.dist/GoogleTimezoneAPI.js.map +0 -1
  22. package/.dist/GoogleUtil.d.ts +0 -8
  23. package/.dist/GoogleUtil.js +0 -91
  24. package/.dist/GoogleUtil.js.map +0 -1
  25. package/.dist/IPStack.d.ts +0 -1
  26. package/.dist/IPStack.js +0 -36
  27. package/.dist/IPStack.js.map +0 -1
  28. package/.dist/ImageUtil.d.ts +0 -15
  29. package/.dist/ImageUtil.js +0 -26
  30. package/.dist/ImageUtil.js.map +0 -1
  31. package/.dist/ReduxUtil.d.ts +0 -1
  32. package/.dist/ReduxUtil.js +0 -11
  33. package/.dist/ReduxUtil.js.map +0 -1
  34. package/.dist/UrlUtil.d.ts +0 -4
  35. package/.dist/UrlUtil.js +0 -33
  36. package/.dist/UrlUtil.js.map +0 -1
  37. package/.dist/env.d.ts +0 -5
  38. package/.dist/env.js +0 -9
  39. package/.dist/env.js.map +0 -1
  40. package/.dist/formatPhoneNumber.d.ts +0 -1
  41. package/.dist/formatPhoneNumber.js +0 -23
  42. package/.dist/formatPhoneNumber.js.map +0 -1
  43. package/.dist/percentage.d.ts +0 -1
  44. package/.dist/percentage.js +0 -23
  45. package/.dist/percentage.js.map +0 -1
  46. package/.dist/price.d.ts +0 -3
  47. package/.dist/price.js +0 -58
  48. package/.dist/price.js.map +0 -1
  49. package/.dist/random.d.ts +0 -1
  50. package/.dist/random.js +0 -8
  51. package/.dist/random.js.map +0 -1
  52. package/.dist/time.d.ts +0 -38
  53. package/.dist/time.js +0 -175
  54. package/.dist/time.js.map +0 -1
  55. package/.dist/url.d.ts +0 -4
  56. package/.dist/url.js +0 -65
  57. package/.dist/url.js.map +0 -1
  58. package/.dist/wait.d.ts +0 -2
  59. package/.dist/wait.js +0 -40
  60. package/.dist/wait.js.map +0 -1
  61. package/src/ClientTrackingUtil.ts +0 -44
  62. package/src/FacebookUtil.ts +0 -63
  63. package/src/GoogleUtil.ts +0 -81
  64. package/src/ImageUtil.ts +0 -27
  65. package/src/ReduxUtil.ts +0 -9
  66. package/src/UrlUtil.ts +0 -38
  67. package/src/env.ts +0 -5
  68. package/src/percentage.ts +0 -21
  69. package/src/price.ts +0 -64
  70. package/src/time.ts +0 -168
  71. package/src/url.ts +0 -73
  72. package/src/wait.ts +0 -24
  73. package/tsconfig.json +0 -27
  74. package/tslint.json +0 -21
  75. /package/{src/formatPhoneNumber.ts → formatPhoneNumber.ts} +0 -0
  76. /package/{src/random.ts → random.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { AsyncParser } from 'json2csv';
2
2
 
3
- export function fromJson(fields: any[], data: object): Promise<string> {
3
+ export function fromJson(fields: string[], data: object): Promise<string> {
4
4
  return new Promise((resolve, reject) => {
5
5
  const json = JSON.stringify(data);
6
6
  const opts = { fields };
@@ -2,7 +2,7 @@ import * as Time from './time';
2
2
  import * as request from 'request-promise-native';
3
3
  import {
4
4
  GOOGLE_TIMEZONE_API_KEY
5
- } from './env';
5
+ } from './../env';
6
6
 
7
7
  export async function info(lat, lng): Promise<any> {
8
8
  const baseUrl = 'https://maps.googleapis.com/maps/api/timezone/json';
@@ -2,12 +2,11 @@ import * as request from 'request-promise-native';
2
2
  import {
3
3
  IP_STACK_API_KEY,
4
4
  LOAD_TEST_ENABLED,
5
- } from "./env";
5
+ } from "./../env";
6
6
 
7
7
  export async function gecodeIPAddress(ipAddress) {
8
8
  // Return mock data for load testing
9
9
  if(LOAD_TEST_ENABLED) {
10
- console.log('LOAD_TEST_ENABLED=true');
11
10
  return {
12
11
  city: 'Polson',
13
12
  region_code: 'MT',
@@ -0,0 +1,49 @@
1
+ import wait from './wait';
2
+
3
+ export default class MongoConnectionManager {
4
+ public connected: boolean;
5
+ public mongoConnectionString: string;
6
+ public isReplicaSet: boolean;
7
+ private mongoose: any;
8
+ private mongoConnectionStringInternal: string;
9
+
10
+ constructor(mongoose: any, mongoConnectionString: string, username: string = '', password: string = '') {
11
+ const parsed = new URL(mongoConnectionString);
12
+
13
+ parsed.username = username;
14
+ parsed.password = password;
15
+ parsed.pathname = '/admin';
16
+
17
+ this.connected = false;
18
+ this.mongoConnectionStringInternal = parsed.toString();
19
+ this.isReplicaSet = parsed.protocol === 'mongodb+srv:';
20
+
21
+ // redact username/password from publicly available connection string
22
+ parsed.username = '__user__';
23
+ parsed.password = '__pass__';
24
+ this.mongoConnectionString = parsed.toString();
25
+ this.mongoose = mongoose;
26
+ }
27
+
28
+ public async connect() {
29
+ while(!this.connected) {
30
+ console.log('Attempting to connect to Mongo...');
31
+ this.mongoose.connect(this.mongoConnectionStringInternal, {
32
+ ssl: false,
33
+ useUnifiedTopology: true,
34
+ useNewUrlParser: true,
35
+ })
36
+ .then(() => {
37
+ this.connected = true;
38
+ console.log(`Connected to MongoDB: ${this.mongoConnectionString}`);
39
+ })
40
+ .catch((e: any) => {
41
+ console.error(`There was an error connecting to MongoDB: ${this.mongoConnectionString}`);
42
+ console.error(e);
43
+ });
44
+
45
+ // wait five seconds before trying again
46
+ await wait(5000);
47
+ }
48
+ }
49
+ }
package/package.json CHANGED
@@ -1,28 +1,15 @@
1
1
  {
2
2
  "name": "@sellout/utils",
3
- "version": "0.0.384",
3
+ "version": "1.0.0",
4
4
  "description": "Sellout.io utils",
5
+ "main": "index.js",
5
6
  "scripts": {
6
- "prepare": "npm run build",
7
- "build": "tsc --project .",
8
- "start": "nodemon --watch src -e json,js,ts -x \"npm run build\""
7
+ "test": "echo \"Error: no test specified\" && exit 1"
9
8
  },
10
9
  "repository": {
11
10
  "type": "git",
12
11
  "url": "www.github.com/sellout-tickets/sellout/commmon/utils"
13
12
  },
14
13
  "author": "samheutmaker@gmail.com",
15
- "license": "MIT",
16
- "dependencies": {
17
- "json2csv": "^5.0.7",
18
- "moment-timezone": "^0.5.33",
19
- "request": "^2.88.2",
20
- "request-promise-native": "^1.0.8"
21
- },
22
- "devDependencies": {
23
- "@types/node": "^20.11.19",
24
- "nodemon": "^2.0.22",
25
- "typescript": "^4.4.2"
26
- },
27
- "gitHead": "1cbafa1999f5f1f90bf6c4fa934d2b6e0278a3de"
14
+ "license": "MIT"
28
15
  }
package/price.ts ADDED
@@ -0,0 +1,5 @@
1
+ export const output = (price: number): string => {
2
+ price = price / 100;
3
+ return price.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
4
+ // return `$${price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`;
5
+ };
package/query.ts ADDED
@@ -0,0 +1,31 @@
1
+ export interface IQuery {
2
+ any: string;
3
+ userId: string;
4
+ eventId: string;
5
+ artistId: string;
6
+ venueId: string;
7
+ startDate: number;
8
+ endDate: number;
9
+ }
10
+
11
+ export interface IPbQuery {
12
+ key: string;
13
+ value: any;
14
+ }
15
+
16
+ export function toPb(query: object): IPbQuery[] {
17
+ let pbQuery: IPbQuery[] = Object.keys(query).reduce((cur, key) => {
18
+ if (!query[key]) return cur;
19
+ cur.push({ key: key, value: query[key] } as IPbQuery);
20
+ return cur;
21
+ }, [] as IPbQuery[]);
22
+
23
+ return pbQuery;
24
+ }
25
+
26
+ export function fromPb(query: IPbQuery[]): IQuery {
27
+ return query.reduce((c, n) => {
28
+ c[n.key] = n.value;
29
+ return c;
30
+ }, {} as IQuery);
31
+ }
package/time.ts ADDED
@@ -0,0 +1,33 @@
1
+ import * as moment from 'moment-timezone';
2
+
3
+ export const SECOND = 1000;
4
+ export const MINUTE = 60 * SECOND;
5
+ export const HOUR = 60 * MINUTE;
6
+ export const DAY = 24 * HOUR;
7
+
8
+ export const now = function(): number {
9
+ const millis = Date.now();
10
+ const seconds = millis / 1000;
11
+ return Math.floor(seconds);
12
+ };
13
+
14
+ export const date = function(seconds?: number): any {
15
+ if(!seconds) return new Date();
16
+ const millis = seconds * 1000;
17
+ return new Date(millis);
18
+ }
19
+
20
+ export const fromDate = function(millis: number | string): number {
21
+ return Math.floor(new Date(millis).getTime() / 1000);
22
+ }
23
+
24
+ // Use this one, it's better
25
+ export const format = function(secondsSinceEpoch, format = 'M/DD/YYYY h:mma', timezone: string = 'America/Denver' ) {
26
+ if(!timezone) timezone = 'America/Denver';
27
+ const millis = date(secondsSinceEpoch);
28
+ return moment(millis).tz(timezone).format(format);
29
+ }
30
+
31
+ export const formatTimeOfDay = function (secondsSinceEpoch, timezone?: string) {
32
+ return format(secondsSinceEpoch, 'h:mma', timezone);
33
+ }
package/wait.ts ADDED
@@ -0,0 +1,5 @@
1
+ export default function wait(timeoutMs: number, value: any = null): Promise<any> {
2
+ return new Promise((resolve) => {
3
+ setTimeout(() => resolve(value), timeoutMs);
4
+ });
5
+ }
package/.dist/CSV.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function fromJson(fields: any[], data: object): Promise<string>;
package/.dist/CSV.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromJson = void 0;
4
- const json2csv_1 = require("json2csv");
5
- function fromJson(fields, data) {
6
- return new Promise((resolve, reject) => {
7
- const json = JSON.stringify(data);
8
- const opts = { fields };
9
- const transformOpts = {};
10
- const asyncParser = new json2csv_1.AsyncParser(opts, transformOpts);
11
- let csv = '';
12
- asyncParser.processor
13
- .on('data', chunk => {
14
- // console.log(chunk.toString());
15
- csv += chunk.toString();
16
- })
17
- .on('end', () => resolve(csv))
18
- .on('error', err => reject(err));
19
- asyncParser.input.push(json);
20
- asyncParser.input.push(null);
21
- });
22
- }
23
- exports.fromJson = fromJson;
24
- //# sourceMappingURL=CSV.js.map
package/.dist/CSV.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"CSV.js","sourceRoot":"","sources":["../src/CSV.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAEvC,SAAgB,QAAQ,CAAC,MAAa,EAAE,IAAY;IAClD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;QACxB,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,MAAM,WAAW,GAAG,IAAI,sBAAW,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAEzD,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,SAAS;aAClB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;YAClB,iCAAiC;YACjC,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,CAAC,CAAC;aACD,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aAC7B,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAEnC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,4BAmBC"}
@@ -1,9 +0,0 @@
1
- export declare enum ClientTrackingEventTypes {
2
- Purchase = "Purchase"
3
- }
4
- export interface IClientTrackingIds {
5
- googleAnalyticsId?: string;
6
- facebookPixelId?: string;
7
- }
8
- export declare function initialize(clientTrackingIds: IClientTrackingIds): void;
9
- export declare function track(type: ClientTrackingEventTypes, params: any): void | null;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.track = exports.initialize = exports.ClientTrackingEventTypes = void 0;
4
- const GoogleUtil = require("./GoogleUtil");
5
- const FacebookUtil = require("./FacebookUtil");
6
- var ClientTrackingEventTypes;
7
- (function (ClientTrackingEventTypes) {
8
- ClientTrackingEventTypes["Purchase"] = "Purchase";
9
- })(ClientTrackingEventTypes = exports.ClientTrackingEventTypes || (exports.ClientTrackingEventTypes = {}));
10
- ;
11
- function initialize(clientTrackingIds) {
12
- GoogleUtil.initialize(clientTrackingIds.googleAnalyticsId);
13
- FacebookUtil.initialize(clientTrackingIds.facebookPixelId);
14
- }
15
- exports.initialize = initialize;
16
- function track(type, params) {
17
- switch (type) {
18
- case ClientTrackingEventTypes.Purchase:
19
- return trackPurchase(params);
20
- default:
21
- return null;
22
- }
23
- }
24
- exports.track = track;
25
- function trackPurchase({ order, orderTotal, channel, currency = 'USD', }) {
26
- GoogleUtil.track('event', 'purchase', {
27
- transaction_id: order._id,
28
- value: orderTotal / 100,
29
- affiliation: channel,
30
- currency,
31
- });
32
- FacebookUtil.track('track', 'Purchase', {
33
- value: orderTotal / 100,
34
- currency,
35
- });
36
- }
37
- //# sourceMappingURL=ClientTrackingUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClientTrackingUtil.js","sourceRoot":"","sources":["../src/ClientTrackingUtil.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAC3C,+CAA+C;AAE/C,IAAY,wBAEX;AAFD,WAAY,wBAAwB;IAClC,iDAAqB,CAAA;AACvB,CAAC,EAFW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAEnC;AAAA,CAAC;AAOF,SAAgB,UAAU,CAAC,iBAAqC;IAC9D,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC3D,YAAY,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAC7D,CAAC;AAHD,gCAGC;AAED,SAAgB,KAAK,CAAC,IAA8B,EAAE,MAAW;IAC/D,QAAQ,IAAI,EAAE;QACZ,KAAK,wBAAwB,CAAC,QAAQ;YACpC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/B;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC;AAPD,sBAOC;AAED,SAAS,aAAa,CAAC,EACrB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAQ,GAAG,KAAK,GACjB;IACC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;QACpC,cAAc,EAAE,KAAK,CAAC,GAAG;QACzB,KAAK,EAAE,UAAU,GAAG,GAAG;QACvB,WAAW,EAAE,OAAO;QACpB,QAAQ;KACT,CAAC,CAAC;IAEH,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;QACtC,KAAK,EAAE,UAAU,GAAG,GAAG;QACvB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
@@ -1,8 +0,0 @@
1
- /****************************************************************************************
2
- Initialization
3
- ****************************************************************************************/
4
- export declare function initialize(facebookPixelId?: string | null): void;
5
- /****************************************************************************************
6
- Tracking
7
- ****************************************************************************************/
8
- export declare function track(type: string, action: string, params: object): Promise<void>;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.track = exports.initialize = void 0;
13
- const Wait = require("./wait");
14
- const SELLOUT_FACEBOOK_PIXEL_ID = '205397967210775';
15
- function waitForPixel() {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- return yield Wait.forTrue(() => Boolean(window.fbq));
18
- });
19
- }
20
- /****************************************************************************************
21
- Initialization
22
- ****************************************************************************************/
23
- function initialize(facebookPixelId) {
24
- try {
25
- injectPixel(SELLOUT_FACEBOOK_PIXEL_ID);
26
- if (facebookPixelId) {
27
- injectPixel(facebookPixelId);
28
- }
29
- else {
30
- console.log('Facebook Pixel not configured');
31
- }
32
- }
33
- catch (e) {
34
- console.error('Failed to inject Facebook Pixel');
35
- console.error(e);
36
- }
37
- }
38
- exports.initialize = initialize;
39
- function injectPixel(facebookPixelId) {
40
- const headCode = `
41
- < !--Facebook Pixel Code-- >
42
- <script>
43
- !function(f,b,e,v,n,t,s)
44
- {if(f.fbq)return;n=f.fbq=function(){n.callMethod ?
45
- n.callMethod.apply(n, arguments) : n.queue.push(arguments)};
46
- if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
47
- n.queue=[];t=b.createElement(e);t.async=!0;
48
- t.src=v;s=b.getElementsByTagName(e)[0];
49
- s.parentNode.insertBefore(t,s)}(window, document,'script',
50
- 'https://connect.facebook.net/en_US/fbevents.js');
51
- fbq('init', '${facebookPixelId}');
52
- fbq('track', 'PageView');
53
- </script>
54
- <noscript><img height="1" width="1" style="display:none"
55
- src="https://www.facebook.com/tr?id=${facebookPixelId}&ev=PageView&noscript=1"
56
- /></noscript>
57
- <!--End Facebook Pixel Code-- >
58
- `;
59
- const headScript = document.createRange().createContextualFragment(headCode);
60
- document.head.prepend(headScript);
61
- }
62
- /****************************************************************************************
63
- Tracking
64
- ****************************************************************************************/
65
- function track(type, action, params) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- try {
68
- yield waitForPixel();
69
- window.fbq(type, action, params);
70
- }
71
- catch (e) {
72
- console.error('Facebook Pixel failed to track event');
73
- }
74
- });
75
- }
76
- exports.track = track;
77
- //# sourceMappingURL=FacebookUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FacebookUtil.js","sourceRoot":"","sources":["../src/FacebookUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAE/B,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAEpD,SAAe,YAAY;;QACzB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;CAAA;AAED;;yFAEyF;AAEzF,SAAgB,UAAU,CAAC,eAA+B;IACxD,IAAI;QACF,WAAW,CAAC,yBAAyB,CAAC,CAAC;QACvC,IAAI,eAAe,EAAE;YACnB,WAAW,CAAC,eAAe,CAAC,CAAC;SAC9B;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;SAC9C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAClB;AACH,CAAC;AAZD,gCAYC;AAED,SAAS,WAAW,CAAC,eAAuB;IAC1C,MAAM,QAAQ,GAAG;;;;;;;;;;;mBAWA,eAAe;;;;4CAIU,eAAe;;;GAGxD,CAAC;IAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC;AAED;;yFAEyF;AAEzF,SAAsB,KAAK,CAAC,IAAY,EAAE,MAAc,EAAE,MAAc;;QACtE,IAAI;YACF,MAAM,YAAY,EAAE,CAAC;YACpB,MAAc,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACvD;IACH,CAAC;CAAA;AAPD,sBAOC"}
@@ -1 +0,0 @@
1
- export declare function info(lat: any, lng: any): Promise<any>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.info = void 0;
13
- const Time = require("./time");
14
- const request = require("request-promise-native");
15
- const env_1 = require("./env");
16
- function info(lat, lng) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const baseUrl = 'https://maps.googleapis.com/maps/api/timezone/json';
19
- const url = `${baseUrl}?location=${lat},${lng}&timestamp=${Time.now()}&key=${env_1.GOOGLE_TIMEZONE_API_KEY}`;
20
- const response = yield request.get(url, {
21
- json: true
22
- });
23
- return response;
24
- });
25
- }
26
- exports.info = info;
27
- //# sourceMappingURL=GoogleTimezoneAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GoogleTimezoneAPI.js","sourceRoot":"","sources":["../src/GoogleTimezoneAPI.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,kDAAkD;AAClD,+BAEe;AAEf,SAAsB,IAAI,CAAC,GAAG,EAAE,GAAG;;QACjC,MAAM,OAAO,GAAG,oDAAoD,CAAC;QACrE,MAAM,GAAG,GAAG,GAAG,OAAO,aAAa,GAAG,IAAI,GAAG,cAAc,IAAI,CAAC,GAAG,EAAE,QAAQ,6BAAuB,EAAE,CAAC;QACvG,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;YACtC,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAPD,oBAOC"}
@@ -1,8 +0,0 @@
1
- /****************************************************************************************
2
- Initialization
3
- ****************************************************************************************/
4
- export declare function initialize(googleAnalyticsId?: string | null): void;
5
- /****************************************************************************************
6
- Tracking
7
- ****************************************************************************************/
8
- export declare function track(type: string, action: string, params: object): Promise<void>;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.track = exports.initialize = void 0;
13
- const Wait = require("./wait");
14
- const env_1 = require("./env");
15
- const SELLOUT_GOOGLE_ANALYTICS_ID = 'UA-112750612-5';
16
- function waitForGTag() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- return yield Wait.forTrue(() => Boolean(window.gtag));
19
- });
20
- }
21
- /****************************************************************************************
22
- Initialization
23
- ****************************************************************************************/
24
- function initialize(googleAnalyticsId) {
25
- try {
26
- injectGoogleAnalytics(SELLOUT_GOOGLE_ANALYTICS_ID);
27
- injectGoogleTagManager(env_1.SELLOUT_GOOGLE_TAG_ID);
28
- if (googleAnalyticsId) {
29
- injectGoogleAnalytics(googleAnalyticsId);
30
- }
31
- else {
32
- console.log('Google Analytics not configured');
33
- }
34
- }
35
- catch (e) {
36
- console.error('Failed to inject Google Analaytics');
37
- console.error(e);
38
- }
39
- }
40
- exports.initialize = initialize;
41
- function injectGoogleAnalytics(googleAnalyticsId) {
42
- const headCode = `
43
- < !--Global site tag(gtag.js) - Google Analytics-- >
44
- <script async src="https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}"></script>
45
- <script>
46
- window.dataLayer = window.dataLayer || [];
47
- function gtag(){dataLayer.push(arguments);}
48
- gtag('js', new Date());
49
- gtag('config', '${googleAnalyticsId}');
50
- </script>
51
- `;
52
- const headScript = document.createRange().createContextualFragment(headCode);
53
- document.head.prepend(headScript);
54
- }
55
- function injectGoogleTagManager(googleTagManagerAccountId) {
56
- const headCode = `
57
- <!-- Google Tag Manager -->
58
- <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
59
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
60
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
61
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
62
- })(window,document,'script','dataLayer','${googleTagManagerAccountId}');</script>
63
- <!-- End Google Tag Manager -->
64
- `;
65
- const headScript = document.createRange().createContextualFragment(headCode);
66
- document.head.prepend(headScript);
67
- const bodyCode = `
68
- <!-- Google Tag Manager (noscript) -->
69
- <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${googleTagManagerAccountId}"
70
- height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
71
- <!-- End Google Tag Manager (noscript) -->
72
- `;
73
- const bodyScript = document.createRange().createContextualFragment(bodyCode);
74
- document.body.prepend(bodyScript);
75
- }
76
- /****************************************************************************************
77
- Tracking
78
- ****************************************************************************************/
79
- function track(type, action, params) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- try {
82
- yield waitForGTag();
83
- window.gtag(type, action, params);
84
- }
85
- catch (e) {
86
- console.error('Google Analytics failed to track event');
87
- }
88
- });
89
- }
90
- exports.track = track;
91
- //# sourceMappingURL=GoogleUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GoogleUtil.js","sourceRoot":"","sources":["../src/GoogleUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,+BAA4C;AAE5C,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;AAErD,SAAe,WAAW;;QACxB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;CAAA;AAED;;yFAEyF;AAEzF,SAAgB,UAAU,CAAC,iBAAiC;IAC1D,IAAI;QACF,qBAAqB,CAAC,2BAA2B,CAAC,CAAC;QACnD,sBAAsB,CAAC,2BAAqB,CAAC,CAAC;QAC9C,IAAI,iBAAiB,EAAE;YACrB,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;SAC1C;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;SAChD;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAClB;AACH,CAAC;AAbD,gCAaC;AAED,SAAS,qBAAqB,CAAC,iBAAyB;IACtD,MAAM,QAAQ,GAAG;;qEAEkD,iBAAiB;;;;;wBAK9D,iBAAiB;;GAEtC,CAAC;IAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,sBAAsB,CAAC,yBAAiC;IAC/D,MAAM,QAAQ,GAAG;;;;;;iDAM8B,yBAAyB;;KAErE,CAAC;IAEJ,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAG;;yEAEsD,yBAAyB;;;GAG/F,CAAC;IAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC;AAED;;yFAEyF;AAEzF,SAAsB,KAAK,CAAC,IAAY,EAAE,MAAc,EAAE,MAAc;;QACtE,IAAI;YACF,MAAM,WAAW,EAAE,CAAC;YACnB,MAAc,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;SACzD;IACH,CAAC;CAAA;AAPD,sBAOC"}
@@ -1 +0,0 @@
1
- export declare function gecodeIPAddress(ipAddress: any): Promise<any>;
package/.dist/IPStack.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.gecodeIPAddress = void 0;
13
- const request = require("request-promise-native");
14
- const env_1 = require("./env");
15
- function gecodeIPAddress(ipAddress) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- // Return mock data for load testing
18
- if (env_1.LOAD_TEST_ENABLED) {
19
- console.log('LOAD_TEST_ENABLED=true');
20
- return {
21
- city: 'Polson',
22
- region_code: 'MT',
23
- zip: '59860',
24
- country_code: 'US',
25
- latitude: 47.6932,
26
- longitude: 114.1631
27
- };
28
- }
29
- const url = `http://api.ipstack.com/${ipAddress}?access_key=${env_1.IP_STACK_API_KEY}`;
30
- return yield request.get(url, {
31
- json: true
32
- });
33
- });
34
- }
35
- exports.gecodeIPAddress = gecodeIPAddress;
36
- //# sourceMappingURL=IPStack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IPStack.js","sourceRoot":"","sources":["../src/IPStack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAkD;AAClD,+BAGe;AAEf,SAAsB,eAAe,CAAC,SAAS;;QAC7C,oCAAoC;QACpC,IAAG,uBAAiB,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;YACtC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI;gBACjB,GAAG,EAAE,OAAO;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAE,QAAQ;aACpB,CAAC;SACH;QAED,MAAM,GAAG,GAAG,0BAA0B,SAAS,eAAe,sBAAgB,EAAE,CAAC;QACjF,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;YAC5B,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;CAAA;AAlBD,0CAkBC"}
@@ -1,15 +0,0 @@
1
- export declare enum ImageSize {
2
- Small = "small",
3
- Medium = "medium",
4
- Original = "original"
5
- }
6
- export declare const getImageUrl: (posterImageUrl: string | {
7
- original: string;
8
- medium: string;
9
- small: string;
10
- } | undefined, size?: ImageSize) => string;
11
- export declare const getPosterImageUrl: (posterImageUrl: string | {
12
- original: string;
13
- medium: string;
14
- small: string;
15
- } | undefined) => string;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPosterImageUrl = exports.getImageUrl = exports.ImageSize = void 0;
4
- var ImageSize;
5
- (function (ImageSize) {
6
- ImageSize["Small"] = "small";
7
- ImageSize["Medium"] = "medium";
8
- ImageSize["Original"] = "original";
9
- })(ImageSize = exports.ImageSize || (exports.ImageSize = {}));
10
- const getImageUrl = (posterImageUrl, size = ImageSize.Original) => {
11
- if (!posterImageUrl)
12
- return '';
13
- // Backward compatibility - if it's a string, return it
14
- if (typeof posterImageUrl === 'string') {
15
- return posterImageUrl;
16
- }
17
- // New object structure - return requested size
18
- return posterImageUrl[size] || posterImageUrl.original || '';
19
- };
20
- exports.getImageUrl = getImageUrl;
21
- // Helper function for direct usage safety
22
- const getPosterImageUrl = (posterImageUrl) => {
23
- return (0, exports.getImageUrl)(posterImageUrl, ImageSize.Original);
24
- };
25
- exports.getPosterImageUrl = getPosterImageUrl;
26
- //# sourceMappingURL=ImageUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ImageUtil.js","sourceRoot":"","sources":["../src/ImageUtil.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AAEM,MAAM,WAAW,GAAG,CACzB,cAAwF,EACxF,OAAkB,SAAS,CAAC,QAAQ,EAC5B,EAAE;IACV,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAE/B,uDAAuD;IACvD,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACtC,OAAO,cAAc,CAAC;KACvB;IAED,+CAA+C;IAC/C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,QAAQ,IAAI,EAAE,CAAC;AAC/D,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB;AAEF,0CAA0C;AACnC,MAAM,iBAAiB,GAAG,CAC/B,cAAwF,EAChF,EAAE;IACV,OAAO,IAAA,mBAAW,EAAC,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B"}
@@ -1 +0,0 @@
1
- export declare function makeCache(items: any[], key: string, start: any): any;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeCache = void 0;
4
- function makeCache(items, key, start) {
5
- return items === null || items === void 0 ? void 0 : items.reduce((cur, item) => {
6
- cur[item[key]] = item;
7
- return cur;
8
- }, Object.assign({}, start));
9
- }
10
- exports.makeCache = makeCache;
11
- //# sourceMappingURL=ReduxUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReduxUtil.js","sourceRoot":"","sources":["../src/ReduxUtil.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,KAAY,EAAE,GAAW,EAAE,KAAU;IAC7D,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAClB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACZ,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,oBACI,KAAK,EACX,CAAC;AACJ,CAAC;AARD,8BAQC"}
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import * as url from 'url';
3
- export declare function parse(inputUrl: string): url.UrlWithParsedQuery;
4
- export declare function setQueryString(paramObj: any, replaceState?: boolean, clearExisting?: boolean): string;