(core) Move Notifier to /ext

Summary:
This makes it possible to configure a SendGrid-based Notifier
instance via a JSON configuration file.

Test Plan: Tested manually.

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3432
This commit is contained in:
George Gevoian
2022-05-17 15:25:36 -07:00
parent 365f3c7ae2
commit 2fd8a34ff8
10 changed files with 43 additions and 27 deletions

View File

@@ -899,9 +899,9 @@ export function isAffirmative(parameter: any): boolean {
* Returns whether a value is neither null nor undefined, with a type guard for the return type.
*
* This is particularly useful for filtering, e.g. if `array` includes values of type
* T|null|undefined, then TypeScript can tell that `array.filter(isObject)` has the type T[].
* T|null|undefined, then TypeScript can tell that `array.filter(isNonNullish)` has the type T[].
*/
export function isObject<T>(value: T | null | undefined): value is T {
export function isNonNullish<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}

View File

@@ -1,7 +1,7 @@
import escapeRegExp = require('lodash/escapeRegExp');
import last = require('lodash/last');
import memoize = require('lodash/memoize');
import {getDistinctValues, isObject} from 'app/common/gutil';
import {getDistinctValues, isNonNullish} from 'app/common/gutil';
// Simply importing 'moment-guess' inconsistently imports bundle.js or bundle.esm.js depending on environment
import * as guessFormat from '@gristlabs/moment-guess/dist/bundle.js';
import * as moment from 'moment-timezone';
@@ -346,7 +346,7 @@ export function guessDateFormat(values: Array<string | null>, timezone: string =
* May return null if there are no matching formats or choosing one is too expensive.
*/
export function guessDateFormats(values: Array<string | null>, timezone: string = 'UTC'): string[] | null {
const dateStrings: string[] = values.filter(isObject);
const dateStrings: string[] = values.filter(isNonNullish);
const sample = getDistinctValues(dateStrings, 100);
const formats: Record<string, number> = {};
for (const dateString of sample) {