@hebcal/rest-api 3.10.1 → 3.13.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/bundle.js +3221 -534
- package/dist/bundle.min.js +2 -2
- package/dist/index.js +85 -22
- package/dist/index.mjs +85 -23
- package/package.json +14 -22
- package/rest-api.d.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/rest-api v3.
|
|
1
|
+
/*! @hebcal/rest-api v3.13.0 */
|
|
2
2
|
import { flags, Zmanim, HebrewCalendar, Locale } from '@hebcal/core';
|
|
3
3
|
import * as leyn from '@hebcal/leyning';
|
|
4
4
|
|
|
@@ -156,6 +156,9 @@ function getEventCategories(ev) {
|
|
|
156
156
|
|
|
157
157
|
case flags.MINOR_HOLIDAY:
|
|
158
158
|
return ['holiday', 'minor'];
|
|
159
|
+
|
|
160
|
+
case flags.MISHNA_YOMI:
|
|
161
|
+
return ['mishnayomi'];
|
|
159
162
|
// fall through to string-based category
|
|
160
163
|
}
|
|
161
164
|
|
|
@@ -318,16 +321,60 @@ function makeTorahMemoText(ev, il) {
|
|
|
318
321
|
*/
|
|
319
322
|
|
|
320
323
|
function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
const u = new URL(url);
|
|
325
|
+
const isHebcal = u.host === 'www.hebcal.com';
|
|
326
|
+
|
|
327
|
+
if (isHebcal) {
|
|
328
|
+
if (il) {
|
|
329
|
+
u.searchParams.set('i', 'on');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const path = u.pathname;
|
|
333
|
+
const isHolidays = path.startsWith('/holidays/');
|
|
334
|
+
const isSedrot = path.startsWith('/sedrot/');
|
|
335
|
+
|
|
336
|
+
if (isHolidays || isSedrot) {
|
|
337
|
+
u.host = 'hebcal.com';
|
|
338
|
+
|
|
339
|
+
if (isHolidays) {
|
|
340
|
+
u.pathname = '/h/' + path.substring(10);
|
|
341
|
+
} else {
|
|
342
|
+
u.pathname = '/s/' + path.substring(8);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
|
|
346
|
+
if (utmSource) {
|
|
347
|
+
u.searchParams.set('us', utmSource);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (utmMedium) {
|
|
351
|
+
u.searchParams.set('um', utmMedium);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (utmCampaign) {
|
|
356
|
+
u.searchParams.set('uc', utmCampaign);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return u.toString();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
utmSource = isHebcal ? utmSource : 'hebcal.com';
|
|
364
|
+
|
|
365
|
+
if (utmSource) {
|
|
366
|
+
u.searchParams.set('utm_source', utmSource);
|
|
325
367
|
}
|
|
326
368
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
369
|
+
if (utmMedium) {
|
|
370
|
+
u.searchParams.set('utm_medium', utmMedium);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (utmCampaign) {
|
|
374
|
+
u.searchParams.set('utm_campaign', utmCampaign);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return u.toString();
|
|
331
378
|
}
|
|
332
379
|
/**
|
|
333
380
|
* @private
|
|
@@ -467,7 +514,7 @@ function eventsToClassicApi(events, options, leyning = true) {
|
|
|
467
514
|
cc: location.getCountryCode(),
|
|
468
515
|
country: countryNames[location.getCountryCode()]
|
|
469
516
|
};
|
|
470
|
-
['admin1', 'asciiname', 'geo', 'zip', 'state', 'geonameid'].forEach(k => {
|
|
517
|
+
['admin1', 'asciiname', 'geo', 'zip', 'state', 'stateName', 'geonameid'].forEach(k => {
|
|
471
518
|
if (location[k]) {
|
|
472
519
|
result.location[k] = location[k];
|
|
473
520
|
}
|
|
@@ -634,10 +681,12 @@ function formatLeyningResult(reading) {
|
|
|
634
681
|
* @param {boolean} il
|
|
635
682
|
* @param {string} tzid
|
|
636
683
|
* @param {string} mainUrl
|
|
684
|
+
* @param {string} utmSource
|
|
685
|
+
* @param {string} utmMedium
|
|
637
686
|
* @return {string[]}
|
|
638
687
|
*/
|
|
639
688
|
|
|
640
|
-
function getLinkAndGuid(ev, il, tzid, mainUrl) {
|
|
689
|
+
function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
|
|
641
690
|
let link;
|
|
642
691
|
let guid;
|
|
643
692
|
const dt = ev.eventTime || ev.getDate().greg();
|
|
@@ -649,11 +698,11 @@ function getLinkAndGuid(ev, il, tzid, mainUrl) {
|
|
|
649
698
|
const url0 = ev.url();
|
|
650
699
|
|
|
651
700
|
if (url0) {
|
|
652
|
-
link = appendIsraelAndTracking(url0, il,
|
|
701
|
+
link = appendIsraelAndTracking(url0, il, utmSource, utmMedium).replace(/&/g, '&');
|
|
653
702
|
guid = `${url0}#${anchor}`;
|
|
654
703
|
} else {
|
|
655
704
|
const url1 = `${mainUrl}&dt=${dtStr}`;
|
|
656
|
-
const url = appendIsraelAndTracking(url1, il,
|
|
705
|
+
const url = appendIsraelAndTracking(url1, il, utmSource, utmMedium).replace(/&/g, '&');
|
|
657
706
|
guid = url1.replace(/&/g, '&') + `#${anchor}`;
|
|
658
707
|
link = `${url}#${anchor}`;
|
|
659
708
|
}
|
|
@@ -701,7 +750,7 @@ const localeToLg = {
|
|
|
701
750
|
*/
|
|
702
751
|
|
|
703
752
|
function eventsToRss2(events, options) {
|
|
704
|
-
|
|
753
|
+
options.dayFormat = new Intl.DateTimeFormat('en-US', {
|
|
705
754
|
weekday: 'long',
|
|
706
755
|
day: '2-digit',
|
|
707
756
|
month: 'long',
|
|
@@ -709,13 +758,14 @@ function eventsToRss2(events, options) {
|
|
|
709
758
|
});
|
|
710
759
|
const location = options.location;
|
|
711
760
|
const mainUrl = options.mainUrl;
|
|
712
|
-
const
|
|
713
|
-
const buildDate = options.buildDate || new Date();
|
|
761
|
+
const buildDate = options.buildDate = options.buildDate || new Date();
|
|
714
762
|
const thisYear = buildDate.getFullYear();
|
|
715
|
-
const lastBuildDate = buildDate.toUTCString();
|
|
763
|
+
const lastBuildDate = options.lastBuildDate = buildDate.toUTCString();
|
|
716
764
|
const title = options.title || getCalendarTitle(events, options);
|
|
717
765
|
const description = options.description || title;
|
|
718
|
-
const
|
|
766
|
+
const utmSource = options.utmSource || 'shabbat1c';
|
|
767
|
+
const utmMedium = options.utmMedium || 'rss';
|
|
768
|
+
const mainUrlEsc = appendIsraelAndTracking(mainUrl, location && location.getIsrael(), utmSource, utmMedium, options.utmCampaign).replace(/&/g, '&');
|
|
719
769
|
const selfUrlEsc = options.selfUrl.replace(/&/g, '&');
|
|
720
770
|
const lang = options.lang || localeToLg[options.locale] || options.locale || 'en-US';
|
|
721
771
|
let str = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -730,7 +780,7 @@ function eventsToRss2(events, options) {
|
|
|
730
780
|
<lastBuildDate>${lastBuildDate}</lastBuildDate>
|
|
731
781
|
`;
|
|
732
782
|
events.forEach(ev => {
|
|
733
|
-
str +=
|
|
783
|
+
str += eventToRssItem2(ev, options);
|
|
734
784
|
});
|
|
735
785
|
str += '</channel>\n</rss>\n';
|
|
736
786
|
return str;
|
|
@@ -757,6 +807,16 @@ function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
|
|
|
757
807
|
|
|
758
808
|
return lastBuildDate;
|
|
759
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* @param {Event} ev
|
|
812
|
+
* @param {HebrewCalendar.Options} options
|
|
813
|
+
* @return {string}
|
|
814
|
+
*/
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
function eventToRssItem2(ev, options) {
|
|
818
|
+
return eventToRssItem(ev, options.evPubDate, options.lastBuildDate, options.dayFormat, options.location, options.mainUrl, options);
|
|
819
|
+
}
|
|
760
820
|
/**
|
|
761
821
|
* @param {Event} ev
|
|
762
822
|
* @param {boolean} evPubDate
|
|
@@ -764,17 +824,19 @@ function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
|
|
|
764
824
|
* @param {Intl.DateTimeFormat} dayFormat
|
|
765
825
|
* @param {Location} location
|
|
766
826
|
* @param {string} mainUrl
|
|
827
|
+
* @param {HebrewCalendar.Options} [options]
|
|
767
828
|
* @return {string}
|
|
768
829
|
*/
|
|
769
830
|
|
|
770
|
-
|
|
771
|
-
function eventToRssItem(ev, evPubDate, lastBuildDate, dayFormat, location, mainUrl) {
|
|
831
|
+
function eventToRssItem(ev, evPubDate, lastBuildDate, dayFormat, location, mainUrl, options) {
|
|
772
832
|
let subj = ev.render();
|
|
773
833
|
const evDate = ev.getDate().greg();
|
|
774
834
|
const pubDate = getPubDate(ev, evPubDate, evDate, lastBuildDate);
|
|
775
835
|
const il = location ? location.getIsrael() : false;
|
|
776
836
|
const tzid = location ? location.getTzid() : 'UTC';
|
|
777
|
-
const
|
|
837
|
+
const utmSource = options && options.utmSource || 'shabbat1c';
|
|
838
|
+
const utmMedium = options && options.utmMedium || 'rss';
|
|
839
|
+
const linkGuid = getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium);
|
|
778
840
|
const link = linkGuid[0];
|
|
779
841
|
const guid = linkGuid[1];
|
|
780
842
|
const categories = getEventCategories(ev);
|
|
@@ -865,4 +927,4 @@ function eventToFullCalendar(ev, tzid, il) {
|
|
|
865
927
|
return result;
|
|
866
928
|
}
|
|
867
929
|
|
|
868
|
-
export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem, eventsToClassicApi, eventsToCsv, eventsToRss, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, makeAnchor, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, timeZoneOffsetStr, toISOString, toISOStringWithTimezone };
|
|
930
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/rest-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hebcal"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@hebcal/core": "^3.
|
|
24
|
+
"@hebcal/core": "^3.33.3",
|
|
25
25
|
"@hebcal/leyning": "^4.12.1"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
@@ -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.5",
|
|
47
|
+
"@babel/preset-env": "^7.16.11",
|
|
48
|
+
"@babel/register": "^7.17.0",
|
|
49
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
50
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
59
51
|
"@rollup/plugin-json": "^4.1.0",
|
|
60
|
-
"@rollup/plugin-node-resolve": "^13.1.
|
|
61
|
-
"ava": "^
|
|
62
|
-
"core-js": "^3.
|
|
63
|
-
"eslint": "^8.
|
|
52
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
53
|
+
"ava": "^4.1.0",
|
|
54
|
+
"core-js": "^3.21.1",
|
|
55
|
+
"eslint": "^8.10.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.70.0",
|
|
68
60
|
"rollup-plugin-terser": "^7.0.2"
|
|
69
61
|
}
|
|
70
62
|
}
|
package/rest-api.d.ts
CHANGED
|
@@ -40,7 +40,8 @@ declare module '@hebcal/rest-api' {
|
|
|
40
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: HebrewCalendar.Options): string;
|
|
43
|
-
export function eventToRssItem(ev: Event, evPubDate: boolean, lastBuildDate: string, dayFormat: Intl.DateTimeFormat, location: Location, baseUrl: string): string;
|
|
43
|
+
export function eventToRssItem(ev: Event, evPubDate: boolean, lastBuildDate: string, dayFormat: Intl.DateTimeFormat, location: Location, baseUrl: string, options?: HebrewCalendar.Options): string;
|
|
44
|
+
export function eventToRssItem2(ev: Event, options: HebrewCalendar.Options): string;
|
|
44
45
|
export function getDownloadFilename(options: HebrewCalendar.Options): string;
|
|
45
46
|
export function pad2(number: number): string;
|
|
46
47
|
export function pad4(number: number): string;
|