Skip to content

Commit

Permalink
Dev (#1)
Browse files Browse the repository at this point in the history
* Baseline for Master (ONDC-Official#12)

* Working on Github Actions.

* Working on Deployment.

* Fix: Github Actions.

* Fixed username.

* Working on deployment.

* Update clone-and-setup.yml

* Update clone-and-setup.yml

* Update clone-and-setup.yml

* sanity commit.

* snaity commit.

* s.

* sc.

* logging.

* Update app-deployment.yml

* Update app-deployment.yml

* Update db-operations.yml

* Update db-operations.yml

* Update db-operations.yml

* Update db-operations.yml

* Update db-operations.yml

* Removing unused classes.

* Update db-operations.yml

* Update db-operations.yml

* Update app-deployment.yml

* Update app-deployment.yml

* Working on deployment.

* Update db-operations.yml

* Update db-operations.yml

* Update package.json

* Working on Deployment migration runner.

* Fixing docker network.

* sc

* Working on UI fixes.

* Working on QR Download and schema changes.

* Working on decoupling action from formData.

* Minor changes.

* Logging the migrations.

* Debugging.

* changing env name.

* Update app-deployment.yml

* Resolved bug; consolidated migrations.
  • Loading branch information
abhik-wil authored Jan 13, 2025
1 parent af06c55 commit 8e9a5a3
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 181 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- CreateEnum
CREATE TYPE "TemplateStage" AS ENUM ('DRAFT', 'REVIEW', 'SUBMITTED', 'PUBLISHED');

-- CreateEnum
CREATE TYPE "UsecaseStage" AS ENUM ('DRAFT', 'REVIEW', 'SUBMITTED', 'PUBLISHED');

-- CreateTable
CREATE TABLE "Template" (
"id" TEXT NOT NULL DEFAULT substr(gen_random_uuid()::text, 1, 16),
"name" TEXT,
"description" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"value" JSONB NOT NULL,
"templateStage" "TemplateStage" NOT NULL,
"usecaseCategoryId" TEXT,
"usecaseSubcategoryId" TEXT,

CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Usecase" (
"id" TEXT NOT NULL DEFAULT substr(gen_random_uuid()::text, 1, 16),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"value" JSONB NOT NULL,
"templateId" TEXT NOT NULL,
"name" TEXT,
"description" TEXT,
"creatorName" TEXT,
"qrPdfLink" TEXT,
"usecaseStage" "UsecaseStage" NOT NULL,

CONSTRAINT "Usecase_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "UsecaseCategory" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "UsecaseCategory_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "UsecaseSubcategory" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"usecaseCategoryId" TEXT NOT NULL,

CONSTRAINT "UsecaseSubcategory_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "Template_usecaseCategoryId_usecaseSubcategoryId_idx" ON "Template"("usecaseCategoryId", "usecaseSubcategoryId");

-- CreateIndex
CREATE UNIQUE INDEX "Template_usecaseCategoryId_usecaseSubcategoryId_key" ON "Template"("usecaseCategoryId", "usecaseSubcategoryId");

-- CreateIndex
CREATE UNIQUE INDEX "UsecaseCategory_name_key" ON "UsecaseCategory"("name");

-- CreateIndex
CREATE UNIQUE INDEX "UsecaseSubcategory_name_key" ON "UsecaseSubcategory"("name");

-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_usecaseCategoryId_fkey" FOREIGN KEY ("usecaseCategoryId") REFERENCES "UsecaseCategory"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_usecaseSubcategoryId_fkey" FOREIGN KEY ("usecaseSubcategoryId") REFERENCES "UsecaseSubcategory"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Usecase" ADD CONSTRAINT "Usecase_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UsecaseSubcategory" ADD CONSTRAINT "UsecaseSubcategory_usecaseCategoryId_fkey" FOREIGN KEY ("usecaseCategoryId") REFERENCES "UsecaseCategory"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
40 changes: 25 additions & 15 deletions deeplink-generator/seeding/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,34 @@ async function main() {
}
});
console.log(categorySubcategoryMap);
Object.keys(categorySubcategoryMap).forEach(async (category) => {
const c = await prisma.usecaseCategory.create({
data: {
name: category,
},
});
const sc = await prisma.usecaseSubcategory.createMany({
data: categorySubcategoryMap[category].map((subCategory) => ({
name: subCategory,
usecaseCategoryId: c.id,
})),
});
console.log("Seeded Subcategory", sc);
});
const createdCategories = await Promise.all(
Object.keys(categorySubcategoryMap).map((category) =>
prisma.usecaseCategory.create({
data: {
name: category,
UsecaseSubcategory: {
createMany: {
data: categorySubcategoryMap[category].map((name) => ({
name,
})),
},
},
},
include: {
UsecaseSubcategory: true,
}
})
)
);
console.log("Seeded Categories", createdCategories);

const seededCategories = await prisma.usecaseCategory.findMany();
const seededSubCategories = await prisma.usecaseSubcategory.findMany();

console.log("Seeded Categories", seededCategories);
console.log("Seeded SubCategories", seededSubCategories);


console.log("Seeded Categories", seededCategories);
console.log("Seeded SubCategories", seededSubCategories);

Expand All @@ -65,7 +75,7 @@ async function main() {
category.name.toLowerCase() === file.category.toLowerCase()
)[0].id
);

console.log(
"FILTERED sub-category",
file.subCategory.toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const GenerateDeepLinkPage = async ({
const templateId = (await params).templateId;
const template = await getTemplateById(templateId);
const templateValue = flattenTemplate(template!.value);

const handleSubmit = async (form: FormData) => {
"use server";
const value = formDataToFormItemArray(form);
Expand All @@ -50,7 +49,10 @@ const GenerateDeepLinkPage = async ({
templateId,
value: value.map(({ name, value }) => {
try {
JSON.parse(value);
const v = JSON.parse(value);
if (typeof v !== "object") {
throw new Error("Primitive values as strings are not allowed");
}
return { name, value: `{{${name}}}` };
} catch {
return { name, value };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const PublishDeepLinkPage = async ({
justifyContent="flex-start"
>
<FieldName fieldName="Creater's Name" />
<Typography variant="h5">&nbsp; &nbsp;</Typography>
<TextField sx={{ ml: 1 }} name="creatorName" fullWidth />
</Stack>

Expand All @@ -78,7 +77,6 @@ const PublishDeepLinkPage = async ({
justifyContent="flex-start"
>
<FieldName fieldName="Deeplink Name" />
<Typography variant="h5">&nbsp; &nbsp;</Typography>
<TextField sx={{ ml: 1 }} name="name" fullWidth required/>
</Stack>

Expand All @@ -89,7 +87,6 @@ const PublishDeepLinkPage = async ({
justifyContent="flex-start"
>
<FieldName fieldName="Description" />
<Typography variant="h5">&nbsp; &nbsp;</Typography>
<TextField sx={{ ml: 1 }} name="description" fullWidth required/>
</Stack>

Expand Down Expand Up @@ -118,11 +115,13 @@ const PublishDeepLinkPage = async ({
</Stack>
<Divider />
</Grid>
<Grid size={{ xs: 12 }}>
<Grid size={{ xs: 12 }}>
<UsecaseEditor usecase={usecase!} />
{/* <Typography>{JSON.stringify(usecase?.value)}</Typography> */}
</Grid>
</Grid>
</Grid>
</Paper>
<Box
sx={{
Expand Down
4 changes: 2 additions & 2 deletions deeplink-generator/src/app/components/UsecaseEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export const UsecaseEditor = ({ usecase }: UsecaseEditorProps) => {
.filter(
(key) =>
!(
(flattenedUsecase[key] as string).startsWith("{{") &&
(flattenedUsecase[key] as string).endsWith("}}")
(flattenedUsecase[key]!.toString()).startsWith("{{") &&
(flattenedUsecase[key]!.toString()).endsWith("}}")
)
)
.map((key: string) => (
Expand Down
Binary file modified deeplink-generator/src/app/favicon.ico
Binary file not shown.
Binary file added deeplink-generator/src/app/ondc_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deeplink-generator/src/app/utils/inflate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,5 @@ export function inflateDeepLink(formData: FormItem[]) {
formData.forEach((item) => {
setNestedValue(result, item.name, item.value);
});

return result;
}

0 comments on commit 8e9a5a3

Please sign in to comment.