Просмотр исходного кода

add pdf-converter-client package

Futa Arai 1 год назад
Родитель
Сommit
bf711c1a4c

+ 1 - 1
apps/app/package.json

@@ -83,7 +83,7 @@
     "@growi/remark-growi-directive": "workspace:^",
     "@growi/remark-lsx": "workspace:^",
     "@growi/slack": "workspace:^",
-    "@growi/pdf-converter": "workspace:^",
+    "@growi/pdf-converter-client": "workspace:^",
     "@keycloak/keycloak-admin-client": "^18.0.0",
     "@slack/web-api": "^6.2.4",
     "@slack/webhook": "^6.0.0",

+ 1 - 1
apps/app/src/features/page-bulk-export/server/service/page-bulk-export-job-cron/request-pdf-converter.ts

@@ -1,4 +1,4 @@
-import { PdfCtrlSyncJobStatus202Status, PdfCtrlSyncJobStatusBodyStatus, pdfCtrlSyncJobStatus } from '^/../pdf-converter/dist/client-library';
+import { PdfCtrlSyncJobStatus202Status, PdfCtrlSyncJobStatusBodyStatus, pdfCtrlSyncJobStatus } from '@growi/pdf-converter-client';
 
 import { configManager } from '~/server/service/config-manager';
 

+ 1 - 0
packages/pdf-converter-client/.gitignore

@@ -0,0 +1 @@
+dist/

+ 6 - 0
packages/pdf-converter-client/orval.config.js

@@ -0,0 +1,6 @@
+module.exports = {
+  'client-library': {
+    input: '../../apps/pdf-converter/specs/v3/docs/swagger.yaml',
+    output: './src/index.ts',
+  },
+};

+ 16 - 0
packages/pdf-converter-client/package.json

@@ -0,0 +1,16 @@
+{
+  "name": "@growi/pdf-converter-client",
+  "version": "1.0.0",
+  "main": "dist/index.js",
+  "types": "dist/index.d.ts",
+  "license": "MIT",
+  "private": true,
+  "scripts": {
+    "lint": "pnpm eslint **/*.{js,ts}",
+    "gen:client-code": "orval",
+    "build": "pnpm gen:client-code && tsc -p tsconfig.json"
+  },
+  "devDependencies": {
+    "orval": "=7.2.0"
+  }
+}

+ 96 - 0
packages/pdf-converter-client/src/index.ts

@@ -0,0 +1,96 @@
+/**
+ * Generated by orval v7.2.0 🍺
+ * Do not edit manually.
+ * Api documentation
+ * OpenAPI spec version: 1.0.0
+ */
+import axios from 'axios'
+import type {
+  AxiosRequestConfig,
+  AxiosResponse
+} from 'axios'
+export type PdfCtrlSyncJobStatus202Status = typeof PdfCtrlSyncJobStatus202Status[keyof typeof PdfCtrlSyncJobStatus202Status];
+
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const PdfCtrlSyncJobStatus202Status = {
+  HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
+  HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',
+  FAILED: 'FAILED',
+  PDF_EXPORT_DONE: 'PDF_EXPORT_DONE',
+} as const;
+
+export type PdfCtrlSyncJobStatus202 = {
+  status: PdfCtrlSyncJobStatus202Status;
+};
+
+export type PdfCtrlSyncJobStatusBodyStatus = typeof PdfCtrlSyncJobStatusBodyStatus[keyof typeof PdfCtrlSyncJobStatusBodyStatus];
+
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const PdfCtrlSyncJobStatusBodyStatus = {
+  HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
+  HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',
+  FAILED: 'FAILED',
+} as const;
+
+export type PdfCtrlSyncJobStatusBody = {
+  expirationDate?: string;
+  jobId?: string;
+  status?: PdfCtrlSyncJobStatusBodyStatus;
+};
+
+export interface GenericError {
+  /**
+   * An error message
+   * @minLength 1
+   */
+  message: string;
+  /**
+   * The error name
+   * @minLength 1
+   */
+  name: string;
+  [key: string]: unknown;
+ }
+
+export interface InternalServerError {
+  /** A list of related errors */
+  errors?: GenericError[];
+  /**
+   * An error message
+   * @minLength 1
+   */
+  message: string;
+  /**
+   * The error name
+   * @minLength 1
+   */
+  name: string;
+  /** The stack trace (only in development mode) */
+  stack?: string;
+  /** The status code of the exception */
+  status: number;
+}
+
+
+
+
+
+  /**
+ * 
+    Sync job pdf convert status with GROWI.
+    Register or update job inside pdf-converter with given jobId, expirationDate, and status.
+    Return resulting status of job to GROWI.
+  
+ */
+export const pdfCtrlSyncJobStatus = <TData = AxiosResponse<PdfCtrlSyncJobStatus202>>(
+    pdfCtrlSyncJobStatusBody?: PdfCtrlSyncJobStatusBody, options?: AxiosRequestConfig
+ ): Promise<TData> => {
+    return axios.post(
+      `/pdf/sync-job`,
+      pdfCtrlSyncJobStatusBody,options
+    );
+  }
+
+export type PdfCtrlSyncJobStatusResult = AxiosResponse<PdfCtrlSyncJobStatus202>

+ 11 - 0
packages/pdf-converter-client/tsconfig.json

@@ -0,0 +1,11 @@
+{
+  "extends": "../../tsconfig.base.json",
+  "compilerOptions": {
+    "baseUrl": ".",
+    "outDir": "dist",
+    "declaration": true,
+    "rootDir": "src",
+    "noEmit": false
+  },
+  "include": ["./src/**/*"]
+}

+ 12 - 14
pnpm-lock.yaml

@@ -231,9 +231,9 @@ importers:
       '@growi/core':
         specifier: workspace:^
         version: link:../../packages/core
-      '@growi/pdf-converter':
+      '@growi/pdf-converter-client':
         specifier: workspace:^
-        version: link:../pdf-converter
+        version: link:../../packages/pdf-converter-client
       '@growi/pluginkit':
         specifier: workspace:^
         version: link:../../packages/pluginkit
@@ -1312,6 +1312,12 @@ importers:
         specifier: ^13.6.19
         version: 13.6.19
 
+  packages/pdf-converter-client:
+    devDependencies:
+      orval:
+        specifier: '=7.2.0'
+        version: 7.2.0(encoding@0.1.13)(openapi-types@12.1.3)(typescript@5.4.2)
+
   packages/pluginkit:
     dependencies:
       '@growi/core':
@@ -11569,9 +11575,6 @@ packages:
   remark-stringify@9.0.1:
     resolution: {integrity: sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==}
 
-  remark-toc@9.0.0:
-    resolution: {integrity: sha512-KJ9txbo33GjDAV1baHFze7ij4G8c7SGYoY8Kzsm2gzFpbhL/bSoVpMMzGa3vrNDSWASNd/3ppAqL7cP2zD6JIA==}
-
   remark@13.0.0:
     resolution: {integrity: sha512-HDz1+IKGtOyWN+QgBiAT0kn+2s6ovOxHyPAFGKVE81VSzJ+mq7RwHFledEvB5F1p4iJvOah/LOKdFuzvRnNLCA==}
 
@@ -21446,7 +21449,7 @@ snapshots:
       eslint: 8.41.0
       eslint-import-resolver-node: 0.3.6
       eslint-import-resolver-typescript: 2.7.1(eslint-plugin-import@2.26.0)(eslint@8.41.0)
-      eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-typescript@2.7.1)(eslint@8.41.0)
+      eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-typescript@2.7.1(eslint-plugin-import@2.26.0)(eslint@8.41.0))(eslint@8.41.0)
       eslint-plugin-jsx-a11y: 6.5.1(eslint@8.41.0)
       eslint-plugin-react: 7.30.1(eslint@8.41.0)
       eslint-plugin-react-hooks: 4.6.0(eslint@8.41.0)
@@ -21506,7 +21509,7 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  eslint-module-utils@2.7.3(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-node@0.3.6)(eslint-import-resolver-typescript@2.7.1):
+  eslint-module-utils@2.7.3(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-node@0.3.6)(eslint-import-resolver-typescript@2.7.1(eslint-plugin-import@2.26.0)(eslint@8.41.0)):
     dependencies:
       debug: 3.2.7
       find-up: 2.1.0
@@ -21528,7 +21531,7 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  eslint-plugin-import@2.26.0(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-typescript@2.7.1)(eslint@8.41.0):
+  eslint-plugin-import@2.26.0(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-typescript@2.7.1(eslint-plugin-import@2.26.0)(eslint@8.41.0))(eslint@8.41.0):
     dependencies:
       array-includes: 3.1.5
       array.prototype.flat: 1.3.2
@@ -21536,7 +21539,7 @@ snapshots:
       doctrine: 2.1.0
       eslint: 8.41.0
       eslint-import-resolver-node: 0.3.6
-      eslint-module-utils: 2.7.3(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-node@0.3.6)(eslint-import-resolver-typescript@2.7.1)
+      eslint-module-utils: 2.7.3(@typescript-eslint/parser@5.59.7(eslint@8.41.0)(typescript@5.0.4))(eslint-import-resolver-node@0.3.6)(eslint-import-resolver-typescript@2.7.1(eslint-plugin-import@2.26.0)(eslint@8.41.0))
       has: 1.0.3
       is-core-module: 2.15.1
       is-glob: 4.0.3
@@ -26699,11 +26702,6 @@ snapshots:
     dependencies:
       mdast-util-to-markdown: 0.6.5
 
-  remark-toc@9.0.0:
-    dependencies:
-      '@types/mdast': 4.0.4
-      mdast-util-toc: 7.1.0
-
   remark@13.0.0:
     dependencies:
       remark-parse: 9.0.0