Comparing version 1.1.0 to 1.1.1
@@ -39,32 +39,35 @@ import { Fetcher } from '@literate.ink/utilities'; | ||
declare enum Moment { | ||
MORNING = "MORNING", | ||
LUNCH = "LUNCH", | ||
EVENING = "EVENING" | ||
} | ||
declare const Moment: { | ||
readonly MORNING: "MORNING"; | ||
readonly LUNCH: "LUNCH"; | ||
readonly EVENING: "EVENING"; | ||
}; | ||
type Moment = typeof Moment[keyof typeof Moment]; | ||
declare enum PaymentMethod { | ||
CARD = "CARD", | ||
CASH = "CASH", | ||
IZLY = "IZLY", | ||
MONEO = "MONEO" | ||
} | ||
declare const PaymentMethod: { | ||
readonly CARD: "CARD"; | ||
readonly CASH: "CASH"; | ||
readonly IZLY: "IZLY"; | ||
readonly MONEO: "MONEO"; | ||
}; | ||
type PaymentMethod = typeof PaymentMethod[keyof typeof PaymentMethod]; | ||
declare enum RestaurantKind { | ||
CAFETERIA = "CAFETERIA", | ||
RESTAURANT = "RESTAURANT", | ||
APPROVED_RESTAURANT = "APPROVED_RESTAURANT", | ||
MANAGED_RESTAURANT = "MANAGED_RESTAURANT", | ||
ADMINISTRATIVE_RESTAURANT = "ADMINISTRATIVE_RESTAURANT", | ||
COFFEE_CORNER = "COFFEE_CORNER", | ||
BREWERY = "BREWERY", | ||
FOOD_TRUCK = "FOOD_TRUCK", | ||
SELF_SERVICE = "SELF_SERVICE", | ||
KIOSK = "KIOSK", | ||
PIZZERIA = "PIZZERIA", | ||
GROCERY_STORE = "GROCERY_STORE", | ||
SCOOTER = "SCOOTER", | ||
CROUS_AND_GO = "CROUS_AND_GO", | ||
SANDWICH_SHOP = "SANDWICH_SHOP" | ||
} | ||
declare const RestaurantKind: { | ||
readonly CAFETERIA: "CAFETERIA"; | ||
readonly RESTAURANT: "RESTAURANT"; | ||
readonly APPROVED_RESTAURANT: "APPROVED_RESTAURANT"; | ||
readonly MANAGED_RESTAURANT: "MANAGED_RESTAURANT"; | ||
readonly ADMINISTRATIVE_RESTAURANT: "ADMINISTRATIVE_RESTAURANT"; | ||
readonly COFFEE_CORNER: "COFFEE_CORNER"; | ||
readonly BREWERY: "BREWERY"; | ||
readonly FOOD_TRUCK: "FOOD_TRUCK"; | ||
readonly SELF_SERVICE: "SELF_SERVICE"; | ||
readonly KIOSK: "KIOSK"; | ||
readonly PIZZERIA: "PIZZERIA"; | ||
readonly GROCERY_STORE: "GROCERY_STORE"; | ||
readonly SCOOTER: "SCOOTER"; | ||
readonly CROUS_AND_GO: "CROUS_AND_GO"; | ||
readonly SANDWICH_SHOP: "SANDWICH_SHOP"; | ||
}; | ||
type RestaurantKind = typeof RestaurantKind[keyof typeof RestaurantKind]; | ||
@@ -97,6 +100,6 @@ interface Restaurant { | ||
declare function restaurants(identifier: string, fetcher?: Fetcher): Promise<Array<Restaurant>>; | ||
declare function isRestaurantOpen(restaurant: Restaurant, dayIndex: number, moment: Moment): boolean; | ||
declare function meals(restaurant: Restaurant, date?: Date): Array<Meal> | undefined; | ||
declare const restaurants: (identifier: string, fetcher?: Fetcher) => Promise<Array<Restaurant>>; | ||
declare const isRestaurantOpen: (restaurant: Restaurant, dayIndex: number, moment: Moment) => boolean; | ||
declare const meals: (restaurant: Restaurant, date?: Date) => Array<Meal> | undefined; | ||
export { type Contact, type Feed, type Image, type Meal, type MealCategory, type Menu, Moment, PaymentMethod, type Restaurant, RestaurantKind, UnknownEnumValue, feeds, isRestaurantOpen, meals, restaurants }; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,s={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(s,{Moment:()=>A,PaymentMethod:()=>O,RestaurantKind:()=>m,UnknownEnumValue:()=>l,feeds:()=>c,isRestaurantOpen:()=>_,meals:()=>D,restaurants:()=>I}),module.exports=(e=s,((e,s,i,o)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let u of n(s))a.call(e,u)||u===i||t(e,u,{get:()=>s[u],enumerable:!(o=r(s,u))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=require("@literate.ink/utilities"),o=class{url;constructor(e){this.url=new URL("http://webservices-v2.crous-mobile.fr/feed/"+e)}};function u(e){return{name:e.name.replace("FLUX ",""),identifier:e.url.split("/")[4],isDefault:e.is_default}}async function c(e=i.defaultFetcher){const t=new o("feeds.json"),{content:r}=await e(t),{results:n}=JSON.parse(r);return n.map(u)}var R=require("@literate.ink/utilities");function E(e){return{name:e.name,dishes:e.dishes.map((e=>e.name))}}var l=class extends Error{constructor(e,t){super(`Expected a value from the enum '${e}', but got '${t}'`),this.name="UnknownEnumValue"}},A=(e=>(e.MORNING="MORNING",e.LUNCH="LUNCH",e.EVENING="EVENING",e))(A||{}),O=(e=>(e.CARD="CARD",e.CASH="CASH",e.IZLY="IZLY",e.MONEO="MONEO",e))(O||{}),m=(e=>(e.CAFETERIA="CAFETERIA",e.RESTAURANT="RESTAURANT",e.APPROVED_RESTAURANT="APPROVED_RESTAURANT",e.MANAGED_RESTAURANT="MANAGED_RESTAURANT",e.ADMINISTRATIVE_RESTAURANT="ADMINISTRATIVE_RESTAURANT",e.COFFEE_CORNER="COFFEE_CORNER",e.BREWERY="BREWERY",e.FOOD_TRUCK="FOOD_TRUCK",e.SELF_SERVICE="SELF_SERVICE",e.KIOSK="KIOSK",e.PIZZERIA="PIZZERIA",e.GROCERY_STORE="GROCERY_STORE",e.SCOOTER="SCOOTER",e.CROUS_AND_GO="CROUS_AND_GO",e.SANDWICH_SHOP="SANDWICH_SHOP",e))(m||{});function N(e){switch(e){case"matin":return"MORNING";case"midi":return"LUNCH";case"soir":return"EVENING";default:throw new l("Moment",e)}}function d(e){let t;const r=e.foodcategory.map(E).filter((e=>"informations"!==e.name&&"Fermeture"!==e.name||(void 0===t&&(t=e.dishes[0]),!1)));return{moment:N(e.name),information:t,categories:r}}function S(e){return{date:new Date(e.date),meals:e.meal.map(d)}}function f(e){const t=e.name;switch(t){case"Carte bancaire":return"CARD";case"Espèce":return"CASH";case"IZLY":return"IZLY";case"Monéo":return"MONEO";default:throw new l("PaymentMethod",t)}}function p(e){switch(e){case"Cafétéria":return"CAFETERIA";case"Restaurant":return"RESTAURANT";case"Restaurant agréé":return"APPROVED_RESTAURANT";case"Restaurant géré":return"MANAGED_RESTAURANT";case"Coffee Corner":return"COFFEE_CORNER";case"Brasserie":return"BREWERY";case"Foodtruck":return"FOOD_TRUCK";case"Restaurant administratif":return"ADMINISTRATIVE_RESTAURANT";case"Libre-service":return"SELF_SERVICE";case"Kiosque":return"KIOSK";case"Pizzéria":return"PIZZERIA";case"épicerie":return"GROCERY_STORE";case"Triporteur":return"SCOOTER";case"crous and go":return"CROUS_AND_GO";case"Sandwicherie":return"SANDWICH_SHOP";default:throw new l("RestaurantKind",e)}}function T(e){return{href:e.src,description:e.alt}}function C(e){return{id:e.id,title:e.title,latitude:e.lat,longitude:e.lon,area:e.area,address:e.adresse,opening:e.opening,closing:e.closing,kind:p(e.type),accessibility:e.accessibility,wifi:e.wifi,shortDescription:e.shortdesc,description:e.description,access:e.access,operationalHours:e.operationalhours,contact:(t=e.contact,{phone:t.tel,email:t.email}),crousAndGo:e.crousandgo,album:e.album&&T(e.album),photo:T(e.photo),paymentMethods:e.payment.map(f),menus:e.menus.map(S)};var t}async function I(e,t=R.defaultFetcher){const r=new o(`${e}/externe/crous-${e}.min.json`),n=(await t(r)).content.replace(/[\u0000-\u001F]/g,""),{restaurants:a}=JSON.parse(n);return a.map(C)}function _(e,t,r){return"1"===e.opening.split(",")[t]["LUNCH"===r?1:"MORNING"===r?0:2]}function D(e,t=new Date){const r=t.toLocaleDateString();return e.menus.find((e=>e.date.toLocaleDateString()===r))?.meals}//# sourceMappingURL=index.js.map | ||
"use strict";var e=require("@literate.ink/utilities"),t=class{url;constructor(e){this.url=new URL("http://webservices-v2.crous-mobile.fr/feed/"+e)}},r=e=>({name:e.name.replace("FLUX ",""),identifier:e.url.split("/")[4],isDefault:e.is_default});var a=e=>({name:e.name,dishes:e.dishes.map((e=>e.name))}),n=class extends Error{constructor(e,t){super(`Expected a value from the enum '${e}', but got '${t}'`),this.name="UnknownEnumValue"}},s={MORNING:"MORNING",LUNCH:"LUNCH",EVENING:"EVENING"},i={CARD:"CARD",CASH:"CASH",IZLY:"IZLY",MONEO:"MONEO"},o={CAFETERIA:"CAFETERIA",RESTAURANT:"RESTAURANT",APPROVED_RESTAURANT:"APPROVED_RESTAURANT",MANAGED_RESTAURANT:"MANAGED_RESTAURANT",ADMINISTRATIVE_RESTAURANT:"ADMINISTRATIVE_RESTAURANT",COFFEE_CORNER:"COFFEE_CORNER",BREWERY:"BREWERY",FOOD_TRUCK:"FOOD_TRUCK",SELF_SERVICE:"SELF_SERVICE",KIOSK:"KIOSK",PIZZERIA:"PIZZERIA",GROCERY_STORE:"GROCERY_STORE",SCOOTER:"SCOOTER",CROUS_AND_GO:"CROUS_AND_GO",SANDWICH_SHOP:"SANDWICH_SHOP"},R=e=>{switch(e){case"matin":return s.MORNING;case"midi":return s.LUNCH;case"soir":return s.EVENING;default:throw new n("Moment",e)}},c=e=>{let t;const r=e.foodcategory.map(a).filter((e=>"informations"!==e.name&&"Fermeture"!==e.name||(void 0===t&&(t=e.dishes[0]),!1)));return{moment:R(e.name),information:t,categories:r}},u=e=>({date:new Date(e.date),meals:e.meal.map(c)}),E=e=>{const t=e.name;switch(t){case"Carte bancaire":return i.CARD;case"Espèce":return i.CASH;case"IZLY":return i.IZLY;case"Monéo":return i.MONEO;default:throw new n("PaymentMethod",t)}},A=e=>{switch(e){case"Cafétéria":return o.CAFETERIA;case"Restaurant":return o.RESTAURANT;case"Restaurant agréé":return o.APPROVED_RESTAURANT;case"Restaurant géré":return o.MANAGED_RESTAURANT;case"Coffee Corner":return o.COFFEE_CORNER;case"Brasserie":return o.BREWERY;case"Foodtruck":return o.FOOD_TRUCK;case"Restaurant administratif":return o.ADMINISTRATIVE_RESTAURANT;case"Libre-service":return o.SELF_SERVICE;case"Kiosque":return o.KIOSK;case"Pizzéria":return o.PIZZERIA;case"épicerie":return o.GROCERY_STORE;case"Triporteur":return o.SCOOTER;case"crous and go":return o.CROUS_AND_GO;case"Sandwicherie":return o.SANDWICH_SHOP;default:throw new n("RestaurantKind",e)}},O=e=>({href:e.src,description:e.alt}),l=e=>{return{id:e.id,title:e.title,latitude:e.lat,longitude:e.lon,area:e.area,address:e.adresse,opening:e.opening,closing:e.closing,kind:A(e.type),accessibility:e.accessibility,wifi:e.wifi,shortDescription:e.shortdesc,description:e.description,access:e.access,operationalHours:e.operationalhours,contact:(t=e.contact,{phone:t.tel,email:t.email}),crousAndGo:e.crousandgo,album:e.album&&O(e.album),photo:O(e.photo),paymentMethods:e.payment.map(E),menus:e.menus.map(u)};var t};exports.Moment=s,exports.PaymentMethod=i,exports.RestaurantKind=o,exports.UnknownEnumValue=n,exports.feeds=async function(a=e.defaultFetcher){const n=new t("feeds.json"),{content:s}=await a(n),{results:i}=JSON.parse(s);return i.map(r)},exports.isRestaurantOpen=(e,t,r)=>"1"===e.opening.split(",")[t][r===s.LUNCH?1:r===s.MORNING?0:2],exports.meals=(e,t=new Date)=>{const r=t.toLocaleDateString();return e.menus.find((e=>e.date.toLocaleDateString()===r))?.meals},exports.restaurants=async(r,a=e.defaultFetcher)=>{const n=new t(`${r}/externe/crous-${r}.min.json`),s=(await a(n)).content.replace(/[\u0000-\u001F]/g,""),{restaurants:i}=JSON.parse(s);return i.map(l)};//# sourceMappingURL=index.js.map |
{ | ||
"name": "crowous", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A wrapper for the Crous Mobile internal API.", | ||
"repository": "https://github.com/LiterateInk/Crowous", | ||
"sideEffects": false, | ||
"main": "./dist/index.js", | ||
@@ -10,8 +11,13 @@ "module": "./dist/index.mjs", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/index.js" | ||
"import": { | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup src/index.ts --dts --minify terser --clean --format cjs,esm --sourcemap", | ||
"build": "tsup", | ||
"release": "release-it", | ||
@@ -67,4 +73,4 @@ "lint": "tsc && eslint ." | ||
"dependencies": { | ||
"@literate.ink/utilities": "1.0.0-10281844077.1" | ||
"@literate.ink/utilities": "1.0.0-10336585950.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81295
89
+ Added@literate.ink/utilities@1.0.0-10336585950.1(transitive)
- Removed@literate.ink/utilities@1.0.0-10281844077.1(transitive)