mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -14,6 +14,7 @@ export const Webhook = t.iface([], {
|
||||
|
||||
export const WebhookFields = t.iface([], {
|
||||
"url": "string",
|
||||
"authorization": t.opt("string"),
|
||||
"eventTypes": t.array(t.union(t.lit("add"), t.lit("update"))),
|
||||
"tableId": "string",
|
||||
"watchedColIds": t.opt(t.array("string")),
|
||||
@@ -29,6 +30,7 @@ export const WebhookStatus = t.union(t.lit('idle'), t.lit('sending'), t.lit('ret
|
||||
|
||||
export const WebhookSubscribe = t.iface([], {
|
||||
"url": "string",
|
||||
"authorization": t.opt("string"),
|
||||
"eventTypes": t.array(t.union(t.lit("add"), t.lit("update"))),
|
||||
"watchedColIds": t.opt(t.array("string")),
|
||||
"enabled": t.opt("boolean"),
|
||||
@@ -45,6 +47,7 @@ export const WebhookSummary = t.iface([], {
|
||||
"id": "string",
|
||||
"fields": t.iface([], {
|
||||
"url": "string",
|
||||
"authorization": t.opt("string"),
|
||||
"unsubscribeKey": "string",
|
||||
"eventTypes": t.array("string"),
|
||||
"isReadyColumn": t.union("string", "null"),
|
||||
@@ -64,6 +67,7 @@ export const WebhookUpdate = t.iface([], {
|
||||
|
||||
export const WebhookPatch = t.iface([], {
|
||||
"url": t.opt("string"),
|
||||
"authorization": t.opt("string"),
|
||||
"eventTypes": t.opt(t.array(t.union(t.lit("add"), t.lit("update")))),
|
||||
"tableId": t.opt("string"),
|
||||
"watchedColIds": t.opt(t.array("string")),
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface Webhook {
|
||||
|
||||
export interface WebhookFields {
|
||||
url: string;
|
||||
authorization?: string;
|
||||
eventTypes: Array<"add"|"update">;
|
||||
tableId: string;
|
||||
watchedColIds?: string[];
|
||||
@@ -26,6 +27,7 @@ export type WebhookStatus = 'idle'|'sending'|'retrying'|'postponed'|'error'|'inv
|
||||
// tableId from the url) but generics are not yet supported by ts-interface-builder
|
||||
export interface WebhookSubscribe {
|
||||
url: string;
|
||||
authorization?: string;
|
||||
eventTypes: Array<"add"|"update">;
|
||||
watchedColIds?: string[];
|
||||
enabled?: boolean;
|
||||
@@ -42,6 +44,7 @@ export interface WebhookSummary {
|
||||
id: string;
|
||||
fields: {
|
||||
url: string;
|
||||
authorization?: string;
|
||||
unsubscribeKey: string;
|
||||
eventTypes: string[];
|
||||
isReadyColumn: string|null;
|
||||
@@ -64,6 +67,7 @@ export interface WebhookUpdate {
|
||||
// ts-interface-builder
|
||||
export interface WebhookPatch {
|
||||
url?: string;
|
||||
authorization?: string;
|
||||
eventTypes?: Array<"add"|"update">;
|
||||
tableId?: string;
|
||||
watchedColIds?: string[];
|
||||
|
||||
27
app/common/normalizedDateTimeString.ts
Normal file
27
app/common/normalizedDateTimeString.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
/**
|
||||
* Output an ISO8601 format datetime string, with timezone.
|
||||
* Any string fed in without timezone is expected to be in UTC.
|
||||
*
|
||||
* When connected to postgres, dates will be extracted as Date objects,
|
||||
* with timezone information. The normalization done here is not
|
||||
* really needed in this case.
|
||||
*
|
||||
* Timestamps in SQLite are stored as UTC, and read as strings
|
||||
* (without timezone information). The normalization here is
|
||||
* pretty important in this case.
|
||||
*/
|
||||
export function normalizedDateTimeString(dateTime: any): string {
|
||||
if (!dateTime) { return dateTime; }
|
||||
if (dateTime instanceof Date) {
|
||||
return moment(dateTime).toISOString();
|
||||
}
|
||||
if (typeof dateTime === 'string' || typeof dateTime === 'number') {
|
||||
// When SQLite returns a string, it will be in UTC.
|
||||
// Need to make sure it actually have timezone info in it
|
||||
// (will not by default).
|
||||
return moment.utc(dateTime).toISOString();
|
||||
}
|
||||
throw new Error(`normalizedDateTimeString cannot handle ${dateTime}`);
|
||||
}
|
||||
Reference in New Issue
Block a user