@evenicanpm/portal-dms-adapaters 1.4.0 → 1.6.0

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.
@@ -0,0 +1,2 @@
1
+ export * from "./paperless/client";
2
+ export * from "./paperless/config";
@@ -0,0 +1,108 @@
1
+ /**
2
+ *
3
+ * @module PaperlessProvider
4
+ * @category dms-provider
5
+ * Pure functions for extracting data from paperless-ngx
6
+ */
7
+ import type { TableViewParams } from "@evenicanpm/storefront-portal-types-schemas";
8
+ /**
9
+ * Paperless-Specific document config parameters.
10
+ */
11
+ export interface PaperlessDocConfig {
12
+ /** Paperless uses type for broad category of document */
13
+ type: string;
14
+ /** Paperless tags */
15
+ tags: string[];
16
+ /** Property names to map back from papaless to the UI */
17
+ paperlessToPortalMap: Record<string, string>;
18
+ }
19
+ /**
20
+ * Configuration for Paperless Client
21
+ */
22
+ export interface PaperlessClientConfig {
23
+ /** Credentials username */
24
+ username: string;
25
+ /** Credentials password */
26
+ password: string;
27
+ /** Base of paperless web-server */
28
+ baseUrl: string;
29
+ /** The endpoint prefix to fetch docs from paperless */
30
+ documentEndpoint: string;
31
+ tenantField: string;
32
+ customFieldsEndpoint: string;
33
+ }
34
+ /**
35
+ * Input for building a REST URL to fetch documents from Paperless
36
+ */
37
+ interface PaperlessUrlInput {
38
+ config: PaperlessClientConfig;
39
+ params: TableViewParams;
40
+ paperlessParams: PaperlessDocConfig;
41
+ /** Property name to filter by for multi-tenancy so customer only sees their own docs */
42
+ customerId: string;
43
+ canViewAll: boolean;
44
+ docId?: string;
45
+ }
46
+ /**
47
+ *
48
+ * Builds URL for fetching documents from Paperless.
49
+ * Takes credentials, parameters and document settings and Builds
50
+ * a fetch-ready URL.
51
+ *
52
+ * @param PaperlessAuth Credentials for paperless basic auth.
53
+ *
54
+ */
55
+ export declare const buildPaperlessRESTUrl: ({ config, params, paperlessParams, customerId, canViewAll, }: PaperlessUrlInput) => Request;
56
+ /**
57
+ * Builds a fetch-ready request for downloading a single document
58
+ * from Paperless.
59
+ *
60
+ * Uses Paperless basic authentication and the provided document ID
61
+ * to construct the download endpoint URL and required headers.
62
+ *
63
+ * @param input.config Paperless configuration containing base URL and credentials
64
+ * @param input.docId ID of the document to download
65
+ */
66
+ export declare const buildPaperlessDownloadRequest: (input: {
67
+ config: PaperlessClientConfig;
68
+ docId: string;
69
+ }) => Request;
70
+ export declare const buildCustomFieldsRequest: (input: {
71
+ config: PaperlessClientConfig;
72
+ }) => Request;
73
+ interface PaperlessResponse {
74
+ /** an array with all id's of docs */
75
+ all?: number[];
76
+ /** Property name from paperless */
77
+ results: PaperlessDoc[];
78
+ }
79
+ export type PaperlessCustomFieldEntry = {
80
+ field: number;
81
+ value: unknown;
82
+ name?: string;
83
+ };
84
+ export interface PaperlessDoc {
85
+ id: string | number;
86
+ title: string;
87
+ created_date: string;
88
+ document_type: string;
89
+ customer_id: string;
90
+ custom_fields: PaperlessCustomFieldEntry[];
91
+ }
92
+ export type CustomFieldsMap = Record<number, string>;
93
+ interface TransformPaperlessResponseInput {
94
+ paperlessResponse: PaperlessResponse;
95
+ customFieldsMap: Record<number, string>;
96
+ transformDoc: (data: PaperlessDoc, cfMap: Record<number, string>) => unknown;
97
+ }
98
+ /**
99
+ * TODO: CREATE ZOD SCHEMA FOR PAPERLESS RESPONSE
100
+ * TODO:
101
+ * @param
102
+ * @returns
103
+ */
104
+ export declare const transformPaperlessResponse: ({ paperlessResponse: { results, all }, customFieldsMap, transformDoc, }: TransformPaperlessResponseInput) => {
105
+ data: unknown[];
106
+ items: number;
107
+ };
108
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { PaperlessClientConfig } from "./client";
2
+ export declare const createPaperlessConfig: (input: {
3
+ username: string;
4
+ password: string;
5
+ baseUrl: string;
6
+ documentEndpoint?: string;
7
+ tenantField?: string;
8
+ customFieldsEndpoint?: string;
9
+ }) => PaperlessClientConfig;
10
+ export declare const createPaperlessAssets: (input?: {
11
+ logoUrl?: string;
12
+ }) => {
13
+ logoUrl: string;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evenicanpm/portal-dms-adapaters",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -13,6 +13,10 @@
13
13
  "exports": {
14
14
  ".": "./src/index.ts"
15
15
  },
16
+ "files": [
17
+ "dist",
18
+ "src"
19
+ ],
16
20
  "types": "./dist/index.d.ts",
17
21
  "devDependencies": {
18
22
  "@types/node": "^25.3.0",
@@ -22,5 +26,5 @@
22
26
  "@evenicanpm/storefront-portal-types-schemas": "*",
23
27
  "zod": "^3.0.0"
24
28
  },
25
- "gitHead": "0614726ec6b7ce9564706514a6b756b390a13e96"
29
+ "gitHead": "9b18fe6294cc0e57332ec8703825a609ac7b73b2"
26
30
  }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "moduleResolution": "bundler",
8
- "sourceMap": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "declaration": true,
12
- "preserveSymlinks": true,
13
- "resolveJsonModule": true,
14
- "isolatedModules": true,
15
- "emitDeclarationOnly": true,
16
- "jsx": "preserve",
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "allowJs": true,
22
- "forceConsistentCasingInFileNames": true,
23
- "incremental": true,
24
- "rootDir": "./src",
25
- "outDir": "./dist"
26
- },
27
- "include": ["src"]
28
- }