@awolve/myoffice 2.12.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,13 @@
3
3
  * for new mail, and a minimal single line for replies. `none` sends neither.
4
4
  */
5
5
  export type SignatureStyle = 'standard' | 'minimal' | 'none';
6
+ /**
7
+ * A signature has an HTML rendering and may have a plain-text one beside it
8
+ * (`signature.txt`, `signature-minimal.txt`). Only the HTML files are installed
9
+ * today; the text ones are read when present so a text/plain body never gets
10
+ * markup pasted into it (myoffice bug #2).
11
+ */
12
+ export type SignatureFormat = 'html' | 'text';
6
13
  export declare function isSignatureStyle(value: unknown): value is SignatureStyle;
7
14
  /**
8
15
  * Read a signature. Returns null when the style is `none` or the file has not
@@ -12,5 +19,11 @@ export declare function isSignatureStyle(value: unknown): value is SignatureStyl
12
19
  * A missing minimal signature falls back to the standard one rather than
13
20
  * sending nothing: an over-formal sign-off beats a reply that looks anonymous.
14
21
  */
15
- export declare function getSignature(style?: SignatureStyle): string | null;
22
+ export declare function getSignature(style?: SignatureStyle, format?: SignatureFormat): string | null;
23
+ /**
24
+ * Append the chosen signature to a body, or return the body untouched if there
25
+ * is none. A plain-text body only ever gets the plain-text rendering: when no
26
+ * `.txt` signature is installed, nothing is appended rather than the HTML one.
27
+ */
28
+ export declare function appendSignature(body: string, isHtml: boolean, style: SignatureStyle): string;
16
29
  //# sourceMappingURL=signature.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAO7D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,GAAE,cAA2B,GAAG,MAAM,GAAG,IAAI,CAa9E"}
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAa9C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,GAAE,cAA2B,EAClC,MAAM,GAAE,eAAwB,GAC/B,MAAM,GAAG,IAAI,CAcf;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAI5F"}
@@ -3,8 +3,14 @@ import { homedir } from 'os';
3
3
  import { join } from 'path';
4
4
  const CONFIG_DIR = join(homedir(), '.config', 'myoffice-mcp');
5
5
  const FILES = {
6
- standard: join(CONFIG_DIR, 'signature.html'),
7
- minimal: join(CONFIG_DIR, 'signature-minimal.html'),
6
+ html: {
7
+ standard: join(CONFIG_DIR, 'signature.html'),
8
+ minimal: join(CONFIG_DIR, 'signature-minimal.html'),
9
+ },
10
+ text: {
11
+ standard: join(CONFIG_DIR, 'signature.txt'),
12
+ minimal: join(CONFIG_DIR, 'signature-minimal.txt'),
13
+ },
8
14
  };
9
15
  export function isSignatureStyle(value) {
10
16
  return value === 'standard' || value === 'minimal' || value === 'none';
@@ -17,10 +23,11 @@ export function isSignatureStyle(value) {
17
23
  * A missing minimal signature falls back to the standard one rather than
18
24
  * sending nothing: an over-formal sign-off beats a reply that looks anonymous.
19
25
  */
20
- export function getSignature(style = 'standard') {
26
+ export function getSignature(style = 'standard', format = 'html') {
21
27
  if (style === 'none')
22
28
  return null;
23
- const candidates = style === 'minimal' ? [FILES.minimal, FILES.standard] : [FILES.standard];
29
+ const files = FILES[format];
30
+ const candidates = style === 'minimal' ? [files.minimal, files.standard] : [files.standard];
24
31
  for (const path of candidates) {
25
32
  try {
26
33
  if (!existsSync(path))
@@ -35,4 +42,15 @@ export function getSignature(style = 'standard') {
35
42
  }
36
43
  return null;
37
44
  }
45
+ /**
46
+ * Append the chosen signature to a body, or return the body untouched if there
47
+ * is none. A plain-text body only ever gets the plain-text rendering: when no
48
+ * `.txt` signature is installed, nothing is appended rather than the HTML one.
49
+ */
50
+ export function appendSignature(body, isHtml, style) {
51
+ const signature = getSignature(style, isHtml ? 'html' : 'text');
52
+ if (!signature)
53
+ return body;
54
+ return isHtml ? `${body}<br><br>${signature}` : `${body}\n\n--\n${signature}`;
55
+ }
38
56
  //# sourceMappingURL=signature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAQ9D,MAAM,KAAK,GAAoD;IAC7D,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAC5C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAAC;CACpD,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,QAAwB,UAAU;IAC7D,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;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version": "2.13.1",
4
4
  "description": "CLI for personal Microsoft 365 access - email, calendar, tasks, OneDrive, Teams, Planner",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "tsc",
15
+ "test": "node --import tsx --test tests/signature.test.ts",
15
16
  "prepublishOnly": "npm run build",
16
17
  "postinstall": "echo '\n✅ @awolve/myoffice installed!\n\nRun: myoffice --help\nOr: npx @awolve/myoffice --help\n'",
17
18
  "start": "node dist/cli.js",
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}