Skip to content

Commit

Permalink
File upload fixes (end-to-end) (#1706)
Browse files Browse the repository at this point in the history
* feat(backoffice-v2): added a cell for downloading files

* feat(backoffice-v2): extended the image viewer to allow downloading files

* fix(backoffice-v2): fixed wrong file location for download file svg

* refactor(backoffice-v2): removed DownloadFile from the cells map as its no longer a cell

* feat(backoffice-v2): provided fallback to image viewer item for download only files

* refactor(*): improved file upload handling by providing fallback to mime type and extension

* refactor(*): removed changes unrelated to pr

* fix(workflow-core): fixed error on trying to transform optional response and added a clearer error

* fix(*): re-introduced file type into the system - missing type broke the backoffice

* revert(common): removed unintended mime types from schema

* revert(workflows-service): removed unintended file type from filter

* refactor(*): made changes to address pr comments

* refactor(workflows-service): added missing pr comment change

* fix(workflows-service): fixed failing ci actions

* refactor(workflows-service): updated getMimeType

* fix(workflows-service): fixed file system upload flow failing to get mime type and extension

also removed null from mime type / file extension helpers

* feat(*): added logs as requested from pr comments

* chore(*): ran version-packages

* fix(*): fixed pnpm lockfile
  • Loading branch information
Omri-Levy authored Nov 30, 2023
1 parent 591c20a commit 483950b
Show file tree
Hide file tree
Showing 40 changed files with 396 additions and 79 deletions.
9 changes: 9 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @ballerine/backoffice-v2

## 0.5.30

### Patch Changes

- Updated dependencies [ea423a22]
- @ballerine/common@0.7.28
- @ballerine/workflow-browser-sdk@0.5.27
- @ballerine/workflow-node-sdk@0.5.27

## 0.5.29

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ballerine/backoffice-v2",
"version": "0.5.29",
"version": "0.5.30",
"description": "Ballerine - Backoffice",
"homepage": "https://github.com/ballerine-io/ballerine",
"repository": {
Expand Down Expand Up @@ -51,9 +51,9 @@
},
"dependencies": {
"@ballerine/ui": "0.3.16",
"@ballerine/common": "0.7.27",
"@ballerine/workflow-browser-sdk": "0.5.26",
"@ballerine/workflow-node-sdk": "0.5.26",
"@ballerine/common": "0.7.28",
"@ballerine/workflow-browser-sdk": "0.5.27",
"@ballerine/workflow-node-sdk": "0.5.27",
"@fontsource/inter": "^4.5.15",
"@formkit/auto-animate": "1.0.0-beta.5",
"@hookform/resolvers": "^3.1.0",
Expand Down
8 changes: 8 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# kyb-app

## 0.1.24

### Patch Changes

- Updated dependencies [ea423a22]
- @ballerine/common@0.7.28
- @ballerine/workflow-browser-sdk@0.5.27

## 0.1.23

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.1.23",
"version": "0.1.24",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -16,8 +16,8 @@
"dependencies": {
"@ballerine/blocks": "0.1.21",
"@ballerine/ui": "0.3.16",
"@ballerine/common": "^0.7.27",
"@ballerine/workflow-browser-sdk": "0.5.26",
"@ballerine/common": "^0.7.28",
"@ballerine/workflow-browser-sdk": "0.5.27",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
"@rjsf/core": "^5.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { HTTPError } from 'ky';
import get from 'lodash/get';
import set from 'lodash/set';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { getDocumentFileTypePath } from '@/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField/helpers/getDocumentFileTypePath';

interface DocumentFieldParams {
documentData: Partial<Document>;
Expand Down Expand Up @@ -94,13 +95,15 @@ export const DocumentField = (
}

const fileIdPath = getDocumentFileIdPath(definition);
const fileTypePath = getDocumentFileTypePath(definition);

try {
const uploadResult = await uploadFile({ file });

// @ts-ignore
set(document, fileIdPath, uploadResult.id);
// set(document, fileTypePath, file.type);
// @ts-ignore
set(document, fileTypePath, file.type);
set(document, 'decision', {});

stateApi.setContext(context);
Expand Down
8 changes: 8 additions & 0 deletions examples/headless-example/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ballerine/headless-example

## 0.1.27

### Patch Changes

- Updated dependencies [ea423a22]
- @ballerine/common@0.7.28
- @ballerine/workflow-browser-sdk@0.5.27

## 0.1.26

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions examples/headless-example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/headless-example",
"private": true,
"version": "0.1.26",
"version": "0.1.27",
"type": "module",
"scripts": {
"spellcheck": "cspell \"*\"",
Expand Down Expand Up @@ -34,8 +34,8 @@
"vite": "^4.1.0"
},
"dependencies": {
"@ballerine/common": "0.7.27",
"@ballerine/workflow-browser-sdk": "0.5.26",
"@ballerine/common": "0.7.28",
"@ballerine/workflow-browser-sdk": "0.5.27",
"@felte/reporter-svelte": "^1.1.5",
"@felte/validator-zod": "^1.0.13",
"@fontsource/inter": "^4.5.15",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/common

## 0.7.28

### Patch Changes

- ea423a22: updated validation to allow file type on document page

## 0.7.27

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"name": "@ballerine/common",
"author": "Ballerine <[email protected]>",
"version": "0.7.27",
"version": "0.7.28",
"description": "common",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down
21 changes: 20 additions & 1 deletion packages/common/src/schemas/documents/default-context-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,26 @@ export const defaultContextSchema = Type.Object({
version: Type.Optional(Type.Number()),
pages: Type.Array(
Type.Union([
Type.Object({ ballerineFileId: Type.String() }, { additionalProperties: false }),
Type.Object(
{
ballerineFileId: Type.String(),
type: Type.Optional(
Type.String({
enum: [
'application/pdf',
'image/png',
'image/jpg',
'image/jpeg',
// Backwards compatibility
'pdf',
'png',
'jpg',
],
}),
),
},
{ additionalProperties: false },
),
Type.Object(
{
ballerineFileId: Type.Optional(Type.String()),
Expand Down
8 changes: 8 additions & 0 deletions packages/workflow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ballerine/workflow-core

## 0.5.27

### Patch Changes

- 85d24981: fixed error on trying to transform optional response and added a clearer error message
- Updated dependencies [ea423a22]
- @ballerine/common@0.7.28

## 0.5.26

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/workflow-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/workflow-core",
"author": "Ballerine <[email protected]>",
"version": "0.5.26",
"version": "0.5.27",
"description": "workflow-core",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"node": ">=12"
},
"dependencies": {
"@ballerine/common": "0.7.27",
"@ballerine/common": "0.7.28",
"ajv": "^8.12.0",
"i18n-iso-countries": "^7.6.0",
"jmespath": "^0.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export class ApiPlugin {

if (apiResponse.ok) {
const result = await apiResponse.json();
const responseBody = await this.transformData(
this.response!.transformers,
result as AnyRecord,
);
let responseBody = result as AnyRecord;

if (this.response?.transformers) {
responseBody = await this.transformData(this.response.transformers, result as AnyRecord);
}

const { isValidResponse, errorMessage } = await this.validateContent(
this.response!.schemaValidator,
Expand Down Expand Up @@ -143,9 +144,15 @@ export class ApiPlugin {

async transformData(transformers: Transformers, record: AnyRecord) {
let mutatedRecord = record;

if (!transformers) {
throw new Error('No transformers were provided');
}

for (const transformer of transformers) {
mutatedRecord = await this.transformByTransformer(transformer, mutatedRecord);
}

return mutatedRecord;
}

Expand Down
38 changes: 22 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions sdks/web-ui-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# web-ui-sdk

## 1.4.25

### Patch Changes

- Updated dependencies [ea423a22]
- @ballerine/common@0.7.28

## 1.4.24

### Patch Changes
Expand Down
Loading

0 comments on commit 483950b

Please sign in to comment.