Skip to content

Commit

Permalink
Update deps. (#10)
Browse files Browse the repository at this point in the history
Update deps.
Update pdfjs and import.
Fix tests.
Add devcontainer.
Increment version.
  • Loading branch information
williamparry authored Dec 26, 2022
1 parent 17675d5 commit 418e73a
Show file tree
Hide file tree
Showing 8 changed files with 9,096 additions and 6,643 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-18"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"editor.minimap.enabled": false
}
15,676 changes: 9,053 additions & 6,623 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openlawnz/openlawnz-parsers",
"version": "1.0.1",
"version": "1.0.2",
"description": "OpenLaw NZ Parsers used to extract information from New Zealand case law PDF files.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -28,20 +28,20 @@
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"dependencies": {
"fuse.js": "^6.4.1",
"pdfjs-dist": "^2.4.456"
"fuse.js": "6.6.2",
"pdfjs-dist": "3.1.81"
},
"devDependencies": {
"@types/jest": "^26.0.13",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.4.2",
"prettier": "^2.1.1",
"ts-jest": "^26.3.0",
"typescript": "^4.0.2",
"@types/jest": "^29.2.4",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.3.1",
"prettier": "^2.8.1",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4",
"rimraf": "^3.0.2"
}
}
4 changes: 2 additions & 2 deletions src/convertPDFURL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ describe('convertPDFWithPDFJS', () => {
it('Throws an error when URL does not exist', async () => {
await expect(
convertPDFURLWithPDFJS(
'https://pdfs.openlaw.nz/jdo_1376398801000_4ffaed38-cd90-4488-a5da-8b1c61829c5ew.pdf',
'https://openlawnz-pdfs-prod.s3-ap-southeast-2.amazonaws.com/jdo_1376398801000_4ffaed38-cd90-4488-a5da-8b1c61829c5ew.pdf',
),
).rejects.toEqual(new Error('Invalid PDF structure.'));
});

it('Loads a PDF', async () => {
const pages = await convertPDFURLWithPDFJS(
'https://pdfs.openlaw.nz/jdo_1376398801000_4ffaed38-cd90-4488-a5da-8b1c61829c5e.pdf',
'https://openlawnz-pdfs-prod.s3-ap-southeast-2.amazonaws.com/jdo_1376398801000_4ffaed38-cd90-4488-a5da-8b1c61829c5e.pdf',
);
expect(pages.length).toBe(8);
});
Expand Down
4 changes: 2 additions & 2 deletions src/convertPDFURL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pdfjsLib from 'pdfjs-dist/es5/build/pdf.js';
import { getDocument } from 'pdfjs-dist';

export type PDFJSConversionPage = {
items: {
Expand All @@ -25,7 +25,7 @@ const convertPDFURLWithPDFJS = async (pdfURL: string): Promise<PDFJSConversionPa
}

const pages = [];
const loadingTask = pdfjsLib.getDocument(pdfURL);
const loadingTask = getDocument(pdfURL);
const doc = await loadingTask.promise;
const numPages = doc.numPages;

Expand Down
2 changes: 1 addition & 1 deletion src/getVersion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import getVersion from './getVersion';

describe('getVersion', () => {
it('Should return correct version', async () => {
expect(getVersion()).toBe('1.0.1');
expect(getVersion()).toBe('1.0.2');
});
});
2 changes: 1 addition & 1 deletion src/parseCaseCitations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Case Citations', () => {
it('Testing neutral citation regex - match on each type of neutral', () => {
const caseText = fs.readFileSync(`${__dirname}/testData/caseCitations/caseCitations.txt`).toString();

let neutralCitations = caseText.match(regNeutralCite);
let neutralCitations = caseText.match(regNeutralCite) || new Array<string>();
// remove errant line breaks
neutralCitations = neutralCitations.map((x) => {
return x.replace(/\n/g, ' ');
Expand Down

0 comments on commit 418e73a

Please sign in to comment.