@grenoble-hands-on/web-adapters
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,17 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CityBuilder = void 0; | ||
var GeoPositionBuilder_1 = require("./GeoPositionBuilder"); | ||
var CityBuilder = /** @class */ (function () { | ||
function CityBuilder() { | ||
} | ||
CityBuilder.prototype.withName = function (name) { | ||
import { GeoPositionBuilder } from './GeoPositionBuilder'; | ||
export class CityBuilder { | ||
withName(name) { | ||
this.name = name; | ||
return this; | ||
}; | ||
CityBuilder.prototype.withPosition = function (position) { | ||
} | ||
withPosition(position) { | ||
this.position = position; | ||
return this; | ||
}; | ||
CityBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
@@ -21,10 +16,8 @@ name: this.name, | ||
}; | ||
}; | ||
CityBuilder.example = function () { | ||
} | ||
static example() { | ||
return new CityBuilder() | ||
.withName("Grenoble") | ||
.withPosition(new GeoPositionBuilder_1.GeoPositionBuilder().build()); | ||
}; | ||
return CityBuilder; | ||
}()); | ||
exports.CityBuilder = CityBuilder; | ||
.withPosition(new GeoPositionBuilder().build()); | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,17 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GeoPosition = void 0; | ||
var GeoPosition = /** @class */ (function () { | ||
function GeoPosition(latitude, longitude) { | ||
export class GeoPosition { | ||
constructor(latitude, longitude) { | ||
this.latitude = latitude; | ||
this.longitude = longitude; | ||
} | ||
GeoPosition.isLongitudeInvalid = function (longitude) { | ||
static isLongitudeInvalid(longitude) { | ||
return (isNaN(+longitude) || +longitude < -180 || +longitude > 180); | ||
}; | ||
GeoPosition.isLatitudeInvalid = function (latitude) { | ||
} | ||
static isLatitudeInvalid(latitude) { | ||
return (isNaN(+latitude) || +latitude < -180 || +latitude > 180); | ||
}; | ||
return GeoPosition; | ||
}()); | ||
exports.GeoPosition = GeoPosition; | ||
} | ||
} |
@@ -1,21 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GeoPositionBuilder = void 0; | ||
var GeoPosition_1 = require("./GeoPosition"); | ||
var GeoPositionBuilder = /** @class */ (function () { | ||
function GeoPositionBuilder() { | ||
} | ||
GeoPositionBuilder.prototype.withLongitude = function (longitude) { | ||
import { GeoPosition } from './GeoPosition'; | ||
export class GeoPositionBuilder { | ||
withLongitude(longitude) { | ||
this.longitude = longitude; | ||
return this; | ||
}; | ||
GeoPositionBuilder.prototype.withLatitude = function (latitude) { | ||
} | ||
withLatitude(latitude) { | ||
this.latitude = latitude; | ||
return this; | ||
}; | ||
GeoPositionBuilder.prototype.build = function () { | ||
return new GeoPosition_1.GeoPosition(this.latitude, this.longitude); | ||
}; | ||
return GeoPositionBuilder; | ||
}()); | ||
exports.GeoPositionBuilder = GeoPositionBuilder; | ||
} | ||
build() { | ||
return new GeoPosition(this.latitude, this.longitude); | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WeatherState = void 0; | ||
var WeatherState; | ||
export var WeatherState; | ||
(function (WeatherState) { | ||
@@ -22,2 +19,2 @@ WeatherState["partly_cloudy"] = "partly_cloudy"; | ||
WeatherState["unknown"] = "unknown"; | ||
})(WeatherState = exports.WeatherState || (exports.WeatherState = {})); | ||
})(WeatherState || (WeatherState = {})); |
@@ -1,42 +0,28 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WeatherState = void 0; | ||
__exportStar(require("./usecases/GetCitiesUseCase"), exports); | ||
__exportStar(require("./usecases/GetCityUseCase"), exports); | ||
__exportStar(require("./usecases/RetrieveCityDailyWeatherUseCase"), exports); | ||
__exportStar(require("./usecases/RetrieveCityHourlyWeatherUseCase"), exports); | ||
__exportStar(require("./usecases/AddCityUseCase"), exports); | ||
__exportStar(require("./entities/GeoPosition"), exports); | ||
__exportStar(require("./entities/DailyWeather"), exports); | ||
__exportStar(require("./entities/HourlyWeather"), exports); | ||
__exportStar(require("./entities/City"), exports); | ||
__exportStar(require("./entities/CityBuilder"), exports); | ||
__exportStar(require("./entities/GeoPositionBuilder"), exports); | ||
__exportStar(require("./ports/presenters/GetCitiesPresentation"), exports); | ||
__exportStar(require("./ports/presenters/GetCityPresentation"), exports); | ||
__exportStar(require("./ports/presenters/RetrieveDailyWeatherPresentation"), exports); | ||
__exportStar(require("./ports/presenters/RetrieveHourlyWeatherPresentation"), exports); | ||
__exportStar(require("./ports/presenters/AddCityPresentationBuilder"), exports); | ||
__exportStar(require("./ports/presenters/GetCitiesPresentationBuilder"), exports); | ||
__exportStar(require("./ports/presenters/RetrieveDailyWeatherPresentationBuilder"), exports); | ||
__exportStar(require("./ports/presenters/RetrieveHourlyWeatherPresentationBuilder"), exports); | ||
__exportStar(require("./ports/presenters/GetCityPresentationBuilder"), exports); | ||
__exportStar(require("./ports/presenters/AddCityPresentation"), exports); | ||
__exportStar(require("./ports/repositories/CityRepository"), exports); | ||
__exportStar(require("./ports/repositories/WeatherRepository"), exports); | ||
__exportStar(require("./ports/request/GetCityRequest"), exports); | ||
__exportStar(require("./ports/request/RetrieveWeatherRequest"), exports); | ||
__exportStar(require("./ports/request/AddCityRequest"), exports); | ||
__exportStar(require("./entities/UniteDegree"), exports); | ||
var WeatherState_1 = require("./entities/WeatherState"); | ||
Object.defineProperty(exports, "WeatherState", { enumerable: true, get: function () { return WeatherState_1.WeatherState; } }); | ||
export * from './usecases/GetCitiesUseCase'; | ||
export * from './usecases/GetCityUseCase'; | ||
export * from './usecases/RetrieveCityDailyWeatherUseCase'; | ||
export * from './usecases/RetrieveCityHourlyWeatherUseCase'; | ||
export * from './usecases/AddCityUseCase'; | ||
export * from './entities/GeoPosition'; | ||
export * from './entities/DailyWeather'; | ||
export * from './entities/HourlyWeather'; | ||
export * from './entities/City'; | ||
export * from './entities/CityBuilder'; | ||
export * from './entities/GeoPositionBuilder'; | ||
export * from './ports/presenters/GetCitiesPresentation'; | ||
export * from './ports/presenters/GetCityPresentation'; | ||
export * from './ports/presenters/RetrieveDailyWeatherPresentation'; | ||
export * from './ports/presenters/RetrieveHourlyWeatherPresentation'; | ||
export * from './ports/presenters/AddCityPresentationBuilder'; | ||
export * from './ports/presenters/GetCitiesPresentationBuilder'; | ||
export * from './ports/presenters/RetrieveDailyWeatherPresentationBuilder'; | ||
export * from './ports/presenters/RetrieveHourlyWeatherPresentationBuilder'; | ||
export * from './ports/presenters/GetCityPresentationBuilder'; | ||
export * from './ports/presenters/AddCityPresentation'; | ||
export * from './ports/repositories/CityRepository'; | ||
export * from './ports/repositories/WeatherRepository'; | ||
export * from './ports/request/GetCityRequest'; | ||
export * from './ports/request/RetrieveWeatherRequest'; | ||
export * from './ports/request/AddCityRequest'; | ||
export * from './entities/UniteDegree'; | ||
export { WeatherState } from './entities/WeatherState'; |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NewCityFields = void 0; | ||
var NewCityFields; | ||
export var NewCityFields; | ||
(function (NewCityFields) { | ||
@@ -9,2 +6,2 @@ NewCityFields["cityName"] = "cityName"; | ||
NewCityFields["longitude"] = "longitude"; | ||
})(NewCityFields = exports.NewCityFields || (exports.NewCityFields = {})); | ||
})(NewCityFields || (NewCityFields = {})); |
@@ -1,18 +0,15 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityPresentationBuilder = void 0; | ||
var AddCityPresentationBuilder = /** @class */ (function () { | ||
function AddCityPresentationBuilder() { | ||
this.notifyNewCityInvalid = function () { return null; }; | ||
this.notifyCityAdded = function () { return null; }; | ||
export class AddCityPresentationBuilder { | ||
constructor() { | ||
this.notifyNewCityInvalid = () => null; | ||
this.notifyCityAdded = () => null; | ||
} | ||
AddCityPresentationBuilder.prototype.withNotifyCityAdded = function (notifyCityAdded) { | ||
withNotifyCityAdded(notifyCityAdded) { | ||
this.notifyCityAdded = notifyCityAdded; | ||
return this; | ||
}; | ||
AddCityPresentationBuilder.prototype.withNotifyNewCityInvalid = function (notifyNewCityInvalid) { | ||
} | ||
withNotifyNewCityInvalid(notifyNewCityInvalid) { | ||
this.notifyNewCityInvalid = notifyNewCityInvalid; | ||
return this; | ||
}; | ||
AddCityPresentationBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
@@ -22,5 +19,3 @@ notifyNewCityInvalid: this.notifyNewCityInvalid, | ||
}; | ||
}; | ||
return AddCityPresentationBuilder; | ||
}()); | ||
exports.AddCityPresentationBuilder = AddCityPresentationBuilder; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,19 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetCitiesPresentationBuilder = void 0; | ||
var GetCitiesPresentationBuilder = /** @class */ (function () { | ||
function GetCitiesPresentationBuilder() { | ||
this.displayCities = function () { return null; }; | ||
export class GetCitiesPresentationBuilder { | ||
constructor() { | ||
this.displayCities = () => null; | ||
} | ||
GetCitiesPresentationBuilder.prototype.withDisplayCities = function (displayCities) { | ||
withDisplayCities(displayCities) { | ||
this.displayCities = displayCities; | ||
return this; | ||
}; | ||
GetCitiesPresentationBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
displayCities: this.displayCities | ||
}; | ||
}; | ||
return GetCitiesPresentationBuilder; | ||
}()); | ||
exports.GetCitiesPresentationBuilder = GetCitiesPresentationBuilder; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,19 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetCityPresentationBuilder = void 0; | ||
var GetCityPresentationBuilder = /** @class */ (function () { | ||
function GetCityPresentationBuilder() { | ||
this.displayCity = function () { return null; }; | ||
export class GetCityPresentationBuilder { | ||
constructor() { | ||
this.displayCity = () => null; | ||
} | ||
GetCityPresentationBuilder.prototype.withDisplayCity = function (displayCity) { | ||
withDisplayCity(displayCity) { | ||
this.displayCity = displayCity; | ||
return this; | ||
}; | ||
GetCityPresentationBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
displayCity: this.displayCity | ||
}; | ||
}; | ||
return GetCityPresentationBuilder; | ||
}()); | ||
exports.GetCityPresentationBuilder = GetCityPresentationBuilder; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,19 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RetrieveDailyWeatherPresentationBuilder = void 0; | ||
var RetrieveDailyWeatherPresentationBuilder = /** @class */ (function () { | ||
function RetrieveDailyWeatherPresentationBuilder() { | ||
this.displayWeather = function () { return null; }; | ||
export class RetrieveDailyWeatherPresentationBuilder { | ||
constructor() { | ||
this.displayWeather = () => null; | ||
} | ||
RetrieveDailyWeatherPresentationBuilder.prototype.withDisplayWeather = function (displayWeather) { | ||
withDisplayWeather(displayWeather) { | ||
this.displayWeather = displayWeather; | ||
return this; | ||
}; | ||
RetrieveDailyWeatherPresentationBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
displayWeather: this.displayWeather, | ||
}; | ||
}; | ||
return RetrieveDailyWeatherPresentationBuilder; | ||
}()); | ||
exports.RetrieveDailyWeatherPresentationBuilder = RetrieveDailyWeatherPresentationBuilder; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,19 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RetrieveHourlyWeatherPresentationBuilder = void 0; | ||
var RetrieveHourlyWeatherPresentationBuilder = /** @class */ (function () { | ||
function RetrieveHourlyWeatherPresentationBuilder() { | ||
this.displayWeather = function () { return null; }; | ||
export class RetrieveHourlyWeatherPresentationBuilder { | ||
constructor() { | ||
this.displayWeather = () => null; | ||
} | ||
RetrieveHourlyWeatherPresentationBuilder.prototype.withDisplayWeather = function (displayWeather) { | ||
withDisplayWeather(displayWeather) { | ||
this.displayWeather = displayWeather; | ||
return this; | ||
}; | ||
RetrieveHourlyWeatherPresentationBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
displayWeather: this.displayWeather, | ||
}; | ||
}; | ||
return RetrieveHourlyWeatherPresentationBuilder; | ||
}()); | ||
exports.RetrieveHourlyWeatherPresentationBuilder = RetrieveHourlyWeatherPresentationBuilder; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityRequest = void 0; | ||
var AddCityRequest = /** @class */ (function () { | ||
function AddCityRequest(cityName, latitude, longitude, dryRun) { | ||
if (dryRun === void 0) { dryRun = false; } | ||
export class AddCityRequest { | ||
constructor(cityName, latitude, longitude, dryRun = false) { | ||
this.cityName = cityName; | ||
@@ -12,4 +8,2 @@ this.latitude = latitude; | ||
} | ||
return AddCityRequest; | ||
}()); | ||
exports.AddCityRequest = AddCityRequest; | ||
} |
@@ -1,10 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetCityRequest = void 0; | ||
var GetCityRequest = /** @class */ (function () { | ||
function GetCityRequest(city) { | ||
export class GetCityRequest { | ||
constructor(city) { | ||
this.city = city; | ||
} | ||
return GetCityRequest; | ||
}()); | ||
exports.GetCityRequest = GetCityRequest; | ||
} |
@@ -1,12 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RetrieveWeatherRequest = void 0; | ||
var RetrieveWeatherRequest = /** @class */ (function () { | ||
function RetrieveWeatherRequest(city, unite) { | ||
if (unite === void 0) { unite = 'C'; } | ||
export class RetrieveWeatherRequest { | ||
constructor(city, unite = 'C') { | ||
this.city = city; | ||
this.unite = unite; | ||
} | ||
return RetrieveWeatherRequest; | ||
}()); | ||
exports.RetrieveWeatherRequest = RetrieveWeatherRequest; | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,86 +10,46 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityUseCase = void 0; | ||
var AddCityPresentation_1 = require("../ports/presenters/AddCityPresentation"); | ||
var GeoPosition_1 = require("../entities/GeoPosition"); | ||
var CityBuilder_1 = require("../entities/CityBuilder"); | ||
var GeoPositionBuilder_1 = require("../entities/GeoPositionBuilder"); | ||
var AddCityUseCase = /** @class */ (function () { | ||
function AddCityUseCase(cityRepository) { | ||
import { NewCityFields } from '../ports/presenters/AddCityPresentation'; | ||
import { GeoPosition } from '../entities/GeoPosition'; | ||
import { CityBuilder } from '../entities/CityBuilder'; | ||
import { GeoPositionBuilder } from '../entities/GeoPositionBuilder'; | ||
export class AddCityUseCase { | ||
constructor(cityRepository) { | ||
this.cityRepository = cityRepository; | ||
} | ||
AddCityUseCase.prototype.execute = function (addCityRequest, presenter) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var errors, city; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
errors = this.validate(addCityRequest, presenter); | ||
if (!!errors.size) return [3 /*break*/, 2]; | ||
city = new CityBuilder_1.CityBuilder() | ||
.withName(addCityRequest.cityName) | ||
.withPosition(new GeoPositionBuilder_1.GeoPositionBuilder() | ||
.withLatitude(+addCityRequest.latitude) | ||
.withLongitude(+addCityRequest.longitude) | ||
.build()) | ||
.build(); | ||
return [4 /*yield*/, this.cityRepository.addCity(city)]; | ||
case 1: | ||
_a.sent(); | ||
presenter.notifyCityAdded(city); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
execute(addCityRequest, presenter) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const errors = this.validate(addCityRequest, presenter); | ||
if (!errors.size) { | ||
const city = new CityBuilder() | ||
.withName(addCityRequest.cityName) | ||
.withPosition(new GeoPositionBuilder() | ||
.withLatitude(+addCityRequest.latitude) | ||
.withLongitude(+addCityRequest.longitude) | ||
.build()) | ||
.build(); | ||
yield this.cityRepository.addCity(city); | ||
presenter.notifyCityAdded(city); | ||
} | ||
}); | ||
}; | ||
AddCityUseCase.prototype.validate = function (addCityRequest, presenter) { | ||
var errors = new Map(); | ||
} | ||
validate(addCityRequest, presenter) { | ||
const errors = new Map(); | ||
if (addCityRequest.cityName == null || !addCityRequest.cityName.length) { | ||
errors.set(AddCityPresentation_1.NewCityFields.cityName, 'City name is required'); | ||
errors.set(NewCityFields.cityName, 'City name is required'); | ||
} | ||
if (addCityRequest.latitude == null || !addCityRequest.latitude.length) { | ||
errors.set(AddCityPresentation_1.NewCityFields.latitude, 'Latitude is required'); | ||
errors.set(NewCityFields.latitude, 'Latitude is required'); | ||
} | ||
else if (GeoPosition_1.GeoPosition.isLatitudeInvalid(addCityRequest.latitude)) { | ||
errors.set(AddCityPresentation_1.NewCityFields.latitude, 'Latitude must be an number between -180 and 180'); | ||
else if (GeoPosition.isLatitudeInvalid(addCityRequest.latitude)) { | ||
errors.set(NewCityFields.latitude, 'Latitude must be an number between -180 and 180'); | ||
} | ||
if (addCityRequest.longitude == null || !addCityRequest.longitude.length) { | ||
errors.set(AddCityPresentation_1.NewCityFields.longitude, 'Longitude is required'); | ||
errors.set(NewCityFields.longitude, 'Longitude is required'); | ||
} | ||
else if (GeoPosition_1.GeoPosition.isLongitudeInvalid(addCityRequest.longitude)) { | ||
errors.set(AddCityPresentation_1.NewCityFields.longitude, 'Longitude must be an number between -180 and 180'); | ||
else if (GeoPosition.isLongitudeInvalid(addCityRequest.longitude)) { | ||
errors.set(NewCityFields.longitude, 'Longitude must be an number between -180 and 180'); | ||
} | ||
presenter.notifyNewCityInvalid(errors); | ||
return errors; | ||
}; | ||
return AddCityUseCase; | ||
}()); | ||
exports.AddCityUseCase = AddCityUseCase; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,51 +10,12 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetCitiesUseCase = void 0; | ||
var GetCitiesUseCase = /** @class */ (function () { | ||
function GetCitiesUseCase(cityRepository) { | ||
export class GetCitiesUseCase { | ||
constructor(cityRepository) { | ||
this.cityRepository = cityRepository; | ||
} | ||
GetCitiesUseCase.prototype.execute = function (presentation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cities; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.cityRepository.getCities()]; | ||
case 1: | ||
cities = _a.sent(); | ||
presentation.displayCities(cities); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
execute(presentation) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const cities = yield this.cityRepository.getCities(); | ||
presentation.displayCities(cities); | ||
}); | ||
}; | ||
return GetCitiesUseCase; | ||
}()); | ||
exports.GetCitiesUseCase = GetCitiesUseCase; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,52 +10,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetCityUseCase = void 0; | ||
var GetCityUseCase = /** @class */ (function () { | ||
function GetCityUseCase(cityRepository) { | ||
export class GetCityUseCase { | ||
constructor(cityRepository) { | ||
this.cityRepository = cityRepository; | ||
} | ||
GetCityUseCase.prototype.execute = function (request, presentation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_b = (_a = presentation).displayCity; | ||
return [4 /*yield*/, this.cityRepository.getCity(request.city)]; | ||
case 1: | ||
_b.apply(_a, [_c.sent()]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
execute(request, presentation) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
presentation.displayCity(yield this.cityRepository.getCity(request.city)); | ||
}); | ||
}; | ||
return GetCityUseCase; | ||
}()); | ||
exports.GetCityUseCase = GetCityUseCase; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,63 +10,24 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RetrieveCityDailyWeatherUseCase = void 0; | ||
var RetrieveCityDailyWeatherUseCase = /** @class */ (function () { | ||
function RetrieveCityDailyWeatherUseCase(weatherRepository) { | ||
export class RetrieveCityDailyWeatherUseCase { | ||
constructor(weatherRepository) { | ||
this.weatherRepository = weatherRepository; | ||
} | ||
RetrieveCityDailyWeatherUseCase.prototype.execute = function (request, presenter) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var weekWeather; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.weatherRepository.getCityDailyWeather(request.city).then(function (weather) { | ||
if (request.unite == 'F') { | ||
return weather.map(function (w) { | ||
w.unite = 'F'; | ||
w.temperatureMin = w.temperatureMin * (9 / 5) + 32; | ||
w.temperatureMax = w.temperatureMax * (9 / 5) + 32; | ||
return w; | ||
}); | ||
} | ||
else { | ||
return weather; | ||
} | ||
})]; | ||
case 1: | ||
weekWeather = _a.sent(); | ||
presenter.displayWeather(weekWeather); | ||
return [2 /*return*/]; | ||
execute(request, presenter) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const weekWeather = yield this.weatherRepository.getCityDailyWeather(request.city).then((weather) => { | ||
if (request.unite == 'F') { | ||
return weather.map(w => { | ||
w.unite = 'F'; | ||
w.temperatureMin = w.temperatureMin * (9 / 5) + 32; | ||
w.temperatureMax = w.temperatureMax * (9 / 5) + 32; | ||
return w; | ||
}); | ||
} | ||
else { | ||
return weather; | ||
} | ||
}); | ||
presenter.displayWeather(weekWeather); | ||
}); | ||
}; | ||
return RetrieveCityDailyWeatherUseCase; | ||
}()); | ||
exports.RetrieveCityDailyWeatherUseCase = RetrieveCityDailyWeatherUseCase; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,62 +10,23 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RetrieveCityHourlyWeatherUseCase = void 0; | ||
var RetrieveCityHourlyWeatherUseCase = /** @class */ (function () { | ||
function RetrieveCityHourlyWeatherUseCase(weatherRepository) { | ||
export class RetrieveCityHourlyWeatherUseCase { | ||
constructor(weatherRepository) { | ||
this.weatherRepository = weatherRepository; | ||
} | ||
RetrieveCityHourlyWeatherUseCase.prototype.execute = function (request, presenter) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var weekWeather; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.weatherRepository.getCityHourlyWeather(request.city).then(function (weather) { | ||
if (request.unite == 'F') { | ||
return weather.map(function (w) { | ||
w.unite = 'F'; | ||
w.temperature = Math.round(w.temperature * (9 / 5) + 32); | ||
return w; | ||
}); | ||
} | ||
else { | ||
return weather; | ||
} | ||
})]; | ||
case 1: | ||
weekWeather = _a.sent(); | ||
presenter.displayWeather(weekWeather); | ||
return [2 /*return*/]; | ||
execute(request, presenter) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const weekWeather = yield this.weatherRepository.getCityHourlyWeather(request.city).then((weather) => { | ||
if (request.unite == 'F') { | ||
return weather.map(w => { | ||
w.unite = 'F'; | ||
w.temperature = Math.round(w.temperature * (9 / 5) + 32); | ||
return w; | ||
}); | ||
} | ||
else { | ||
return weather; | ||
} | ||
}); | ||
presenter.displayWeather(weekWeather); | ||
}); | ||
}; | ||
return RetrieveCityHourlyWeatherUseCase; | ||
}()); | ||
exports.RetrieveCityHourlyWeatherUseCase = RetrieveCityHourlyWeatherUseCase; | ||
} | ||
} |
@@ -1,33 +0,28 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityPresenterBuilder = void 0; | ||
var AddCityPresenter_1 = require("../presenters/AddCityPresenter"); | ||
var AddCityPresenterBuilder = /** @class */ (function () { | ||
function AddCityPresenterBuilder(vm) { | ||
var _this = this; | ||
if (vm === void 0) { vm = new AddCityPresenter_1.AddCityPresenterVM(); } | ||
import { AddCityPresenterVM } from '../presenters/AddCityPresenter'; | ||
export class AddCityPresenterBuilder { | ||
constructor(vm = new AddCityPresenterVM()) { | ||
this.vm = vm; | ||
this.onVmUpdate = function (subscriber) { return subscriber(_this.vm); }; | ||
this.validateCityName = function () { return null; }; | ||
this.validateLatitude = function () { return null; }; | ||
this.validateLongitude = function () { return null; }; | ||
this.create = function () { return null; }; | ||
this.onVmUpdate = subscriber => subscriber(this.vm); | ||
this.validateCityName = () => null; | ||
this.validateLatitude = () => null; | ||
this.validateLongitude = () => null; | ||
this.create = () => null; | ||
} | ||
AddCityPresenterBuilder.prototype.withValidateCityName = function (validateCityName) { | ||
withValidateCityName(validateCityName) { | ||
this.validateCityName = validateCityName; | ||
return this; | ||
}; | ||
AddCityPresenterBuilder.prototype.withValidateLatitude = function (validateLatitude) { | ||
} | ||
withValidateLatitude(validateLatitude) { | ||
this.validateLatitude = validateLatitude; | ||
return this; | ||
}; | ||
AddCityPresenterBuilder.prototype.withValidateLongitude = function (validateLongitude) { | ||
} | ||
withValidateLongitude(validateLongitude) { | ||
this.validateLongitude = validateLongitude; | ||
return this; | ||
}; | ||
AddCityPresenterBuilder.prototype.withCreate = function (create) { | ||
} | ||
withCreate(create) { | ||
this.create = create; | ||
return this; | ||
}; | ||
AddCityPresenterBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
@@ -41,5 +36,3 @@ vm: this.vm, | ||
}; | ||
}; | ||
return AddCityPresenterBuilder; | ||
}()); | ||
exports.AddCityPresenterBuilder = AddCityPresenterBuilder; | ||
} | ||
} |
@@ -1,18 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CitiesPresenterBuilder = void 0; | ||
var CitiesPresenter_1 = require("../presenters/CitiesPresenter"); | ||
var CitiesPresenterBuilder = /** @class */ (function () { | ||
function CitiesPresenterBuilder(vm) { | ||
var _this = this; | ||
if (vm === void 0) { vm = new CitiesPresenter_1.CitiesPresenterVM(); } | ||
import { CitiesPresenterVM } from '../presenters/CitiesPresenter'; | ||
export class CitiesPresenterBuilder { | ||
constructor(vm = new CitiesPresenterVM()) { | ||
this.vm = vm; | ||
this.fetchCities = function () { return Promise.resolve(); }; | ||
this.onVmUpdate = function (subscriber) { return subscriber(_this.vm); }; | ||
this.fetchCities = () => Promise.resolve(); | ||
this.onVmUpdate = subscriber => subscriber(this.vm); | ||
} | ||
CitiesPresenterBuilder.prototype.withFetchCities = function (fetchCities) { | ||
withFetchCities(fetchCities) { | ||
this.fetchCities = fetchCities; | ||
return this; | ||
}; | ||
CitiesPresenterBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
@@ -23,5 +18,3 @@ vm: this.vm, | ||
}; | ||
}; | ||
return CitiesPresenterBuilder; | ||
}()); | ||
exports.CitiesPresenterBuilder = CitiesPresenterBuilder; | ||
} | ||
} |
@@ -1,33 +0,28 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CityPresenterBuilder = void 0; | ||
var CityPresenter_1 = require("../presenters/CityPresenter"); | ||
var CityPresenterBuilder = /** @class */ (function () { | ||
function CityPresenterBuilder(vm) { | ||
var _this = this; | ||
if (vm === void 0) { vm = new CityPresenter_1.CityPresenterVM(); } | ||
import { CityPresenterVM } from '../presenters/CityPresenter'; | ||
export class CityPresenterBuilder { | ||
constructor(vm = new CityPresenterVM()) { | ||
this.vm = vm; | ||
this.fetchWeather = function () { return Promise.resolve(); }; | ||
this.fetchCity = function () { return Promise.resolve(); }; | ||
this.updateMode = function () { return null; }; | ||
this.updateTemperatureUnit = function () { return null; }; | ||
this.onVmUpdate = function (subscriber) { return subscriber(_this.vm); }; | ||
this.fetchWeather = () => Promise.resolve(); | ||
this.fetchCity = () => Promise.resolve(); | ||
this.updateMode = () => null; | ||
this.updateTemperatureUnit = () => null; | ||
this.onVmUpdate = subscriber => subscriber(this.vm); | ||
} | ||
CityPresenterBuilder.prototype.withFetchWeather = function (fetchWeather) { | ||
withFetchWeather(fetchWeather) { | ||
this.fetchWeather = fetchWeather; | ||
return this; | ||
}; | ||
CityPresenterBuilder.prototype.withFetchCity = function (fetchCity) { | ||
} | ||
withFetchCity(fetchCity) { | ||
this.fetchCity = fetchCity; | ||
return this; | ||
}; | ||
CityPresenterBuilder.prototype.withUpdateMode = function (updateMode) { | ||
} | ||
withUpdateMode(updateMode) { | ||
this.updateMode = updateMode; | ||
return this; | ||
}; | ||
CityPresenterBuilder.prototype.withUpdateTemperatureUnit = function (updateTemperatureUnit) { | ||
} | ||
withUpdateTemperatureUnit(updateTemperatureUnit) { | ||
this.updateTemperatureUnit = updateTemperatureUnit; | ||
return this; | ||
}; | ||
CityPresenterBuilder.prototype.build = function () { | ||
} | ||
build() { | ||
return { | ||
@@ -41,5 +36,3 @@ vm: this.vm, | ||
}; | ||
}; | ||
return CityPresenterBuilder; | ||
}()); | ||
exports.CityPresenterBuilder = CityPresenterBuilder; | ||
} | ||
} |
@@ -1,29 +0,17 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./presenters/Presenter"), exports); | ||
__exportStar(require("./presenters/CitiesPresenter"), exports); | ||
__exportStar(require("./presenters/CityPresenter"), exports); | ||
__exportStar(require("./presenters/AddCityPresenter"), exports); | ||
__exportStar(require("./presenters/factories/CitiesPresenterFactory"), exports); | ||
__exportStar(require("./presenters/factories/AddCityPresenterFactory"), exports); | ||
__exportStar(require("./presenters/factories/CityPresenterFactory"), exports); | ||
__exportStar(require("./repositories/http/WeatherRepository7Timer"), exports); | ||
__exportStar(require("./repositories/http/dto/DailyWeather7Timer"), exports); | ||
__exportStar(require("./repositories/http/mapper/WeatherMapper"), exports); | ||
__exportStar(require("./repositories/inmemory/CityRepositoryInMemory"), exports); | ||
__exportStar(require("./router/Navigation"), exports); | ||
__exportStar(require("./router/NavigationRoute"), exports); | ||
__exportStar(require("./router/FakeNavigation"), exports); | ||
__exportStar(require("./builders/AddCityPresenterBuilder"), exports); | ||
__exportStar(require("./builders/CitiesPresenterBuilder"), exports); | ||
__exportStar(require("./builders/CityPresenterBuilder"), exports); | ||
export * from './presenters/Presenter'; | ||
export * from './presenters/CitiesPresenter'; | ||
export * from './presenters/CityPresenter'; | ||
export * from './presenters/AddCityPresenter'; | ||
export * from './presenters/factories/CitiesPresenterFactory'; | ||
export * from './presenters/factories/AddCityPresenterFactory'; | ||
export * from './presenters/factories/CityPresenterFactory'; | ||
export * from './repositories/http/WeatherRepository7Timer'; | ||
export * from './repositories/http/dto/DailyWeather7Timer'; | ||
export * from './repositories/http/mapper/WeatherMapper'; | ||
export * from './repositories/inmemory/CityRepositoryInMemory'; | ||
export * from './router/Navigation'; | ||
export * from './router/NavigationRoute'; | ||
export * from './router/FakeNavigation'; | ||
export * from './builders/AddCityPresenterBuilder'; | ||
export * from './builders/CitiesPresenterBuilder'; | ||
export * from './builders/CityPresenterBuilder'; |
@@ -1,22 +0,6 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityPresenter = exports.AddCityPresenterVM = void 0; | ||
var domain_1 = require("@grenoble-hands-on/domain"); | ||
var Presenter_1 = require("./Presenter"); | ||
var NavigationRoute_1 = require("../router/NavigationRoute"); | ||
var AddCityPresenterVM = /** @class */ (function () { | ||
function AddCityPresenterVM() { | ||
import { AddCityPresentationBuilder, AddCityRequest, NewCityFields } from '@grenoble-hands-on/domain'; | ||
import { Presenter } from './Presenter'; | ||
import { NavigationRoute } from '../router/NavigationRoute'; | ||
export class AddCityPresenterVM { | ||
constructor() { | ||
this.cityNameTouched = false; | ||
@@ -27,53 +11,46 @@ this.latitudeTouched = false; | ||
} | ||
return AddCityPresenterVM; | ||
}()); | ||
exports.AddCityPresenterVM = AddCityPresenterVM; | ||
var AddCityPresenter = /** @class */ (function (_super) { | ||
__extends(AddCityPresenter, _super); | ||
function AddCityPresenter(addCityUseCase, navigator) { | ||
var _this = _super.call(this, new AddCityPresenterVM()) || this; | ||
_this.addCityUseCase = addCityUseCase; | ||
_this.navigator = navigator; | ||
return _this; | ||
} | ||
export class AddCityPresenter extends Presenter { | ||
constructor(addCityUseCase, navigator) { | ||
super(new AddCityPresenterVM()); | ||
this.addCityUseCase = addCityUseCase; | ||
this.navigator = navigator; | ||
} | ||
AddCityPresenter.prototype.validateCityName = function (cityName) { | ||
validateCityName(cityName) { | ||
this.vm.cityName = cityName; | ||
this.vm.cityNameTouched = true; | ||
this.validate(); | ||
}; | ||
AddCityPresenter.prototype.validateLongitude = function (longitude) { | ||
} | ||
validateLongitude(longitude) { | ||
this.vm.longitude = longitude; | ||
this.vm.longitudeTouched = true; | ||
this.validate(); | ||
}; | ||
AddCityPresenter.prototype.validateLatitude = function (latitude) { | ||
} | ||
validateLatitude(latitude) { | ||
this.vm.latitude = latitude; | ||
this.vm.latitudeTouched = true; | ||
this.validate(); | ||
}; | ||
AddCityPresenter.prototype.create = function () { | ||
} | ||
create() { | ||
this.addCityUseCase | ||
.execute(new domain_1.AddCityRequest(this.vm.cityName || '', this.vm.latitude || '', this.vm.longitude || ''), this.createAddNewCityPresenter()) | ||
.execute(new AddCityRequest(this.vm.cityName || '', this.vm.latitude || '', this.vm.longitude || ''), this.createAddNewCityPresenter()) | ||
.then(); | ||
}; | ||
AddCityPresenter.prototype.validate = function () { | ||
this.addCityUseCase.validate(new domain_1.AddCityRequest(this.vm.cityName || '', this.vm.latitude || '', this.vm.longitude || ''), this.createAddNewCityPresenter()); | ||
}; | ||
AddCityPresenter.prototype.createAddNewCityPresenter = function () { | ||
var _this = this; | ||
return new domain_1.AddCityPresentationBuilder() | ||
.withNotifyNewCityInvalid(function (errors) { | ||
_this.vm.cityNameError = _this.vm.cityNameTouched ? errors.get(domain_1.NewCityFields.cityName) : ''; | ||
_this.vm.latitudeError = _this.vm.latitudeTouched ? errors.get(domain_1.NewCityFields.latitude) : ''; | ||
_this.vm.longitudeError = _this.vm.longitudeTouched ? errors.get(domain_1.NewCityFields.longitude) : ''; | ||
_this.vm.canCreateCity = errors.size == 0; | ||
_this.updateVM(); | ||
} | ||
validate() { | ||
this.addCityUseCase.validate(new AddCityRequest(this.vm.cityName || '', this.vm.latitude || '', this.vm.longitude || ''), this.createAddNewCityPresenter()); | ||
} | ||
createAddNewCityPresenter() { | ||
return new AddCityPresentationBuilder() | ||
.withNotifyNewCityInvalid((errors) => { | ||
this.vm.cityNameError = this.vm.cityNameTouched ? errors.get(NewCityFields.cityName) : ''; | ||
this.vm.latitudeError = this.vm.latitudeTouched ? errors.get(NewCityFields.latitude) : ''; | ||
this.vm.longitudeError = this.vm.longitudeTouched ? errors.get(NewCityFields.longitude) : ''; | ||
this.vm.canCreateCity = errors.size == 0; | ||
this.updateVM(); | ||
}) | ||
.withNotifyCityAdded(function (city) { | ||
_this.navigator.navigate(NavigationRoute_1.NavigationRoute.CITY(city)).then(); | ||
.withNotifyCityAdded((city) => { | ||
this.navigator.navigate(NavigationRoute.CITY(city)).then(); | ||
}) | ||
.build(); | ||
}; | ||
return AddCityPresenter; | ||
}(Presenter_1.Presenter)); | ||
exports.AddCityPresenter = AddCityPresenter; | ||
} | ||
} |
@@ -1,15 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -24,66 +10,21 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
import { GetCitiesPresentationBuilder } from '@grenoble-hands-on/domain'; | ||
import { Presenter } from './Presenter'; | ||
export class CitiesPresenterVM { | ||
} | ||
export class CitiesPresenter extends Presenter { | ||
constructor(getCitiesUseCase) { | ||
super(new CitiesPresenterVM()); | ||
this.getCitiesUseCase = getCitiesUseCase; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CitiesPresenter = exports.CitiesPresenterVM = void 0; | ||
var domain_1 = require("@grenoble-hands-on/domain"); | ||
var Presenter_1 = require("./Presenter"); | ||
var CitiesPresenterVM = /** @class */ (function () { | ||
function CitiesPresenterVM() { | ||
fetchCities() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.getCitiesUseCase.execute(new GetCitiesPresentationBuilder() | ||
.withDisplayCities((cities) => { | ||
this.vm.cities = cities; | ||
this.updateVM(); | ||
}) | ||
.build()); | ||
}); | ||
} | ||
return CitiesPresenterVM; | ||
}()); | ||
exports.CitiesPresenterVM = CitiesPresenterVM; | ||
var CitiesPresenter = /** @class */ (function (_super) { | ||
__extends(CitiesPresenter, _super); | ||
function CitiesPresenter(getCitiesUseCase) { | ||
var _this = _super.call(this, new CitiesPresenterVM()) || this; | ||
_this.getCitiesUseCase = getCitiesUseCase; | ||
return _this; | ||
} | ||
CitiesPresenter.prototype.fetchCities = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getCitiesUseCase.execute(new domain_1.GetCitiesPresentationBuilder() | ||
.withDisplayCities(function (cities) { | ||
_this.vm.cities = cities; | ||
_this.updateVM(); | ||
}) | ||
.build())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return CitiesPresenter; | ||
}(Presenter_1.Presenter)); | ||
exports.CitiesPresenter = CitiesPresenter; | ||
} |
@@ -1,15 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -24,35 +10,6 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CityPresenter = exports.CityPresenterVM = void 0; | ||
var Presenter_1 = require("./Presenter"); | ||
var domain_1 = require("@grenoble-hands-on/domain"); | ||
var CityPresenterVM = /** @class */ (function () { | ||
function CityPresenterVM() { | ||
import { Presenter } from './Presenter'; | ||
import { GetCityPresentationBuilder, GetCityRequest, RetrieveDailyWeatherPresentationBuilder, RetrieveHourlyWeatherPresentationBuilder, RetrieveWeatherRequest } from '@grenoble-hands-on/domain'; | ||
export class CityPresenterVM { | ||
constructor() { | ||
this.loading = false; | ||
@@ -62,113 +19,68 @@ this.temperatureUnite = 'C'; | ||
} | ||
return CityPresenterVM; | ||
}()); | ||
exports.CityPresenterVM = CityPresenterVM; | ||
var CityPresenter = /** @class */ (function (_super) { | ||
__extends(CityPresenter, _super); | ||
function CityPresenter(cityId, getCityUseCase, retrieveCityWeatherUseCase, retrieveCityHourlyWeatherUseCase) { | ||
var _this = _super.call(this, new CityPresenterVM()) || this; | ||
_this.cityId = cityId; | ||
_this.getCityUseCase = getCityUseCase; | ||
_this.retrieveCityWeatherUseCase = retrieveCityWeatherUseCase; | ||
_this.retrieveCityHourlyWeatherUseCase = retrieveCityHourlyWeatherUseCase; | ||
return _this; | ||
} | ||
export class CityPresenter extends Presenter { | ||
constructor(cityId, getCityUseCase, retrieveCityWeatherUseCase, retrieveCityHourlyWeatherUseCase) { | ||
super(new CityPresenterVM()); | ||
this.cityId = cityId; | ||
this.getCityUseCase = getCityUseCase; | ||
this.retrieveCityWeatherUseCase = retrieveCityWeatherUseCase; | ||
this.retrieveCityHourlyWeatherUseCase = retrieveCityHourlyWeatherUseCase; | ||
} | ||
CityPresenter.prototype.fetchCity = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var presenter; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
presenter = new domain_1.GetCityPresentationBuilder() | ||
.withDisplayCity(function (city) { | ||
_this.vm.city = city; | ||
_this.updateVM(); | ||
}) | ||
.build(); | ||
return [4 /*yield*/, this.getCityUseCase.execute(new domain_1.GetCityRequest(this.cityId), presenter)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
fetchCity() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const presenter = new GetCityPresentationBuilder() | ||
.withDisplayCity(city => { | ||
this.vm.city = city; | ||
this.updateVM(); | ||
}) | ||
.build(); | ||
yield this.getCityUseCase.execute(new GetCityRequest(this.cityId), presenter); | ||
}); | ||
}; | ||
CityPresenter.prototype.fetchWeather = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.vm.loading = true; | ||
this.vm.hourlyWeather = undefined; | ||
this.vm.dailyWeather = undefined; | ||
this.updateVM(); | ||
if (!(this.vm.mode == 'daily')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.fetchDailyWeather()]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, this.fetchHourlyWeather()]; | ||
case 3: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
fetchWeather() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.vm.loading = true; | ||
this.vm.hourlyWeather = undefined; | ||
this.vm.dailyWeather = undefined; | ||
this.updateVM(); | ||
if (this.vm.mode == 'daily') { | ||
yield this.fetchDailyWeather(); | ||
} | ||
else { | ||
yield this.fetchHourlyWeather(); | ||
} | ||
}); | ||
}; | ||
CityPresenter.prototype.updateTemperatureUnite = function (temperatureUnite) { | ||
} | ||
updateTemperatureUnite(temperatureUnite) { | ||
this.vm.temperatureUnite = temperatureUnite; | ||
this.fetchWeather(); | ||
}; | ||
CityPresenter.prototype.updateMode = function (mode) { | ||
} | ||
updateMode(mode) { | ||
this.vm.mode = mode; | ||
this.fetchWeather(); | ||
}; | ||
CityPresenter.prototype.fetchHourlyWeather = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var presenter; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
presenter = new domain_1.RetrieveHourlyWeatherPresentationBuilder() | ||
.withDisplayWeather(function (weather) { | ||
_this.vm.hourlyWeather = weather; | ||
_this.vm.loading = false; | ||
_this.updateVM(); | ||
}) | ||
.build(); | ||
return [4 /*yield*/, this.retrieveCityHourlyWeatherUseCase.execute(new domain_1.RetrieveWeatherRequest(this.cityId, this.vm.temperatureUnite), presenter)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
fetchHourlyWeather() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const presenter = new RetrieveHourlyWeatherPresentationBuilder() | ||
.withDisplayWeather((weather) => { | ||
this.vm.hourlyWeather = weather; | ||
this.vm.loading = false; | ||
this.updateVM(); | ||
}) | ||
.build(); | ||
yield this.retrieveCityHourlyWeatherUseCase.execute(new RetrieveWeatherRequest(this.cityId, this.vm.temperatureUnite), presenter); | ||
}); | ||
}; | ||
CityPresenter.prototype.fetchDailyWeather = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var presenter; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
presenter = new domain_1.RetrieveDailyWeatherPresentationBuilder() | ||
.withDisplayWeather(function (weather) { | ||
_this.vm.dailyWeather = weather; | ||
_this.vm.loading = false; | ||
_this.updateVM(); | ||
}) | ||
.build(); | ||
return [4 /*yield*/, this.retrieveCityWeatherUseCase.execute(new domain_1.RetrieveWeatherRequest(this.cityId, this.vm.temperatureUnite), presenter)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
fetchDailyWeather() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const presenter = new RetrieveDailyWeatherPresentationBuilder() | ||
.withDisplayWeather((weather) => { | ||
this.vm.dailyWeather = weather; | ||
this.vm.loading = false; | ||
this.updateVM(); | ||
}) | ||
.build(); | ||
yield this.retrieveCityWeatherUseCase.execute(new RetrieveWeatherRequest(this.cityId, this.vm.temperatureUnite), presenter); | ||
}); | ||
}; | ||
return CityPresenter; | ||
}(Presenter_1.Presenter)); | ||
exports.CityPresenter = CityPresenter; | ||
} | ||
} |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddCityPresenterFactory = void 0; | ||
var AddCityPresenter_1 = require("../AddCityPresenter"); | ||
var AddCityPresenterFactory = /** @class */ (function () { | ||
function AddCityPresenterFactory(addNewCityUseCase, navigation) { | ||
import { AddCityPresenter } from '../AddCityPresenter'; | ||
export class AddCityPresenterFactory { | ||
constructor(addNewCityUseCase, navigation) { | ||
this.addNewCityUseCase = addNewCityUseCase; | ||
this.navigation = navigation; | ||
} | ||
AddCityPresenterFactory.prototype.build = function () { | ||
return new AddCityPresenter_1.AddCityPresenter(this.addNewCityUseCase, this.navigation); | ||
}; | ||
return AddCityPresenterFactory; | ||
}()); | ||
exports.AddCityPresenterFactory = AddCityPresenterFactory; | ||
build() { | ||
return new AddCityPresenter(this.addNewCityUseCase, this.navigation); | ||
} | ||
} |
@@ -1,14 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CitiesPresenterFactory = void 0; | ||
var CitiesPresenter_1 = require("../CitiesPresenter"); | ||
var CitiesPresenterFactory = /** @class */ (function () { | ||
function CitiesPresenterFactory(getCitiesUseCase) { | ||
import { CitiesPresenter } from '../CitiesPresenter'; | ||
export class CitiesPresenterFactory { | ||
constructor(getCitiesUseCase) { | ||
this.getCitiesUseCase = getCitiesUseCase; | ||
} | ||
CitiesPresenterFactory.prototype.build = function () { | ||
return new CitiesPresenter_1.CitiesPresenter(this.getCitiesUseCase); | ||
}; | ||
return CitiesPresenterFactory; | ||
}()); | ||
exports.CitiesPresenterFactory = CitiesPresenterFactory; | ||
build() { | ||
return new CitiesPresenter(this.getCitiesUseCase); | ||
} | ||
} |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CityPresenterFactory = void 0; | ||
var CityPresenter_1 = require("../CityPresenter"); | ||
var CityPresenterFactory = /** @class */ (function () { | ||
function CityPresenterFactory(getCityUseCase, retrieveCityWeatherUseCase, retrieveCityHourlyWeatherUseCase) { | ||
import { CityPresenter } from '../CityPresenter'; | ||
export class CityPresenterFactory { | ||
constructor(getCityUseCase, retrieveCityWeatherUseCase, retrieveCityHourlyWeatherUseCase) { | ||
this.getCityUseCase = getCityUseCase; | ||
@@ -11,7 +8,5 @@ this.retrieveCityWeatherUseCase = retrieveCityWeatherUseCase; | ||
} | ||
CityPresenterFactory.prototype.build = function (cityId) { | ||
return new CityPresenter_1.CityPresenter(cityId, this.getCityUseCase, this.retrieveCityWeatherUseCase, this.retrieveCityHourlyWeatherUseCase); | ||
}; | ||
return CityPresenterFactory; | ||
}()); | ||
exports.CityPresenterFactory = CityPresenterFactory; | ||
build(cityId) { | ||
return new CityPresenter(cityId, this.getCityUseCase, this.retrieveCityWeatherUseCase, this.retrieveCityHourlyWeatherUseCase); | ||
} | ||
} |
@@ -1,18 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Presenter = void 0; | ||
var Presenter = /** @class */ (function () { | ||
function Presenter(vm) { | ||
export class Presenter { | ||
constructor(vm) { | ||
this.vm = vm; | ||
} | ||
Presenter.prototype.updateVM = function () { | ||
updateVM() { | ||
var _a; | ||
(_a = this.subscriber) === null || _a === void 0 ? void 0 : _a.call(this.subscriber, this.vm); | ||
}; | ||
Presenter.prototype.onVmUpdate = function (subscriber) { | ||
} | ||
onVmUpdate(subscriber) { | ||
this.subscriber = subscriber; | ||
this.subscriber(this.vm); | ||
}; | ||
return Presenter; | ||
}()); | ||
exports.Presenter = Presenter; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,51 +0,44 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WeatherMapper = void 0; | ||
var domain_1 = require("@grenoble-hands-on/domain"); | ||
var WeatherMapper = /** @class */ (function () { | ||
function WeatherMapper() { | ||
} | ||
WeatherMapper.toDailyDomain = function (weather) { | ||
var _this = this; | ||
return weather.dataseries.map(function (serie) { | ||
import { WeatherState } from '@grenoble-hands-on/domain'; | ||
export class WeatherMapper { | ||
static toDailyDomain(weather) { | ||
return weather.dataseries.map(serie => { | ||
return { | ||
day: _this.formatDate(_this.parseDate(serie.date.toString())), | ||
day: this.formatDate(this.parseDate(serie.date.toString())), | ||
temperatureMax: serie.temp2m.max, | ||
temperatureMin: serie.temp2m.min, | ||
weather: _this.getWeatherState(serie.weather), | ||
weather: this.getWeatherState(serie.weather), | ||
unite: 'C' | ||
}; | ||
}); | ||
}; | ||
WeatherMapper.toHourlyDomain = function (weather) { | ||
var _this = this; | ||
var date = this.parseTime(weather.init); | ||
return weather.dataseries.map(function (serie) { | ||
var time = new Date(date.getFullYear(), date.getMonth(), date.getDay(), date.getHours() + serie.timepoint); | ||
} | ||
static toHourlyDomain(weather) { | ||
const date = this.parseTime(weather.init); | ||
return weather.dataseries.map(serie => { | ||
const time = new Date(date.getFullYear(), date.getMonth(), date.getDay(), date.getHours() + serie.timepoint); | ||
return { | ||
time: _this.formatTime(time), | ||
time: this.formatTime(time), | ||
temperature: serie.temp2m, | ||
weather: _this.getWeatherState(serie.weather), | ||
weather: this.getWeatherState(serie.weather), | ||
unite: 'C' | ||
}; | ||
}); | ||
}; | ||
WeatherMapper.formatDate = function (date) { | ||
var day = ('0' + date.getDate()).slice(-2); | ||
var month = ('0' + (date.getMonth() + 1)).slice(-2); | ||
var year = date.getFullYear(); | ||
return day + "/" + month + "/" + year; | ||
}; | ||
WeatherMapper.formatTime = function (date) { | ||
var minutes = ('0' + date.getMinutes()).slice(-2); | ||
var hour = ('0' + date.getHours()).slice(-2); | ||
return hour + ":" + minutes; | ||
}; | ||
WeatherMapper.parseDate = function (date) { | ||
} | ||
static formatDate(date) { | ||
const day = ('0' + date.getDate()).slice(-2); | ||
const month = ('0' + (date.getMonth() + 1)).slice(-2); | ||
const year = date.getFullYear(); | ||
return `${day}/${month}/${year}`; | ||
} | ||
static formatTime(date) { | ||
const minutes = ('0' + date.getMinutes()).slice(-2); | ||
const hour = ('0' + date.getHours()).slice(-2); | ||
return `${hour}:${minutes}`; | ||
} | ||
static parseDate(date) { | ||
return new Date(+date.substring(0, 4), +date.substring(4, 6) - 1, +date.substring(6)); | ||
}; | ||
WeatherMapper.parseTime = function (date) { | ||
} | ||
static parseTime(date) { | ||
return new Date(+date.substring(0, 4), +date.substring(4, 6) - 1, +date.substring(6, 8) - 1, +date.substring(8)); | ||
}; | ||
WeatherMapper.getWeatherState = function (weather) { | ||
} | ||
static getWeatherState(weather) { | ||
switch (weather) { | ||
@@ -55,3 +48,3 @@ case 'clear': | ||
case 'clearnight': | ||
return domain_1.WeatherState.sunny; | ||
return WeatherState.sunny; | ||
case 'pcloudy': | ||
@@ -63,11 +56,11 @@ case 'pcloudyday': | ||
case 'windynight': | ||
return domain_1.WeatherState.partly_cloudy; | ||
return WeatherState.partly_cloudy; | ||
case 'mcloudy': | ||
case 'mcloudynight': | ||
case 'mcloudyday': | ||
return domain_1.WeatherState.cloudy_s_sunny; | ||
return WeatherState.cloudy_s_sunny; | ||
case 'cloudy': | ||
case 'cloudyday': | ||
case 'cloudynight': | ||
return domain_1.WeatherState.cloudy; | ||
return WeatherState.cloudy; | ||
case 'fog': | ||
@@ -78,3 +71,3 @@ case 'fogday': | ||
case 'humidday': | ||
return domain_1.WeatherState.fog; | ||
return WeatherState.fog; | ||
case 'lightrain': | ||
@@ -86,34 +79,32 @@ case 'lightrainday': | ||
case 'rainnight': | ||
return domain_1.WeatherState.rain; | ||
return WeatherState.rain; | ||
case 'oshower': | ||
case 'oshowerday': | ||
case 'oshowernight': | ||
return domain_1.WeatherState.rain_s_sunny; | ||
return WeatherState.rain_s_sunny; | ||
case 'ishower': | ||
case 'ishowerday': | ||
case 'ishowernight': | ||
return domain_1.WeatherState.sunny_s_rain; | ||
return WeatherState.sunny_s_rain; | ||
case 'lightsnow': | ||
case 'lightsnowday': | ||
case 'lightsnownight': | ||
return domain_1.WeatherState.snow_light; | ||
return WeatherState.snow_light; | ||
case 'snow': | ||
case 'snowday': | ||
case 'snownight': | ||
return domain_1.WeatherState.snow; | ||
return WeatherState.snow; | ||
case 'rainsnow': | ||
case 'rainsnowday': | ||
case 'rainsnownight': | ||
return domain_1.WeatherState.sleet; | ||
return WeatherState.sleet; | ||
case 'ts': | ||
case 'tstorm': | ||
case 'tsrrain': | ||
return domain_1.WeatherState.thunderstorms; | ||
return WeatherState.thunderstorms; | ||
default: | ||
console.debug('unknown state : ' + weather); | ||
return domain_1.WeatherState.unknown; | ||
return WeatherState.unknown; | ||
} | ||
}; | ||
return WeatherMapper; | ||
}()); | ||
exports.WeatherMapper = WeatherMapper; | ||
} | ||
} |
@@ -1,25 +0,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WeatherRepository7Timer = void 0; | ||
var WeatherMapper_1 = require("./mapper/WeatherMapper"); | ||
var WeatherRepository7Timer = /** @class */ (function () { | ||
function WeatherRepository7Timer(http, cityRepository) { | ||
import { WeatherMapper } from './mapper/WeatherMapper'; | ||
export class WeatherRepository7Timer { | ||
constructor(http, cityRepository) { | ||
this.http = http; | ||
this.cityRepository = cityRepository; | ||
this.BASE_URL = "http://www.7timer.info/bin/api.pl"; | ||
this.BASE_URL = `http://www.7timer.info/bin/api.pl`; | ||
} | ||
WeatherRepository7Timer.prototype.getCityDailyWeather = function (cityId) { | ||
var _this = this; | ||
getCityDailyWeather(cityId) { | ||
return this.cityRepository.getCity(cityId) | ||
.then(function (city) { return _this.http.get(_this.BASE_URL + "?lon=" + city.position.longitude + "&lat=" + city.position.latitude + "&product=civillight&output=json"); }) | ||
.then(function (res) { return WeatherMapper_1.WeatherMapper.toDailyDomain(res); }); | ||
}; | ||
WeatherRepository7Timer.prototype.getCityHourlyWeather = function (cityId) { | ||
var _this = this; | ||
.then((city) => this.http.get(`${this.BASE_URL}?lon=${city.position.longitude}&lat=${city.position.latitude}&product=civillight&output=json`)) | ||
.then((res) => WeatherMapper.toDailyDomain(res)); | ||
} | ||
getCityHourlyWeather(cityId) { | ||
return this.cityRepository.getCity(cityId) | ||
.then(function (city) { return _this.http.get(_this.BASE_URL + "?lon=" + city.position.longitude + "&lat=" + city.position.latitude + "&product=civil&output=json"); }) | ||
.then(function (res) { return WeatherMapper_1.WeatherMapper.toHourlyDomain(res); }); | ||
}; | ||
return WeatherRepository7Timer; | ||
}()); | ||
exports.WeatherRepository7Timer = WeatherRepository7Timer; | ||
.then((city) => this.http.get(`${this.BASE_URL}?lon=${city.position.longitude}&lat=${city.position.latitude}&product=civil&output=json`)) | ||
.then((res) => WeatherMapper.toHourlyDomain(res)); | ||
} | ||
} |
@@ -1,34 +0,23 @@ | ||
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CityRepositoryInMemory = void 0; | ||
var domain_1 = require("@grenoble-hands-on/domain"); | ||
var INITIAL_CITIES = [ | ||
{ name: "GRENOBLE", position: new domain_1.GeoPosition(45.183916, 5.703630) }, | ||
{ name: "SINGAPOUR", position: new domain_1.GeoPosition(1.295600, 103.858995) }, | ||
{ name: "BORDEAUX", position: new domain_1.GeoPosition(44.848089, -0.571017) }, | ||
{ name: "BREST", position: new domain_1.GeoPosition(48.389397, -4.499237) }, | ||
{ name: "MONTREAL", position: new domain_1.GeoPosition(45.523000, -73.581700) }, | ||
{ name: "LYON", position: new domain_1.GeoPosition(45.767443, 4.858798) }, | ||
{ name: "RENNES", position: new domain_1.GeoPosition(48.113409, -1.661249) }, | ||
{ name: "NANTES", position: new domain_1.GeoPosition(47.207408, -1.556187) }, | ||
{ name: "LILLE", position: new domain_1.GeoPosition(50.648670, 3.075520) }, | ||
{ name: "PARIS", position: new domain_1.GeoPosition(48.878932, 2.328487) } | ||
import { GeoPosition } from '@grenoble-hands-on/domain'; | ||
const INITIAL_CITIES = [ | ||
{ name: "GRENOBLE", position: new GeoPosition(45.183916, 5.703630) }, | ||
{ name: "SINGAPOUR", position: new GeoPosition(1.295600, 103.858995) }, | ||
{ name: "BORDEAUX", position: new GeoPosition(44.848089, -0.571017) }, | ||
{ name: "BREST", position: new GeoPosition(48.389397, -4.499237) }, | ||
{ name: "MONTREAL", position: new GeoPosition(45.523000, -73.581700) }, | ||
{ name: "LYON", position: new GeoPosition(45.767443, 4.858798) }, | ||
{ name: "RENNES", position: new GeoPosition(48.113409, -1.661249) }, | ||
{ name: "NANTES", position: new GeoPosition(47.207408, -1.556187) }, | ||
{ name: "LILLE", position: new GeoPosition(50.648670, 3.075520) }, | ||
{ name: "PARIS", position: new GeoPosition(48.878932, 2.328487) } | ||
]; | ||
var CityRepositoryInMemory = /** @class */ (function () { | ||
function CityRepositoryInMemory(cities) { | ||
if (cities === void 0) { cities = INITIAL_CITIES; } | ||
export class CityRepositoryInMemory { | ||
constructor(cities = INITIAL_CITIES) { | ||
this.cities = cities; | ||
} | ||
CityRepositoryInMemory.prototype.getCities = function () { | ||
getCities() { | ||
return Promise.resolve(this.cities); | ||
}; | ||
CityRepositoryInMemory.prototype.getCity = function (city) { | ||
var resolvedCity = this.cities.find(function (c) { return c.name == city; }); | ||
} | ||
getCity(city) { | ||
const resolvedCity = this.cities.find(c => c.name == city); | ||
if (resolvedCity) { | ||
@@ -38,11 +27,9 @@ return Promise.resolve(resolvedCity); | ||
else { | ||
throw new Error(city + " doesn't exist in this repository"); | ||
throw new Error(`${city} doesn't exist in this repository`); | ||
} | ||
}; | ||
CityRepositoryInMemory.prototype.addCity = function (city) { | ||
this.cities = __spreadArrays(this.cities, [city]); | ||
} | ||
addCity(city) { | ||
this.cities = [...this.cities, city]; | ||
return Promise.resolve(); | ||
}; | ||
return CityRepositoryInMemory; | ||
}()); | ||
exports.CityRepositoryInMemory = CityRepositoryInMemory; | ||
} | ||
} |
@@ -1,15 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FakeNavigation = void 0; | ||
var FakeNavigation = /** @class */ (function () { | ||
function FakeNavigation(currentRoute) { | ||
if (currentRoute === void 0) { currentRoute = ''; } | ||
export class FakeNavigation { | ||
constructor(currentRoute = '') { | ||
this.currentRoute = currentRoute; | ||
} | ||
FakeNavigation.prototype.navigate = function (route) { | ||
navigate(route) { | ||
this.currentRoute = route; | ||
return Promise.resolve(); | ||
}; | ||
return FakeNavigation; | ||
}()); | ||
exports.FakeNavigation = FakeNavigation; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NavigationRoute = void 0; | ||
var NavigationRoute = /** @class */ (function () { | ||
function NavigationRoute() { | ||
} | ||
NavigationRoute.CITY = function (city) { return "/city/" + city.name; }; | ||
NavigationRoute.HOME = '/'; | ||
NavigationRoute.CITIES = '/cities'; | ||
return NavigationRoute; | ||
}()); | ||
exports.NavigationRoute = NavigationRoute; | ||
export class NavigationRoute { | ||
static CITY(city) { return `/city/${city.name}`; } | ||
} | ||
NavigationRoute.HOME = '/'; | ||
NavigationRoute.CITIES = '/cities'; |
{ | ||
"name": "@grenoble-hands-on/web-adapters", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Martin Choraine <martin.choraine@gmail.com>", | ||
@@ -9,3 +9,5 @@ "homepage": "https://github.com/Zenika/grenoble-hands-on-front-clean-architecture", | ||
"types": "dist/web/adapters/src/index.d.ts", | ||
"files": ["dist/**/*"], | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"scripts": { | ||
@@ -17,3 +19,3 @@ "build": "tsc", | ||
"dependencies": { | ||
"@grenoble-hands-on/domain": "0.0.2" | ||
"@grenoble-hands-on/domain": "0.0.3" | ||
}, | ||
@@ -20,0 +22,0 @@ "devDependencies": { |
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
0
103505
127
2173
+ Added@grenoble-hands-on/domain@0.0.3(transitive)
- Removed@grenoble-hands-on/domain@0.0.2(transitive)