Skip to content

Commit

Permalink
Merge branch 'dev' into illiar/feat/kyb-iframe-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
chesterkmr committed Nov 28, 2024
2 parents c7368b0 + e059a8a commit 18a217e
Show file tree
Hide file tree
Showing 55 changed files with 1,120 additions and 634 deletions.
53 changes: 38 additions & 15 deletions .github/workflows/hotfix-wf-service.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Under Testing - Hotfix on workflows-service
name: Hotfix on workflows-service

on:
workflow_dispatch:
Expand Down Expand Up @@ -34,6 +34,7 @@ jobs:
docker_image: ${{ steps.docker-version.outputs.image }} # ghcr.io/ballerine-io/workflows-service
docker_tag: ${{ steps.docker-version.outputs.tag }} # <short_sha>-<branch_name>
docker_full_image: ${{ steps.docker-version.outputs.full_image }} # ghcr.io/ballerine-io/workflows-service:<short_sha>-<branch_name>
sanitized-branch: ${{ steps.sanitized-branch.outputs.sanitized-branch-name }}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -61,6 +62,10 @@ jobs:
uses: ./.github/actions/bump-version
with:
tag: ${{ steps.version.outputs.tag }}

- name: "Determine Branch"
id: sanitized-branch
uses: transferwise/sanitize-branch-name@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down Expand Up @@ -94,8 +99,9 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.ref_name }}
type=raw,value=dev
type=raw,value=${{ steps.version.outputs.sha_short }}-${{ github.ref_name }}
type=raw,value=${{ inputs.environment }}
type=raw,value=${{ steps.version.outputs.sha_short }}-${{ inputs.environment }}
type=raw,value=${{ steps.version.outputs.sha_short }}-${{ steps.sanitized-branch.outputs.sanitized-branch-name }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'prod') }}
type=sha,format=short
Expand All @@ -104,7 +110,7 @@ jobs:
run: |
DOCKER_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
DOCKER_TAG=${{ steps.version.outputs.sha_short }}-${{ github.ref_name }}
DOCKER_FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.sha_short }}-${{ github.ref_name }}
DOCKER_FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.sha_short }}-${{ steps.sanitized-branch.outputs.sanitized-branch-name }}
echo "DOCKER_IMAGE=$DOCKER_IMAGE"
echo "DOCKER_TAG=$DOCKER_TAG"
Expand All @@ -120,8 +126,8 @@ jobs:
echo "sha_short: ${{ steps.version.outputs.sha_short }}"
echo "docker_meta-tags: ${{ steps.docker_meta.outputs.tags }}"
echo "bump-version-version: ${{ steps.bump-version.outputs.version }}"
echo "bump-version-tag: ${{ steps.bump-version.outputs.tag }}"
echo "bump-version-version: ${{ steps.bump-version.outputs.version }}-hotfix"
echo "bump-version-tag: ${{ steps.bump-version.outputs.tag }}-hotfix"
- name: Build and push Docker image
uses: docker/build-push-action@v5
Expand All @@ -133,7 +139,7 @@ jobs:
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.docker_meta.outputs.tags }}
build-args: |
"RELEASE=${{ steps.bump-version.outputs.tag }}"
"RELEASE=${{ steps.bump-version.outputs.tag }}-hotfix"
"SHORT_SHA=${{ steps.version.outputs.sha_short }}"
- name: Scan Docker Image
Expand All @@ -148,6 +154,23 @@ jobs:
trivyignores: ./.trivyignore
vuln-type: 'os,library'
severity: 'CRITICAL'

- name: Update Service version in Environment
run: |
if [ "${{ inputs.environment }}" == "prod" ]; then
ENV="PROD"
elif [ "${{ inputs.environment }}" == "sb" ]; then
ENV="SB"
else
ENV="DEV"
fi
echo "$ENV"
curl -X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_CI_ENV_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/ballerine-io/ballerine/actions/variables/${ENV^^}_WF_SHORT_SHA" \
-d "{\"name\":\"${ENV}_WF_SHORT_SHA\",\"value\":\"${{ steps.version.outputs.sha_short }}\"}"
build-and-push-ee-image:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -221,14 +244,14 @@ jobs:
images: ${{needs.build-and-push-image.outputs.docker_image}}-ee
tags: |
type=raw,value=${{ inputs.environment }}
type=raw,value=${{ needs.build-and-push-image.outputs.sha_short }}-${{ steps.lastcommit.outputs.shorthash }}-${{ inputs.environment }}
type=raw,value=${{ needs.build-and-push-image.outputs.sha_short }}-${{ steps.lastcommit.outputs.shorthash }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}
type=sha,format=short
- name: Docker metadata version
id: docker-version
run: |
DOCKER_IMAGE=${{needs.build-and-push-image.outputs.docker_image}}-ee
DOCKER_TAG=${{ needs.build-and-push-image.outputs.sha_short }}-${{ steps.lastcommit.outputs.shorthash }}-${{ inputs.environment }}
DOCKER_TAG=${{ needs.build-and-push-image.outputs.sha_short }}-${{ steps.lastcommit.outputs.shorthash }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}
DOCKER_FULL_IMAGE=$DOCKER_IMAGE:$DOCKER_TAG
echo "DOCKER_IMAGE=$DOCKER_IMAGE"
Expand Down Expand Up @@ -292,15 +315,15 @@ jobs:
repository: ballerine-io/cloud-infra-config
branch: main
commitChange: true
message: "Performed HotFix to ${{ inputs.environment }} wf-service image Version to ${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }} - (Commit hash: ${{ github.sha }}, commit message: ${{ github.event.head_commit.message }})"
message: "Performed HotFix to ${{ inputs.environment }} wf-service application image Version to ${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }} - (Commit hash: ${{ github.sha }}, commit message: ${{ github.event.head_commit.message }})"
token: ${{ secrets.GIT_TOKEN }}
changes: |
{
"kubernetes/helm/wf-service/${{steps.update_helm_check.outputs.file_name}}": {
"image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }}",
"prismaMigrate.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }}",
"dbMigrate.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }}",
"dataSync.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }}"
"image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}",
"prismaMigrate.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}",
"dbMigrate.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}",
"dataSync.image.tag": "${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }}"
}
}
send-to-slack:
Expand All @@ -317,7 +340,7 @@ jobs:
uses: slackapi/[email protected]
with:
channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
slack-message: "Hotfix on Wf-service Deployment in ${{ inputs.environment }} with tag ${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }} build result: ${{ job.status }}. successfully updated the hotfix on wf-service helm values for ${{ inputs.environment }}."
slack-message: "Hotfix on Wf-service app Deployment in ${{ inputs.environment }} with tag ${{ needs.build-and-push-image.outputs.sha_short }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ needs.build-and-push-image.outputs.sanitized-branch }} build result: ${{ job.status }}. successfully updated the hotfix on wf-service helm values for ${{ inputs.environment }}."
env:
SLACK_BOT_TOKEN: ${{ secrets.ARGO_SLACK_BOT_TOKEN }}

Expand Down
24 changes: 24 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @ballerine/backoffice-v2

## 0.7.75

### Patch Changes

- bump
- Updated dependencies
- @ballerine/common@0.9.54
- @ballerine/workflow-browser-sdk@0.6.71
- @ballerine/workflow-node-sdk@0.6.71

## 0.7.74

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.70
- @ballerine/workflow-node-sdk@0.6.70

## 0.7.73

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.69
- @ballerine/workflow-node-sdk@0.6.69

## 0.7.72

### 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.7.72",
"version": "0.7.75",
"description": "Ballerine - Backoffice",
"homepage": "https://github.com/ballerine-io/ballerine",
"type": "module",
Expand Down Expand Up @@ -52,11 +52,11 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.27",
"@ballerine/common": "0.9.53",
"@ballerine/common": "0.9.54",
"@ballerine/react-pdf-toolkit": "^1.2.47",
"@ballerine/ui": "^0.5.47",
"@ballerine/workflow-browser-sdk": "0.6.68",
"@ballerine/workflow-node-sdk": "0.6.68",
"@ballerine/workflow-browser-sdk": "0.6.71",
"@ballerine/workflow-node-sdk": "0.6.71",
"@botpress/webchat": "^2.1.10",
"@botpress/webchat-generator": "^0.2.9",
"@fontsource/inter": "^4.5.15",
Expand Down
20 changes: 20 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# kyb-app

## 0.3.86

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.54
- @ballerine/workflow-browser-sdk@0.6.71

## 0.3.85

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.70

## 0.3.84

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.69

## 0.3.83

### 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.3.83",
"version": "0.3.86",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -16,9 +16,9 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.27",
"@ballerine/common": "^0.9.53",
"@ballerine/common": "^0.9.54",
"@ballerine/ui": "0.5.47",
"@ballerine/workflow-browser-sdk": "0.6.68",
"@ballerine/workflow-browser-sdk": "0.6.71",
"@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 @@ -16,6 +16,7 @@ export const StateManager = ({
workflowId,
initialContext,
config,
additionalContext,
}: StateManagerProps) => {
const machine = useMemo(() => {
const initialMachineState = {
Expand All @@ -29,14 +30,15 @@ export const StateManager = ({
definitionType,
extensions,
initialMachineState,
additionalContext,
);

machine.overrideContext(initialMachineState);

return machine;
}, []);
}, [additionalContext]);

const { machineApi } = useMachineLogic(machine);
const { machineApi } = useMachineLogic(machine, additionalContext);
const {
contextPayload,
isPluginLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class PluginRunnerHandler implements ActionHandler {

async run(_: CollectionFlowContext, action: Action<PluginRunnerParams>, api: StateMachineAPI) {
await api.invokePlugin(action.params.pluginName);

return api.getContext();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CollectionFlowContext } from '@/domains/collection-flow/types/flow-context.types';
import { isErrorWithMessage } from '@ballerine/common';
import { AnyRecord, isErrorWithMessage } from '@ballerine/common';
import { AnyObject } from '@ballerine/ui';
import { WorkflowBrowserSDK } from '@ballerine/workflow-browser-sdk';
import { useCallback, useMemo, useState } from 'react';

export interface StateMachineAPI {
invokePlugin: (pluginName: string) => Promise<void>;
invokePlugin: (pluginName: string, additionalContext?: AnyRecord) => Promise<void>;
sendEvent: (eventName: string) => Promise<void>;
setContext: (newContext: CollectionFlowContext) => CollectionFlowContext;
getContext: () => CollectionFlowContext;
Expand All @@ -14,21 +14,22 @@ export interface StateMachineAPI {

export const useMachineLogic = (
machine: WorkflowBrowserSDK,
additionalContext?: AnyRecord,
): { isInvokingPlugin: boolean; machineApi: StateMachineAPI } => {
const [isInvokingPlugin, setInvokingPlugin] = useState(false);

const invokePlugin = useCallback(
async (pluginName: string) => {
setInvokingPlugin(true);
try {
await machine.invokePlugin(pluginName);
await machine.invokePlugin(pluginName, additionalContext);
} catch (error) {
console.log('Failed to invoke plugin', isErrorWithMessage(error) ? error.message : error);
} finally {
setInvokingPlugin(false);
}
},
[machine],
[machine, additionalContext],
);

const sendEvent = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { State } from '@/components/organisms/DynamicUI/StateManager/types';
import { AnyRecord } from '@ballerine/common';
import { AnyObject } from '@ballerine/ui';
import { createWorkflow } from '@ballerine/workflow-browser-sdk';

Expand All @@ -8,6 +9,7 @@ export const createStateMachine = (
definitionType: string,
extensions: AnyObject,
workflowContext?: AnyObject,
additionalContext?: AnyRecord,
) =>
createWorkflow({
runtimeId: workflowId,
Expand All @@ -16,4 +18,5 @@ export const createStateMachine = (
definitionType: 'statechart-json',
extensions: extensions,
workflowContext: workflowContext,
additionalContext: additionalContext,
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CollectionFlowConfig,
CollectionFlowContext,
} from '@/domains/collection-flow/types/flow-context.types';
import { AnyRecord } from '@ballerine/common';
import { AnyChildren, AnyObject } from '@ballerine/ui';
import { MachineConfig } from 'xstate';

Expand All @@ -26,4 +27,5 @@ export interface StateManagerProps {
children: AnyChildren | StateManagerChildCallback;
initialContext: CollectionFlowContext | null;
config?: CollectionFlowConfig;
additionalContext?: AnyRecord;
}
3 changes: 3 additions & 0 deletions apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from '@ballerine/common';
import { AnyObject } from '@ballerine/ui';
import { FailedScreen } from './components/pages/FailedScreen';
import { useAdditionalWorkflowContext } from './hooks/useAdditionalWorkflowContext';

const elems = {
h1: Title,
Expand Down Expand Up @@ -73,6 +74,7 @@ export const CollectionFlow = withSessionProtected(() => {
const { customer } = useCustomer();
const { t } = useTranslation();
const { themeDefinition } = useTheme();
const additionalContext = useAdditionalWorkflowContext();

const elements = schema?.uiSchema?.elements;
const definition = schema?.definition.definition;
Expand Down Expand Up @@ -141,6 +143,7 @@ export const CollectionFlow = withSessionProtected(() => {
extensions={schema?.definition.extensions}
definition={definition as State}
config={collectionFlowData?.config}
additionalContext={additionalContext}
>
{({ state, stateApi }) => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useAdditionalWorkflowContext';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useMemo } from 'react';
import { useSearchParams } from 'react-router-dom';

export const useAdditionalWorkflowContext = () => {
const [searchParams] = useSearchParams();

const context = useMemo(() => {
return {
query: {
token: searchParams.get('token'),
},
};
}, [searchParams]);

return context;
};
Loading

0 comments on commit 18a217e

Please sign in to comment.