From 4313b0387c694dd399d7b6e2bb36fe94cbdcd589 Mon Sep 17 00:00:00 2001
From: Sadaf <119438857+Sadaf-A@users.noreply.github.com>
Date: Sun, 26 Nov 2023 10:45:22 +0530
Subject: [PATCH] ready to publish (#271)
* code fix
* removed: logs
* modified: made the code ready to be published
* added: edgechains to generated package.json
* modified: package.json
---
JS/edgechains/examples/htmljs.ts | 86 +-
JS/edgechains/examples/src/config/db.ts | 19 -
JS/edgechains/examples/src/index.ts | 6 +-
.../examples/src/layouts/ExampleLayout.ts | 8 +-
.../examples/src/service/HydeSearchService.ts | 6 +-
JS/edgechains/examples/tsconfig.json | 4 +-
.../__common/esbuild.build.js | 45 +
.../lib/create-edgechains/__common/htmljs.ts | 46 +
.../create-edgechains/__common/ormconfig.json | 11 +
.../__common/package-lock.json | 7733 +++++++++++++++++
.../create-edgechains/__common/package.json | 48 +
.../create-edgechains/__common/src/index.ts | 16 +
.../__common/src/jsonnet/hyde.jsonnet | 18 +
.../__common/src/jsonnet/prompts.jsonnet | 103 +
.../__common/src/layouts/ExampleLayout.ts | 282 +
.../__common/src/routes/hydeSearch.route.ts | 76 +
.../src/service/HydeSearchService.test.ts | 36 +
.../__common/src/service/HydeSearchService.ts | 132 +
.../src/testGeneration/TestGenerator.ts | 66 +
.../src/testGeneration/prompts.jsonnet | 28 +
.../src/testGeneration/testGenerator.jsonnet | 18 +
.../__common/src/types/HydeFragmentData.ts | 10 +
.../create-edgechains/__common/tsconfig.json | 20 +
JS/edgechains/lib/create-edgechains/index.ts | 337 +
.../lib/create-edgechains/package-lock.json | 4458 ++++++++++
.../lib/create-edgechains/package.json | 41 +
.../scripts/create-edgechains.js | 2 +
.../lib/create-edgechains/src/get-env.ts | 10 +
.../create-edgechains/src/get-gitignore.ts | 16 +
.../create-edgechains/src/get-package-json.ts | 63 +
.../lib/create-edgechains/src/get-tsconfig.ts | 26 +
.../lib/create-edgechains/tsconfig.json | 16 +
JS/edgechains/lib/package-lock.json | 404 +-
JS/edgechains/lib/package.json | 5 +-
.../lib/src/lib/clients/PostgresClient.ts | 10 +-
JS/edgechains/lib/src/lib/config/db.ts | 19 -
36 files changed, 14067 insertions(+), 157 deletions(-)
delete mode 100644 JS/edgechains/examples/src/config/db.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/esbuild.build.js
create mode 100644 JS/edgechains/lib/create-edgechains/__common/htmljs.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/ormconfig.json
create mode 100644 JS/edgechains/lib/create-edgechains/__common/package-lock.json
create mode 100644 JS/edgechains/lib/create-edgechains/__common/package.json
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/index.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/jsonnet/hyde.jsonnet
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/jsonnet/prompts.jsonnet
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/layouts/ExampleLayout.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/routes/hydeSearch.route.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/service/HydeSearchService.test.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/service/HydeSearchService.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/testGeneration/TestGenerator.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/testGeneration/prompts.jsonnet
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/testGeneration/testGenerator.jsonnet
create mode 100644 JS/edgechains/lib/create-edgechains/__common/src/types/HydeFragmentData.ts
create mode 100644 JS/edgechains/lib/create-edgechains/__common/tsconfig.json
create mode 100644 JS/edgechains/lib/create-edgechains/index.ts
create mode 100644 JS/edgechains/lib/create-edgechains/package-lock.json
create mode 100644 JS/edgechains/lib/create-edgechains/package.json
create mode 100755 JS/edgechains/lib/create-edgechains/scripts/create-edgechains.js
create mode 100644 JS/edgechains/lib/create-edgechains/src/get-env.ts
create mode 100644 JS/edgechains/lib/create-edgechains/src/get-gitignore.ts
create mode 100644 JS/edgechains/lib/create-edgechains/src/get-package-json.ts
create mode 100644 JS/edgechains/lib/create-edgechains/src/get-tsconfig.ts
create mode 100644 JS/edgechains/lib/create-edgechains/tsconfig.json
delete mode 100644 JS/edgechains/lib/src/lib/config/db.ts
diff --git a/JS/edgechains/examples/htmljs.ts b/JS/edgechains/examples/htmljs.ts
index ae460e4de..10f118755 100644
--- a/JS/edgechains/examples/htmljs.ts
+++ b/JS/edgechains/examples/htmljs.ts
@@ -1,58 +1,46 @@
-import { html } from "hono/html";
+import { html } from 'hono/html'
// These functions form the basis of the html.js framework and will be moved to a separate lib
export const view = (viewToRender) => {
- return async (c) => {
- const newBody = await viewToRender({ context: c });
- return c.html(newBody);
- };
-};
+ return async (c) => {
+ const newBody = await viewToRender({ context: c })
+ return c.html(newBody)
+ }
+}
export const rootLayout = (layoutToApply) => {
- return async (c, next) => {
- await next();
- if (c.req.header("HX-Request") !== "true") {
- // Req is a normal request, so we render the whole page which means adding the root layout
- const curBody = await c.res.text();
- c.res = undefined; // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0
- const newBody = await layoutToApply({ context: c, children: html(curBody) });
- c.res = c.html(newBody);
- }
- // Else do nothing and let the original response be sent
- };
-};
+ return async (c, next) => {
+ await next()
+ if (c.req.header('HX-Request') !== 'true') {
+ // Req is a normal request, so we render the whole page which means adding the root layout
+ const curBody = await c.res.text()
+ c.res = undefined // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0
+ const newBody = await layoutToApply({ context: c, children: html(curBody) })
+ c.res = c.html(newBody)
+ }
+ // Else do nothing and let the original response be sent
+ }
+}
export const layout = (layoutToApply) => {
- return async (c, next) => {
- await next();
- if (
- (c.req.header("HX-Request") === "true" &&
- (c.req.header("HX-Boosted") === "true" || !c.req.header("HX-Target"))) ||
- c.req.header("HX-Request") !== "true"
- ) {
- // Req is regular req or boosted link, so we apply layouts
- const curBody = await c.res.text();
- c.res = undefined; // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0
- const newBody = await layoutToApply({ context: c, children: html(curBody) });
- c.res = c.html(newBody);
- }
- // Else do nothing and let the original response be sent, which will be a partial update applied to the page with hx-target
- };
-};
-
-export const Link: any = ({ to, "hx-target": hxTarget, class: className, children }) => {
- if (hxTarget) {
- return html`${children}`;
- } else {
- return html`${children}`;
+ return async (c, next) => {
+ await next()
+ if ((c.req.header('HX-Request') === 'true' && (c.req.header('HX-Boosted') === 'true' || !c.req.header('HX-Target'))) || c.req.header('HX-Request') !== 'true') {
+ // Req is regular req or boosted link, so we apply layouts
+ const curBody = await c.res.text()
+ c.res = undefined // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0
+ const newBody = await layoutToApply({ context: c, children: html(curBody) })
+ c.res = c.html(newBody)
}
-};
+ // Else do nothing and let the original response be sent, which will be a partial update applied to the page with hx-target
+ }
+}
+
+export const Link: any = ({ to, "hx-target": hxTarget, "class": className, children }) => {
+ if (hxTarget) {
+ return html`${children}`
+ } else {
+ return html`${children}`
+ }
+}
\ No newline at end of file
diff --git a/JS/edgechains/examples/src/config/db.ts b/JS/edgechains/examples/src/config/db.ts
deleted file mode 100644
index dedc888c1..000000000
--- a/JS/edgechains/examples/src/config/db.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { createConnection, Connection, getManager, EntityManager } from "typeorm";
-
-class DatabaseConnection {
- private static connection: Connection | undefined;
-
- public static async establishDatabaseConnection(): Promise {
- if (!DatabaseConnection.connection) {
- DatabaseConnection.connection = await createConnection();
- }
- return DatabaseConnection.connection;
- }
-
- public static async getEntityManager(): Promise {
- await DatabaseConnection.establishDatabaseConnection();
- return getManager();
- }
-}
-
-export default DatabaseConnection;
diff --git a/JS/edgechains/examples/src/index.ts b/JS/edgechains/examples/src/index.ts
index a27951006..7068b02ac 100644
--- a/JS/edgechains/examples/src/index.ts
+++ b/JS/edgechains/examples/src/index.ts
@@ -1,17 +1,15 @@
import "dotenv/config";
import { serve } from "@hono/node-server";
import { Hono } from "hono";
-import DatabaseConnection from "./config/db.js";
import { HydeSearchRouter } from "./routes/hydeSearch.route.js";
-import { view } from "../htmljs.js";
+import { view } from "../htmljs.js"
import ExampleLayout from "./layouts/ExampleLayout.js";
-DatabaseConnection.establishDatabaseConnection();
const app = new Hono();
app.route("/", HydeSearchRouter);
-app.get("/", view(ExampleLayout));
+app.get("/", view(ExampleLayout))
serve(app, () => {
console.log("server running on port 3000");
diff --git a/JS/edgechains/examples/src/layouts/ExampleLayout.ts b/JS/edgechains/examples/src/layouts/ExampleLayout.ts
index 90df407b0..53ef219ce 100644
--- a/JS/edgechains/examples/src/layouts/ExampleLayout.ts
+++ b/JS/edgechains/examples/src/layouts/ExampleLayout.ts
@@ -1,5 +1,5 @@
-import { html } from "hono/html";
-import { FC } from "hono/jsx";
+import { html } from 'hono/html'
+import { FC } from 'hono/jsx'
const ExampleLayout: FC = (props) => html`
@@ -277,6 +277,6 @@ const ExampleLayout: FC = (props) => html`