fix: use fork of joi with full features on browser

This commit is contained in:
sbplat 2024-02-05 12:15:01 -05:00
parent 829127c3f8
commit e7b4c93481
9 changed files with 43 additions and 10 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ node_modules/
dist/ dist/
android/ android/
ios/ ios/
releases/ releases/
.vscode/

View File

@ -17,9 +17,9 @@ function Dynamic() {
const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>; const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>;
LoadingModule.then((Module) => { LoadingModule.then((Module) => {
const Operator = Module[capitalizeFirstLetter(selectedValue)]; const Operator = Module[capitalizeFirstLetter(selectedValue)];
const description = Operator.schema.describe(); // TODO: The browser build of joi does not include describe. const description = Operator.schema.describe();
console.log(description); console.log("abc", description);
// TODO: use description to generate fields // TODO: use description to generate fields
}); });
}); });

29
package-lock.json generated
View File

@ -10,6 +10,9 @@
"server-node", "server-node",
"shared-operations" "shared-operations"
], ],
"dependencies": {
"@stirling-tools/joi": "github:Stirling-Tools/joi"
},
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.17.0", "@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0", "@typescript-eslint/parser": "^6.17.0",
@ -1924,6 +1927,32 @@
"resolved": "shared-operations", "resolved": "shared-operations",
"link": true "link": true
}, },
"node_modules/@stirling-tools/joi": {
"version": "17.12.0",
"resolved": "git+ssh://git@github.com/Stirling-Tools/joi.git#f2994904b4716082ac74449cfa1f1574616c5883",
"license": "BSD-3-Clause",
"dependencies": {
"@hapi/address": "^5.1.1",
"@hapi/formula": "^3.0.2",
"@hapi/hoek": "^11.0.2",
"@hapi/pinpoint": "^2.0.1",
"@hapi/tlds": "^1.0.2",
"@hapi/topo": "^6.0.2"
}
},
"node_modules/@stirling-tools/joi/node_modules/@hapi/hoek": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-11.0.4.tgz",
"integrity": "sha512-PnsP5d4q7289pS2T2EgGz147BFJ2Jpb4yrEdkpz2IhgEUzos1S7HTl7ezWh1yfYzYlj89KzLdCRkqsP6SIryeQ=="
},
"node_modules/@stirling-tools/joi/node_modules/@hapi/topo": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-6.0.2.tgz",
"integrity": "sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg==",
"dependencies": {
"@hapi/hoek": "^11.0.2"
}
},
"node_modules/@swc/core": { "node_modules/@swc/core": {
"version": "1.3.102", "version": "1.3.102",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.102.tgz", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.102.tgz",

View File

@ -21,5 +21,8 @@
"engines": { "engines": {
"npm": ">=7.24.2" "npm": ">=7.24.2"
}, },
"engineStrict": true "engineStrict": true,
"dependencies": {
"@stirling-tools/joi": "github:Stirling-Tools/joi"
}
} }

View File

@ -4,7 +4,7 @@ import { Operator, Progress, oneToOne } from ".";
import * as pdfcpuWrapper from "#pdfcpu"; // This is updated by tsconfig.json/paths for the context (browser, node, etc.) this module is used in. import * as pdfcpuWrapper from "#pdfcpu"; // This is updated by tsconfig.json/paths for the context (browser, node, etc.) this module is used in.
import Joi from "joi"; import Joi from "@stirling-tools/joi";
import { JoiPDFFileSchema } from "../wrappers/PdfFileJoi"; import { JoiPDFFileSchema } from "../wrappers/PdfFileJoi";
import i18next from "i18next"; import i18next from "i18next";

View File

@ -1,5 +1,5 @@
import { Action } from "../../declarations/Action"; import { Action } from "../../declarations/Action";
import Joi from "joi"; import Joi from "@stirling-tools/joi";
export interface ValidationResult { export interface ValidationResult {
valid: boolean, valid: boolean,

View File

@ -1,5 +1,5 @@
import Joi from "joi"; import Joi from "@stirling-tools/joi";
import { PDFPage } from "pdf-lib"; import { PDFPage } from "pdf-lib";
import { PdfFile, RepresentationType, JoiPDFFileSchema } from "../wrappers/PdfFileJoi"; import { PdfFile, RepresentationType, JoiPDFFileSchema } from "../wrappers/PdfFileJoi";

View File

@ -1,7 +1,7 @@
import * as PDFJS from "pdfjs-dist"; import * as PDFJS from "pdfjs-dist";
import type { PDFDocumentProxy as PDFJSDocument } from "pdfjs-dist/types/src/display/api"; import type { PDFDocumentProxy as PDFJSDocument } from "pdfjs-dist/types/src/display/api";
import { PDFDocument as PDFLibDocument } from "pdf-lib"; import { PDFDocument as PDFLibDocument } from "pdf-lib";
import Joi from "joi"; import Joi from "@stirling-tools/joi";
export enum RepresentationType { export enum RepresentationType {
Uint8Array, Uint8Array,

View File

@ -1,4 +1,4 @@
import Joi from "joi"; import Joi from "@stirling-tools/joi";
import { PdfFile } from "./PdfFile"; import { PdfFile } from "./PdfFile";
export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- also handles single files */ | PdfFile[] | PdfFile, helpers) => { export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- also handles single files */ | PdfFile[] | PdfFile, helpers) => {