@hebcal/rest-api 3.19.5 → 4.2.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/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- /*! @hebcal/rest-api v3.19.5 */
2
- import { flags, HDate, Zmanim, HebrewCalendar, Locale, gematriya } from '@hebcal/core';
3
- import * as leyn from '@hebcal/leyning';
1
+ /*! @hebcal/rest-api v4.2.0 */
2
+ import { flags, HDate, HebrewCalendar, Zmanim, Locale, gematriya } from '@hebcal/core';
3
+ import { getLeyningForParshaHaShavua, getLeyningForHoliday, formatAliyahWithBook } from '@hebcal/leyning';
4
+ import { getTriennialForParshaHaShavua } from '@hebcal/triennial';
4
5
 
5
6
  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. 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. Remembers those who died in the War of Independence and other wars in Israel. The full name of the holiday is Yom HaZikaron LeHalalei Ma'arakhot Yisrael ul'Nifge'ei Pe'ulot HaEivah (Hebrew: יוֹם הזִּכָּרוֹן לְחַלְלֵי מַעֲרָכוֹת יִשְׂרָאֵל וּלְנִפְגְעֵי פְּעֻלּוֹת הָאֵיבָה), Memorial Day for the Fallen Soldiers of the Wars of Israel and Victims of Actions of Terrorism. 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 Kippur Katan":"Minor day of atonement occurring monthly on the day preceeding each Rosh Chodesh","Yom Yerushalayim":"Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"};
6
7
 
@@ -118,17 +119,6 @@ function pad4(number) {
118
119
 
119
120
  return '' + number;
120
121
  }
121
- /**
122
- * Get offset string (like "+05:00" or "-08:00") from tzid (like "Europe/Moscow")
123
- * @deprecated
124
- * @param {string} tzid
125
- * @param {Date} date
126
- * @return {string}
127
- */
128
-
129
- function timeZoneOffsetStr(tzid, date) {
130
- return Zmanim.timeZoneOffset(tzid, date);
131
- }
132
122
  /**
133
123
  * Returns just the date portion as YYYY-MM-DD
134
124
  * @param {Date} d
@@ -138,20 +128,6 @@ function timeZoneOffsetStr(tzid, date) {
138
128
  function toISOString(d) {
139
129
  return pad4(d.getFullYear()) + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate());
140
130
  }
141
- /**
142
- * Returns a string like "2018-09-01T12:30:00-05:00"
143
- * @deprecated
144
- * @param {Date} date
145
- * @param {string} timeStr must be formatted with only hours and minutes, like "17:12"
146
- * @param {string} tzid like "America/New_York"
147
- * @return {string}
148
- */
149
-
150
- function toISOStringWithTimezone(date, timeStr, tzid) {
151
- const str = toISOString(date);
152
- if (!timeStr) return str;
153
- return str + 'T' + timeStr + ':00' + Zmanim.timeZoneOffset(tzid, date);
154
- }
155
131
  /**
156
132
  * Returns a category and subcategory name
157
133
  * @param {Event} ev
@@ -332,7 +308,7 @@ function makeTorahMemoText(ev, il) {
332
308
  return '';
333
309
  }
334
310
 
335
- const reading = mask & flags.PARSHA_HASHAVUA ? leyn.getLeyningForParshaHaShavua(ev, il) : leyn.getLeyningForHoliday(ev, il);
311
+ const reading = mask & flags.PARSHA_HASHAVUA ? getLeyningForParshaHaShavua(ev, il) : getLeyningForHoliday(ev, il);
336
312
  let memo = '';
337
313
 
338
314
  if (reading && (reading.summary || reading.haftara)) {
@@ -637,17 +613,17 @@ function eventToClassicApiObject(ev, options, leyning = true) {
637
613
  if (leyning) {
638
614
  const il = options.il;
639
615
  const isParsha = mask === flags.PARSHA_HASHAVUA;
640
- const reading = isParsha ? leyn.getLeyningForParshaHaShavua(ev, il) : leyn.getLeyningForHoliday(ev, il);
616
+ const reading = isParsha ? getLeyningForParshaHaShavua(ev, il) : getLeyningForHoliday(ev, il);
641
617
 
642
618
  if (reading) {
643
619
  result.leyning = formatLeyningResult(reading);
644
620
  const hyear = hd.getFullYear();
645
621
 
646
622
  if (isParsha && !il && hyear >= 5745) {
647
- const triReading = leyn.getTriennialForParshaHaShavua(ev);
623
+ const triReading = getTriennialForParshaHaShavua(ev);
648
624
 
649
625
  if (triReading) {
650
- result.leyning.triennial = formatAliyot({}, triReading);
626
+ result.leyning.triennial = formatAliyot({}, triReading.aliyot);
651
627
  }
652
628
  }
653
629
  }
@@ -714,13 +690,13 @@ function formatAliyot(result, aliyot) {
714
690
 
715
691
  if (typeof aliyah !== 'undefined') {
716
692
  const k = num == 'M' ? 'maftir' : num;
717
- result[k] = leyn.formatAliyahWithBook(aliyah);
693
+ result[k] = formatAliyahWithBook(aliyah);
718
694
  }
719
695
  });
720
696
  return result;
721
697
  }
722
698
  /**
723
- * @param {leyn.Leyning} reading
699
+ * @param {Leyning} reading
724
700
  * @return {Object}
725
701
  */
726
702
 
@@ -794,32 +770,7 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
794
770
 
795
771
  return [link, guid];
796
772
  }
797
- /**
798
- * @param {Event[]} events
799
- * @param {Location} location
800
- * @param {string} mainUrl
801
- * @param {string} selfUrl
802
- * @param {string} [lang] language such as 'he' (default 'en-US')
803
- * @param {boolean} [evPubDate] if true, use event time as pubDate (false uses lastBuildDate)
804
- * @return {string}
805
- */
806
-
807
773
 
808
- function eventsToRss(events, location, mainUrl, selfUrl, lang = 'en-US', evPubDate = true) {
809
- const cityDescr = location.getName();
810
- const options = {
811
- location,
812
- mainUrl,
813
- selfUrl,
814
- lang,
815
- evPubDate,
816
- title: Locale.gettext('Shabbat') + ` Times for ${cityDescr}`,
817
- description: `Weekly Shabbat candle lighting times for ${cityDescr}`,
818
- utmSource: 'shabbat1c',
819
- utmMedium: 'rss'
820
- };
821
- return eventsToRss2(events, options);
822
- }
823
774
  const localeToLg = {
824
775
  's': 'en',
825
776
  'a': 'en',
@@ -900,28 +851,15 @@ function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
900
851
 
901
852
 
902
853
  function eventToRssItem2(ev, options) {
903
- return eventToRssItem(ev, options.evPubDate, options.lastBuildDate, options.dayFormat, options.location, options.mainUrl, options);
904
- }
905
- /**
906
- * @param {Event} ev
907
- * @param {boolean} evPubDate
908
- * @param {string} lastBuildDate
909
- * @param {Intl.DateTimeFormat} dayFormat
910
- * @param {Location} location
911
- * @param {string} mainUrl
912
- * @param {CalOptions} [options]
913
- * @return {string}
914
- */
915
-
916
- function eventToRssItem(ev, evPubDate, lastBuildDate, dayFormat, location, mainUrl, options) {
917
854
  let subj = ev.render();
918
855
  const evDate = ev.getDate().greg();
919
- const pubDate = getPubDate(ev, evPubDate, evDate, lastBuildDate);
856
+ const pubDate = getPubDate(ev, options.evPubDate, evDate, options.lastBuildDate);
857
+ const location = options.location;
920
858
  const il = location ? location.getIsrael() : false;
921
859
  const tzid = location ? location.getTzid() : 'UTC';
922
860
  const utmSource = options && options.utmSource || 'shabbat1c';
923
861
  const utmMedium = options && options.utmMedium || 'rss';
924
- const linkGuid = getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium);
862
+ const linkGuid = getLinkAndGuid(ev, il, tzid, options.mainUrl, utmSource, utmMedium);
925
863
  const link = linkGuid[0];
926
864
  const guid = linkGuid[1];
927
865
  const categories = getEventCategories(ev);
@@ -946,6 +884,7 @@ function eventToRssItem(ev, evPubDate, lastBuildDate, dayFormat, location, mainU
946
884
  memo = ev.getFlags() & flags.PARSHA_HASHAVUA ? makeTorahMemoText(ev, il) : ev.memo || holidayDescription[ev.basename()];
947
885
  }
948
886
 
887
+ const dayFormat = options.dayFormat;
949
888
  const description = memo || dayFormat.format(evDate);
950
889
  const geoTags = cat0 == 'candles' ? `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` : '';
951
890
  return `<item>
@@ -1012,4 +951,4 @@ function eventToFullCalendar(ev, tzid, il) {
1012
951
  return result;
1013
952
  }
1014
953
 
1015
- 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 };
954
+ export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, locationToPlainObj, makeAnchor, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, toISOString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/rest-api",
3
- "version": "3.19.5",
3
+ "version": "4.2.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal"
@@ -21,8 +21,9 @@
21
21
  "url": "https://github.com/hebcal/hebcal-rest-api/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@hebcal/core": "^3.42.2",
25
- "@hebcal/leyning": "^4.19.1"
24
+ "@hebcal/core": "^3.42.3",
25
+ "@hebcal/leyning": "^6.0.3",
26
+ "@hebcal/triennial": "^1.0.1"
26
27
  },
27
28
  "scripts": {
28
29
  "build": "rollup -c",
@@ -43,20 +44,20 @@
43
44
  "verbose": true
44
45
  },
45
46
  "devDependencies": {
46
- "@babel/core": "^7.18.10",
47
+ "@babel/core": "^7.18.13",
47
48
  "@babel/preset-env": "^7.18.10",
48
49
  "@babel/register": "^7.18.9",
49
50
  "@rollup/plugin-babel": "^5.3.1",
50
51
  "@rollup/plugin-commonjs": "^22.0.2",
51
52
  "@rollup/plugin-json": "^4.1.0",
52
53
  "@rollup/plugin-node-resolve": "^13.3.0",
53
- "ava": "^4.3.1",
54
- "core-js": "^3.24.1",
54
+ "ava": "^4.3.3",
55
+ "core-js": "^3.25.0",
55
56
  "eslint": "^8.22.0",
56
57
  "eslint-config-google": "^0.14.0",
57
58
  "jsdoc": "^3.6.11",
58
59
  "jsdoc-to-markdown": "^7.1.1",
59
- "rollup": "^2.78.0",
60
+ "rollup": "^2.78.1",
60
61
  "rollup-plugin-terser": "^7.0.2"
61
62
  }
62
63
  }
package/rest-api.d.ts CHANGED
@@ -35,12 +35,11 @@ declare module '@hebcal/rest-api' {
35
35
  */
36
36
  export function shouldRenderBrief(ev: Event): boolean;
37
37
  /**
38
- * @param [lang] - language such as 'he' (default 'en-US')
39
- * @param [evPubDate] - if true, use event time as pubDate (false uses lastBuildDate)
38
+ * Extends `CalOptions` with
39
+ * `lang` - language such as 'he' (default 'en-US')
40
+ * `evPubDate` - if true, use event time as pubDate (false uses lastBuildDate)
40
41
  */
41
- export function eventsToRss(events: Event[], location: Location, mainUrl: string, selfUrl: string, lang?: string, evPubDate?: boolean): string;
42
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
43
  export function eventToRssItem2(ev: Event, options: CalOptions): string;
45
44
  export function getDownloadFilename(options: CalOptions): string;
46
45
  export function pad2(number: number): string;
@@ -50,22 +49,10 @@ declare module '@hebcal/rest-api' {
50
49
  * Converts to lowercase and replaces non-word characters with hyphen ('-').
51
50
  */
52
51
  export function makeAnchor(s: string): string;
53
- /**
54
- * Get offset string (like "+05:00" or "-08:00") from tzid (like "Europe/Moscow")
55
- * @deprecated
56
- */
57
- export function timeZoneOffsetStr(tzid: string, date: Date): string;
58
52
  /**
59
53
  * Returns just the date portion as YYYY-MM-DD
60
54
  */
61
55
  export function toISOString(d: Date): string;
62
- /**
63
- * Returns a string like "2018-09-01T12:30:00-05:00'"
64
- * @deprecated
65
- * @param timeStr - must be formatted with only hours and minutes, like "17:12"
66
- * @param tzid - like "America/New_York"
67
- */
68
- export function toISOStringWithTimezone(date: Date, timeStr: string, tzid: string): string;
69
56
  /**
70
57
  * Returns a category and subcategory name
71
58
  */