From 4c4338602382cd0072d88c67967994e34dbac1e1 Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Thu, 2 May 2024 14:00:11 -0400 Subject: [PATCH 1/9] Add draft of schema file --- schema.json | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 schema.json diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..58e4129 --- /dev/null +++ b/schema.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Thunderbird In-App Notifications", + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "Unique ID set by the server" + }, + "start_at": { + "type": "string", + "format": "date-time", + "description": "Timestamp after which Thunderbird will show the event after startup." + }, + "end_at": { + "type": "string", + "format": "date-time", + "description": "Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user." + }, + "title": { + "type": "string", + "description": "Short sentence describing the event which will be displayed in the Thunderbird UI." + }, + "description": { + "type": "string", + "description": "A short paragraph that can contain HTML and will be displayed in the Thunderbird UI." + }, + "URL": { + "type": "string", + "format": "uri", + "description": "URL to load, if any." + }, + "CTA": { + "type": "string", + "description": "Link text to show for the URL." + }, + "severity": { + "enum": [1, 2, 3, 4, 5], + "description": "Severity level, where 1 is the most important/urgent and 5 is the least." + }, + "type": { + "enum": ["donation", "message", "security", "blog"], + "description": "Category of notification." + } + }, + "required": [ + "id", + "start_at", + "end_at", + "title", + "description", + "severity", + "type" + ] + } + ] +} From 5ffbd768acf21eb1f5d76bdb01b93466bc241805 Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Thu, 2 May 2024 14:40:33 -0400 Subject: [PATCH 2/9] Makes CTA dependent on URL --- schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schema.json b/schema.json index 58e4129..ea712e8 100644 --- a/schema.json +++ b/schema.json @@ -55,7 +55,8 @@ "description", "severity", "type" - ] + ], + "dependentRequired": { "CTA": ["URL"] } } ] } From ca5518351cd01c40c4878ffd6aa26e4b8fd3ffcc Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Fri, 3 May 2024 10:53:43 -0400 Subject: [PATCH 3/9] Updates version of schema, adjusting syntax for array --- schema.json | 114 ++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/schema.json b/schema.json index ea712e8..f5dc3a7 100644 --- a/schema.json +++ b/schema.json @@ -1,62 +1,60 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Thunderbird In-App Notifications", "type": "array", - "items": [ - { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid", - "description": "Unique ID set by the server" - }, - "start_at": { - "type": "string", - "format": "date-time", - "description": "Timestamp after which Thunderbird will show the event after startup." - }, - "end_at": { - "type": "string", - "format": "date-time", - "description": "Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user." - }, - "title": { - "type": "string", - "description": "Short sentence describing the event which will be displayed in the Thunderbird UI." - }, - "description": { - "type": "string", - "description": "A short paragraph that can contain HTML and will be displayed in the Thunderbird UI." - }, - "URL": { - "type": "string", - "format": "uri", - "description": "URL to load, if any." - }, - "CTA": { - "type": "string", - "description": "Link text to show for the URL." - }, - "severity": { - "enum": [1, 2, 3, 4, 5], - "description": "Severity level, where 1 is the most important/urgent and 5 is the least." - }, - "type": { - "enum": ["donation", "message", "security", "blog"], - "description": "Category of notification." - } - }, - "required": [ - "id", - "start_at", - "end_at", - "title", - "description", - "severity", - "type" - ], - "dependentRequired": { "CTA": ["URL"] } - } - ] + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "Unique ID set by the server" + }, + "start_at": { + "type": "string", + "format": "date-time", + "description": "Timestamp after which Thunderbird will show the event after startup." + }, + "end_at": { + "type": "string", + "format": "date-time", + "description": "Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user." + }, + "title": { + "type": "string", + "description": "Short sentence describing the event which will be displayed in the Thunderbird UI." + }, + "description": { + "type": "string", + "description": "A short paragraph that can contain HTML and will be displayed in the Thunderbird UI." + }, + "URL": { + "type": "string", + "format": "uri", + "description": "URL to load, if any." + }, + "CTA": { + "type": "string", + "description": "Link text to show for the URL." + }, + "severity": { + "enum": [1, 2, 3, 4, 5], + "description": "Severity level, where 1 is the most important/urgent and 5 is the least." + }, + "type": { + "enum": ["donation", "message", "security", "blog"], + "description": "Category of notification." + } + }, + "required": [ + "id", + "start_at", + "end_at", + "title", + "description", + "severity", + "type" + ], + "dependentRequired": { "CTA": ["URL"] } + } } From 604a09c6dbc682f7fef1f8d12f904619cd7a3278 Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Fri, 3 May 2024 11:30:10 -0400 Subject: [PATCH 4/9] Add targeting --- schema.json | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/schema.json b/schema.json index f5dc3a7..58fadea 100644 --- a/schema.json +++ b/schema.json @@ -44,6 +44,22 @@ "type": { "enum": ["donation", "message", "security", "blog"], "description": "Category of notification." + }, + "targeting": { + "type": "object", + "properties": { + "percent_chance": { + "type": "number", + "minimum": 0, + "maximum": 100 + }, + "exclude": { + "$ref": "#/definitions/profile" + }, + "include": { + "$ref": "#/definitions/profile" + } + } } }, "required": [ @@ -53,8 +69,50 @@ "title", "description", "severity", - "type" + "type", + "targeting" ], "dependentRequired": { "CTA": ["URL"] } + }, + "definitions": { + "profile": { + "type": "object", + "properties": { + "locales": { + "type": "array", + "items": { + "type": "string" + } + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + }, + "channels": { + "type": "array", + "items": { + "enum": ["esr", "release", "beta", "daily"], + "description": "Channel" + } + }, + "operating_systems": { + "type": "array", + "items": { + "enum": [ + "windows", + "macos", + "linux", + "freebsd", + "openbsd", + "netbsd", + "solaris" + ], + "description": "Operating System" + } + } + } + } } } From 97799b0be33719aafa42fc8b11dcb398e582c06c Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Fri, 3 May 2024 12:04:32 -0400 Subject: [PATCH 5/9] Per PR feedback: text tweak, include/exclude arrays of profile, add OS "other" --- schema.json | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/schema.json b/schema.json index 58fadea..0f0134d 100644 --- a/schema.json +++ b/schema.json @@ -31,7 +31,7 @@ "URL": { "type": "string", "format": "uri", - "description": "URL to load, if any." + "description": "URL to open from the CTA, if any." }, "CTA": { "type": "string", @@ -54,10 +54,16 @@ "maximum": 100 }, "exclude": { - "$ref": "#/definitions/profile" + "type": "array", + "items": { + "$ref": "#/definitions/profile" + } }, "include": { - "$ref": "#/definitions/profile" + "type": "array", + "items": { + "$ref": "#/definitions/profile" + } } } } @@ -107,7 +113,8 @@ "freebsd", "openbsd", "netbsd", - "solaris" + "solaris", + "other" ], "description": "Operating System" } From e0653bc4f7e3001e75fed6d5b8e68c00c8cc81fc Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Tue, 14 May 2024 16:18:15 -0400 Subject: [PATCH 6/9] Update description to indicate UTC timestamps --- schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema.json b/schema.json index 0f0134d..ac4b900 100644 --- a/schema.json +++ b/schema.json @@ -13,12 +13,12 @@ "start_at": { "type": "string", "format": "date-time", - "description": "Timestamp after which Thunderbird will show the event after startup." + "description": "UTC Timestamp after which Thunderbird will show the event after startup." }, "end_at": { "type": "string", "format": "date-time", - "description": "Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user." + "description": "UTC Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user." }, "title": { "type": "string", From dc625a9fe4ee0047f9bc20aec962fd7bdac39af0 Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Tue, 14 May 2024 17:02:25 -0400 Subject: [PATCH 7/9] Add "default" channel --- schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.json b/schema.json index ac4b900..f49838e 100644 --- a/schema.json +++ b/schema.json @@ -99,7 +99,7 @@ "channels": { "type": "array", "items": { - "enum": ["esr", "release", "beta", "daily"], + "enum": ["default", "esr", "release", "beta", "daily"], "description": "Channel" } }, From caf5d02e9be06e9ed14ab9d812532cce84a7b20a Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Mon, 20 May 2024 10:40:25 -0400 Subject: [PATCH 8/9] Match OS names from AppConstants.sys.mjs --- schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema.json b/schema.json index f49838e..e33a93f 100644 --- a/schema.json +++ b/schema.json @@ -107,8 +107,8 @@ "type": "array", "items": { "enum": [ - "windows", - "macos", + "win", + "macosx", "linux", "freebsd", "openbsd", From 566caa457e8e3f234bb3538d956e97e78a4475f3 Mon Sep 17 00:00:00 2001 From: Chris Aquino Date: Fri, 7 Jun 2024 16:18:12 -0400 Subject: [PATCH 9/9] Add version of schema auto-generated by pydantic model --- generated-schema.json | 244 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 generated-schema.json diff --git a/generated-schema.json b/generated-schema.json new file mode 100644 index 0000000..95a7373 --- /dev/null +++ b/generated-schema.json @@ -0,0 +1,244 @@ +{ + "$defs": { + "ChannelEnum": { + "enum": [ + "default", + "esr", + "release", + "beta", + "daily" + ], + "title": "ChannelEnum", + "type": "string" + }, + "Notification": { + "properties": { + "id": { + "format": "uuid", + "title": "Id", + "type": "string" + }, + "start_at": { + "format": "date-time", + "title": "Start At", + "type": "string" + }, + "end_at": { + "format": "date-time", + "title": "End At", + "type": "string" + }, + "title": { + "title": "Title", + "type": "string" + }, + "description": { + "title": "Description", + "type": "string" + }, + "URL": { + "anyOf": [ + { + "format": "uri", + "maxLength": 2083, + "minLength": 1, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Url" + }, + "CTA": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Cta" + }, + "severity": { + "$ref": "#/$defs/SeverityEnum" + }, + "type": { + "$ref": "#/$defs/TypeEnum" + }, + "targeting": { + "$ref": "#/$defs/Targeting" + } + }, + "required": [ + "id", + "start_at", + "end_at", + "title", + "description", + "severity", + "type", + "targeting" + ], + "title": "Notification", + "type": "object" + }, + "OperatingSystemEnum": { + "enum": [ + "win", + "macosx", + "linux", + "freebsd", + "openbsd", + "netbsd", + "solaris", + "other" + ], + "title": "OperatingSystemEnum", + "type": "string" + }, + "Profile": { + "properties": { + "locales": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Locales" + }, + "versions": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Versions" + }, + "channels": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/ChannelEnum" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Channels" + }, + "operating_systems": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/OperatingSystemEnum" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Operating Systems" + } + }, + "title": "Profile", + "type": "object" + }, + "SeverityEnum": { + "enum": [ + 1, + 2, + 3, + 4, + 5 + ], + "title": "SeverityEnum", + "type": "integer" + }, + "Targeting": { + "properties": { + "percent_chance": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Percent Chance" + }, + "exclude": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Profile" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Exclude" + }, + "include": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Profile" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Include" + } + }, + "title": "Targeting", + "type": "object" + }, + "TypeEnum": { + "enum": [ + "donation", + "message", + "security", + "blog" + ], + "title": "TypeEnum", + "type": "string" + } + }, + "items": { + "$ref": "#/$defs/Notification" + }, + "title": "NotificationSchema", + "type": "array" +} \ No newline at end of file