@drdoc-com/pi-drdoc 1.0.3 → 1.0.5

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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Pi Plugin for Dr.DOC DMS
1
+ # Pi Package for Dr.DOC® ECM/DMS
2
2
 
3
- An integration plugin Package for the **Pi Agent** (`pi.dev`) ecosystem to interact seamlessly with the [**Dr.DOC Document Management System** \(DMS/ECM\)](https://drdoc.com/node/de/products/web).
3
+ An integration package/plugin/extension for the **Pi Agent** (`pi.dev`) ecosystem to interact seamlessly with the [**Dr.DOC® Document Management System** \(ECM/DMS\)](https://drdoc.com/node/de/products/web).
4
4
 
5
- This plugin allows the Pi Agent to query Dr.DOC archives, fetch document blobs, store files locally, generate direct web links, and display inline document previews.
5
+ This extension package allows the Pi Agent to query Dr.DOC archives, fetch document blobs, store files locally, generate direct web links, and display inline document previews.
6
6
 
7
7
  ---
8
8
 
@@ -11,14 +11,18 @@ This plugin allows the Pi Agent to query Dr.DOC archives, fetch document blobs,
11
11
  The integration between Pi Agent and Dr.DOC is split into two primary operational directions:
12
12
 
13
13
  ### 1. Pi → Dr.DOC (This Plugin)
14
- This plugin enables the **Pi Agent** to make outgoing API calls to **Dr.DOC**. The agent uses these tool functions to search archives, retrieve documents, save them locally, and process binary/image data.
14
+ *This* plugin enables the **Pi Agent** to make outgoing API calls to **Dr.DOC**. The agent uses these tool functions to search archives, retrieve documents, save them locally, and process binary/image data.
15
+
16
+ * **GitHub Repository:** [github.com/drdoc-com/pi-drdoc](https://github.com/drdoc-com/pi-drdoc)
17
+ * **npm Package:** [npmjs.com/package/@drdoc-com/pi-drdoc](https://www.npmjs.com/package/@drdoc-com/pi-drdoc)
18
+ * **Pi Package Registry:** [pi.dev/packages/@drdoc-com/pi-drdoc](https://pi.dev/packages/@drdoc-com/pi-drdoc)
15
19
 
16
20
  ### 2. Dr.DOC → Pi (OpenAI API Wrapper)
17
21
  To allow **Dr.DOC** (or external tools) to send requests to Pi using the standard OpenAI API format, the `@drdoc-com/pi-openai-api-wrapper` package can be used.
18
22
 
19
23
  * **GitHub Repository:** [github.com/drdoc-com/pi-openai-api-wrapper](https://github.com/drdoc-com/pi-openai-api-wrapper)
20
- * **Pi Package Registry:** [pi.dev/packages/@drdoc-com/pi-openai-api-wrapper](https://pi.dev/packages/@drdoc-com/pi-openai-api-wrapper)
21
24
  * **npm Package:** [npmjs.com/package/@drdoc-com/pi-openai-api-wrapper](https://www.npmjs.com/package/@drdoc-com/pi-openai-api-wrapper)
25
+ * **Pi Package Registry:** [pi.dev/packages/@drdoc-com/pi-openai-api-wrapper](https://pi.dev/packages/@drdoc-com/pi-openai-api-wrapper)
22
26
 
23
27
  ---
24
28
 
@@ -74,7 +78,7 @@ Suche im Dr.DOC Archiv "rec" alle Rechnungen von Firma Amazon aus diesem Jahr.
74
78
 
75
79
  ## Configuration
76
80
 
77
- The plugin utilizes configuration options supplied by the Dr.DOC client or environment variables.
81
+ The extension package utilizes configuration options supplied by the Dr.DOC client or environment variables.
78
82
 
79
83
  ### Environment Variables
80
84
 
@@ -83,8 +87,10 @@ The plugin utilizes configuration options supplied by the Dr.DOC client or envir
83
87
  | `DRDOC_BASE_URL` | Base URL of the Dr.DOC instance | `https://drdoc.com` |
84
88
  | `DRDOC_CONFIG_DIR` (alt. `PI_CONFIG_DIR`) | Custom directory for config files | `~/.pi/agent` |
85
89
  | `DRDOC_DOWNLOAD_DIR` | Custom directory for downloaded files | `~/.drdoc/downloads` |
86
- | `DRDOC_IGNORE_SSL` | Ignore TLS/SSL Errors (Set `NODE_TLS_REJECT_UNAUTHORIZED=0`) | `` |
87
- | `DRDOC_DEBUG` | Enable Debugging | `` |
90
+ | `DRDOC_IGNORE_SSL` | Ignore TLS/SSL Errors (Set `NODE_TLS_REJECT_UNAUTHORIZED=0`) | |
91
+ | `DRDOC_AI_FS_<ArchiveName>` | Dr.DOC *Archive specific* (upper-case) IMPORT_ASCII FieldSelection Name for Field Descriptions. | `DRDOC_AI_FS` |
92
+ | `DRDOC_AI_FS` | Dr.DOC IMPORT_ASCII FieldSelection Name for Field Descriptions. | `STD_AI_INVOICE_IN`, `DD_FIELD_DESC`, `STD_FIELD_DESC` |
93
+ | `DRDOC_DEBUG` | Enable Debugging | |
88
94
 
89
95
  ---
90
96
 
@@ -99,7 +105,8 @@ The plugin utilizes configuration options supplied by the Dr.DOC client or envir
99
105
  ## License
100
106
 
101
107
  This project is licensed under the Apache License 2.0.
102
- Dr.DOC DMS is licensed is under proprietary License.
108
+
109
+ Dr.DOC® ECM/DMS is licensed is under proprietary License.
103
110
 
104
111
  ---
105
112
 
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@drdoc-com/pi-drdoc",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Dr.DOC DMS Integration Package for PI Agent",
5
5
  "type": "module",
6
6
  "license": "Apache License 2.0",
7
7
  "keywords": [
8
8
  "pi-package",
9
9
  "pi-agent",
10
- "drdoc",
11
10
  "rest-api",
12
11
  "skill",
13
- "dms",
14
- "Dr.DOC"
12
+ "drdoc",
13
+ "Dr.DOC",
14
+ "dms"
15
15
  ],
16
16
  "private": false,
17
17
  "pi": {
@@ -31,7 +31,7 @@
31
31
  "author": "Dr.DOC GmbH, DE-80802 Munich",
32
32
  "devDependencies": {
33
33
  "typescript": "^7.0.2",
34
- "@types/node": "^26.2.0"
34
+ "@types/node": "^24.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@earendil-works/pi-coding-agent": "*"
@@ -163,7 +163,8 @@ export class DrDocClient {
163
163
  try {
164
164
  const dataToSave = JSON.stringify(this.config, null, 2);
165
165
  fs.writeFileSync(this.storageFilePath, dataToSave, "utf-8");
166
- msgLog('DD Anmeldedaten wurden gespeichert unter: ', this.storageFilePath);
166
+ if (process.env.DRDOC_DEBUG)
167
+ msgLog('Dr.DOC Anmeldedaten wurden gespeichert unter: ', this.storageFilePath);
167
168
  } catch (error) {
168
169
  throw new Error(`Fehler beim Speichern der Anmeldedaten: ${error instanceof Error ? error.message : String(error)}`);
169
170
  }
@@ -192,8 +193,11 @@ export class DrDocClient {
192
193
  if (setCookie) {
193
194
  const match = setCookie.match(/uid=([^;]+)/);
194
195
  if (match) {
196
+ const oldCookieValue = this.config.sessionCookie;
195
197
  this.config.sessionCookie = `uid=${match[1]}`;
196
- // this.saveCredentials(this.config);
198
+ // bei Cookie Änderung, Cookie uid explizit abspeichern
199
+ if (oldCookieValue != this.config.sessionCookie)
200
+ this.saveCredentials();
197
201
  }
198
202
  }
199
203
  }
@@ -330,11 +334,13 @@ export class DrDocClient {
330
334
  // Dauerhaftes Speichern der gesamten DrDocConfig nach erfolgreichem Login
331
335
  this.saveCredentials();
332
336
 
333
- msgLog('DD: Sign in OK:', this.config);
337
+ if (process.env.DRDOC_DEBUG)
338
+ msgLog('DD: Sign in OK: ', JSON.stringify(this.config));
334
339
  }
335
340
  else {
336
-
337
- console.warn('DD: Sign in ERR:', this.config);
341
+ //if (process.env.DRDOC_DEBUG)
342
+ if (process.env.DRDOC_DEBUG)
343
+ msgLog('DD: Sign in ERROR: ' + JSON.stringify(this.config));
338
344
  }
339
345
 
340
346
  return response;
@@ -349,11 +355,14 @@ export class DrDocClient {
349
355
 
350
356
  // Überprüfung auf erfolgreiche Anmeldung
351
357
  if (response && !response.HasError) {
352
- msgLog('DD: State OK:', this.config);
358
+ if (process.env.DRDOC_DEBUG)
359
+ msgLog('Dr.DOC: State OK:', this.config);
353
360
  return true;
354
361
  }
355
362
  else {
356
- msgError('DD: State ERR:', this.config);
363
+ msgError('Bitte erneut anmelden mit Slash Command `/drdoc_login`');
364
+ if (process.env.DRDOC_DEBUG)
365
+ msgLog('Dr.DOC: State ERROR: ' + JSON.stringify(this.config));
357
366
  return false;
358
367
  }
359
368
  }
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ export default function (pi: any): void {
17
17
 
18
18
  // Login
19
19
  pi.registerCommand("drdoc_login", {
20
- description: "Benutzer anmelden in Dr.DOC über die REST API und speichert die Session.",
20
+ description: "Benutzer anmelden in Dr.DOC über die REST API und speichert die Session: `/drdoc_login <baseUrl> <username> <password> <totp> <ignoreSSL:1,0>`",
21
21
  handler: async (args: string, ctx: any) => {
22
22
  // Entfernen leerer Strings nach dem String-Split
23
23
  const parts = args.trim().split(/\s+/); //.filter(Boolean);
@@ -34,18 +34,18 @@ export default function (pi: any): void {
34
34
  try {
35
35
  //initializeDrDocClient({ baseUrl, username, password, totp, ignoreSSL });
36
36
  //const client = new DrDocClient({ baseUrl, username, password, totp, ignoreSSL });
37
- const client = await getClient({ baseUrl, username, password, totp, ignoreSSL: (ignoreSSL == '1' || ignoreSSL == 'true') });
37
+ const client = await getClient({ baseUrl, username, password, totp, ignoreSSL: (ignoreSSL == '1' || ignoreSSL == 'true') }, true);
38
38
  if (process.env.DRDOC_DEBUG)
39
39
  msgLog('Client: ', client);
40
40
 
41
- const response = await client.signin(username, password, totp);
41
+ /*const response = await client.signin(username, password, totp);
42
42
 
43
43
  if (response.HasError) {
44
44
  msgError(`Anmeldung fehlgeschlagen: ${response.Error?.Message}`);
45
45
  return;
46
46
  }
47
47
 
48
- msgInfo("Erfolgreich an Dr.DOC angemeldet. Die Session ist aktiv.");
48
+ msgInfo("Erfolgreich an Dr.DOC angemeldet. Die Session ist aktiv.");*/
49
49
  } catch (err: any) {
50
50
  msgError(`Fehler bei der Verbindung: ${err.message}`);
51
51
  }
package/src/tools.ts CHANGED
@@ -11,13 +11,27 @@ let clientInstance: DrDocClient | null = null;
11
11
  */
12
12
  export async function getClient(config: DrDocConfig = {} as DrDocConfig, force: Boolean = false): Promise<DrDocClient> {
13
13
  if (!clientInstance || force) {
14
- msgInfo('getClient: init instance');
14
+ if (process.env.DRDOC_DEBUG)
15
+ msgInfo('getClient: init instance');
15
16
  clientInstance = new DrDocClient(config);
17
+
16
18
  // Verbindung testen
17
- if (await clientInstance.state())
18
- msgInfo('getClient: state ok');
19
+ if (await clientInstance.state()) {
20
+ msgInfo('Bereits in Dr.DOC angemeldet. Die Session ist aktiv.');
21
+ }
19
22
  else {
20
- throw new Error("getClient: DrDocClient ist nicht initialisiert. Bitte vorher den Befehl /drdoc_login ausführen.");
23
+ const response = await clientInstance.signin(config.username, config.password, config.totp);
24
+ if (response.HasError)
25
+ throw new Error("getClient: DrDocClient ist nicht initialisiert. Bitte vorher den Befehl /drdoc_login ausführen.");
26
+
27
+ msgInfo("Erfolgreich an Dr.DOC angemeldet. Die Session ist aktiv.");
28
+
29
+ // Verbindung testen
30
+ /*if (await clientInstance.state())
31
+ msgInfo('getClient: state ok');
32
+ else {
33
+
34
+ }*/
21
35
  }
22
36
  }
23
37
  return clientInstance;
@@ -138,8 +152,10 @@ export const drdocTools = [
138
152
  if (process.env.DRDOC_DEBUG)
139
153
  msgLog('drdoc_properties_fields:', args);
140
154
  return safeExecuteClient(["archive"], args, async (client, safeArgs) => {
141
- const defNameArray = ['STD_AI_INVOICE_IN', 'DD_FIELD_DESC', 'STD_FIELD_DESC'];
155
+ const defNameArray = [process.env['DRDOC_AI_FS_' + safeArgs.archive.toUpperCase()], process.env.DRDOC_AI_FS, 'STD_AI_INVOICE_IN', 'DD_FIELD_DESC', 'STD_FIELD_DESC'];
142
156
  for (let defName of defNameArray) {
157
+ if (!defName)
158
+ continue;
143
159
  const fs = await client.getFieldSelection(safeArgs.archive, "IMPORT_ASCII", defName);
144
160
  if (process.env.DRDOC_DEBUG)
145
161
  msgLog('props:', fs);
@@ -170,29 +186,31 @@ Suchoperatoren:
170
186
  - ! als logischer NOT Operator als Prefix, muss dem Suchbegriff vorangestellt werden.
171
187
  - !* für leere Felder
172
188
  - <-> für Datumsbereich, Zeitraum, Bereichssuche, Zahlenbereich; A<->B von A bis einschließlich B; Format für Datumsbereich: DD.MM.YYYY<->DD.MM.YYYY z.B. 01.07.2024<->31.07.2024.
173
- Beispiele für Suchoperatoren:
174
- - *TEXT* für trunkierte/Substring Suche nach TEXT (Feldwert enthält TEXT), MUSS zwingend bei unklaren/ungenauen/unspezifischen Eingaben verwendet werden!
175
- - !*TEXT* für Feldwert enthält TEXT nicht
176
- - !* für leeren, nicht gefüllte Feldwerte
177
- - !TEXT für alle Feldwerte, abgesehen von TEXT bzw. alles bis auf TEXT.
178
- - !A&B für exakte Suche nach B jedoch ohne A
179
- - "A|B" (Pippe) für exakte Suche nach A oder B
180
- - !*A*&*B* für Suche nach enthält (Substring) B aber enthält kein A
181
- - 01.01.2020<->31.12.2020 für Datumssuchbereichs-Suche (Bereichssuche) vom 01.01.2020 bis einschließlich 31.12.2020 (1 Jahr)
182
- - 01.07.2024<->31.07.2024 für Datumssuchbereichs-Suche (Bereichssuche) vom 01.07.2024 bis einschließlich 31.07.2024 für den Monat Juli 2024 (1 Monat)
183
189
  Datumsformat: DD.MM.YYYY
184
190
  Zahlenformat: 0.00
185
191
  Variablen:
186
- - %DY% Variable für Datumsbereich im aktuellen/diesen Jahr
187
- - %DMY% Variable für Datumsbereich im aktuellen/diesen Monat
188
- - %DWY% Variable für Datumsbereich in der aktuellen/diesen Woche (7 Tage)
192
+ - %DY% Variable für Datumsbereich im *aktuellen Jahr*
193
+ - %DMY% Variable für Datumsbereich im *aktuellen Monat*
194
+ - %DWY% Variable für Datumsbereich in der *aktuellen Woche* (7 Tage)
189
195
  - %B% Variable für angemeldeten Benutzer
190
196
  - %D% Variable für aktuelles Datum (heutiger Tag)
191
197
  - %D-1% Variable für gestriges Datum bzw. gestern
192
198
  - %D-2% Variable für vorgestern
193
199
  - %D+1% Variable für morgiges Datum bzw. morgen
194
200
  - %D+2% Variable für übermorgen
195
- Beispiel: Filter für alle Eingangsrechnungen im Zeitraum Juli 2024 (01.07.2024 bis einschließlich 31.07.2024) von Firma Amazon:
201
+ Beispiele:
202
+ - *TEXT* für trunkierte/Substring Suche nach TEXT (Feldwert enthält TEXT), MUSS zwingend bei unklaren/ungenauen/unspezifischen Eingaben verwendet werden!
203
+ - !*TEXT* für Feldwert enthält TEXT nicht
204
+ - !* für leeren, nicht gefüllte Feldwerte
205
+ - !TEXT für alle Feldwerte, abgesehen von TEXT bzw. alles bis auf TEXT.
206
+ - !A&B für exakte Suche nach B jedoch ohne A
207
+ - "A|B" (Pippe) für exakte Suche nach A oder B
208
+ - !*A*&*B* für Suche nach enthält (Substring) B aber enthält kein A
209
+ - 01.01.2020<->31.12.2020 für Datumssuchbereichs-Suche (Bereichssuche) vom 01.01.2020 bis einschließlich 31.12.2020 (1 Jahr)
210
+ - 01.07.2024<->31.07.2024 für Datumssuchbereichs-Suche (Bereichssuche) vom 01.07.2024 bis einschließlich 31.07.2024 für den Monat Juli 2024 (1 Monat)
211
+ - %DY% für Datumssuchbereichs-Suche (Bereichssuche) im aktuellen Jahr, z.B. vom 01.01.2020 bis einschließlich 31.12.2020 (1 Jahr)
212
+ - %DMY% für Datumssuchbereichs-Suche (Bereichssuche) im aktuellen Monat, z.B. vom 01.01.2020 bis einschließlich 31.01.2020 (1 Monat)
213
+ Text-Beispiel: Filter für alle Eingangsrechnungen im Zeitraum Juli 2024 (01.07.2024 bis einschließlich 31.07.2024) von Firma Amazon:
196
214
  { date: "01.07.2024<->31.07.2024", c_company: "*Amazon*", inout: "0", type: "Rechnung" }
197
215
  `,
198
216
  parameters: {
@@ -404,4 +422,4 @@ Datumsformat: DD.MM.YYYY
404
422
  });
405
423
  },
406
424
  },
407
- ];
425
+ ];