Skip to content

Commit

Permalink
bal 2704 (#2719)
Browse files Browse the repository at this point in the history
* feat: bal-2704

* feat: small change

---------

Co-authored-by: Alon Peretz <8467965+alonp99@users.noreply.github.com>
  • Loading branch information
tomer-shvadron and alonp99 authored Sep 18, 2024
1 parent c697b2e commit c13e7be
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,13 @@ export const getUniversalDocuments = (): TDocument[] => {
version: 1,
propertiesSchema: {},
},
{
category: 'general_documents',
type: 'letter_of_authorization',
issuer: { country: 'ZZ' },
issuingVersion: 1,
version: 1,
propertiesSchema: {},
},
];
};
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- A unique constraint covering the columns `[crossEnvKey]` on the table `UiDefinition` will be added. If there are existing duplicate values, this will fail.
- Added the required column `crossEnvKey` to the `UiDefinition` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "UiDefinition" ADD COLUMN "crossEnvKey" TEXT NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "UiDefinition_crossEnvKey_key" ON "UiDefinition"("crossEnvKey");
1 change: 1 addition & 0 deletions services/workflows-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ enum UiDefinitionContext {

model UiDefinition {
id String @id @default(cuid())
crossEnvKey String @unique
workflowDefinitionId String
uiContext UiDefinitionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const uiKybParentUiSchema = (workflowDefinitionId: string, projectId: str
definition: definition,
workflowDefinitionId: workflowDefinitionId,
projectId: projectId,
crossEnvKey: workflowDefinitionId,
} as const satisfies Prisma.UiDefinitionUncheckedCreateInput);

export const uiKybParentDynamicExample = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export const composeAssociatedUiDefinition = (workflowDefinitionId: string, proj
AssociatedCompanyDocumentsPage,
],
},
definition: definition,
definition,
workflowDefinitionId: workflowDefinitionId,
projectId: projectId,
projectId,
crossEnvKey: workflowDefinitionId,
} satisfies Prisma.UiDefinitionUncheckedCreateInput;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const uiKybWithAssociatedParentUiSchema = (
definition: definition,
workflowDefinitionId: workflowDefinitionId,
projectId: projectId,
crossEnvKey: workflowDefinitionId,
} as const satisfies Prisma.UiDefinitionUncheckedCreateInput);

export const uiKybParentWithAssociatedCompanies = async (
Expand Down
5 changes: 2 additions & 3 deletions services/workflows-service/src/business/business.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,15 @@ export class BusinessService {

this.logger.log('Finished company information fetch');

const companyInformation = plainToClass(CompanyInformationModel, {
return plainToClass(CompanyInformationModel, {
name: result.name,
companyNumber: result.companyNumber,
companyType: result.companyType,
jurisdictionCode: result.jurisdictionCode,
incorporationDate: result.incorporationDate,
currentStatus: result.currentStatus,
vat: '',
});

return companyInformation;
} catch (e) {
// TODO: have global axios error handler - BAL-916, BAL-917
if (e instanceof AxiosError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface TCompanyInformation {
jurisdictionCode: string;
incorporationDate: string;
companyType: string;
currentStatus: string;
}

export interface FetchCompanyInformationParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class GetBusinessInformationDto {
@IsString()
@IsOptional()
@IsNullable()
state!: string | null;
state?: string | null;

@IsString()
@IsOptional()
vendor!: string;
vendor?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const sync = async (objectsToSync: SyncedObject[]) => {
}
stats.totalSyncObjectsForCurrentEnv++;

appLoggerService.log(`Stating object sync for ${crossEnvKey} in ${tableName}`);
appLoggerService.log(`Starting object sync for ${crossEnvKey} in ${tableName}`);
let existingRecord: DataSyncPayload['scalars'] | null = null;
try {
const columnsHash = objectMd5(stableStringify(columns));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CurrentProject } from '@/common/decorators/current-project.decorator';
import { ProjectIds } from '@/common/decorators/project-ids.decorator';
import { WhereIdInput } from '@/common/where-id-input';
import * as errors from '@/errors';
import { ProjectScopeService } from '@/project/project-scope.service';
import type { InputJsonValue, TProjectId, TProjectIds } from '@/types';
import { UiDefinitionByRuntimeIdDto } from '@/ui-definition/dtos/ui-definition-by-runtime-id.dto';
import { UiDefinitionByWorkflowDefinitionIdDto } from '@/ui-definition/dtos/ui-definition-by-workflow-definition-id.dto';
Expand All @@ -17,10 +16,7 @@ import * as swagger from '@nestjs/swagger';
@common.Controller('internal/ui-definition')
@Injectable()
export class UiDefinitionControllerInternal {
constructor(
protected readonly service: UiDefinitionService,
protected readonly projectScopeService: ProjectScopeService,
) {}
constructor(protected readonly service: UiDefinitionService) {}

@common.Post()
@swagger.ApiCreatedResponse({ type: UiDefinitionCreateDto })
Expand All @@ -32,6 +28,7 @@ export class UiDefinitionControllerInternal {
return await this.service.create({
data: {
...data,
crossEnvKey: data.workflowDefinitionId,
definition: data.definition as InputJsonValue,
uiSchema: data.uiSchema as InputJsonValue,
projectId: currentProjectId,
Expand All @@ -46,9 +43,7 @@ export class UiDefinitionControllerInternal {
@common.Param() params: WhereIdInput,
@ProjectIds() projectIds: TProjectIds,
): Promise<UiDefinitionModel> {
const uiDefinition = await this.service.getById(params.id, {}, projectIds);

return uiDefinition;
return await this.service.getById(params.id, {}, projectIds);
}

@common.Get('/workflow-definition/:workflowDefinitionId')
Expand All @@ -58,13 +53,11 @@ export class UiDefinitionControllerInternal {
@common.Param() params: UiDefinitionByWorkflowDefinitionIdDto,
@ProjectIds() projectIds: TProjectIds,
): Promise<UiDefinitionModel> {
const uiDefinition = await this.service.getByWorkflowDefinitionId(
return await this.service.getByWorkflowDefinitionId(
params.workflowDefinitionId,
params.uiContext,
projectIds,
);

return uiDefinition;
}

@common.Get('/workflow-runtime/:workflowRuntimeId')
Expand All @@ -75,13 +68,6 @@ export class UiDefinitionControllerInternal {
@common.Query() query: UiDefinitionByRuntimeIdDto,
@ProjectIds() projectIds: TProjectIds,
): Promise<UiDefinitionModel> {
const uiDefinition = await this.service.getByRuntimeId(
workflowRuntimeId,
query.uiContext,
projectIds,
{},
);

return uiDefinition;
return await this.service.getByRuntimeId(workflowRuntimeId, query.uiContext, projectIds, {});
}
}

0 comments on commit c13e7be

Please sign in to comment.