Skip to content

Commit 077e5d2

Browse files
committed
chore: update docs + schema, cleanup + fixes
1 parent 9baf474 commit 077e5d2

File tree

13 files changed

+144
-18
lines changed

13 files changed

+144
-18
lines changed

docs/docs/community/CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,22 @@ npm run pre-commit
101101

102102
The recommended IDE for this project is [Visual Studio Code](https://code.visualstudio.com/), but any other IDEs with support for TypeScript and NPM will do. Make sure to configure the IDE to respect the [Code Style](#code-style) settings.
103103

104-
### Testing
104+
### Code Style
105+
106+
We use [Prettier](https://prettier.io/) to automatically format our code and ensure a consistent style. It is recommended to [configure your IDE](https://prettier.io/docs/en/editors) to format the code (e.g. on saving) using Prettier.
107+
108+
### Testing Locally
105109

106110
Please add/update the tests for any change to keep the codebase in a well-tested state. For every source file `*.ts` the corresponding test file is named `*.spec.ts` and they are implemented using [Jest](https://jestjs.io/) as the testing framework.
107111
Remote services are mocked (see [MockFactory.ts](https://github.com/ahochsteger/gmail-processor/blob/main/src/test/mocks/MockFactory.ts)) to simplify local testing in isolation.
108112

109113
After the changes and tests are done run the `pre-commit` script that validates the changes and updates all generated artifacts (like documentation, examples, JSON schema files, ...) and include all updated files in your commit.
110114

111-
### Code Style
115+
### Beta Testing on Google Apps Script
112116

113-
We use [Prettier](https://prettier.io/) to automatically format our code and ensure a consistent style. It is recommended to [configure your IDE](https://prettier.io/docs/en/editors) to format the code (e.g. on saving) using Prettier.
117+
Use the following Script ID in combination with the version `HEAD` to test and give feedback before changes are released:
118+
119+
`1yhOQyl_xWtnGJn_bzlL7oA4d_q5KoMyZyWIqXDJX1SY7bi22_lpjMiQK`
114120

115121
### Development Resources
116122

docs/docs/reference/actions.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ Store an attachment to a Google Drive location.
4242
| `location` | `string` | The location (path + filename) of the Google Drive file.<br />For shared folders or Team Drives prepend the location with the folder ID like `{id:<folderId>}/...`.<br />Supports [placeholder](placeholder.mdx) substitution. |
4343
| `toMimeType` | `string` | Convert to a Google file type using one of the <a href="https://developers.google.com/drive/api/guides/mime-types?hl=en">supported mime-types by Google Drive</a>, like:<br />* `application/vnd.google-apps.document`: Google Docs<br />* `application/vnd.google-apps.presentation`: Google Slides<br />* `application/vnd.google-apps.spreadsheet`: Google Sheets |
4444

45+
### `attachment.storeDecryptedPdf`
46+
47+
Decrypt a PDF attachment and store it to a Google Drive location.<br />NOTE: PDF decryption is done in an asynchronous process which causes<br />some limitations (failure detection, logs will appear later mixed with<br />other actions).
48+
49+
| Arguments | Type | Description |
50+
|-----------|------|-------------|
51+
| `conflictStrategy` | `ConflictStrategy` | The strategy to be used in case a file already exists at the desired location. See [Enum Type `ConflictStrategy`](enum-types.mdx#conflictstrategy) for valid values. |
52+
| `description` | `string` | The description to be attached to the Google Drive file.<br />Supports [placeholder](placeholder.mdx) substitution. |
53+
| `location` | `string` | The location (path + filename) of the Google Drive file.<br />For shared folders or Team Drives prepend the location with the folder ID like `{id:<folderId>}/...`.<br />Supports [placeholder](placeholder.mdx) substitution. |
54+
| `password` | `string` | The password to be used PDF decryption. |
55+
| `toMimeType` | `string` | Convert to a Google file type using one of the <a href="https://developers.google.com/drive/api/guides/mime-types?hl=en">supported mime-types by Google Drive</a>, like:<br />* `application/vnd.google-apps.document`: Google Docs<br />* `application/vnd.google-apps.presentation`: Google Slides<br />* `application/vnd.google-apps.spreadsheet`: Google Sheets |
56+
4557
## Global Actions
4658

4759
### `global.log`

docs/docs/reference/placeholder.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ These placeholder are valid globally and can also be used for internal purposes
1616
| <a id="placeholder.date.now">`date.now`</a> | Current Timestamp | The current timestamp. Use `"${<key>:date::<format>}"` 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"`). | `"2023-06-26 09:00:00"` |
1717
| <a id="placeholder.env.runMode">`env.runMode`</a> | Runmode | The runMode used for processing. | `"safe-mode"` |
1818
| <a id="placeholder.env.timezone">`env.timezone`</a> | Timezone | The timezone used for processing. | `"Etc/UTC"` |
19-
| <a id="placeholder.lib.description">`lib.description`</a> | Library Description | The description of the Gmail Processor library. | `""` |
20-
| <a id="placeholder.lib.name">`lib.name`</a> | Library Name | The name of the Gmail Processor library. | `"gmail-processor"` |
21-
| <a id="placeholder.lib.version">`lib.version`</a> | Library Version | The version of the Gmail Processor library. | `"0.0.0"` |
19+
| <a id="placeholder.lib.description">`lib.description`</a> | Library Description | The description of the Gmail Processor library. | `"__PACKAGE_DESCRIPTION__"` |
20+
| <a id="placeholder.lib.name">`lib.name`</a> | Library Name | The name of the Gmail Processor library. | `"__PACKAGE_NAME__"` |
21+
| <a id="placeholder.lib.version">`lib.version`</a> | Library Version | The version of the Gmail Processor library. | `"__PACKAGE_VERSION__"` |
2222
| <a id="placeholder.user.email">`user.email`</a> | User Email | The email address of the active user. | `"[email protected]"` |
2323

2424
## Processing Placeholder

global.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"@rollup/plugin-commonjs": "28.0.2",
104104
"@rollup/plugin-json": "6.1.0",
105105
"@rollup/plugin-node-resolve": "16.0.0",
106+
"@rollup/plugin-replace": "^6.0.2",
106107
"@rollup/plugin-terser": "0.4.4",
107108
"@rollup/plugin-typescript": "12.1.2",
108109
"@types/addressparser": "1.0.3",

rollup.config.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import { babel } from "@rollup/plugin-babel"
22
import commonjs from "@rollup/plugin-commonjs"
33
import json from "@rollup/plugin-json"
44
import resolve from "@rollup/plugin-node-resolve"
5+
import replace from "@rollup/plugin-replace"
56
import terser from "@rollup/plugin-terser"
67
import typescript from "@rollup/plugin-typescript"
8+
import fs from "fs"
79
import { defineConfig } from "rollup"
810
import analyzer from "rollup-plugin-analyzer"
911
import gas from "rollup-plugin-google-apps-script"
1012
import { visualizer } from "rollup-plugin-visualizer"
1113

14+
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
15+
1216
export default defineConfig({
1317
context: "globalThis",
1418
input: "./build/lib/index.js",
@@ -18,6 +22,14 @@ export default defineConfig({
1822
name: "GmailProcessorLib",
1923
},
2024
plugins: [
25+
replace({
26+
preventAssignment: true,
27+
values: {
28+
__PACKAGE_DESCRIPTION__: pkg.description,
29+
__PACKAGE_NAME__: pkg.name,
30+
__PACKAGE_VERSION__: pkg.version,
31+
},
32+
}),
2133
json(),
2234
resolve({
2335
//preferBuiltins: false,

scripts/update-examples.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ export EXAMPLE_SRC_BASEDIR="${EXAMPLE_SRC_BASEDIR:-src/examples}"
66
export GAS_EXAMPLES_BASEDIR="${GAS_EXAMPLES_BASEDIR:-src/gas/examples}"
77
export TEMPLATES_BASEDIR="${TEMPLATES_BASEDIR:-src/templates}"
88

9+
# Validate examples (e.g. no direct lib includes - causes docs build failure):
10+
echo "Checking for invalid lib includes ... "
11+
(
12+
find "${EXAMPLE_SRC_BASEDIR}" -type f -name '*.ts' \
13+
| grep -E -v '\.spec\.ts$' \
14+
| xargs grep -E 'from "../../lib"$'
15+
) && exit 1
16+
917
# Remove generated files (otherwise typedoc may fail):
1018
npx ts-node scripts/update-examples.ts clean
1119

src/examples/advanced/decryptPdf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ConflictStrategy } from "../../lib"
2-
import { ProcessingStatus } from "../../lib/Context"
1+
import { ConflictStrategy } from "../../lib/adapter/GDriveAdapter"
32
import { Config } from "../../lib/config/Config"
43
import { MarkProcessedMethod } from "../../lib/config/SettingsConfig"
4+
import { ProcessingStatus } from "../../lib/Context"
55
import { E2EInitConfig, E2ETest, E2ETestConfig } from "../../lib/e2e/E2E"
66
import { Example, ExampleCategory, ExampleInfo } from "../Example"
77
import { E2EDefaults } from "./../../lib/e2e/E2EDefaults"

src/lib/EnvProvider.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as packageInfo from "../../package.json"
21
import {
32
ContextType,
43
EnvContext,
@@ -32,19 +31,19 @@ export class EnvProvider {
3231
),
3332
"lib.description": mi(
3433
MIT.STRING,
35-
() => packageInfo.description,
34+
() => "__PACKAGE_DESCRIPTION__", // NOTE: Is replaced during build
3635
"Library Description",
3736
"The description of the Gmail Processor library.",
3837
),
3938
"lib.name": mi(
4039
MIT.STRING,
41-
() => packageInfo.name,
40+
() => "__PACKAGE_NAME__", // NOTE: Is replaced during build
4241
"Library Name",
4342
"The name of the Gmail Processor library.",
4443
),
4544
"lib.version": mi(
4645
MIT.STRING,
47-
() => packageInfo.version,
46+
() => "__PACKAGE_VERSION__", // NOTE: Is replaced during build
4847
"Library Version",
4948
"The version of the Gmail Processor library.",
5049
),

0 commit comments

Comments
 (0)