@hebcal/rest-api 3.12.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -8
- package/dist/bundle.js +3255 -581
- package/dist/bundle.min.js +2 -2
- package/dist/index.js +97 -42
- package/dist/index.mjs +98 -44
- package/package.json +15 -23
- package/rest-api.d.ts +12 -10
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
|
-
/*! @hebcal/rest-api v3.
|
|
1
|
+
/*! @hebcal/rest-api v3.14.0 */
|
|
2
2
|
import { flags, Zmanim, HebrewCalendar, Locale } from '@hebcal/core';
|
|
3
3
|
import * as leyn from '@hebcal/leyning';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const Chanukah="Hanukkah, the Jewish festival of rededication. Also known as the Festival of Lights";const Pesach="Passover, the Feast of Unleavened Bread. Also called Chag HaMatzot (the Festival of Matzah), it commemorates the Exodus and freedom of the Israelites from ancient Egypt";const Purim="Celebration of Jewish deliverance as told by Megilat Esther. It commemorates a time when the Jewish people living in Persia were saved from extermination";const Shavuot="Festival of Weeks. Commemorates the giving of the Torah at Mount Sinai";const Sigd="Ethiopian Jewish holiday occurring 50 days after Yom Kippur";const Sukkot="Feast of Booths";var holidayDescription = {"Asara B'Tevet":"Fast commemorating the siege of Jerusalem",Chanukah:Chanukah,"Days of the Omer":"7 weeks from the second night of Pesach to the day before Shavuot","Lag BaOmer":"33rd day of counting the Omer","Leil Selichot":"Prayers for forgiveness in preparation for the High Holidays","Pesach Sheni":"Second Passover, one month after Passover",Pesach:Pesach,"Purim Katan":"Minor Purim celebration during Adar I on leap years",Purim:Purim,"Rosh Chodesh Nisan":"Start of month of Nisan on the Hebrew calendar. נִיסָן (transliterated Nisan or Nissan) is the 1st month of the Hebrew year, has 30 days, and corresponds to March or April on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Iyyar":"Start of month of Iyyar on the Hebrew calendar. אִיָיר (transliterated Iyyar or Iyar) is the 2nd month of the Hebrew year, has 29 days, and corresponds to April or May on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sivan":"Start of month of Sivan on the Hebrew calendar. Sivan (סִיוָן) is the 3rd month of the Hebrew year, has 30 days, and corresponds to May or June on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tamuz":"Start of month of Tamuz on the Hebrew calendar. תַּמּוּז (transliterated Tamuz or Tammuz) is the 4th month of the Hebrew year, has 29 days, and corresponds to June or July on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Av":"Start of month of Av on the Hebrew calendar. Av (אָב) is the 5th month of the Hebrew year, has 30 days, and corresponds to July or August on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Elul":"Start of month of Elul on the Hebrew calendar. Elul (אֱלוּל) is the 6th month of the Hebrew year, has 29 days, and corresponds to August or September on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Cheshvan":"Start of month of Cheshvan on the Hebrew calendar. חֶשְׁוָן (transliterated Cheshvan or Heshvan) is the 8th month of the Hebrew year, has 29 or 30 days, and corresponds to October or November on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Kislev":"Start of month of Kislev on the Hebrew calendar. Kislev (כִּסְלֵו) is the 9th month of the Hebrew year, has 30 or 29 days, and corresponds to November or December on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tevet":"Start of month of Tevet on the Hebrew calendar. Tevet (טֵבֵת) is the 10th month of the Hebrew year, has 29 days, and corresponds to December or January on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sh'vat":"Start of month of Sh'vat on the Hebrew calendar. שְׁבָט (transliterated Sh'vat or Shevat) is the 11th month of the Hebrew year, has 30 days, and corresponds to January or February on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar":"Start of month of Adar on the Hebrew calendar. Adar (אַדָר) is the 12th month of the Hebrew year, has 29 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar I":"Start of month of Adar I (on leap years) on the Hebrew calendar. Adar I (אַדָר א׳) is the 12th month of the Hebrew year, occurs only on leap years, has 30 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar II":"Start of month of Adar II (on leap years) on the Hebrew calendar. Adar II (אַדָר ב׳), sometimes \"Adar Bet\" or \"Adar Sheni\", is the 13th month of the Hebrew year, has 29 days, occurs only on leap years, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Hashana":"The Jewish New Year. Also spelled Rosh Hashanah","Rosh Hashana LaBehemot":"New Year for Tithing Animals","Shabbat Chazon":"Shabbat before Tish'a B'Av (Shabbat of Prophecy/Shabbat of Vision)","Shabbat HaChodesh":"Shabbat before Rosh Chodesh Nissan","Shabbat HaGadol":"Shabbat before Pesach","Shabbat Machar Chodesh":"When Shabbat falls the day before Rosh Chodesh","Shabbat Nachamu":"Shabbat after Tish'a B'Av (Shabbat of Consolation). The first of seven Shabbatot leading up to Rosh Hashanah. Named after the Haftarah (from Isaiah 40) which begins with the verse נַחֲמוּ נַחֲמוּ, עַמִּי (\"Comfort, oh comfort my people\")","Shabbat Parah":"Shabbat of the Red Heifer","Shabbat Rosh Chodesh":"When Shabbat falls on Rosh Chodesh","Shabbat Shekalim":"Shabbat before Rosh Chodesh Adar","Shabbat Shirah":"Shabbat of Song","Shabbat Shuva":"Shabbat that falls between Rosh Hashanah and Yom Kippur (Shabbat of Returning)","Shabbat Zachor":"Shabbat before Purim",Shavuot:Shavuot,"Shmini Atzeret":"Eighth Day of Assembly","Shushan Purim":"Purim celebrated in Jerusalem and walled cities",Sigd:Sigd,"Simchat Torah":"Day of Celebrating the Torah",Sukkot:Sukkot,"Ta'anit Bechorot":"Fast of the First Born","Ta'anit Esther":"Fast of Esther","Tish'a B'Av":"The Ninth of Av. Fast commemorating the destruction of the two Temples","Tu B'Av":"Minor Jewish holiday of love. Observed on the 15th day of the Hebrew month of Av","Tu BiShvat":"New Year for Trees","Tzom Gedaliah":"Fast of the Seventh Month. Commemorates the assassination of the Jewish governor of Judah","Tzom Tammuz":"Fast commemorating breaching of the walls of Jerusalem before the destruction of the Second Temple","Yom HaAliyah":"Recognizes Aliyah, immigration to the Jewish State of Israel","Yom HaAliyah School Observance":"Aliyah Day observed in Israeli schools","Yom HaAtzma'ut":"Israeli Independence Day. Commemorates the declaration of independence of Israel in 1948. Note that Hebcal displays modern holidays like Yom HaAtzma'ut according to the Israeli schedule. Although Yom HaAtzma'ut is normally observed on the 5th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaZikaron, which always precedes it) would conflict with Shabbat","Yom HaShoah":"Holocaust Memorial Day","Yom HaZikaron":"Israeli Memorial Day. Note that Hebcal displays modern holidays like Yom HaZikaron according to the Israeli schedule. Although Yom Hazikaron is normally observed on the 4th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaAtzma'ut, which always follows it) would conflict with Shabbat","Yom Kippur":"Day of Atonement","Yom Yerushalayim":"Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"};
|
|
6
|
+
|
|
7
|
+
const AD="Andorra";const AE="United Arab Emirates";const AF="Afghanistan";const AI="Anguilla";const AL="Albania";const AM="Armenia";const AO="Angola";const AR="Argentina";const AS="American Samoa";const AT="Austria";const AU="Australia";const AW="Aruba";const AZ="Azerbaijan";const BA="Bosnia and Herzegovina";const BB="Barbados";const BD="Bangladesh";const BE="Belgium";const BF="Burkina Faso";const BG="Bulgaria";const BH="Bahrain";const BI="Burundi";const BJ="Benin";const BM="Bermuda";const BN="Brunei";const BO="Bolivia";const BR="Brazil";const BS="Bahamas";const BT="Bhutan";const BW="Botswana";const BY="Belarus";const BZ="Belize";const CA="Canada";const CD="Democratic Republic of the Congo";const CF="Central African Republic";const CG="Republic of the Congo";const CH="Switzerland";const CI="Ivory Coast";const CK="Cook Islands";const CL="Chile";const CM="Cameroon";const CN="China";const CO="Colombia";const CR="Costa Rica";const CU="Cuba";const CV="Cape Verde";const CW="Curacao";const CY="Cyprus";const CZ="Czech Republic";const DE="Germany";const DK="Denmark";const DM="Dominica";const DO="Dominican Republic";const DZ="Algeria";const EC="Ecuador";const EE="Estonia";const EG="Egypt";const ER="Eritrea";const ES="Spain";const ET="Ethiopia";const FI="Finland";const FJ="Fiji";const FK="Falkland Islands";const FO="Faroe Islands";const FR="France";const GA="Gabon";const GB="United Kingdom";const GE="Georgia";const GH="Ghana";const GI="Gibraltar";const GL="Greenland";const GM="Gambia";const GN="Guinea";const GQ="Equatorial Guinea";const GR="Greece";const GT="Guatemala";const GW="Guinea-Bissau";const GY="Guyana";const HK="Hong Kong";const HN="Honduras";const HR="Croatia";const HT="Haiti";const HU="Hungary";const ID="Indonesia";const IE="Ireland";const IL="Israel";const IM="Isle of Man";const IN="India";const IQ="Iraq";const IR="Iran";const IS="Iceland";const IT="Italy";const JM="Jamaica";const JO="Jordan";const JP="Japan";const KE="Kenya";const KG="Kyrgyzstan";const KH="Cambodia";const KM="Comoros";const KN="Saint Kitts and Nevis";const KP="North Korea";const KR="South Korea";const KW="Kuwait";const KY="Cayman Islands";const KZ="Kazakhstan";const LA="Laos";const LB="Lebanon";const LC="Saint Lucia";const LI="Liechtenstein";const LR="Liberia";const LS="Lesotho";const LT="Lithuania";const LU="Luxembourg";const LV="Latvia";const LY="Libya";const MA="Morocco";const MD="Moldova";const ME="Montenegro";const MG="Madagascar";const MK="Macedonia";const ML="Mali";const MM="Myanmar";const MN="Mongolia";const MP="Northern Mariana Islands";const MR="Mauritania";const MS="Montserrat";const MT="Malta";const MU="Mauritius";const MW="Malawi";const MX="Mexico";const MY="Malaysia";const MZ="Mozambique";const NA="Namibia";const NC="New Caledonia";const NE="Niger";const NG="Nigeria";const NI="Nicaragua";const NL="Netherlands";const NO="Norway";const NP="Nepal";const NU="Niue";const NZ="New Zealand";const OM="Oman";const PA="Panama";const PE="Peru";const PF="French Polynesia";const PG="Papua New Guinea";const PH="Philippines";const PK="Pakistan";const PL="Poland";const PR="Puerto Rico";const PT="Portugal";const PY="Paraguay";const QA="Qatar";const RO="Romania";const RS="Serbia";const RU="Russia";const RW="Rwanda";const SA="Saudi Arabia";const SB="Solomon Islands";const SC="Seychelles";const SD="Sudan";const SE="Sweden";const SG="Singapore";const SH="Saint Helena";const SI="Slovenia";const SK="Slovakia";const SL="Sierra Leone";const SN="Senegal";const SO="Somalia";const SR="Suriname";const ST="Sao Tome and Principe";const SV="El Salvador";const SY="Syria";const SZ="Swaziland";const TC="Turks and Caicos Islands";const TD="Chad";const TG="Togo";const TH="Thailand";const TJ="Tajikistan";const TM="Turkmenistan";const TN="Tunisia";const TR="Turkey";const TV="Tuvalu";const TW="Taiwan";const TZ="Tanzania";const UA="Ukraine";const UG="Uganda";const US="United States";const UY="Uruguay";const UZ="Uzbekistan";const VC="Saint Vincent and the Grenadines";const VE="Venezuela";const VG="British Virgin Islands";const VN="Vietnam";const WS="Samoa";const YE="Yemen";const YT="Mayotte";const ZA="South Africa";const ZM="Zambia";const ZW="Zimbabwe";var countryNames = {AD:AD,AE:AE,AF:AF,AI:AI,AL:AL,AM:AM,AO:AO,AR:AR,AS:AS,AT:AT,AU:AU,AW:AW,AZ:AZ,BA:BA,BB:BB,BD:BD,BE:BE,BF:BF,BG:BG,BH:BH,BI:BI,BJ:BJ,BM:BM,BN:BN,BO:BO,BR:BR,BS:BS,BT:BT,BW:BW,BY:BY,BZ:BZ,CA:CA,CD:CD,CF:CF,CG:CG,CH:CH,CI:CI,CK:CK,CL:CL,CM:CM,CN:CN,CO:CO,CR:CR,CU:CU,CV:CV,CW:CW,CY:CY,CZ:CZ,DE:DE,DK:DK,DM:DM,DO:DO,DZ:DZ,EC:EC,EE:EE,EG:EG,ER:ER,ES:ES,ET:ET,FI:FI,FJ:FJ,FK:FK,FO:FO,FR:FR,GA:GA,GB:GB,GE:GE,GH:GH,GI:GI,GL:GL,GM:GM,GN:GN,GQ:GQ,GR:GR,GT:GT,GW:GW,GY:GY,HK:HK,HN:HN,HR:HR,HT:HT,HU:HU,ID:ID,IE:IE,IL:IL,IM:IM,IN:IN,IQ:IQ,IR:IR,IS:IS,IT:IT,JM:JM,JO:JO,JP:JP,KE:KE,KG:KG,KH:KH,KM:KM,KN:KN,KP:KP,KR:KR,KW:KW,KY:KY,KZ:KZ,LA:LA,LB:LB,LC:LC,LI:LI,LR:LR,LS:LS,LT:LT,LU:LU,LV:LV,LY:LY,MA:MA,MD:MD,ME:ME,MG:MG,MK:MK,ML:ML,MM:MM,MN:MN,MP:MP,MR:MR,MS:MS,MT:MT,MU:MU,MW:MW,MX:MX,MY:MY,MZ:MZ,NA:NA,NC:NC,NE:NE,NG:NG,NI:NI,NL:NL,NO:NO,NP:NP,NU:NU,NZ:NZ,OM:OM,PA:PA,PE:PE,PF:PF,PG:PG,PH:PH,PK:PK,PL:PL,PR:PR,PT:PT,PY:PY,QA:QA,RO:RO,RS:RS,RU:RU,RW:RW,SA:SA,SB:SB,SC:SC,SD:SD,SE:SE,SG:SG,SH:SH,SI:SI,SK:SK,SL:SL,SN:SN,SO:SO,SR:SR,ST:ST,SV:SV,SY:SY,SZ:SZ,TC:TC,TD:TD,TG:TG,TH:TH,TJ:TJ,TM:TM,TN:TN,TR:TR,TV:TV,TW:TW,TZ:TZ,UA:UA,UG:UG,US:US,UY:UY,UZ:UZ,VC:VC,VE:VE,VG:VG,VN:VN,WS:WS,YE:YE,YT:YT,ZA:ZA,ZM:ZM,ZW:ZW};
|
|
6
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @param {Location} location
|
|
11
|
+
* @return {string}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function locationToPlainObj(location) {
|
|
15
|
+
if (typeof location === 'object' && location !== null && typeof location.name === 'string') {
|
|
16
|
+
const o = {
|
|
17
|
+
title: location.getName(),
|
|
18
|
+
city: location.getShortName(),
|
|
19
|
+
tzid: location.getTzid(),
|
|
20
|
+
latitude: location.getLatitude(),
|
|
21
|
+
longitude: location.getLongitude(),
|
|
22
|
+
cc: location.getCountryCode(),
|
|
23
|
+
country: countryNames[location.getCountryCode()]
|
|
24
|
+
};
|
|
25
|
+
['admin1', 'asciiname', 'geo', 'zip', 'state', 'stateName', 'geonameid'].forEach(k => {
|
|
26
|
+
if (location[k]) {
|
|
27
|
+
o[k] = location[k];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return o;
|
|
31
|
+
} else {
|
|
32
|
+
return {
|
|
33
|
+
geo: 'none'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
7
37
|
/**
|
|
8
38
|
* Helper function to transform a string to make it more usable in a URL or filename.
|
|
9
39
|
* Converts to lowercase and replaces non-word characters with hyphen ('-').
|
|
@@ -17,7 +47,7 @@ function makeAnchor(s) {
|
|
|
17
47
|
return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
|
|
18
48
|
}
|
|
19
49
|
/**
|
|
20
|
-
* @param {
|
|
50
|
+
* @param {CalOptions} options
|
|
21
51
|
* @return {string}
|
|
22
52
|
*/
|
|
23
53
|
|
|
@@ -203,7 +233,7 @@ function renderTitleWithoutTime(ev) {
|
|
|
203
233
|
/**
|
|
204
234
|
* Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
|
|
205
235
|
* @param {Event[]} events
|
|
206
|
-
* @param {
|
|
236
|
+
* @param {CalOptions} options
|
|
207
237
|
* @return {string}
|
|
208
238
|
*/
|
|
209
239
|
|
|
@@ -321,16 +351,64 @@ function makeTorahMemoText(ev, il) {
|
|
|
321
351
|
*/
|
|
322
352
|
|
|
323
353
|
function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
354
|
+
const u = new URL(url);
|
|
355
|
+
const isHebcal = u.host === 'www.hebcal.com';
|
|
356
|
+
|
|
357
|
+
if (isHebcal) {
|
|
358
|
+
if (il) {
|
|
359
|
+
u.searchParams.set('i', 'on');
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const path = u.pathname;
|
|
363
|
+
const isHolidays = path.startsWith('/holidays/');
|
|
364
|
+
const isSedrot = path.startsWith('/sedrot/');
|
|
365
|
+
const isOmer = path.startsWith('/omer/');
|
|
366
|
+
|
|
367
|
+
if (isHolidays || isSedrot || isOmer) {
|
|
368
|
+
u.host = 'hebcal.com';
|
|
369
|
+
|
|
370
|
+
if (isHolidays) {
|
|
371
|
+
u.pathname = '/h/' + path.substring(10);
|
|
372
|
+
} else if (isSedrot) {
|
|
373
|
+
u.pathname = '/s/' + path.substring(8);
|
|
374
|
+
} else {
|
|
375
|
+
// isOmer
|
|
376
|
+
u.pathname = '/o/' + path.substring(6);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
|
|
380
|
+
if (utmSource) {
|
|
381
|
+
u.searchParams.set('us', utmSource);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (utmMedium) {
|
|
385
|
+
u.searchParams.set('um', utmMedium);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (utmCampaign) {
|
|
390
|
+
u.searchParams.set('uc', utmCampaign);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return u.toString();
|
|
394
|
+
}
|
|
328
395
|
}
|
|
329
396
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
397
|
+
utmSource = isHebcal ? utmSource : 'hebcal.com';
|
|
398
|
+
|
|
399
|
+
if (utmSource) {
|
|
400
|
+
u.searchParams.set('utm_source', utmSource);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (utmMedium) {
|
|
404
|
+
u.searchParams.set('utm_medium', utmMedium);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (utmCampaign) {
|
|
408
|
+
u.searchParams.set('utm_campaign', utmCampaign);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return u.toString();
|
|
334
412
|
}
|
|
335
413
|
/**
|
|
336
414
|
* @private
|
|
@@ -367,7 +445,7 @@ const CATEGORY = {
|
|
|
367
445
|
/**
|
|
368
446
|
* Renders an Event as a string
|
|
369
447
|
* @param {Event} e
|
|
370
|
-
* @param {
|
|
448
|
+
* @param {CalOptions} options
|
|
371
449
|
* @return {string}
|
|
372
450
|
*/
|
|
373
451
|
|
|
@@ -443,12 +521,10 @@ function eventsToCsv(events, options) {
|
|
|
443
521
|
return [csvHeader].concat(events.map(e => eventToCsv(e, options))).join('\r\n') + '\r\n';
|
|
444
522
|
}
|
|
445
523
|
|
|
446
|
-
var AD="Andorra";var AE="United Arab Emirates";var AF="Afghanistan";var AI="Anguilla";var AL="Albania";var AM="Armenia";var AO="Angola";var AR="Argentina";var AS="American Samoa";var AT="Austria";var AU="Australia";var AW="Aruba";var AZ="Azerbaijan";var BA="Bosnia and Herzegovina";var BB="Barbados";var BD="Bangladesh";var BE="Belgium";var BF="Burkina Faso";var BG="Bulgaria";var BH="Bahrain";var BI="Burundi";var BJ="Benin";var BM="Bermuda";var BN="Brunei";var BO="Bolivia";var BR="Brazil";var BS="Bahamas";var BT="Bhutan";var BW="Botswana";var BY="Belarus";var BZ="Belize";var CA="Canada";var CD="Democratic Republic of the Congo";var CF="Central African Republic";var CG="Republic of the Congo";var CH="Switzerland";var CI="Ivory Coast";var CK="Cook Islands";var CL="Chile";var CM="Cameroon";var CN="China";var CO="Colombia";var CR="Costa Rica";var CU="Cuba";var CV="Cape Verde";var CW="Curacao";var CY="Cyprus";var CZ="Czech Republic";var DE="Germany";var DK="Denmark";var DM="Dominica";var DO="Dominican Republic";var DZ="Algeria";var EC="Ecuador";var EE="Estonia";var EG="Egypt";var ER="Eritrea";var ES="Spain";var ET="Ethiopia";var FI="Finland";var FJ="Fiji";var FK="Falkland Islands";var FO="Faroe Islands";var FR="France";var GA="Gabon";var GB="United Kingdom";var GE="Georgia";var GH="Ghana";var GI="Gibraltar";var GL="Greenland";var GM="Gambia";var GN="Guinea";var GQ="Equatorial Guinea";var GR="Greece";var GT="Guatemala";var GW="Guinea-Bissau";var GY="Guyana";var HK="Hong Kong";var HN="Honduras";var HR="Croatia";var HT="Haiti";var HU="Hungary";var ID="Indonesia";var IE="Ireland";var IL="Israel";var IM="Isle of Man";var IN="India";var IQ="Iraq";var IR="Iran";var IS="Iceland";var IT="Italy";var JM="Jamaica";var JO="Jordan";var JP="Japan";var KE="Kenya";var KG="Kyrgyzstan";var KH="Cambodia";var KM="Comoros";var KN="Saint Kitts and Nevis";var KP="North Korea";var KR="South Korea";var KW="Kuwait";var KY="Cayman Islands";var KZ="Kazakhstan";var LA="Laos";var LB="Lebanon";var LC="Saint Lucia";var LI="Liechtenstein";var LR="Liberia";var LS="Lesotho";var LT="Lithuania";var LU="Luxembourg";var LV="Latvia";var LY="Libya";var MA="Morocco";var MD="Moldova";var ME="Montenegro";var MG="Madagascar";var MK="Macedonia";var ML="Mali";var MM="Myanmar";var MN="Mongolia";var MP="Northern Mariana Islands";var MR="Mauritania";var MS="Montserrat";var MT="Malta";var MU="Mauritius";var MW="Malawi";var MX="Mexico";var MY="Malaysia";var MZ="Mozambique";var NA="Namibia";var NC="New Caledonia";var NE="Niger";var NG="Nigeria";var NI="Nicaragua";var NL="Netherlands";var NO="Norway";var NP="Nepal";var NU="Niue";var NZ="New Zealand";var OM="Oman";var PA="Panama";var PE="Peru";var PF="French Polynesia";var PG="Papua New Guinea";var PH="Philippines";var PK="Pakistan";var PL="Poland";var PR="Puerto Rico";var PT="Portugal";var PY="Paraguay";var QA="Qatar";var RO="Romania";var RS="Serbia";var RU="Russia";var RW="Rwanda";var SA="Saudi Arabia";var SB="Solomon Islands";var SC="Seychelles";var SD="Sudan";var SE="Sweden";var SG="Singapore";var SH="Saint Helena";var SI="Slovenia";var SK="Slovakia";var SL="Sierra Leone";var SN="Senegal";var SO="Somalia";var SR="Suriname";var ST="Sao Tome and Principe";var SV="El Salvador";var SY="Syria";var SZ="Swaziland";var TC="Turks and Caicos Islands";var TD="Chad";var TG="Togo";var TH="Thailand";var TJ="Tajikistan";var TM="Turkmenistan";var TN="Tunisia";var TR="Turkey";var TV="Tuvalu";var TW="Taiwan";var TZ="Tanzania";var UA="Ukraine";var UG="Uganda";var US="United States";var UY="Uruguay";var UZ="Uzbekistan";var VC="Saint Vincent and the Grenadines";var VE="Venezuela";var VG="British Virgin Islands";var VN="Vietnam";var WS="Samoa";var YE="Yemen";var YT="Mayotte";var ZA="South Africa";var ZM="Zambia";var ZW="Zimbabwe";var countryNames = {AD:AD,AE:AE,AF:AF,AI:AI,AL:AL,AM:AM,AO:AO,AR:AR,AS:AS,AT:AT,AU:AU,AW:AW,AZ:AZ,BA:BA,BB:BB,BD:BD,BE:BE,BF:BF,BG:BG,BH:BH,BI:BI,BJ:BJ,BM:BM,BN:BN,BO:BO,BR:BR,BS:BS,BT:BT,BW:BW,BY:BY,BZ:BZ,CA:CA,CD:CD,CF:CF,CG:CG,CH:CH,CI:CI,CK:CK,CL:CL,CM:CM,CN:CN,CO:CO,CR:CR,CU:CU,CV:CV,CW:CW,CY:CY,CZ:CZ,DE:DE,DK:DK,DM:DM,DO:DO,DZ:DZ,EC:EC,EE:EE,EG:EG,ER:ER,ES:ES,ET:ET,FI:FI,FJ:FJ,FK:FK,FO:FO,FR:FR,GA:GA,GB:GB,GE:GE,GH:GH,GI:GI,GL:GL,GM:GM,GN:GN,GQ:GQ,GR:GR,GT:GT,GW:GW,GY:GY,HK:HK,HN:HN,HR:HR,HT:HT,HU:HU,ID:ID,IE:IE,IL:IL,IM:IM,IN:IN,IQ:IQ,IR:IR,IS:IS,IT:IT,JM:JM,JO:JO,JP:JP,KE:KE,KG:KG,KH:KH,KM:KM,KN:KN,KP:KP,KR:KR,KW:KW,KY:KY,KZ:KZ,LA:LA,LB:LB,LC:LC,LI:LI,LR:LR,LS:LS,LT:LT,LU:LU,LV:LV,LY:LY,MA:MA,MD:MD,ME:ME,MG:MG,MK:MK,ML:ML,MM:MM,MN:MN,MP:MP,MR:MR,MS:MS,MT:MT,MU:MU,MW:MW,MX:MX,MY:MY,MZ:MZ,NA:NA,NC:NC,NE:NE,NG:NG,NI:NI,NL:NL,NO:NO,NP:NP,NU:NU,NZ:NZ,OM:OM,PA:PA,PE:PE,PF:PF,PG:PG,PH:PH,PK:PK,PL:PL,PR:PR,PT:PT,PY:PY,QA:QA,RO:RO,RS:RS,RU:RU,RW:RW,SA:SA,SB:SB,SC:SC,SD:SD,SE:SE,SG:SG,SH:SH,SI:SI,SK:SK,SL:SL,SN:SN,SO:SO,SR:SR,ST:ST,SV:SV,SY:SY,SZ:SZ,TC:TC,TD:TD,TG:TG,TH:TH,TJ:TJ,TM:TM,TN:TN,TR:TR,TV:TV,TW:TW,TZ:TZ,UA:UA,UG:UG,US:US,UY:UY,UZ:UZ,VC:VC,VE:VE,VG:VG,VN:VN,WS:WS,YE:YE,YT:YT,ZA:ZA,ZM:ZM,ZW:ZW};
|
|
447
|
-
|
|
448
524
|
/**
|
|
449
525
|
* Formats a list events for the classic Hebcal.com JSON API response
|
|
450
526
|
* @param {Event[]} events
|
|
451
|
-
* @param {
|
|
527
|
+
* @param {CalOptions} options
|
|
452
528
|
* @param {boolean} [leyning=true]
|
|
453
529
|
* @return {Object}
|
|
454
530
|
*/
|
|
@@ -458,36 +534,14 @@ function eventsToClassicApi(events, options, leyning = true) {
|
|
|
458
534
|
title: getCalendarTitle(events, options),
|
|
459
535
|
date: new Date().toISOString()
|
|
460
536
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (typeof location === 'object' && typeof location.name === 'string') {
|
|
464
|
-
result.location = {
|
|
465
|
-
title: location.getName(),
|
|
466
|
-
city: location.getShortName(),
|
|
467
|
-
tzid: location.getTzid(),
|
|
468
|
-
latitude: location.getLatitude(),
|
|
469
|
-
longitude: location.getLongitude(),
|
|
470
|
-
cc: location.getCountryCode(),
|
|
471
|
-
country: countryNames[location.getCountryCode()]
|
|
472
|
-
};
|
|
473
|
-
['admin1', 'asciiname', 'geo', 'zip', 'state', 'geonameid'].forEach(k => {
|
|
474
|
-
if (location[k]) {
|
|
475
|
-
result.location[k] = location[k];
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
} else {
|
|
479
|
-
result.location = {
|
|
480
|
-
geo: 'none'
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
|
|
537
|
+
result.location = locationToPlainObj(options.location);
|
|
484
538
|
result.items = events.map(ev => eventToClassicApiObject(ev, options, leyning));
|
|
485
539
|
return result;
|
|
486
540
|
}
|
|
487
541
|
/**
|
|
488
542
|
* Converts a Hebcal event to a classic Hebcal.com JSON API object
|
|
489
543
|
* @param {Event} ev
|
|
490
|
-
* @param {
|
|
544
|
+
* @param {CalOptions} options
|
|
491
545
|
* @param {boolean} [leyning=true]
|
|
492
546
|
* @return {Object}
|
|
493
547
|
*/
|
|
@@ -701,7 +755,7 @@ const localeToLg = {
|
|
|
701
755
|
};
|
|
702
756
|
/**
|
|
703
757
|
* @param {Event[]} events
|
|
704
|
-
* @param {
|
|
758
|
+
* @param {CalOptions} options
|
|
705
759
|
* @return {string}
|
|
706
760
|
*/
|
|
707
761
|
|
|
@@ -765,7 +819,7 @@ function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
|
|
|
765
819
|
}
|
|
766
820
|
/**
|
|
767
821
|
* @param {Event} ev
|
|
768
|
-
* @param {
|
|
822
|
+
* @param {CalOptions} options
|
|
769
823
|
* @return {string}
|
|
770
824
|
*/
|
|
771
825
|
|
|
@@ -780,7 +834,7 @@ function eventToRssItem2(ev, options) {
|
|
|
780
834
|
* @param {Intl.DateTimeFormat} dayFormat
|
|
781
835
|
* @param {Location} location
|
|
782
836
|
* @param {string} mainUrl
|
|
783
|
-
* @param {
|
|
837
|
+
* @param {CalOptions} [options]
|
|
784
838
|
* @return {string}
|
|
785
839
|
*/
|
|
786
840
|
|
|
@@ -883,4 +937,4 @@ function eventToFullCalendar(ev, tzid, il) {
|
|
|
883
937
|
return result;
|
|
884
938
|
}
|
|
885
939
|
|
|
886
|
-
export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, makeAnchor, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, timeZoneOffsetStr, toISOString, toISOStringWithTimezone };
|
|
940
|
+
export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, locationToPlainObj, makeAnchor, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, timeZoneOffsetStr, toISOString, toISOStringWithTimezone };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/rest-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hebcal"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@hebcal/core": "^3.
|
|
25
|
-
"@hebcal/leyning": "^4.
|
|
24
|
+
"@hebcal/core": "^3.36.3",
|
|
25
|
+
"@hebcal/leyning": "^4.13.3"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "rollup -c",
|
|
@@ -39,32 +39,24 @@
|
|
|
39
39
|
"require": [
|
|
40
40
|
"@babel/register"
|
|
41
41
|
],
|
|
42
|
-
"babel": {
|
|
43
|
-
"testOptions": {
|
|
44
|
-
"presets": [
|
|
45
|
-
"@babel/env"
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
42
|
"inherit": true,
|
|
50
43
|
"verbose": true
|
|
51
44
|
},
|
|
52
45
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@babel/
|
|
55
|
-
"@babel/
|
|
56
|
-
"@babel
|
|
57
|
-
"@rollup/plugin-
|
|
58
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
46
|
+
"@babel/core": "^7.17.10",
|
|
47
|
+
"@babel/preset-env": "^7.17.10",
|
|
48
|
+
"@babel/register": "^7.17.7",
|
|
49
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
50
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
59
51
|
"@rollup/plugin-json": "^4.1.0",
|
|
60
|
-
"@rollup/plugin-node-resolve": "^13.
|
|
61
|
-
"ava": "^
|
|
62
|
-
"core-js": "^3.
|
|
63
|
-
"eslint": "^8.
|
|
52
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
53
|
+
"ava": "^4.2.0",
|
|
54
|
+
"core-js": "^3.22.4",
|
|
55
|
+
"eslint": "^8.14.0",
|
|
64
56
|
"eslint-config-google": "^0.14.0",
|
|
65
|
-
"jsdoc": "^3.6.
|
|
66
|
-
"jsdoc-to-markdown": "^7.1.
|
|
67
|
-
"rollup": "^2.
|
|
57
|
+
"jsdoc": "^3.6.10",
|
|
58
|
+
"jsdoc-to-markdown": "^7.1.1",
|
|
59
|
+
"rollup": "^2.71.1",
|
|
68
60
|
"rollup-plugin-terser": "^7.0.2"
|
|
69
61
|
}
|
|
70
62
|
}
|
package/rest-api.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/// <reference types="node"/>
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {Event, Location, CalOptions} from '@hebcal/core';
|
|
4
4
|
|
|
5
5
|
declare module '@hebcal/rest-api' {
|
|
6
6
|
/**
|
|
7
7
|
* Renders an Event as a string
|
|
8
8
|
*/
|
|
9
|
-
export function eventToCsv(e: Event, options:
|
|
10
|
-
export function eventsToCsv(events: Event[], options:
|
|
9
|
+
export function eventToCsv(e: Event, options: CalOptions): string;
|
|
10
|
+
export function eventsToCsv(events: Event[], options: CalOptions): string;
|
|
11
11
|
/**
|
|
12
12
|
* Formats a list events for the classic Hebcal.com JSON API response
|
|
13
13
|
*/
|
|
14
|
-
export function eventsToClassicApi(events: Event[], options:
|
|
14
|
+
export function eventsToClassicApi(events: Event[], options: CalOptions, leyning?: boolean): any;
|
|
15
15
|
/**
|
|
16
16
|
* Converts a Hebcal event to a classic Hebcal.com JSON API object
|
|
17
17
|
*/
|
|
18
|
-
export function eventToClassicApiObject(ev: Event, options:
|
|
18
|
+
export function eventToClassicApiObject(ev: Event, options: CalOptions, leyning?: boolean): any;
|
|
19
19
|
/**
|
|
20
20
|
* Converts a Hebcal event to a FullCalendar.io object
|
|
21
21
|
* @param tzid - timeZone identifier
|
|
@@ -39,10 +39,10 @@ declare module '@hebcal/rest-api' {
|
|
|
39
39
|
* @param [evPubDate] - if true, use event time as pubDate (false uses lastBuildDate)
|
|
40
40
|
*/
|
|
41
41
|
export function eventsToRss(events: Event[], location: Location, mainUrl: string, selfUrl: string, lang?: string, evPubDate?: boolean): string;
|
|
42
|
-
export function eventsToRss2(events: Event[], options:
|
|
43
|
-
export function eventToRssItem(ev: Event, evPubDate: boolean, lastBuildDate: string, dayFormat: Intl.DateTimeFormat, location: Location, baseUrl: string, options?:
|
|
44
|
-
export function eventToRssItem2(ev: Event, options:
|
|
45
|
-
export function getDownloadFilename(options:
|
|
42
|
+
export function eventsToRss2(events: Event[], options: CalOptions): string;
|
|
43
|
+
export function eventToRssItem(ev: Event, evPubDate: boolean, lastBuildDate: string, dayFormat: Intl.DateTimeFormat, location: Location, baseUrl: string, options?: CalOptions): string;
|
|
44
|
+
export function eventToRssItem2(ev: Event, options: CalOptions): string;
|
|
45
|
+
export function getDownloadFilename(options: CalOptions): string;
|
|
46
46
|
export function pad2(number: number): string;
|
|
47
47
|
export function pad4(number: number): string;
|
|
48
48
|
/**
|
|
@@ -73,7 +73,7 @@ declare module '@hebcal/rest-api' {
|
|
|
73
73
|
/**
|
|
74
74
|
* Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
|
|
75
75
|
*/
|
|
76
|
-
export function getCalendarTitle(events: Event[], options:
|
|
76
|
+
export function getCalendarTitle(events: Event[], options: CalOptions): string;
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Returns an English language description of the holiday
|
|
@@ -81,6 +81,8 @@ declare module '@hebcal/rest-api' {
|
|
|
81
81
|
*/
|
|
82
82
|
export function getHolidayDescription(ev: Event, firstSentence?: boolean): string;
|
|
83
83
|
|
|
84
|
+
export function locationToPlainObj(location: Location): string;
|
|
85
|
+
|
|
84
86
|
export interface StringMap {
|
|
85
87
|
[key: string]: string;
|
|
86
88
|
}
|