.*)"`). | `Subject 1` |
-| `message.to` | The comma-separated recipients of the message. See [GmailMessage.getTo()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getTo\(\)) reference docs. | `message-to@example.com` |
-| `message.url` | The URL of the message. | `https://mail.google.com/mail/u/0...` |
-| `messageConfig.index` | The index number (0-based) of the message config. | `0` |
+| Key | Title | Description | Example |
+|-----|-------|-------------|---------|
+| `message.bcc` | Message BCC | The comma-separated recipients bcc'd on the message. See [GmailMessage.getBcc()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getBcc\(\)) reference docs. | `message-bcc@example.com` |
+| `message.body` | Message Body | The body of the message. See [GmailMessage.getBody()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getBody\(\)) reference docs. | `Message body with contained u...` |
+| `message.body.match.1` | message.body Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"(?https://raw\\.githubusercontent\\.com/ahochsteger/gmail-processor/main/src/e2e-test/files/(?[0-9A-Za-z_-]+\\.txt))"`). | `https://raw.githubusercontent.co...` |
+| `message.body.match.2` | message.body Regex Match Group 2 | The matching regex group number as defined in the match config (e.g.: `"(?https://raw\\.githubusercontent\\.com/ahochsteger/gmail-processor/main/src/e2e-test/files/(?[0-9A-Za-z_-]+\\.txt))"`). | `plain-text-from-repo.txt` |
+| `message.body.match.filename` | message.body Regex Match Group filename | The matching named regex group name as defined in the match config (e.g.: `"(?https://raw\\.githubusercontent\\.com/ahochsteger/gmail-processor/main/src/e2e-test/files/(?[0-9A-Za-z_-]+\\.txt))"`). | `plain-text-from-repo.txt` |
+| `message.body.match.url` | message.body Regex Match Group url | The matching named regex group name as defined in the match config (e.g.: `"(?https://raw\\.githubusercontent\\.com/ahochsteger/gmail-processor/main/src/e2e-test/files/(?[0-9A-Za-z_-]+\\.txt))"`). | `https://raw.githubusercontent.co...` |
+| `message.cc` | Message CC | The comma-separated recipients cc'd on the message. See [GmailMessage.getCc()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getCc\(\)) reference docs. | `message-cc@example.com` |
+| `message.date` | Message Date | The date and time of the message. See [GmailMessage.getDate()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getDate\(\)) reference docs. Use `"${:date::}"` to format the date/time using a custom [date-fns format strings](https://date-fns.org/docs/format) (default: `"yyyy-MM-dd HH:mm:ss"`). | `2019-05-02 07:15:28` |
+| `message.from` | Sender | The sender of the message. See [GmailMessage.getFrom()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getFrom\(\)) reference docs. | `message-from@example.com` |
+| `message.from.domain` | Sender Domain | The sender domain of the message. See [GmailMessage.getFrom()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getFrom\(\)) reference docs. | `example.com` |
+| `message.from.match.1` | message.from Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"(.+)@example.com"`). | `message-from` |
+| `message.id` | Message ID | The ID of the message. See [GmailMessage.getId()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getId\(\)) reference docs. | `message-id` |
+| `message.index` | Message Index | The index number (0-based) of the message. | `0` |
+| `message.isDraft` | Draft Message | `true` if the message is a draft. See [GmailMessage.isDraft()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isDraft\(\)) reference docs. | `false` |
+| `message.isInChats` | Chat Message | `true` if the message is a chat. See [GmailMessage.isInChats()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isInChats\(\)) reference docs. | `false` |
+| `message.isInInbox` | Inbox Message | `true` if the message is in the inbox. See [GmailMessage.isInInbox()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isInInbox\(\)) reference docs. | `true` |
+| `message.isInPriorityInbox` | Priority Inbox Message | `true` if if the message is in the priority inbox. See [GmailMessage.isInPriorityInbox()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isInPriorityInbox\(\)) reference docs. | `false` |
+| `message.isInTrash` | Trash Message | `true` if the message is in the trash. See [GmailMessage.isInTrash()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isInTrash\(\)) reference docs. | `false` |
+| `message.isStarred` | Starred Message | `true` if the message is starred. See [GmailMessage.isStarred()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isStarred\(\)) reference docs. | `false` |
+| `message.isUnread` | Unread Message | `true` if the message is unread. See [GmailMessage.isUnread()](https://developers.google.com/apps-script/reference/gmail/gmail-message#isUnread\(\)) reference docs. | `true` |
+| `message.matched` | message Regex Matches | The overall matching result for all conditions in the match config. | `true` |
+| `message.plainBody` | Message Plain Body | The plain body of the message. See [GmailMessage.getPlainBody()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getPlainBody\(\)) reference docs. | |
+| `message.replyTo` | Message Reply To | The reply-to address of the message (usually the sender). See [GmailMessage.getReplyTo()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getReplyTo\(\)) reference docs. | `message-reply-to@example.com` |
+| `message.subject` | Message Subject | The subject of the message. See [GmailMessage.getSubject()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getSubject\(\)) reference docs. | `Message Subject 1` |
+| `message.subject.match.1` | message.subject Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"Message (?.*)"`). | `Subject 1` |
+| `message.subject.match.myMatchGroup` | message.subject Regex Match Group myMatchGroup | The matching named regex group name as defined in the match config (e.g.: `"Message (?.*)"`). | `Subject 1` |
+| `message.to` | Message To | The comma-separated recipients of the message. See [GmailMessage.getTo()](https://developers.google.com/apps-script/reference/gmail/gmail-message#getTo\(\)) reference docs. | `message-to@example.com` |
+| `message.url` | Message URL | The URL of the message. | `https://mail.google.com/mail/u/0...` |
+| `messageConfig.index` | Message Config Index | The index number (0-based) of the message config. | `0` |
## Attachment Placeholder
These placeholder are valid during processing a GMail attachment.
-| Key | Description | Example |
-|-----|-------------|---------|
-| `attachment.contentType` | The content type of the attachment. See [GmailAttachment.getContentType()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getContentType\(\)) reference docs. | `application/pdf` |
-| `attachment.contentType.match.1` | The matching regex group number as defined in the match config (e.g.: `"application/(?.*)"`). | `pdf` |
-| `attachment.contentType.match.appType` | The matching named regex group name as defined in the match config (e.g.: `"application/(?.*)"`). | `pdf` |
-| `attachment.hash` | The SHA1 content hash for the attachment. See [GmailAttachment.getHash()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getHash\(\)) reference docs. | `aa0b8cc192a5d8d5b5d8ecda24fd0961...` |
-| `attachment.index` | The index number (0-based) of the attachment. | `0` |
-| `attachment.isGoogleType` | `true` if this attachment is a Google Workspace file (Sheets, Docs, etc.). See [GmailAttachment.isGoogleType()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#isGoogleType\(\)) reference docs. | `false` |
-| `attachment.matched` | The overall matching result for all conditions in the match config. | `true` |
-| `attachment.name` | The name of the attachment. See [GmailAttachment.getName()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getName\(\)) reference docs. | `attachment1.pdf` |
-| `attachment.name.match.1` | The matching regex group number as defined in the match config (e.g.: `"attachment(?[0-9]+)\\.pdf"`). | `1` |
-| `attachment.name.match.attNr` | The matching named regex group name as defined in the match config (e.g.: `"attachment(?[0-9]+)\\.pdf"`). | `1` |
-| `attachment.size` | The size of the attachment. See [GmailAttachment.getSize()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getSize\(\)) reference docs. | `18` |
-| `attachmentConfig.index` | The index number (0-based) of the attachment config. | `0` |
+| Key | Title | Description | Example |
+|-----|-------|-------------|---------|
+| `attachment.contentType` | Attachment Content Type | The content type of the attachment. See [GmailAttachment.getContentType()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getContentType\(\)) reference docs. | `application/pdf` |
+| `attachment.contentType.match.1` | attachment.contentType Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"application/(?.*)"`). | `pdf` |
+| `attachment.contentType.match.appType` | attachment.contentType Regex Match Group appType | The matching named regex group name as defined in the match config (e.g.: `"application/(?.*)"`). | `pdf` |
+| `attachment.hash` | Attachment Hash | The SHA1 content hash for the attachment. See [GmailAttachment.getHash()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getHash\(\)) reference docs. | `aa0b8cc192a5d8d5b5d8ecda24fd0961...` |
+| `attachment.index` | Attachment Index | The index number (0-based) of the attachment. | `0` |
+| `attachment.isGoogleType` | Google Type Attachment | `true` if this attachment is a Google Workspace file (Sheets, Docs, etc.). See [GmailAttachment.isGoogleType()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#isGoogleType\(\)) reference docs. | `false` |
+| `attachment.matched` | attachment Regex Matches | The overall matching result for all conditions in the match config. | `true` |
+| `attachment.name` | Attachment Name | The name of the attachment. See [GmailAttachment.getName()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getName\(\)) reference docs. | `attachment1.pdf` |
+| `attachment.name.match.1` | attachment.name Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"attachment(?[0-9]+)\\.pdf"`). | `1` |
+| `attachment.name.match.attNr` | attachment.name Regex Match Group attNr | The matching named regex group name as defined in the match config (e.g.: `"attachment(?[0-9]+)\\.pdf"`). | `1` |
+| `attachment.size` | Attachment Size | The size of the attachment. See [GmailAttachment.getSize()](https://developers.google.com/apps-script/reference/gmail/gmail-attachment#getSize\(\)) reference docs. | `18` |
+| `attachmentConfig.index` | Attachment Config Index | The index number (0-based) of the attachment config. | `0` |
## Action Placeholder
These placeholder are valid after certain actions have been executed.
-| Key | Description | Example |
-|-----|-------------|---------|
-| `attachment.docsFile.stored.downloadUrl` | The download URL of the stored OCR docs file (using action `attachment.extractText`) | |
-| `attachment.docsFile.stored.id` | The ID of the stored OCR docs file (using action `attachment.extractText`) | `created-docs-file-id` |
-| `attachment.docsFile.stored.location` | The location of the stored OCR docs file (using action `attachment.extractText`) | `created-docs-file` |
-| `attachment.docsFile.stored.url` | The URL of the stored OCR docs file (using action `attachment.extractText`) | |
-| | The extracted text from the attachment (using action `attachment.extractText`) | `...
Invoice date: 2024-03-13
Inv...` |
-| | The matching regex group number as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `2024-03-13` |
-| | The matching regex group number as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `12345678` |
-| | The matching named regex group name as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `2024-03-13` |
-| | The matching named regex group name as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `12345678` |
+| Key | Title | Description | Example |
+|-----|-------|-------------|---------|
+| `attachment.docsFile.stored.downloadUrl` | Stored Download URL | The download URL of the stored OCR docs file (using action `attachment.extractText`) | |
+| `attachment.docsFile.stored.id` | Stored ID | The ID of the stored OCR docs file (using action `attachment.extractText`) | `created-docs-file-id` |
+| `attachment.docsFile.stored.location` | Stored Location | The location of the stored OCR docs file (using action `attachment.extractText`) | `created-docs-file` |
+| `attachment.docsFile.stored.url` | Stored URL | The URL of the stored OCR docs file (using action `attachment.extractText`) | |
+| | Extracted Text | The extracted text from the attachment (using action `attachment.extractText`) | `...
Invoice date: 2024-03-13
Inv...` |
+| | attachment.extracted Regex Match Group 1 | The matching regex group number as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `2024-03-13` |
+| | attachment.extracted Regex Match Group 2 | The matching regex group number as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `12345678` |
+| | attachment.extracted Regex Match Group invoiceDate | The matching named regex group name as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `2024-03-13` |
+| | attachment.extracted Regex Match Group invoiceNumber | The matching named regex group name as defined in the match config (e.g.: `"Invoice date:\\s*(?[0-9-]+)\\s*Invoice number:\\s*(?[0-9]+)"`). | `12345678` |
## Date Expressions
diff --git a/package.json b/package.json
index 7442b47e..4635bfea 100644
--- a/package.json
+++ b/package.json
@@ -55,13 +55,13 @@
"sonar:local": "npx sonar-scanner -Dsonar.branch.name=local -Dsonar.branch.target=main -Dsonar.projectVersion=''",
"start:docs": "npm run build:docs && cd docs && npm start",
"test": "TZ=UTC jest --reporters=summary --silent",
- "test:examples": "jest --reporters=summary --silent --testPathPattern src/examples",
- "test:verbose": "jest --detectOpenHandles --reporters='default' --runInBand --verbose",
- "update": "concurrently 'npm:update:*'",
+ "test:examples": "TZ=UTC jest --reporters=summary --silent --testPathPattern src/examples",
+ "test:verbose": "TZ=UTC jest --detectOpenHandles --reporters='default' --runInBand --verbose",
+ "update": "TZ=UTC concurrently 'npm:update:*'",
"update:contributors": "npx all-contributors generate",
- "update:docs": "scripts/update-docs.sh",
- "update:examples": "scripts/update-examples.sh",
- "update:schema": "scripts/update-schema.sh"
+ "update:docs": "TZ=UTC scripts/update-docs.sh",
+ "update:examples": "TZ=UTC scripts/update-examples.sh",
+ "update:schema": "TZ=UTC scripts/update-schema.sh"
},
"repository": {
"type": "git",
diff --git a/scripts/update-docs-generate-placeholder.jq b/scripts/update-docs-generate-placeholder.jq
index 19e0b102..5be632b6 100644
--- a/scripts/update-docs-generate-placeholder.jq
+++ b/scripts/update-docs-generate-placeholder.jq
@@ -39,8 +39,8 @@ include "update-docs-generate-common";
"",
$map[.contextType].description,
"",
- "| Key | Description | Example |",
- "|-----|-------------|---------|",
+ "| Key | Title | Description | Example |",
+ "|-----|-------|-------------|---------|",
(
.placeholder
| sort_by(.key)
@@ -48,6 +48,7 @@ include "update-docs-generate-common";
| ("placeholder." + .key) as $placeholderAnchor
| [
"`" + .key + "`",
+ .title,
generateDescription,
(if (.example|length==0) then "" else "`" + (if (.example|length>32) then (.example[0:32]+"...") else .example end) + "`" end)
]
diff --git a/src/examples/advanced/logSheetLogging.ts b/src/examples/advanced/logSheetLogging.ts
index 87eb21a8..f19266ab 100644
--- a/src/examples/advanced/logSheetLogging.ts
+++ b/src/examples/advanced/logSheetLogging.ts
@@ -36,10 +36,11 @@ export const runConfig: Config = {
"log.timestamp",
"log.level",
"log.message",
- "entity.date",
- "entity.subject",
- "entity.from",
- "entity.url",
+ "object.id",
+ "object.date",
+ "object.subject",
+ "object.from",
+ "object.url",
"attachment.name",
"attachment.size",
"attachment.contentType",
diff --git a/src/gas/examples/advanced/logSheetLogging.js b/src/gas/examples/advanced/logSheetLogging.js
index bee3462c..f5c7582b 100644
--- a/src/gas/examples/advanced/logSheetLogging.js
+++ b/src/gas/examples/advanced/logSheetLogging.js
@@ -32,10 +32,11 @@ function logSheetLoggingTest() {
"log.timestamp",
"log.level",
"log.message",
- "entity.date",
- "entity.subject",
- "entity.from",
- "entity.url",
+ "object.id",
+ "object.date",
+ "object.subject",
+ "object.from",
+ "object.url",
"attachment.name",
"attachment.size",
"attachment.contentType",
diff --git a/src/lib/Context.ts b/src/lib/Context.ts
index 84eb33f2..88134868 100644
--- a/src/lib/Context.ts
+++ b/src/lib/Context.ts
@@ -52,18 +52,21 @@ type MetaInfoValueType =
type MetaInfoEntry = {
deprecationInfo?: string
description: string
+ title: string
type: MetaInfoType
value: MetaInfoValueType
}
export function newMetaInfo(
type: MetaInfoType,
value: MetaInfoValueType,
+ title: string,
description: string,
deprecationInfo?: string,
): MetaInfoEntry {
return {
deprecationInfo,
description,
+ title,
type,
value,
}
diff --git a/src/lib/EnvProvider.ts b/src/lib/EnvProvider.ts
index da806f4b..98c14179 100644
--- a/src/lib/EnvProvider.ts
+++ b/src/lib/EnvProvider.ts
@@ -11,20 +11,28 @@ import { Logger as Log } from "./utils/Logger"
export class EnvProvider {
public static buildMetaInfo(ctx: EnvContext) {
const m: MetaInfo = {
- "date.now": mi(MIT.DATE, () => new Date(), "The current timestamp."),
+ "date.now": mi(
+ MIT.DATE,
+ () => new Date(),
+ "Current Timestamp",
+ "The current timestamp.",
+ ),
"env.runMode": mi(
MIT.STRING,
() => ctx.env.runMode,
+ "Runmode",
"The runMode used for processing.",
),
"env.timezone": mi(
MIT.STRING,
() => ctx.env.timezone,
+ "Timezone",
"The timezone used for processing.",
),
"user.email": mi(
MIT.STRING,
() => ctx.env.session.getActiveUser().getEmail(),
+ "User Email",
"The email address of the active user.",
),
}
diff --git a/src/lib/actions/AttachmentActions.ts b/src/lib/actions/AttachmentActions.ts
index 22c34c6b..b7e778ad 100644
--- a/src/lib/actions/AttachmentActions.ts
+++ b/src/lib/actions/AttachmentActions.ts
@@ -55,6 +55,7 @@ export class AttachmentActions implements ActionProvider {
actionMeta["attachment.extracted"] = newMetaInfo(
MetaInfoType.STRING,
result.text,
+ "Extracted Text",
"The extracted text from the attachment (using action `attachment.extractText`)",
)
if (args.extract) {
diff --git a/src/lib/actions/GlobalActions.spec.ts b/src/lib/actions/GlobalActions.spec.ts
index 46e7cd7a..0eef1010 100644
--- a/src/lib/actions/GlobalActions.spec.ts
+++ b/src/lib/actions/GlobalActions.spec.ts
@@ -52,13 +52,14 @@ it("should log with default level (info) to a logSheet", () => {
`${fakedSystemDateTimeString}.000`,
LogLevel.INFO,
"Log message",
+ "aa0b8cc192a5d8d5b5d8ecda24fd0961b10ae283",
"2019-05-02 07:15:28",
"Message Subject 1",
"message-from@example.com",
"https://mail.google.com/mail/u/0/#inbox/message-id",
- "",
- "",
- "",
+ "attachment1.pdf",
+ "18",
+ "application/pdf",
"",
"",
"",
diff --git a/src/lib/adapter/GDriveAdapter.ts b/src/lib/adapter/GDriveAdapter.ts
index 5a689c57..a3ad4fe8 100644
--- a/src/lib/adapter/GDriveAdapter.ts
+++ b/src/lib/adapter/GDriveAdapter.ts
@@ -465,21 +465,25 @@ export class GDriveAdapter extends BaseAdapter {
actionMeta[`${keyPrefix}.stored.location`] = newMetaInfo(
MetaInfoType.STRING,
location,
+ "Stored Location",
`The location ${desc}`,
)
actionMeta[`${keyPrefix}.stored.id`] = newMetaInfo(
MetaInfoType.STRING,
file.getId(),
+ "Stored ID",
`The ID ${desc}`,
)
actionMeta[`${keyPrefix}.stored.url`] = newMetaInfo(
MetaInfoType.STRING,
file.getUrl(),
+ "Stored URL",
`The URL ${desc}`,
)
actionMeta[`${keyPrefix}.stored.downloadUrl`] = newMetaInfo(
MetaInfoType.STRING,
file.getDownloadUrl(),
+ "Stored Download URL",
`The download URL ${desc}`,
)
}
diff --git a/src/lib/adapter/LogAdapter.ts b/src/lib/adapter/LogAdapter.ts
index ce02b803..45517cb1 100644
--- a/src/lib/adapter/LogAdapter.ts
+++ b/src/lib/adapter/LogAdapter.ts
@@ -38,19 +38,16 @@ export class LogAdapter extends BaseAdapter {
fieldConfig: LogFieldConfig[],
name: string,
): LogFieldConfig | undefined {
- let field: LogFieldConfig | undefined
const logConfigField = fieldConfig.find((f) => f.name == name)
- if (logConfigField) {
- field = logConfigField
- } else {
- const contextField = ctx.meta[name]?.value
- if (contextField) {
- field = {
- name: name,
- title: name,
- value: `\${${name}}`,
- } as LogFieldConfig
- }
+ const contextField = ctx.meta[name]
+ const field: LogFieldConfig = {
+ name: name,
+ title: logConfigField?.title ?? contextField?.title ?? name,
+ value:
+ logConfigField?.ctxValues?.[ctx.type] ??
+ logConfigField?.value ??
+ `\${${name}}` ??
+ "",
}
return field
}
@@ -83,7 +80,7 @@ export class LogAdapter extends BaseAdapter {
value = message
} else if (field.name === LOG_LEVEL_NAME) {
value = level
- } else if (field.ctxValues && field.ctxValues[ctx.type]) {
+ } else if (field?.ctxValues?.[ctx.type]) {
value = field.ctxValues[ctx.type] as string
} else if (field.value !== undefined) {
value = field.value ?? ""
diff --git a/src/lib/config/SettingsConfig.ts b/src/lib/config/SettingsConfig.ts
index 78f1a29a..5b51841b 100644
--- a/src/lib/config/SettingsConfig.ts
+++ b/src/lib/config/SettingsConfig.ts
@@ -5,10 +5,10 @@ import { RequiredDeep } from "../utils/UtilityTypes"
// TODO: Use these constants in SettingsConfig below, when typescript-json-schema bug is resolved.
// See https://github.com/YousefED/typescript-json-schema/issues/336#issuecomment-1528969616
+// PR: https://github.com/YousefED/typescript-json-schema/pull/600
export const DEFAULT_SETTING_MAX_BATCH_SIZE = 10
export const DEFAULT_SETTING_MAX_RUNTIME = 280
export const DEFAULT_SETTING_SLEEP_TIME_THREADS = 100
-
export const LOG_MESSAGE_NAME = "log.message"
export const LOG_LEVEL_NAME = "log.level"
@@ -83,7 +83,7 @@ export class LogFieldConfig {
/** The title of the log field that is used as the headline of the log sheet. */
title: string = ""
/** The value of the log field. Supports placeholder substitution. */
- value?: string = ""
+ value?: string = undefined
/** The context-dependent values. It allows different values depending on the context type. */
ctxValues?: LogFieldContextConfig = {}
}
@@ -116,10 +116,11 @@ export class SettingsConfig {
"log.timestamp",
"log.level",
"log.message",
- "entity.date",
- "entity.subject",
- "entity.from",
- "entity.url",
+ "object.id",
+ "object.date",
+ "object.subject",
+ "object.from",
+ "object.url",
"attachment.name",
"attachment.size",
"attachment.contentType",
@@ -139,18 +140,19 @@ export class SettingsConfig {
value: "${date.now:date::yyyy-MM-dd HH:mm:ss.SSS}",
},
{
- name: LOG_LEVEL_NAME,
+ name: "log.level",
title: "Log Level",
},
{
- // Special entry that represents the log message
- name: LOG_MESSAGE_NAME,
+ name: "log.message",
title: "Log Message",
},
- // TODO: Move title to meta info and use from there.
- { name: "context.type", title: "Context Type", value: "${context.type}" },
{
- name: "entity.id",
+ name: "context.type",
+ title: "Context Type",
+ },
+ {
+ name: "object.id",
title: "ID",
ctxValues: {
attachment: "${attachment.hash}",
@@ -159,7 +161,7 @@ export class SettingsConfig {
},
},
{
- name: "entity.url",
+ name: "object.url",
title: "GMail URL",
ctxValues: {
attachment: "${message.url}",
@@ -168,7 +170,7 @@ export class SettingsConfig {
},
},
{
- name: "entity.date",
+ name: "object.date",
title: "Message Date",
ctxValues: {
attachment: "${message.date}",
@@ -177,7 +179,7 @@ export class SettingsConfig {
},
},
{
- name: "entity.subject",
+ name: "object.subject",
title: "Subject",
ctxValues: {
attachment: "${message.subject}",
@@ -186,7 +188,7 @@ export class SettingsConfig {
},
},
{
- name: "entity.from",
+ name: "object.from",
title: "From",
ctxValues: {
attachment: "${message.from}",
@@ -208,17 +210,23 @@ export class SettingsConfig {
{
name: "stored.location",
title: "Stored Location",
- ctxValues: { attachment: "${attachment.stored.location}" },
+ ctxValues: {
+ attachment: "${attachment.stored.location}",
+ },
},
{
name: "stored.url",
title: "Stored URL",
- ctxValues: { attachment: "${attachment.stored.url}" },
+ ctxValues: {
+ attachment: "${attachment.stored.url}",
+ },
},
{
name: "stored.downloadUrl",
title: "Download URL",
- ctxValues: { attachment: "${attachment.stored.downloadUrl}" },
+ ctxValues: {
+ attachment: "${attachment.stored.downloadUrl}",
+ },
},
]
/**
diff --git a/src/lib/config/config-schema-v2.json b/src/lib/config/config-schema-v2.json
index 96c5d353..38f8c3c2 100644
--- a/src/lib/config/config-schema-v2.json
+++ b/src/lib/config/config-schema-v2.json
@@ -1303,7 +1303,6 @@
"type": "string"
},
"value": {
- "default": "",
"description": "The value of the log field. Supports placeholder substitution.",
"title": "value",
"type": "string"
@@ -2644,6 +2643,102 @@
"type": "string"
},
"logConfig": {
+ "default": [
+ {
+ "name": "log.timestamp",
+ "title": "Timestamp",
+ "value": "${date.now:date::yyyy-MM-dd HH:mm:ss.SSS}"
+ },
+ {
+ "name": "log.level",
+ "title": "Log Level"
+ },
+ {
+ "name": "log.message",
+ "title": "Log Message"
+ },
+ {
+ "name": "context.type",
+ "title": "Context Type"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${attachment.hash}",
+ "message": "${message.id}",
+ "thread": "${thread.id}"
+ },
+ "name": "object.id",
+ "title": "ID"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${message.url}",
+ "message": "${message.url}",
+ "thread": "${thread.url}"
+ },
+ "name": "object.url",
+ "title": "GMail URL"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${message.date}",
+ "message": "${message.date}",
+ "thread": "${thread.lastMessageDate}"
+ },
+ "name": "object.date",
+ "title": "Message Date"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${message.subject}",
+ "message": "${message.subject}",
+ "thread": "${thread.firstMessageSubject}"
+ },
+ "name": "object.subject",
+ "title": "Subject"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${message.from}",
+ "message": "${message.from}"
+ },
+ "name": "object.from",
+ "title": "From"
+ },
+ {
+ "name": "attachment.name",
+ "title": "Attachment Name"
+ },
+ {
+ "name": "attachment.contentType",
+ "title": "Content Type"
+ },
+ {
+ "name": "attachment.size",
+ "title": "Attachment Size"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${attachment.stored.location}"
+ },
+ "name": "stored.location",
+ "title": "Stored Location"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${attachment.stored.url}"
+ },
+ "name": "stored.url",
+ "title": "Stored URL"
+ },
+ {
+ "ctxValues": {
+ "attachment": "${attachment.stored.downloadUrl}"
+ },
+ "name": "stored.downloadUrl",
+ "title": "Download URL"
+ }
+ ],
"description": "Defines additional fields that can be used in addition to the built-in ones for log sheet logging.",
"items": {
"$ref": "#/definitions/LogFieldConfig"
@@ -2656,10 +2751,11 @@
"log.timestamp",
"log.level",
"log.message",
- "entity.date",
- "entity.subject",
- "entity.from",
- "entity.url",
+ "object.id",
+ "object.date",
+ "object.subject",
+ "object.from",
+ "object.url",
"attachment.name",
"attachment.size",
"attachment.contentType",
diff --git a/src/lib/processors/AttachmentProcessor.ts b/src/lib/processors/AttachmentProcessor.ts
index bcfd37c9..f74a3eef 100644
--- a/src/lib/processors/AttachmentProcessor.ts
+++ b/src/lib/processors/AttachmentProcessor.ts
@@ -140,6 +140,7 @@ export class AttachmentProcessor extends BaseProcessor {
[`${keyPrefix}.contentType`]: mi(
MIT.STRING,
(att: Attachment) => att.getContentType(),
+ "Attachment Content Type",
this.getRefDocs(
keyPrefix,
"getContentType",
@@ -149,6 +150,7 @@ export class AttachmentProcessor extends BaseProcessor {
[`${keyPrefix}.hash`]: mi(
MIT.STRING,
(att: Attachment) => att.getHash(),
+ "Attachment Hash",
this.getRefDocs(
keyPrefix,
"getHash",
@@ -158,6 +160,7 @@ export class AttachmentProcessor extends BaseProcessor {
[`${keyPrefix}.isGoogleType`]: mi(
MIT.STRING,
(att: Attachment) => att.isGoogleType(),
+ "Google Type Attachment",
this.getRefDocs(
keyPrefix,
"isGoogleType",
@@ -167,21 +170,25 @@ export class AttachmentProcessor extends BaseProcessor {
[`${keyPrefix}.name`]: mi(
MIT.STRING,
(att: Attachment) => att.getName(),
+ "Attachment Name",
this.getRefDocs(keyPrefix, "getName", "The name of the attachment."),
),
[`${keyPrefix}.size`]: mi(
MIT.STRING,
(att: Attachment) => att.getSize(),
+ "Attachment Size",
this.getRefDocs(keyPrefix, "getSize", "The size of the attachment."),
),
[`${keyPrefix}.index`]: mi(
MIT.STRING,
ctx.attachment.index,
+ "Attachment Index",
"The index number (0-based) of the attachment.",
),
"attachmentConfig.index": mi(
MIT.STRING,
ctx.attachment.configIndex,
+ "Attachment Config Index",
"The index number (0-based) of the attachment config.",
),
}
diff --git a/src/lib/processors/BaseProcessor.spec.ts b/src/lib/processors/BaseProcessor.spec.ts
index 178b3f7b..51ee172b 100644
--- a/src/lib/processors/BaseProcessor.spec.ts
+++ b/src/lib/processors/BaseProcessor.spec.ts
@@ -52,6 +52,7 @@ class TestActionProvider implements ActionProvider {
m[TEST_CONTEXT_KEY] = newMetaInfo(
MetaInfoType.STRING,
TEST_CONTEXT_VALUE,
+ "Some Title",
"Some description",
)
return {
diff --git a/src/lib/processors/BaseProcessor.ts b/src/lib/processors/BaseProcessor.ts
index ae68c9e2..5308339e 100644
--- a/src/lib/processors/BaseProcessor.ts
+++ b/src/lib/processors/BaseProcessor.ts
@@ -77,6 +77,7 @@ export abstract class BaseProcessor {
m[`${keyName}.match.${i}`] = mi(
MIT.STRING,
result[i],
+ `${keyName} Regex Match Group ${i}`,
`The matching regex group number as defined in the match config (e.g.: \`${JSON.stringify(value)}\`).`,
)
}
@@ -85,6 +86,7 @@ export abstract class BaseProcessor {
m[`${keyName}.match.${group}`] = mi(
MIT.STRING,
groupValue,
+ `${keyName} Regex Match Group ${group}`,
`The matching named regex group name as defined in the match config (e.g.: \`${JSON.stringify(value)}\`).`,
)
})
@@ -102,6 +104,7 @@ export abstract class BaseProcessor {
m[matchedKey] = mi(
MIT.BOOLEAN,
matchesAll,
+ `${keyPrefix} Regex Matches`,
"The overall matching result for all conditions in the match config.",
)
}
@@ -192,7 +195,12 @@ export abstract class BaseProcessor {
}
ctx.meta = {
...ctx.meta,
- "context.type": newMetaInfo(MIT.STRING, ctx.type, "Context type"),
+ "context.type": newMetaInfo(
+ MIT.STRING,
+ ctx.type,
+ "Context Type",
+ "The type of context.",
+ ),
}
}
diff --git a/src/lib/processors/GmailProcessor.ts b/src/lib/processors/GmailProcessor.ts
index 65f80806..8d290eb3 100644
--- a/src/lib/processors/GmailProcessor.ts
+++ b/src/lib/processors/GmailProcessor.ts
@@ -51,6 +51,7 @@ export class GmailProcessor extends BaseProcessor {
"timer.startTime": mi(
MIT.DATE,
ctx.proc.timer.getStartTime(),
+ "Timer Start Time",
"The start timestamp of the processing script.",
),
}
@@ -59,6 +60,7 @@ export class GmailProcessor extends BaseProcessor {
(m[`variables.${entry.key}`] = mi(
MIT.VARIABLE,
entry.value,
+ `Variable ${entry.key}`,
"A custom defined variable.",
)),
)
diff --git a/src/lib/processors/MessageProcessor.ts b/src/lib/processors/MessageProcessor.ts
index 3d96bfa7..ade5c11f 100644
--- a/src/lib/processors/MessageProcessor.ts
+++ b/src/lib/processors/MessageProcessor.ts
@@ -179,6 +179,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.bcc`]: mi(
MIT.STRING,
(msg: Message) => msg.getBcc(),
+ "Message BCC",
this.getRefDocs(
keyPrefix,
"getBcc",
@@ -188,11 +189,13 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.body`]: mi(
MIT.STRING,
(msg: Message) => msg.getBody(),
+ "Message Body",
this.getRefDocs(keyPrefix, "getBody", "The body of the message."),
),
[`${keyPrefix}.cc`]: mi(
MIT.STRING,
(msg: Message) => msg.getCc(),
+ "Message CC",
this.getRefDocs(
keyPrefix,
"getCc",
@@ -202,6 +205,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.date`]: mi(
MIT.DATE,
(msg: Message) => msg.getDate(),
+ "Message Date",
this.getRefDocs(
keyPrefix,
"getDate",
@@ -211,11 +215,13 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.from`]: mi(
MIT.STRING,
(msg: Message) => msg.getFrom(),
+ "Sender",
this.getRefDocs(keyPrefix, "getFrom", "The sender of the message."),
),
"message.from.domain": mi(
MIT.STRING,
(msg: Message) => msg.getFrom().split("@")[1],
+ "Sender Domain",
this.getRefDocs(
keyPrefix,
"getFrom",
@@ -225,11 +231,13 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.id`]: mi(
MIT.STRING,
(msg: Message) => msg.getId(),
+ "Message ID",
this.getRefDocs(keyPrefix, "getId", "The ID of the message."),
),
[`${keyPrefix}.isDraft`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isDraft(),
+ "Draft Message",
this.getRefDocs(
keyPrefix,
"isDraft",
@@ -239,6 +247,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isInChats`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isInChats(),
+ "Chat Message",
this.getRefDocs(
keyPrefix,
"isInChats",
@@ -248,6 +257,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isInInbox`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isInInbox(),
+ "Inbox Message",
this.getRefDocs(
keyPrefix,
"isInInbox",
@@ -257,6 +267,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isInPriorityInbox`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isInPriorityInbox(),
+ "Priority Inbox Message",
this.getRefDocs(
keyPrefix,
"isInPriorityInbox",
@@ -266,6 +277,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isInTrash`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isInTrash(),
+ "Trash Message",
this.getRefDocs(
keyPrefix,
"isInTrash",
@@ -275,6 +287,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isStarred`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isStarred(),
+ "Starred Message",
this.getRefDocs(
keyPrefix,
"isStarred",
@@ -284,6 +297,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.isUnread`]: mi(
MIT.BOOLEAN,
(msg: Message) => msg.isUnread(),
+ "Unread Message",
this.getRefDocs(
keyPrefix,
"isUnread",
@@ -293,6 +307,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.plainBody`]: mi(
MIT.STRING,
(msg: Message) => msg.getPlainBody(),
+ "Message Plain Body",
this.getRefDocs(
keyPrefix,
"getPlainBody",
@@ -302,6 +317,7 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.replyTo`]: mi(
MIT.STRING,
(msg: Message) => msg.getReplyTo(),
+ "Message Reply To",
this.getRefDocs(
keyPrefix,
"getReplyTo",
@@ -311,11 +327,13 @@ export class MessageProcessor extends BaseProcessor {
[`${keyPrefix}.subject`]: mi(
MIT.STRING,
(msg: Message) => msg.getSubject(),
+ "Message Subject",
this.getRefDocs(keyPrefix, "getSubject", "The subject of the message."),
),
[`${keyPrefix}.to`]: mi(
MIT.STRING,
(msg: Message) => msg.getTo(),
+ "Message To",
this.getRefDocs(
keyPrefix,
"getTo",
@@ -326,16 +344,19 @@ export class MessageProcessor extends BaseProcessor {
MIT.STRING,
(msg: Message) =>
`https://mail.google.com/mail/u/0/#inbox/${msg.getId()}`,
+ "Message URL",
"The URL of the message.",
),
[`${keyPrefix}.index`]: mi(
MIT.NUMBER,
ctx.message.index,
+ "Message Index",
"The index number (0-based) of the message.",
),
"messageConfig.index": mi(
MIT.NUMBER,
ctx.message.configIndex,
+ "Message Config Index",
"The index number (0-based) of the message config.",
),
}
diff --git a/src/lib/processors/ThreadProcessor.ts b/src/lib/processors/ThreadProcessor.ts
index d2d485e1..aa0bae6f 100644
--- a/src/lib/processors/ThreadProcessor.ts
+++ b/src/lib/processors/ThreadProcessor.ts
@@ -102,6 +102,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.firstMessageSubject`]: mi(
MIT.STRING,
(t: Thread) => t.getFirstMessageSubject(),
+ "Thread Subject",
this.getRefDocs(
keyPrefix,
"getFirstMessageSubject",
@@ -111,6 +112,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.hasStarredMessages`]: mi(
MIT.BOOLEAN,
(t: Thread) => t.hasStarredMessages(),
+ "Starred Messages",
this.getRefDocs(
keyPrefix,
"hasStarredMessages",
@@ -120,11 +122,13 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.id`]: mi(
MIT.STRING,
(t: Thread) => t.getId(),
+ "Thread ID",
this.getRefDocs(keyPrefix, "getId", "The ID of the thread."),
),
[`${keyPrefix}.isImportant`]: mi(
MIT.STRING,
(t: Thread) => t.isImportant(),
+ "Important Thread",
this.getRefDocs(
keyPrefix,
"isImportant",
@@ -134,6 +138,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isInChats`]: mi(
MIT.STRING,
(t: Thread) => t.isInChats(),
+ "Chat Thread",
this.getRefDocs(
keyPrefix,
"isInChats",
@@ -143,6 +148,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isInInbox`]: mi(
MIT.STRING,
(t: Thread) => t.isInInbox(),
+ "Inbox Thread",
this.getRefDocs(
keyPrefix,
"isInInbox",
@@ -152,6 +158,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isInPriorityInbox`]: mi(
MIT.STRING,
(t: Thread) => t.isInPriorityInbox(),
+ "Priority Inbox Thread",
this.getRefDocs(
keyPrefix,
"isInPriorityInbox",
@@ -161,6 +168,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isInSpam`]: mi(
MIT.STRING,
(t: Thread) => t.isInSpam(),
+ "Spam Thread",
this.getRefDocs(
keyPrefix,
"isInSpam",
@@ -170,6 +178,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isInTrash`]: mi(
MIT.STRING,
(t: Thread) => t.isInTrash(),
+ "Trash Thread",
this.getRefDocs(
keyPrefix,
"isInTrash",
@@ -179,6 +188,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.isUnread`]: mi(
MIT.STRING,
(t: Thread) => t.isUnread(),
+ "Unread Thread",
this.getRefDocs(
keyPrefix,
"isUnread",
@@ -188,6 +198,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.labels`]: mi(
MIT.STRING,
(t: Thread) => t.getLabels().map((l) => l.getName()),
+ "Thread Labels",
this.getRefDocs(
keyPrefix,
"getLabels",
@@ -197,6 +208,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.lastMessageDate`]: mi(
MIT.DATE,
(t: Thread) => t.getLastMessageDate(),
+ "Thread Date",
this.getRefDocs(
keyPrefix,
"getLastMessageDate",
@@ -206,6 +218,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.messageCount`]: mi(
MIT.NUMBER,
(t: Thread) => t.getMessageCount(),
+ "Thread Message Count",
this.getRefDocs(
keyPrefix,
"getMessageCount",
@@ -215,6 +228,7 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.permalink`]: mi(
MIT.STRING,
(t: Thread) => t.getPermalink(),
+ "Thread Permalink",
this.getRefDocs(
keyPrefix,
"getPermalink",
@@ -224,16 +238,19 @@ export class ThreadProcessor extends BaseProcessor {
[`${keyPrefix}.index`]: mi(
MIT.NUMBER,
ctx.thread.index,
+ "Thread Index",
"The index number (0-based) of the thread.",
),
[`${keyPrefix}.url`]: mi(
MIT.STRING,
(t: Thread) => `https://mail.google.com/mail/u/0/#inbox/${t.getId()}`,
+ "Thread URL",
"The URL of the thread.",
),
"threadConfig.index": mi(
MIT.NUMBER,
ctx.thread.configIndex,
+ "Thread Config Index",
"The index number (0-based) of the thead config.",
),
}
diff --git a/src/test/docs/update-docs.spec.ts b/src/test/docs/update-docs.spec.ts
index c70c4dff..eba7cc61 100644
--- a/src/test/docs/update-docs.spec.ts
+++ b/src/test/docs/update-docs.spec.ts
@@ -46,7 +46,7 @@ function genMetaInfoDocs(contextType: PlaceholderContextType, m: MetaInfo, posit
if (idx < arr.length - 1) {
condComma = ","
}
- write(` {"key":"${k}", "type": "${m[k].type}", "scope": "${contextType}", "example": ${JSON.stringify(stringValue)}, "deprecated": ${!!deprInfo}, "deprecationInfo": ${JSON.stringify(deprInfo)}, "description": ${JSON.stringify(desc)}}${condComma}`)
+ write(` {"key":"${k}", "title":"${m[k].title}", "type": "${m[k].type}", "scope": "${contextType}", "example": ${JSON.stringify(stringValue)}, "deprecated": ${!!deprInfo}, "deprecationInfo": ${JSON.stringify(deprInfo)}, "description": ${JSON.stringify(desc)}}${condComma}`)
})
let suffix = ","
if (position === "last") {