UNPKG

amazoom

Version:

Collects data from Amazon.

7 lines 23.4 kB
#!/usr/bin/env node /*! *** amazoom 1.3.0 *** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT *** See https://github.com/Jaid/amazoom !*/!function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=29)}([function(e,t){e.exports=require("sequelize")},function(e,t,r){"use strict";r.d(t,"e",(function(){return u})),r.d(t,"c",(function(){return c})),r.d(t,"a",(function(){return l})),r.d(t,"d",(function(){return d}));var a=r(15),n=r.n(a),i=r(16),o=r.n(i);const s=new n.a({name:"Amazoom",version:"1.3.0",insecurePort:17561,database:"amazoom",useGot:!0,databaseExtensions:"hstore",configSetup:{defaults:o(),secretKeys:["twitchClientId","twitchClientSecret"]}}),u=s.logger,c=s.got,l=s.config,d=(s.appFolder,s.koa);t.b=s},function(e,t,r){"use strict";r.r(t),r.d(t,"schema",(function(){return w})),r.d(t,"indexes",(function(){return g}));var a=r(9),n=r.n(a),i=r(0),o=r.n(i),s=r(4),u=r(17),c=r.n(u),l=r(6),d=r(1),f=r(5),p=r.n(f),h=r(18),m=r.n(h);class y extends o.a.Model{static associate(e){y.belongsTo(e.Product,{foreignKey:{allowNull:!1}}),y.hasMany(e.ProductCheck,{foreignKey:{allowNull:!1}})}static async findByIdentifier(e,t,r){return y.findOne({where:{platform:e,platformIdentifier:t},...r})}static async findByProductId(e,t,r){return y.findOne({where:{platform:e,ProductId:t},...r})}getPlatform(){return r(33)(`./${this.platform}/index.js`).default}async check(){var e;const t=Date.now(),r=this.getPlatform(),a=r.getUrl(this),n=s.default.build({url:a,ProductStateId:this.id}),i=[],o=await c()(async()=>{const e=Date.now(),t=r.makeGot(d.c,this).extend({throwHttpErrors:!1}),n=await t(a),o={url:n.requestUrl,requestHeaders:n.request.gotOptions.headers,responseHeaders:n.headers,body:n.body,httpVersion:n.httpVersion,method:n.request.gotOptions.method,statusCode:n.statusCode,statusMessage:n.statusMessage,time:Date.now()-e};if(i.push(o),200!==n.statusCode)throw new Error("Status code is %s %s",n.statusCode,n.statusMessage);return r.checkState(o,this)},{retries:5,maxTimeout:6e4});if(n.time=Date.now()-t,n.data=o,await n.save(),await l.default.bulkCreate(i.map(e=>({...e,ProductCheckId:n.id})),{logging:!1}),!p()(o))throw new Error("Failed fetching data for %s",this.getName());const u=[];for(const e of y.watchedFields)this[e]!==o[e]&&(this.set(e,o[e]),u.push(e));return e=u,p()(e)&&(d.e.info("%s received %s: %s",this.getName(),m()(u,"field update"),u.join(", ")),await this.save(),n.changes=u.length,await n.save()),u}getName(){return`${this.platform}/${this.platformIdentifier}`}}n()(y,"watchedFields",["price","title","currency"]);const w={platformIdentifier:{type:o.a.STRING,allowNull:!1},platform:{type:o.a.STRING(32),allowNull:!1,defaultValue:"amazon"},title:o.a.STRING,price:o.a.INTEGER,currency:o.a.STRING},g=[{fields:["platform","platformIdentifier"]}];t.default=y},function(e,t,r){"use strict";r.r(t),r.d(t,"schema",(function(){return u}));var a=r(0),n=r.n(a),i=r(4),o=r(2);class s extends n.a.Model{static associate(e){s.hasMany(e.ProductState,{foreignKey:{allowNull:!1}})}static async findByAsin(e,t){return s.findOne({where:{asin:e},...t})}async getLatestCheck(e){return i.default.findOne({where:{ProductId:this.id},...e})}async getStates(){return o.default.findAll({where:{ProductId:this.id}})}async check(){const e=await this.getStates();for(const t of e)await t.check()}static async register(e,t,r){if(await o.default.count({where:{[a.Op.or]:[t]}})>0){const e=await o.default.findOne({where:{...t[0]},attributes:["ProductId"],raw:!0});return{product:await s.findByPk(e.ProductId),isNew:!1}}const n=await s.create({title:e});return await(await o.default.bulkCreate(t.map(e=>({platform:e.platform,platformIdentifier:e.platformIdentifier,ProductId:n.id})))),{product:n,isNew:!0}}}const u={title:{type:n.a.STRING,allowNull:!1}};t.default=s},function(e,t,r){"use strict";r.r(t),r.d(t,"schema",(function(){return o}));var a=r(0),n=r.n(a);class i extends n.a.Model{static associate(e){i.belongsTo(e.ProductState,{foreignKey:{allowNull:!1}}),i.hasMany(e.ProductFetch)}}const o={time:{type:n.a.INTEGER,allowNull:!1},url:n.a.TEXT,data:n.a.JSONB,changes:{type:n.a.SMALLINT,allowNull:!1,defaultValue:0}};t.default=i},function(e,t){e.exports=require("has-content")},function(e,t,r){"use strict";r.r(t),r.d(t,"schema",(function(){return o}));var a=r(0),n=r.n(a);class i extends n.a.Model{static associate(e){i.belongsTo(e.ProductCheck)}}const o={url:{type:n.a.TEXT,allowNull:!1},requestHeaders:{type:n.a.HSTORE,allowNull:!1},responseHeaders:{type:n.a.HSTORE,allowNull:!1},body:{type:n.a.TEXT,allowNull:!1},httpVersion:{type:n.a.STRING,allowNull:!1},method:{type:n.a.STRING,allowNull:!1},statusCode:{type:n.a.SMALLINT,allowNull:!1},statusMessage:{type:n.a.STRING,allowNull:!1},time:{type:n.a.INTEGER,allowNull:!1}};t.default=i},function(e,t,r){"use strict";t.a=["user_subscriptions"]},function(e,t){e.exports=require("fast-koa-router")},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t,r){"use strict";r.r(t),r.d(t,"schema",(function(){return l}));var a=r(0),n=r.n(a),i=r(28),o=r.n(i),s=r(1),u=r(7);class c extends n.a.Model{static associate(e){}static async getByTwitchId(e){return await c.findOne({where:{twitchId:e}})}static async getByTwitchLogin(e){return await c.findOne({where:{loginName:e.toLowerCase()}})}async toTwitchClient(){const e=await o.a.withCredentials(s.a.twitchClientId,this.accessToken,u.a,{clientSecret:s.a.twitchClientSecret,refreshToken:this.refreshToken,onRefresh:e=>this.updateToken(e),expiry:this.tokenExpiryDate},{preAuth:!0,initialScopes:u.a});return this.tokenExpiryDate||(s.e.info("Initial expiry date not set for user %s. Forcing access token refresh.",this.loginName),await e.refreshAccessToken()),s.e.info("Created client for user %s",this.loginName),e}async updateToken(e){s.e.info("Refresh token of user %s",this.loginName),this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.tokenExpiryDate=e.expiryDate,await this.save({fields:["accessToken","refreshToken","tokenExpiryDate"]})}getDisplayName(){return this.displayName||this.loginName||this.twitchId}}const l={twitchId:{type:n.a.STRING(16),unique:!0,allowNull:!1},displayName:n.a.STRING(64),loginName:{allowNull:!1,type:n.a.STRING(64)},accessToken:n.a.STRING,refreshToken:n.a.STRING,followDate:n.a.DATE,subscribedUntil:n.a.DATE,tokenExpiryDate:n.a.DATE,twitchProfile:n.a.JSONB};t.default=c},function(e,t){e.exports=require("parsecurrency")},function(e,t,r){"use strict";r.r(t);var a=r(2);t.default=async e=>{const{platform:t,productId:r,platformIdentifier:n}=e.params,i={platform:t};r?i.ProductId=r:n?i.platformIdentifier=n:e.throw("Missing parameter",400);const o=await a.default.findOne({where:i,raw:!0,attributes:["id","price","platformIdentifier","platform","title","currency"]});e.assert(o,404,"ProductState not found"),e.body=o}},function(e,t,r){"use strict";r.r(t);var a=r(2),n=r(3);t.default=async()=>(await a.default.findAll({order:[["updatedAt","desc"]],attributes:["platform","price","platformIdentifier","currency"],include:[{model:n.default,attributes:["id","title"],required:!0}]})).map(e=>e.toJSON())},function(e,t,r){"use strict";r.r(t);var a=r(3),n=r(2);t.default=async(e,t)=>(await a.default.findByPk(t,{include:[{model:n.default}]})).toJSON()},function(e,t){e.exports=require("jaid-core")},function(e,t){e.exports={twitchClientCallbackUrl:"https://amazoom.jaid.codes/auth/twitch/callback",loginRedirectUrl:"https://preis.farm",frontendHost:"preis.farm"}},function(e,t){e.exports=require("p-retry")},function(e,t,r){e.exports=function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t,r){e.exports=function(){var e=[],t=[],r={},a={},n={};function i(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,r){return t[r]||""}))}function u(e,t){return e.replace(t[0],(function(r,a){var n=s(t[1],arguments);return o(""===r?e[a-1]:r,n)}))}function c(e,t,a){if(!e.length||r.hasOwnProperty(e))return t;for(var n=a.length;n--;){var i=a[n];if(i[0].test(t))return u(t,i)}return t}function l(e,t,r){return function(a){var n=a.toLowerCase();return t.hasOwnProperty(n)?o(a,n):e.hasOwnProperty(n)?o(a,e[n]):c(n,a,r)}}function d(e,t,r,a){return function(a){var n=a.toLowerCase();return!!t.hasOwnProperty(n)||!e.hasOwnProperty(n)&&c(n,n,r)===n}}function f(e,t,r){return(r?t+" ":"")+(1===t?f.singular(e):f.plural(e))}return f.plural=l(n,a,e),f.isPlural=d(n,a,e),f.singular=l(a,n,t),f.isSingular=d(a,n,t),f.addPluralRule=function(t,r){e.push([i(t),r])},f.addSingularRule=function(e,r){t.push([i(e),r])},f.addUncountableRule=function(e){"string"!=typeof e?(f.addPluralRule(e,"$0"),f.addSingularRule(e,"$0")):r[e.toLowerCase()]=!0},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),n[e]=t,a[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach((function(e){return f.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return f.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return f.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f}()},function(e,t,r){r.r(t),r.d(t,"resolveCount",(function(){return i}));var a=r(0),n=r.n(a);const i=e=>{var t=Number.isNaN;if("number"==typeof e)return e;if("number"==typeof(null==e?void 0:e.length))return e.length;if("object"==typeof e)return Object.keys(e).length;const r=+e;return t(r)?0:r},o=(e,t="entry")=>{const r=i(e);return`${r} ${1===r?o.singular(t):o.plural(t)}`};Object.assign(o,n.a),Object.setPrototypeOf(o,Object.getPrototypeOf(n.a)),t.default=o}])},function(e,t){e.exports=require("user-agents")},function(e,t){e.exports=require("cheerio-util")},function(e,t){e.exports=require("json5")},function(e,t){e.exports=require("interval-promise")},function(e,t){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t){e.exports=require("socket-enhance")},function(e,t){e.exports=require("socket.io")},function(e,t){e.exports=require("passport-twitch-new")},function(e,t){e.exports=require("koa-passport")},function(e,t){e.exports=require("twitch")},function(e,t,r){"use strict";r.r(t);var a=r(1);(async()=>{const e={},t=r(30);for(const r of t.keys()){const{pluginName:a}=r.match(/[\/\\](?<pluginName>.+?)[\/\\]index\.js$/).groups;e[a]=t(r).default}await a.b.init(e)})()},function(e,t,r){var a={"./httpApi/index.js":31,"./main/index.js":36,"./socketApi/index.js":40,"./test/index.js":39,"./twitchAuth/index.js":41};function n(e){var t=i(e);return r(t)}function i(e){if(!r.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}n.keys=function(){return Object.keys(a)},n.resolve=i,e.exports=n,n.id=30},function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return i}));var a=r(1),n=r(8);class i{init(){const e={get:{"/preview/:productId/:platform":r(32).default,"/info/product/:productId/:platform":r(12).default,"/info/identifier/:platform/:platformIdentifier":r(12).default},post:{"/registerAsin":r(34).default,"/triggerCheck/product/:productId":r(35).default}};a.d.use(Object(n.router)(e))}}},function(e,t,r){"use strict";r.r(t);var a=r(6),n=r(2),i=r(4);t.default=async e=>{const{productId:t,platform:r}=e.params,o=await a.default.findOne({order:[["id","DESC"]],attributes:["body"],raw:!0,include:[{required:!0,model:i.default,attributes:[],include:[{model:n.default,required:!0,attributes:[],where:{platform:r,ProductId:t}}]}]});e.assert(o,404,"State not found"),e.type="html",e.body=o.body}},function(e,t,r){var a={"./amazon/index.js":42};function n(e){var t=i(e);return r(t)}function i(e){if(!r.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}n.keys=function(){return Object.keys(a)},n.resolve=i,e.exports=n,n.id=33},function(e,t,r){"use strict";r.r(t);var a=r(3);t.default=async e=>{const{asin:t,title:r}=e.query;e.assert(t,400,"Missing asin"),e.assert(r,400,"Missing title");const{product:n,isNew:i}=await a.default.register(r,[{platform:"amazon",platformIdentifier:t}]);e.body={isNew:i,productId:n.id}}},function(e,t,r){"use strict";r.r(t);var a=r(3);t.default=async e=>{const{productId:t}=e.params;if(t){const r=await a.default.findByPk(t);return await r.check(),void(e.body="OK")}e.throw("Missing parameter",400)}},function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return o}));var a=r(2),n=r(22),i=r.n(n);class o{async ready(){i()(this.job,6e4)}async job(){const e=await a.default.findAll();for(const t of e)await t.check()}collectModels(){const e={},t=r(37);for(const r of t.keys())e[r.match(/\.\/(?<key>[\da-z]+)\./i).groups.key]=t(r);return e}}},function(e,t,r){var a={"./Product.js":3,"./ProductCheck.js":4,"./ProductFetch.js":6,"./ProductState.js":2};function n(e){var t=i(e);return r(t)}function i(e){if(!r.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}n.keys=function(){return Object.keys(a)},n.resolve=i,e.exports=n,n.id=37},function(e,t,r){var a={"./getOverview":13,"./getOverview.js":13,"./product":14,"./product.js":14};function n(e){var t=i(e);return r(t)}function i(e){if(!r.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}n.keys=function(){return Object.keys(a)},n.resolve=i,e.exports=n,n.id=38},function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return i}));var a=r(1);const n="B07MLJD32L";class i{preInit(){return"1"===process.env.VSCODE_CLI}async init(){this.got=a.c.extend({baseUrl:"http://localhost",port:a.a.insecurePort})}async ready(){await this.got.post("registerAsin",{query:{asin:n,title:"2TB NVMe m.2 Festplatte"}});const{body:e}=await this.got(`info/identifier/amazon/${n}`,{json:!0});await this.got.post(`triggerCheck/product/${e.id}`);const{body:t}=await this.got(`info/identifier/amazon/${n}`,{json:!0});a.e.info("Price: %s %s",+t.price/100,t.currency)}}},function(e,t,r){"use strict";r.r(t);var a=r(23),n=r.n(a),i=r(24),o=r.n(i),s=r(1),u=new o.a({logger:s.e}),c=r(25),l=r.n(c);const d=r(38);t.default=new class{async init(){this.socketServer=l()(s.b.insecureServer),this.socketServer.on("connection",e=>{for(const[t,r]of Object.entries(this.commands))e.on(t,async(...t)=>{const a=await r(e,...t);void 0!==a&&n()(t)(a)})}),u.enhanceServer(this.socketServer),this.commands=d.keys().reduce((e,t)=>(e[t.match(/\.\/(?<key>[\da-z]+)/i).groups.key]=d(t).default,e),{})}}},function(e,t,r){"use strict";r.r(t);var a=r(26),n=r(1),i=r(27),o=r.n(i),s=r(8),u=r(10),c=r(7);t.default=new class{async init(){this.passport=o.a.use(new a.Strategy({scope:c.a,clientID:n.a.twitchClientId,clientSecret:n.a.twitchClientSecret,callbackURL:n.a.twitchClientCallbackUrl},async(e,t,r,a)=>(await u.default.upsert({accessToken:e,refreshToken:t,broadcasterType:r.broadcaster_type,description:r.description,displayName:r.display_name,twitchId:r.id,loginName:r.login,offlineImageUrl:r.offline_image_url,avatarUrl:r.profile_image_url,viewCount:r.view_count}),n.e.info("Login from Twitch user %s",r.login),a(null,r)))),this.koa=n.d,this.middleware=Object(s.router)({get:{"/auth":e=>{e.type="html",e.body="<a href=/auth/twitch>Login with Twitch</a>"},"/auth/twitch":this.passport.authenticate("twitch"),"/auth/twitch/callback":this.passport.authenticate("twitch",{failureRedirect:"/auth",successRedirect:"/auth/twitch/done",session:!1}),"/auth/twitch/done":this.handleAuthDone}})}async ready(){this.koa.use(this.passport.initialize()),this.koa.use(this.middleware)}handleAuthDone(e){e.redirect(n.a.loginRedirectUrl)}collectModels(){return{TwitchUser:r(10)}}}},function(e,t,r){"use strict";r.r(t);var a=r(9),n=r.n(a),i=r(19),o=r.n(i),s=r(20),u=r.n(s),c=r(11),l=r.n(c),d=r(21),f=r.n(d),p=r(5),h=r.n(p),m=r(1);t.default=new class extends class{async getUrl(e){}async makeGot(e,t){}checkState(e,t){}}{constructor(...e){super(...e),n()(this,"userAgentRoller",new o.a({deviceCategory:"tablet"}))}getUrl(e){return`https://amazon.de/dp/${e.platformIdentifier}`}makeGot(e){return e.extend({headers:{"User-Agent":this.userAgentRoller.random().toString()}})}checkState(e,t){var r;if(e.body.includes("api-services-support@amazon.com"))throw new Error("Has captcha");const a=u.a.load(e.body,{normalizeWhitespace:!0,lowerCaseTags:!0,lowerCaseAttributeNames:!0,recognizeSelfClosing:!0,recognizeCDATA:!0}),n={},i=a.root().findTrByFirstTd("Unverb. Preisempf.:");if(null==i?void 0:i[0]){const e=i[0],r=l()(e);r?("€"===r.symbol?n.listPriceCurrency="EUR":(m.e.warn('Currency symbol for %s is "%s"',t.getName(),r.symbol),n.listPriceCurrency=r.symbol),n.listPrice=100*r.value,n.listPriceSymbol=r.symbol):m.e.warn('Could not parse "%s" with parsecurrency',e)}const o=a("#priceblock_ourprice");if(o){const e=o.textNormalized(),r=l()(e);r?("€"===r.symbol?n.currency="EUR":(m.e.warn('Currency symbol for %s is "%s"',t.getName(),r.symbol),n.currency=r.symbol),n.price=100*r.value):m.e.warn('Could not parse "%s" with parsecurrency',e)}const s=a("#productTitle").textNormalized();r=s,h()(r)&&(n.title=s);const c=a("script[type='text/javascript']").toArray(),d=e=>a.text(e.childNodes).trim(),p=Array(c.length);for(let e=0;e<=c.length-1;e++)p[e]=d(c[e]);const y=[];for(let e=0;e<=p.length-1;e++)h()(p[e],e,p)&&y.push(p[e]);const w=y.find(e=>/'twister-js-init-dpx-data'/s.test(e));if(w){const e=/dataToReturn += +(?<object>{(.+)});/s.exec(w).groups.object;n.dataObject=f.a.parse(e)}const g=y.find(e=>/'ImageBlockATF'.+jQuery\.parseJSON/s.test(e));if(g){const e=/parseJSON\('(?<json>.*?)'\);/s.exec(g).groups.json;n.imagesObject=JSON.parse(e)}return n}}}]);