Skip to content
Merged

v1.4.0 #1045

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/api",
"version": "1.3.0",
"version": "1.4.0",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/app/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const APIMessages = {
ONBOARD_TEMPLATE_SHEET_NOT_FOUND: 'No sheets found in the workbook',
ONBOARD_TEMPLATE_FILE_EMPTY: 'File is empty or invalid',
ONBOARD_TEMPLATE_FILE_EMPTY_RECORDS: 'The file contains empty records',

INVALID_API_RESPONSE_STRUCTURE: `Invalid API response structure. Please recheck the URL and ensure the API is correctly configured to return data.`,
DATATYPE_EMPTY: `The datatype appears to be empty. Please add at least one entry and verify the URL points to the correct data source.`,
};

export const CONSTANTS = {
Expand Down
13 changes: 10 additions & 3 deletions apps/api/src/app/shared/services/bubble-io.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
import { BubbleBaseService } from '@impler/services';
import { BubbleDestinationEntity } from '@impler/dal';
import { ColumnTypesEnum, DEFAULT_KEYS_OBJ, IColumn } from '@impler/shared';
import { APIMessages } from '@shared/constants';

interface IThingsResponse {
response: {
Expand All @@ -17,13 +18,19 @@ interface IThingsResponse {
export class BubbleIoService extends BubbleBaseService {
async getDatatypeData(data: Omit<BubbleDestinationEntity, '_id' | '_templateId'>) {
try {
const response = await axios.get<IThingsResponse>(data.bubbleAppUrl, {
const response = await axios.get<IThingsResponse>(this.createBubbleIoUrl(data.bubbleAppUrl), {
headers: {
Authorization: `Bearer ${data.apiPrivateKey}`,
},
});
if (!response.data.response.results.length)
throw new Error('Datatype is empty. Please add at least one entry to the datatype');

if (!Array.isArray(response.data.response.results)) {
throw new Error(APIMessages.INVALID_API_RESPONSE_STRUCTURE);
}

if (response.data.response.results.length === 0) {
throw new Error(APIMessages.DATATYPE_EMPTY);
}

return response.data.response.results;
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
*This migrartion is for the having only the bubbleAppUrl or streamlined using this send the bubble data to the specified destionation, the
*bubbleAppUrl contains everything the version the datatype and other things, if these fields are not there we construct using the existing data
*/
import '../../config';
import { AppModule } from '../../app.module';

import { NestFactory } from '@nestjs/core';
import { BubbleDestinationRepository } from '@impler/dal';

export async function run() {
const bubbleDestinationRepository: BubbleDestinationRepository = new BubbleDestinationRepository();

// eslint-disable-next-line no-console
console.log('start migration - Constructing, Generating and Updating the bubbleAppUrl');

// Init the mongodb connection
const app = await NestFactory.create(AppModule, {
logger: false,
});

const constructBubbleUrl = async (bubbleDestination: any | undefined | null) => {
const bubbleAppUrl = [{ _id: '', bubbleAppUrl: '' }];
bubbleDestination.forEach((destination) => {
/*
* If no direct URL, try to construct it from available fields
* Type assertion to access potential additional properties
*/
const customDomainName = destination.customDomainName as string | undefined;
const appName = destination.appName as string | undefined;
const environment = destination.environment as string | undefined;
const datatype = destination.datatype as string | undefined;

if (customDomainName || appName) {
// Use custom domain if available, otherwise use app name with bubbleapps.io
let baseUrl = customDomainName ? `https://${customDomainName}` : `https://${appName}.bubbleapps.io`;

// Add version-test for development environment if specified
if (environment === 'development') {
baseUrl += '/version-test';
}

// Construct the full URL with the data type if available
if (datatype) {
bubbleAppUrl.push({ _id: destination._id, bubbleAppUrl: `${baseUrl}/api/1.1/obj/${datatype}` });
}
}
});

return bubbleAppUrl;
};

const bubbleDestinationLink = await bubbleDestinationRepository.find({
bubbleAppUrl: { $exists: true, $ne: null },
});

const bubbleDestinations = await bubbleDestinationRepository.find({});
const bubbleAppUrls = await constructBubbleUrl(bubbleDestinations);
bubbleDestinationLink.map((link) => {
bubbleAppUrls.push({ _id: link._id, bubbleAppUrl: link.bubbleAppUrl });
});

bubbleAppUrls.map(async (url) => {
if (!url._id || !url.bubbleAppUrl) return;

try {
await bubbleDestinationRepository.update({ _id: url._id }, { $set: { bubbleAppUrl: url.bubbleAppUrl } });
} catch (error) {
return null;
}
});

// eslint-disable-next-line no-console
console.log('end migration - Constructed, Generated and Updated the bubbleAppUrl');

app.close();
process.exit(0);
}
run();
2 changes: 1 addition & 1 deletion apps/queue-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/queue-manager",
"version": "1.3.0",
"version": "1.4.0",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
17 changes: 12 additions & 5 deletions apps/queue-manager/src/consumers/send-bubble-data.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
const uploadId = data.uploadId;
const cachedData = data.cache || (await this.getInitialCachedData(uploadId));

if (cachedData && cachedData.bubbleUrl) {
if (cachedData && cachedData.bubbleAppUrl) {
// Get valid data information
let allDataJson: null | any[] = null;
if (cachedData.allDataFilePath) {
Expand All @@ -67,7 +67,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
uploadId,
page,
method: 'POST',
url: cachedData.bubbleUrl,
url: cachedData.bubbleAppUrl,
headers: {
Authorization: `Bearer ${cachedData.apiPrivateKey}`,
'Content-Type': 'text/plain',
Expand All @@ -76,7 +76,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {

await this.makeResponseEntry(
response,
{ bubbleAppUrl: cachedData.bubbleUrl, datatype: cachedData.datatype },
{ bubbleAppUrl: cachedData.bubbleAppUrl, datatype: cachedData.datatype },
cachedData.name,
cachedData.email
);
Expand Down Expand Up @@ -142,7 +142,14 @@ export class SendBubbleDataConsumer extends BaseConsumer {
const templateData = await this.templateRepository.findById(uploadata._templateId, 'name');

const bubbleDestination = await this.bubbleDestinationRepository.findOne({ _templateId: uploadata._templateId });
const bubbleUrl = bubbleDestination.bubbleAppUrl;
if (!bubbleDestination) return null;

const bubbleAppUrl = bubbleDestination.bubbleAppUrl;

// If still no URL, return null as we can't proceed without a valid URL
if (!bubbleAppUrl) {
return null;
}

const defaultValueObj = {};
const customSchema = JSON.parse(uploadata.customSchema) as ITemplateSchemaItem;
Expand All @@ -163,7 +170,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {

return {
page: 1,
bubbleUrl,
bubbleAppUrl,
chunkSize: 500,
email: userEmail,
datatype: bubbleDestination.datatype,
Expand Down
8 changes: 7 additions & 1 deletion apps/web/components/imports/destination/Destination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ export function Destination({ template }: DestinationProps) {
<Input
required
label="Bubble App URL"
placeholder="Bubble App URL"
placeholder="https://acme.in/api/1.1/obj/customers"
description={
<>
<div>Example with default domain: https://your-app.bubbleapps.io/api/1.1/obj/your-datatype</div>
<div>Example with custom domain: https://yourapp.com/api/1.1/obj/your-datatype</div>
</>
}
{...register('bubbleIo.bubbleAppUrl')}
error={errors?.bubbleIo?.bubbleAppUrl?.message}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/web",
"version": "1.3.0",
"version": "1.4.0",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/widget",
"version": "1.3.0",
"version": "1.4.0",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/src/hooks/Phase3/usePhase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
setTotalPages(reviewDataResponse.totalPages);
},
onError(error: IErrorObject) {
notifier.showError({ message: 'Hellow World', title: error.error });
notifier.showError({ message: error.message, title: error.error });
},
}
);
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:

api:
privileged: true
image: "ghcr.io/implerhq/impler/api:1.3.0"
image: "ghcr.io/implerhq/impler/api:1.4.0"
depends_on:
- mongodb
- rabbitmq
Expand Down Expand Up @@ -57,7 +57,7 @@ services:
- impler

queue-manager:
image: "ghcr.io/implerhq/impler/queue-manager:1.3.0"
image: "ghcr.io/implerhq/impler/queue-manager:1.4.0"
depends_on:
- api
- rabbitmq
Expand Down Expand Up @@ -85,7 +85,7 @@ services:
- impler

widget:
image: "ghcr.io/implerhq/impler/widget:1.3.0"
image: "ghcr.io/implerhq/impler/widget:1.4.0"
depends_on:
- api
container_name: widget
Expand All @@ -103,7 +103,7 @@ services:
embed:
depends_on:
- widget
image: "ghcr.io/implerhq/impler/embed:1.3.0"
image: "ghcr.io/implerhq/impler/embed:1.4.0"
container_name: embed
environment:
WIDGET_URL: ${WIDGET_BASE_URL}
Expand All @@ -115,7 +115,7 @@ services:
web:
depends_on:
- api
image: "ghcr.io/implerhq/impler/web:1.3.0"
image: "ghcr.io/implerhq/impler/web:1.4.0"
container_name: web
environment:
NEXT_PUBLIC_API_BASE_URL: ${API_ROOT_URL}
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"npmClient": "pnpm",
"useNx": true,
"packages": ["apps/*", "libs/*", "packages/*"],
"version": "1.3.0"
"version": "1.4.0"
}
2 changes: 1 addition & 1 deletion libs/dal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/dal",
"version": "1.3.0",
"version": "1.4.0",
"author": "implerhq",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion libs/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/embed",
"version": "1.3.0",
"version": "1.4.0",
"private": true,
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/services/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/services",
"version": "1.3.0",
"version": "1.4.0",
"description": "Reusable services to shared between backend api and queue-manager",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/shared",
"version": "1.3.0",
"version": "1.4.0",
"description": "Reusable types and classes to shared between apps and libraries",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/types/upload/upload.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export type SendBubbleCachedData = {
email: string;
datatype: string;
chunkSize: number;
bubbleUrl: string;
bubbleAppUrl: string;
apiPrivateKey: string;
_templateId: string;
recordFormat: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/angular",
"version": "1.3.0",
"version": "1.4.0",
"description": "Angular library to show CSV Excel Importer in angular applications",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/client",
"version": "1.3.0",
"version": "1.4.0",
"description": "API client to be used in end user environments",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/react",
"version": "1.3.0",
"version": "1.4.0",
"description": "React library to show CSV Excel Importer in react applications",
"license": "MIT",
"author": "implerhq",
Expand Down
Loading