pdfdancer-client-typescript 1.0.13 → 1.0.14
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 +10 -6
- package/dist/__tests__/e2e/test-helpers.d.ts.map +1 -1
- package/dist/__tests__/e2e/test-helpers.js +8 -3
- package/dist/__tests__/e2e/test-helpers.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +18 -15
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +21 -18
- package/dist/models.js.map +1 -1
- package/dist/pdfdancer_v1.d.ts +2 -1
- package/dist/pdfdancer_v1.d.ts.map +1 -1
- package/dist/pdfdancer_v1.js +66 -23
- package/dist/pdfdancer_v1.js.map +1 -1
- package/docs/openapi.yml +637 -73
- package/jest.config.js +1 -1
- package/package.json +1 -1
- package/src/__tests__/e2e/image-showcase.test.ts +6 -6
- package/src/__tests__/e2e/image.test.ts +5 -5
- package/src/__tests__/e2e/line-showcase.test.ts +6 -6
- package/src/__tests__/e2e/page-showcase.test.ts +12 -12
- package/src/__tests__/e2e/page.test.ts +3 -3
- package/src/__tests__/e2e/path.test.ts +4 -4
- package/src/__tests__/e2e/snapshot-showcase.test.ts +10 -10
- package/src/__tests__/e2e/snapshot.test.ts +18 -18
- package/src/__tests__/e2e/test-helpers.ts +8 -3
- package/src/__tests__/e2e/token_from_env.test.ts +0 -14
- package/src/index.ts +3 -1
- package/src/models.ts +21 -17
- package/src/pdfdancer_v1.ts +80 -31
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {PDFAssertions} from './pdf-assertions';
|
|
|
6
6
|
describe('Image E2E Tests (Showcase)', () => {
|
|
7
7
|
test('find images', async () => {
|
|
8
8
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
9
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
9
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
10
10
|
|
|
11
11
|
const images = await pdf.selectImages();
|
|
12
12
|
expect(images.length).toBe(12);
|
|
@@ -18,7 +18,7 @@ describe('Image E2E Tests (Showcase)', () => {
|
|
|
18
18
|
|
|
19
19
|
test('delete all images', async () => {
|
|
20
20
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
21
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
21
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
22
22
|
|
|
23
23
|
const images = await pdf.selectImages();
|
|
24
24
|
expect(images.length).toBe(12);
|
|
@@ -36,7 +36,7 @@ describe('Image E2E Tests (Showcase)', () => {
|
|
|
36
36
|
|
|
37
37
|
test('move image', async () => {
|
|
38
38
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
39
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
39
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
40
40
|
|
|
41
41
|
const images = await pdf.selectImages();
|
|
42
42
|
const image = images[10];
|
|
@@ -61,7 +61,7 @@ describe('Image E2E Tests (Showcase)', () => {
|
|
|
61
61
|
|
|
62
62
|
test('find image by position', async () => {
|
|
63
63
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
64
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
64
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
65
65
|
|
|
66
66
|
const none = await pdf.page(5).selectImagesAt(0, 0);
|
|
67
67
|
expect(none.length).toBe(0);
|
|
@@ -73,7 +73,7 @@ describe('Image E2E Tests (Showcase)', () => {
|
|
|
73
73
|
|
|
74
74
|
test('add image via document builder', async () => {
|
|
75
75
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
76
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
76
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
77
77
|
|
|
78
78
|
expect(await pdf.selectImages()).toHaveLength(12);
|
|
79
79
|
expect(await pdf.page(6).selectImages()).toHaveLength(1);
|
|
@@ -103,7 +103,7 @@ describe('Image E2E Tests (Showcase)', () => {
|
|
|
103
103
|
|
|
104
104
|
test('add image via page builder', async () => {
|
|
105
105
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
106
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
106
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
107
107
|
|
|
108
108
|
expect(await pdf.selectImages()).toHaveLength(12);
|
|
109
109
|
expect(await pdf.page(6).selectImages()).toHaveLength(1);
|
|
@@ -12,7 +12,7 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
12
12
|
|
|
13
13
|
test('find images', async () => {
|
|
14
14
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
15
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
15
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
16
16
|
|
|
17
17
|
const images = await pdf.selectImages();
|
|
18
18
|
expect(images).toHaveLength(3);
|
|
@@ -24,7 +24,7 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
24
24
|
|
|
25
25
|
test('delete images', async () => {
|
|
26
26
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
27
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
27
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
28
28
|
|
|
29
29
|
const images = await pdf.selectImages();
|
|
30
30
|
expect(images).toHaveLength(3);
|
|
@@ -50,7 +50,7 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
50
50
|
|
|
51
51
|
test('move image', async () => {
|
|
52
52
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
53
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
53
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
54
54
|
|
|
55
55
|
const images = await pdf.selectImages();
|
|
56
56
|
const image = images[2];
|
|
@@ -79,7 +79,7 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
79
79
|
|
|
80
80
|
test('find image by position', async () => {
|
|
81
81
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
82
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
82
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
83
83
|
|
|
84
84
|
const none = await pdf.page(11).selectImagesAt(0, 0);
|
|
85
85
|
expect(none).toHaveLength(0);
|
|
@@ -91,7 +91,7 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
91
91
|
|
|
92
92
|
test('add image', async () => {
|
|
93
93
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
94
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
94
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
95
95
|
|
|
96
96
|
const before = await pdf.selectImages();
|
|
97
97
|
expect(before).toHaveLength(3);
|
|
@@ -7,7 +7,7 @@ const SAMPLE_PARAGRAPH = 'This is regular Sans text showing alignment and styles
|
|
|
7
7
|
describe('Text Line E2E Tests (Showcase)', () => {
|
|
8
8
|
test('find lines by position multi', async () => {
|
|
9
9
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
10
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
10
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
11
11
|
|
|
12
12
|
for (let i = 0; i < 10; i++) {
|
|
13
13
|
const lines = await pdf.selectTextLines();
|
|
@@ -22,7 +22,7 @@ describe('Text Line E2E Tests (Showcase)', () => {
|
|
|
22
22
|
|
|
23
23
|
test('find lines by position', async () => {
|
|
24
24
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
25
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
25
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
26
26
|
|
|
27
27
|
const lines = await pdf.selectTextLines();
|
|
28
28
|
expect(lines.length).toBe(36);
|
|
@@ -45,7 +45,7 @@ describe('Text Line E2E Tests (Showcase)', () => {
|
|
|
45
45
|
|
|
46
46
|
test('find lines by text', async () => {
|
|
47
47
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
48
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
48
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
49
49
|
|
|
50
50
|
const lines = await pdf.page(0).selectTextLinesStartingWith(SAMPLE_PARAGRAPH);
|
|
51
51
|
expect(lines.length).toBe(1);
|
|
@@ -58,7 +58,7 @@ describe('Text Line E2E Tests (Showcase)', () => {
|
|
|
58
58
|
|
|
59
59
|
test('delete line', async () => {
|
|
60
60
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
61
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
61
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
62
62
|
|
|
63
63
|
const [line] = await pdf.page(0).selectTextLinesStartingWith(SAMPLE_PARAGRAPH);
|
|
64
64
|
await line.delete();
|
|
@@ -72,7 +72,7 @@ describe('Text Line E2E Tests (Showcase)', () => {
|
|
|
72
72
|
|
|
73
73
|
test('move line', async () => {
|
|
74
74
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
75
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
75
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
76
76
|
|
|
77
77
|
const [line] = await pdf.page(0).selectTextLinesStartingWith(SAMPLE_PARAGRAPH);
|
|
78
78
|
const pos = line.position;
|
|
@@ -94,7 +94,7 @@ describe('Text Line E2E Tests (Showcase)', () => {
|
|
|
94
94
|
|
|
95
95
|
test('modify line', async () => {
|
|
96
96
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
97
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
97
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
98
98
|
|
|
99
99
|
const [line] = await pdf.page(0).selectTextLinesStartingWith(SAMPLE_PARAGRAPH);
|
|
100
100
|
await line.edit().text(' replaced ').apply();
|
|
@@ -5,7 +5,7 @@ import {PDFAssertions} from './pdf-assertions';
|
|
|
5
5
|
describe('Page E2E Tests (Showcase)', () => {
|
|
6
6
|
test('get all elements', async () => {
|
|
7
7
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
8
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
8
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
9
9
|
|
|
10
10
|
const elements = await pdf.selectElements();
|
|
11
11
|
expect(elements.length).toBe(99);
|
|
@@ -20,7 +20,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
20
20
|
|
|
21
21
|
test('get pages', async () => {
|
|
22
22
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
23
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
23
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
24
24
|
|
|
25
25
|
const pages = await pdf.pages();
|
|
26
26
|
expect(pages).toBeDefined();
|
|
@@ -30,7 +30,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
30
30
|
|
|
31
31
|
test('get page', async () => {
|
|
32
32
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
33
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
33
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
34
34
|
|
|
35
35
|
const page = pdf.page(2);
|
|
36
36
|
expect(page).toBeDefined();
|
|
@@ -40,7 +40,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
40
40
|
|
|
41
41
|
test('delete page', async () => {
|
|
42
42
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
43
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
43
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
44
44
|
|
|
45
45
|
const page3 = pdf.page(3);
|
|
46
46
|
await page3.delete();
|
|
@@ -54,7 +54,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
54
54
|
|
|
55
55
|
test('move page', async () => {
|
|
56
56
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
57
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
57
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
58
58
|
|
|
59
59
|
const pagesBefore = await pdf.pages();
|
|
60
60
|
expect(pagesBefore.length).toBe(7);
|
|
@@ -68,7 +68,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
68
68
|
|
|
69
69
|
test('add page', async () => {
|
|
70
70
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
71
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
71
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
72
72
|
|
|
73
73
|
const pagesBefore = await pdf.pages();
|
|
74
74
|
expect(pagesBefore.length).toBe(7);
|
|
@@ -83,7 +83,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
83
83
|
|
|
84
84
|
test('add page with builder default', async () => {
|
|
85
85
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
86
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
86
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
87
87
|
|
|
88
88
|
expect((await pdf.pages()).length).toBe(7);
|
|
89
89
|
|
|
@@ -94,7 +94,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
94
94
|
|
|
95
95
|
test('add page with builder A4 portrait', async () => {
|
|
96
96
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
97
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
97
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
98
98
|
|
|
99
99
|
expect((await pdf.pages()).length).toBe(7);
|
|
100
100
|
|
|
@@ -105,7 +105,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
105
105
|
|
|
106
106
|
test('add page with builder letter landscape', async () => {
|
|
107
107
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
108
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
108
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
109
109
|
|
|
110
110
|
expect((await pdf.pages()).length).toBe(7);
|
|
111
111
|
|
|
@@ -116,7 +116,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
116
116
|
|
|
117
117
|
test('add page with builder at index', async () => {
|
|
118
118
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
119
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
119
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
120
120
|
|
|
121
121
|
expect((await pdf.pages()).length).toBe(7);
|
|
122
122
|
|
|
@@ -132,7 +132,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
132
132
|
|
|
133
133
|
test('add page with builder custom size', async () => {
|
|
134
134
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
135
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
135
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
136
136
|
|
|
137
137
|
expect((await pdf.pages()).length).toBe(7);
|
|
138
138
|
|
|
@@ -143,7 +143,7 @@ describe('Page E2E Tests (Showcase)', () => {
|
|
|
143
143
|
|
|
144
144
|
test('add page with builder all options', async () => {
|
|
145
145
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
146
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
146
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
147
147
|
|
|
148
148
|
expect((await pdf.pages()).length).toBe(7);
|
|
149
149
|
|
|
@@ -11,7 +11,7 @@ describe('Page E2E Tests', () => {
|
|
|
11
11
|
|
|
12
12
|
test('get pages', async () => {
|
|
13
13
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
14
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
14
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
15
15
|
|
|
16
16
|
const pages = await client.pages();
|
|
17
17
|
expect(pages).toBeDefined();
|
|
@@ -21,7 +21,7 @@ describe('Page E2E Tests', () => {
|
|
|
21
21
|
|
|
22
22
|
test('get page', async () => {
|
|
23
23
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
24
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
24
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
25
25
|
|
|
26
26
|
const page = client.page(2);
|
|
27
27
|
expect(page).toBeDefined();
|
|
@@ -31,7 +31,7 @@ describe('Page E2E Tests', () => {
|
|
|
31
31
|
|
|
32
32
|
test('delete page', async () => {
|
|
33
33
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
34
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
34
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
35
35
|
|
|
36
36
|
expect(await client.pages()).toHaveLength(12);
|
|
37
37
|
const page3 = client.page(3);
|
|
@@ -10,7 +10,7 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
10
10
|
|
|
11
11
|
test('select paths', async () => {
|
|
12
12
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('basic-paths.pdf');
|
|
13
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
13
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
14
14
|
|
|
15
15
|
const paths = await pdf.selectPaths();
|
|
16
16
|
expect(paths).toHaveLength(9);
|
|
@@ -25,7 +25,7 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
25
25
|
|
|
26
26
|
test('select paths by position', async () => {
|
|
27
27
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('basic-paths.pdf');
|
|
28
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
28
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
29
29
|
|
|
30
30
|
const paths = await pdf.page(0).selectPathsAt(80, 720);
|
|
31
31
|
expect(paths).toHaveLength(1);
|
|
@@ -34,7 +34,7 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
34
34
|
|
|
35
35
|
test('delete path', async () => {
|
|
36
36
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('basic-paths.pdf');
|
|
37
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
37
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
38
38
|
|
|
39
39
|
let paths = await pdf.page(0).selectPathsAt(80, 720);
|
|
40
40
|
expect(paths).toHaveLength(1);
|
|
@@ -56,7 +56,7 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
56
56
|
|
|
57
57
|
test('move path', async () => {
|
|
58
58
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('basic-paths.pdf');
|
|
59
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
59
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
60
60
|
|
|
61
61
|
const [path] = await pdf.page(0).selectPathsAt(80, 720);
|
|
62
62
|
const pos = path.position;
|
|
@@ -4,7 +4,7 @@ import {requireEnvAndFixture} from './test-helpers';
|
|
|
4
4
|
describe('Snapshot E2E Tests (Showcase)', () => {
|
|
5
5
|
test('page snapshot matches select paragraphs', async () => {
|
|
6
6
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
7
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
7
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
8
8
|
|
|
9
9
|
const snapshot = await pdf.getPageSnapshot(0);
|
|
10
10
|
const snapshotParagraphs = snapshot.elements.filter(e => e.type === ObjectType.PARAGRAPH);
|
|
@@ -18,7 +18,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
18
18
|
|
|
19
19
|
test('page snapshot matches select images', async () => {
|
|
20
20
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
21
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
21
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
22
22
|
|
|
23
23
|
const snapshot = await pdf.getPageSnapshot(0);
|
|
24
24
|
const snapshotImages = snapshot.elements.filter(e => e.type === ObjectType.IMAGE);
|
|
@@ -34,7 +34,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
34
34
|
|
|
35
35
|
test('page snapshot matches select forms', async () => {
|
|
36
36
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
37
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
37
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
38
38
|
|
|
39
39
|
const snapshot = await pdf.getPageSnapshot(0);
|
|
40
40
|
const snapshotForms = snapshot.elements.filter(e => e.type === ObjectType.FORM_X_OBJECT);
|
|
@@ -50,7 +50,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
50
50
|
|
|
51
51
|
test('page snapshot matches select form fields', async () => {
|
|
52
52
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
53
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
53
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
54
54
|
|
|
55
55
|
const snapshot = await pdf.getPageSnapshot(0);
|
|
56
56
|
const snapshotFields = snapshot.elements.filter(e => [
|
|
@@ -71,7 +71,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
71
71
|
|
|
72
72
|
test('page snapshot contains all element types', async () => {
|
|
73
73
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
74
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
74
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
75
75
|
|
|
76
76
|
const snapshot = await pdf.getPageSnapshot(0);
|
|
77
77
|
const paragraphCount = snapshot.elements.filter(e => e.type === ObjectType.PARAGRAPH).length;
|
|
@@ -87,7 +87,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
87
87
|
|
|
88
88
|
test('document snapshot matches all pages', async () => {
|
|
89
89
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
90
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
90
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
91
91
|
|
|
92
92
|
const docSnapshot = await pdf.getDocumentSnapshot();
|
|
93
93
|
for (let i = 0; i < docSnapshot.pageCount; i++) {
|
|
@@ -103,7 +103,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
103
103
|
|
|
104
104
|
test('type filter matches select method', async () => {
|
|
105
105
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
106
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
106
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
107
107
|
|
|
108
108
|
const snapshot = await pdf.getPageSnapshot(0, [ObjectType.PARAGRAPH]);
|
|
109
109
|
const selected = await pdf.page(0).selectParagraphs();
|
|
@@ -118,7 +118,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
118
118
|
|
|
119
119
|
test('multiple type filters combined', async () => {
|
|
120
120
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
121
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
121
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
122
122
|
|
|
123
123
|
const snapshot = await pdf.getPageSnapshot(0, [ObjectType.PARAGRAPH, ObjectType.TEXT_LINE]);
|
|
124
124
|
expect(snapshot.elements.every(e => e.type === ObjectType.PARAGRAPH || e.type === ObjectType.TEXT_LINE)).toBe(true);
|
|
@@ -130,7 +130,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
130
130
|
|
|
131
131
|
test('total element count matches expected', async () => {
|
|
132
132
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
133
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
133
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
134
134
|
|
|
135
135
|
const elements = await pdf.selectElements();
|
|
136
136
|
expect(elements.length).toBe(99);
|
|
@@ -143,7 +143,7 @@ describe('Snapshot E2E Tests (Showcase)', () => {
|
|
|
143
143
|
|
|
144
144
|
test('snapshot consistency across multiple pages', async () => {
|
|
145
145
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Showcase.pdf');
|
|
146
|
-
const pdf = await PDFDancer.open(pdfData, token, baseUrl
|
|
146
|
+
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
147
147
|
|
|
148
148
|
const docSnapshot = await pdf.getDocumentSnapshot();
|
|
149
149
|
expect(docSnapshot.pageCount).toBeGreaterThan(1);
|
|
@@ -9,7 +9,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
9
9
|
|
|
10
10
|
test('get document snapshot', async () => {
|
|
11
11
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
12
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
12
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
13
13
|
|
|
14
14
|
const snapshot = await client.getDocumentSnapshot();
|
|
15
15
|
|
|
@@ -42,7 +42,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
42
42
|
|
|
43
43
|
test('get document snapshot with type filter', async () => {
|
|
44
44
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
45
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
45
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
46
46
|
|
|
47
47
|
// Get snapshot filtered by paragraphs only
|
|
48
48
|
const snapshot = await client.getDocumentSnapshot([ObjectType.PARAGRAPH]);
|
|
@@ -59,7 +59,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
59
59
|
|
|
60
60
|
test('get document snapshot with multiple type filters', async () => {
|
|
61
61
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
62
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
62
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
63
63
|
|
|
64
64
|
// Get snapshot filtered by paragraphs and images
|
|
65
65
|
const snapshot = await client.getDocumentSnapshot([ObjectType.PARAGRAPH, ObjectType.IMAGE]);
|
|
@@ -75,7 +75,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
75
75
|
|
|
76
76
|
test('get page snapshot', async () => {
|
|
77
77
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
78
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
78
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
79
79
|
|
|
80
80
|
const pageSnapshot = await client.getPageSnapshot(0);
|
|
81
81
|
|
|
@@ -103,7 +103,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
103
103
|
|
|
104
104
|
test('get page snapshot with type filter', async () => {
|
|
105
105
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
106
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
106
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
107
107
|
|
|
108
108
|
// Get page snapshot filtered by images only
|
|
109
109
|
const pageSnapshot = await client.getPageSnapshot(0, [ObjectType.IMAGE]);
|
|
@@ -118,7 +118,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
118
118
|
|
|
119
119
|
test('get page snapshot via PageClient', async () => {
|
|
120
120
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
121
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
121
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
122
122
|
|
|
123
123
|
const page = client.page(1);
|
|
124
124
|
const pageSnapshot = await page.getSnapshot();
|
|
@@ -132,7 +132,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
132
132
|
|
|
133
133
|
test('get page snapshot via PageClient with type filter', async () => {
|
|
134
134
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
135
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
135
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
136
136
|
|
|
137
137
|
const page = client.page(0);
|
|
138
138
|
const pageSnapshot = await page.getSnapshot([ObjectType.PARAGRAPH]);
|
|
@@ -147,7 +147,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
147
147
|
|
|
148
148
|
test('DocumentSnapshot helper methods', async () => {
|
|
149
149
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
150
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
150
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
151
151
|
|
|
152
152
|
const snapshot = await client.getDocumentSnapshot();
|
|
153
153
|
|
|
@@ -179,7 +179,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
179
179
|
|
|
180
180
|
test('PageSnapshot helper methods', async () => {
|
|
181
181
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
182
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
182
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
183
183
|
|
|
184
184
|
const pageSnapshot = await client.getPageSnapshot(0);
|
|
185
185
|
|
|
@@ -200,7 +200,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
200
200
|
|
|
201
201
|
test('snapshot with form fields', async () => {
|
|
202
202
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('mixed-form-types.pdf');
|
|
203
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
203
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
204
204
|
|
|
205
205
|
// Form fields can be TEXT_FIELD, CHECKBOX, or RADIO_BUTTON
|
|
206
206
|
const snapshot = await client.getDocumentSnapshot([
|
|
@@ -224,7 +224,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
224
224
|
|
|
225
225
|
test('snapshot with paths', async () => {
|
|
226
226
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('basic-paths.pdf');
|
|
227
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
227
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
228
228
|
|
|
229
229
|
const snapshot = await client.getDocumentSnapshot([ObjectType.PATH]);
|
|
230
230
|
|
|
@@ -242,7 +242,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
242
242
|
|
|
243
243
|
test('compare snapshot with individual find operations', async () => {
|
|
244
244
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
245
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
245
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
246
246
|
|
|
247
247
|
// Get snapshot
|
|
248
248
|
const snapshot = await client.getPageSnapshot(0);
|
|
@@ -258,7 +258,7 @@ describe('Snapshot E2E Tests', () => {
|
|
|
258
258
|
|
|
259
259
|
test('snapshot fonts information', async () => {
|
|
260
260
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('ObviouslyAwesome.pdf');
|
|
261
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
261
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
262
262
|
|
|
263
263
|
const snapshot = await client.getDocumentSnapshot();
|
|
264
264
|
|
|
@@ -269,16 +269,17 @@ describe('Snapshot E2E Tests', () => {
|
|
|
269
269
|
// If there are fonts, verify their structure
|
|
270
270
|
if (snapshot.fonts.length > 0) {
|
|
271
271
|
for (const font of snapshot.fonts) {
|
|
272
|
-
expect(font.
|
|
273
|
-
expect(font.
|
|
274
|
-
expect(typeof font.
|
|
272
|
+
expect(font.documentFontName).toBeDefined();
|
|
273
|
+
expect(font.systemFontName).toBeDefined();
|
|
274
|
+
expect(typeof font.documentFontName).toBe('string');
|
|
275
|
+
expect(typeof font.systemFontName).toBe('string');
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
});
|
|
278
279
|
|
|
279
280
|
test('snapshot on empty page', async () => {
|
|
280
281
|
const [baseUrl, token, pdfData] = await requireEnvAndFixture('Empty.pdf');
|
|
281
|
-
const client = await PDFDancer.open(pdfData, token, baseUrl
|
|
282
|
+
const client = await PDFDancer.open(pdfData, token, baseUrl);
|
|
282
283
|
|
|
283
284
|
const snapshot = await client.getDocumentSnapshot();
|
|
284
285
|
|
|
@@ -293,4 +294,3 @@ describe('Snapshot E2E Tests', () => {
|
|
|
293
294
|
expect(Array.isArray(page0Snapshot!.elements)).toBe(true);
|
|
294
295
|
});
|
|
295
296
|
});
|
|
296
|
-
|
|
@@ -42,11 +42,16 @@ export function readToken(): string | null {
|
|
|
42
42
|
export async function serverUp(baseUrl: string): Promise<boolean> {
|
|
43
43
|
try {
|
|
44
44
|
const response = await fetch(`${baseUrl}/ping`, {
|
|
45
|
-
signal: AbortSignal.timeout(
|
|
45
|
+
signal: AbortSignal.timeout(60000)
|
|
46
46
|
});
|
|
47
47
|
const text = await response.text();
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let pongReceived = response.status === 200 && text.includes('Pong');
|
|
49
|
+
if (!pongReceived) {
|
|
50
|
+
console.error(`Server did not respond with Pong. Response: ${text}, status ${response.status}`);
|
|
51
|
+
}
|
|
52
|
+
return pongReceived;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("Server down", e)
|
|
50
55
|
return false;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
@@ -43,20 +43,6 @@ describe('Env Token E2E Tests', () => {
|
|
|
43
43
|
restoreEnv();
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
test('requires token from env or argument', async () => {
|
|
47
|
-
delete process.env.PDFDANCER_TOKEN;
|
|
48
|
-
|
|
49
|
-
await expect(async () => {
|
|
50
|
-
try {
|
|
51
|
-
await PDFDancer.open(pdfData, undefined, baseUrl);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
expect(error).toBeInstanceOf(ValidationException);
|
|
54
|
-
expect((error as Error).message).toBe(MISSING_TOKEN_MESSAGE);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}).rejects.toThrow(MISSING_TOKEN_MESSAGE);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
46
|
test('opens with token from env', async () => {
|
|
61
47
|
process.env.PDFDANCER_TOKEN = validToken;
|
|
62
48
|
const client = await PDFDancer.open(pdfData, undefined, baseUrl);
|
package/src/index.ts
CHANGED
|
@@ -38,10 +38,12 @@ export {
|
|
|
38
38
|
Orientation,
|
|
39
39
|
CommandResult,
|
|
40
40
|
TextStatus,
|
|
41
|
-
|
|
41
|
+
DocumentFontInfo,
|
|
42
42
|
FontType,
|
|
43
43
|
DocumentSnapshot,
|
|
44
44
|
PageSnapshot
|
|
45
45
|
} from './models';
|
|
46
46
|
|
|
47
|
+
export { DocumentFontInfo as FontRecommendation } from './models';
|
|
48
|
+
|
|
47
49
|
export const VERSION = "1.0.0";
|