Compare commits
3 Commits
9ff4057166
...
0e350b1bca
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e350b1bca | |||
| 4bc58460b4 | |||
| a9d725eb29 |
49
convex/_generated/api.d.ts
vendored
Normal file
49
convex/_generated/api.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated `api` utility.
|
||||
*
|
||||
* THIS CODE IS AUTOMATICALLY GENERATED.
|
||||
*
|
||||
* To regenerate, run `npx convex dev`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
import type * as http from "../http.js";
|
||||
|
||||
import type {
|
||||
ApiFromModules,
|
||||
FilterApi,
|
||||
FunctionReference,
|
||||
} from "convex/server";
|
||||
|
||||
declare const fullApi: ApiFromModules<{
|
||||
http: typeof http;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's public API.
|
||||
*
|
||||
* Usage:
|
||||
* ```js
|
||||
* const myFunctionReference = api.myModule.myFunction;
|
||||
* ```
|
||||
*/
|
||||
export declare const api: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "public">
|
||||
>;
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's internal API.
|
||||
*
|
||||
* Usage:
|
||||
* ```js
|
||||
* const myFunctionReference = internal.myModule.myFunction;
|
||||
* ```
|
||||
*/
|
||||
export declare const internal: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "internal">
|
||||
>;
|
||||
|
||||
export declare const components: {};
|
||||
23
convex/_generated/api.js
Normal file
23
convex/_generated/api.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated `api` utility.
|
||||
*
|
||||
* THIS CODE IS AUTOMATICALLY GENERATED.
|
||||
*
|
||||
* To regenerate, run `npx convex dev`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { anyApi, componentsGeneric } from "convex/server";
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's API.
|
||||
*
|
||||
* Usage:
|
||||
* ```js
|
||||
* const myFunctionReference = api.myModule.myFunction;
|
||||
* ```
|
||||
*/
|
||||
export const api = anyApi;
|
||||
export const internal = anyApi;
|
||||
export const components = componentsGeneric();
|
||||
60
convex/_generated/dataModel.d.ts
vendored
Normal file
60
convex/_generated/dataModel.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated data model types.
|
||||
*
|
||||
* THIS CODE IS AUTOMATICALLY GENERATED.
|
||||
*
|
||||
* To regenerate, run `npx convex dev`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
import type {
|
||||
DataModelFromSchemaDefinition,
|
||||
DocumentByName,
|
||||
TableNamesInDataModel,
|
||||
SystemTableNames,
|
||||
} from "convex/server";
|
||||
import type { GenericId } from "convex/values";
|
||||
import schema from "../schema.js";
|
||||
|
||||
/**
|
||||
* The names of all of your Convex tables.
|
||||
*/
|
||||
export type TableNames = TableNamesInDataModel<DataModel>;
|
||||
|
||||
/**
|
||||
* The type of a document stored in Convex.
|
||||
*
|
||||
* @typeParam TableName - A string literal type of the table name (like "users").
|
||||
*/
|
||||
export type Doc<TableName extends TableNames> = DocumentByName<
|
||||
DataModel,
|
||||
TableName
|
||||
>;
|
||||
|
||||
/**
|
||||
* An identifier for a document in Convex.
|
||||
*
|
||||
* Convex documents are uniquely identified by their `Id`, which is accessible
|
||||
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
||||
*
|
||||
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
||||
*
|
||||
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
||||
* strings when type checking.
|
||||
*
|
||||
* @typeParam TableName - A string literal type of the table name (like "users").
|
||||
*/
|
||||
export type Id<TableName extends TableNames | SystemTableNames> =
|
||||
GenericId<TableName>;
|
||||
|
||||
/**
|
||||
* A type describing your Convex data model.
|
||||
*
|
||||
* This type includes information about what tables you have, the type of
|
||||
* documents stored in those tables, and the indexes defined on them.
|
||||
*
|
||||
* This type is used to parameterize methods like `queryGeneric` and
|
||||
* `mutationGeneric` to make them type-safe.
|
||||
*/
|
||||
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
||||
143
convex/_generated/server.d.ts
vendored
Normal file
143
convex/_generated/server.d.ts
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated utilities for implementing server-side Convex query and mutation functions.
|
||||
*
|
||||
* THIS CODE IS AUTOMATICALLY GENERATED.
|
||||
*
|
||||
* To regenerate, run `npx convex dev`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
import {
|
||||
ActionBuilder,
|
||||
HttpActionBuilder,
|
||||
MutationBuilder,
|
||||
QueryBuilder,
|
||||
GenericActionCtx,
|
||||
GenericMutationCtx,
|
||||
GenericQueryCtx,
|
||||
GenericDatabaseReader,
|
||||
GenericDatabaseWriter,
|
||||
} from "convex/server";
|
||||
import type { DataModel } from "./dataModel.js";
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
*
|
||||
* This function will be allowed to read your Convex database and will be accessible from the client.
|
||||
*
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const query: QueryBuilder<DataModel, "public">;
|
||||
|
||||
/**
|
||||
* Define a query that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
||||
*
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
||||
|
||||
/**
|
||||
* Define a mutation in this Convex app's public API.
|
||||
*
|
||||
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
||||
*
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const mutation: MutationBuilder<DataModel, "public">;
|
||||
|
||||
/**
|
||||
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
||||
*
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
||||
|
||||
/**
|
||||
* Define an action in this Convex app's public API.
|
||||
*
|
||||
* An action is a function which can execute any JavaScript code, including non-deterministic
|
||||
* code and code with side-effects, like calling third-party services.
|
||||
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
||||
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
||||
*
|
||||
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const action: ActionBuilder<DataModel, "public">;
|
||||
|
||||
/**
|
||||
* Define an action that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
||||
|
||||
/**
|
||||
* Define an HTTP action.
|
||||
*
|
||||
* The wrapped function will be used to respond to HTTP requests received
|
||||
* by a Convex deployment if the requests matches the path and method where
|
||||
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
||||
*
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
||||
* and a Fetch API `Request` object as its second.
|
||||
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
||||
*/
|
||||
export declare const httpAction: HttpActionBuilder;
|
||||
|
||||
/**
|
||||
* A set of services for use within Convex query functions.
|
||||
*
|
||||
* The query context is passed as the first argument to any Convex query
|
||||
* function run on the server.
|
||||
*
|
||||
* This differs from the {@link MutationCtx} because all of the services are
|
||||
* read-only.
|
||||
*/
|
||||
export type QueryCtx = GenericQueryCtx<DataModel>;
|
||||
|
||||
/**
|
||||
* A set of services for use within Convex mutation functions.
|
||||
*
|
||||
* The mutation context is passed as the first argument to any Convex mutation
|
||||
* function run on the server.
|
||||
*/
|
||||
export type MutationCtx = GenericMutationCtx<DataModel>;
|
||||
|
||||
/**
|
||||
* A set of services for use within Convex action functions.
|
||||
*
|
||||
* The action context is passed as the first argument to any Convex action
|
||||
* function run on the server.
|
||||
*/
|
||||
export type ActionCtx = GenericActionCtx<DataModel>;
|
||||
|
||||
/**
|
||||
* An interface to read from the database within Convex query functions.
|
||||
*
|
||||
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
||||
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
||||
* building a query.
|
||||
*/
|
||||
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
||||
|
||||
/**
|
||||
* An interface to read from and write to the database within Convex mutation
|
||||
* functions.
|
||||
*
|
||||
* Convex guarantees that all writes within a single mutation are
|
||||
* executed atomically, so you never have to worry about partial writes leaving
|
||||
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
||||
* for the guarantees Convex provides your functions.
|
||||
*/
|
||||
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
||||
93
convex/_generated/server.js
Normal file
93
convex/_generated/server.js
Normal file
@@ -0,0 +1,93 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated utilities for implementing server-side Convex query and mutation functions.
|
||||
*
|
||||
* THIS CODE IS AUTOMATICALLY GENERATED.
|
||||
*
|
||||
* To regenerate, run `npx convex dev`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
import {
|
||||
actionGeneric,
|
||||
httpActionGeneric,
|
||||
queryGeneric,
|
||||
mutationGeneric,
|
||||
internalActionGeneric,
|
||||
internalMutationGeneric,
|
||||
internalQueryGeneric,
|
||||
} from "convex/server";
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
*
|
||||
* This function will be allowed to read your Convex database and will be accessible from the client.
|
||||
*
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const query = queryGeneric;
|
||||
|
||||
/**
|
||||
* Define a query that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
||||
*
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const internalQuery = internalQueryGeneric;
|
||||
|
||||
/**
|
||||
* Define a mutation in this Convex app's public API.
|
||||
*
|
||||
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
||||
*
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const mutation = mutationGeneric;
|
||||
|
||||
/**
|
||||
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
||||
*
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const internalMutation = internalMutationGeneric;
|
||||
|
||||
/**
|
||||
* Define an action in this Convex app's public API.
|
||||
*
|
||||
* An action is a function which can execute any JavaScript code, including non-deterministic
|
||||
* code and code with side-effects, like calling third-party services.
|
||||
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
||||
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
||||
*
|
||||
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const action = actionGeneric;
|
||||
|
||||
/**
|
||||
* Define an action that is only accessible from other Convex functions (but not from the client).
|
||||
*
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export const internalAction = internalActionGeneric;
|
||||
|
||||
/**
|
||||
* Define an HTTP action.
|
||||
*
|
||||
* The wrapped function will be used to respond to HTTP requests received
|
||||
* by a Convex deployment if the requests matches the path and method where
|
||||
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
||||
*
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
||||
* and a Fetch API `Request` object as its second.
|
||||
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
||||
*/
|
||||
export const httpAction = httpActionGeneric;
|
||||
13
convex/auth.config.ts
Normal file
13
convex/auth.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { AuthConfig } from "convex/server";
|
||||
|
||||
export default {
|
||||
providers: [
|
||||
{
|
||||
type: "customJwt",
|
||||
applicationID: "convex-app",
|
||||
issuer: "https://convex.kevisual.cn",
|
||||
jwks: "https://api-convex.kevisual.cn/root/convex/jwks.json",
|
||||
algorithm: "RS256",
|
||||
},
|
||||
],
|
||||
};
|
||||
7
convex/convex.config.ts
Normal file
7
convex/convex.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineApp } from "convex/server";
|
||||
const app = defineApp();
|
||||
|
||||
// import myComponent from "../component/convex.config.ts";
|
||||
// app.use(myComponent);
|
||||
|
||||
export default app;
|
||||
39
convex/http.ts
Normal file
39
convex/http.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { httpRouter } from "convex/server";
|
||||
import { httpAction } from "./_generated/server";
|
||||
const http = httpRouter();
|
||||
|
||||
http.route({
|
||||
path: "/auth",
|
||||
method: "POST",
|
||||
handler: httpAction(async (ctx, request) => {
|
||||
// 处理请求并返回响应
|
||||
return new Response(JSON.stringify({ message: "Hello from custom endpoint!" }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
}),
|
||||
})
|
||||
|
||||
// https://api-convex.kevisual.cn/root/convex/jwks.json
|
||||
http.route({
|
||||
path: '/root/convex/jwks.json',
|
||||
method: 'GET',
|
||||
handler: httpAction(async (ctx, request) => {
|
||||
// 返回 JWKS 数据
|
||||
const jwks = {
|
||||
"keys": [
|
||||
{
|
||||
"kty": "RSA",
|
||||
"n": "km4cjJJOMFkl2G5qWMuFmWwF7rmeqRYzYdR8SddKeeMW0e9yIf5pv2Mfwv0aMJUpb-_j3j9M7whx_SEGc_2jx1vxCu1AlYURhnnLTWdsR-ZRPr2LK9UstMrgpWV425R2RliqXTDTYlSxUUlD9nPue_tqbfwN2aM9MCarm67xK_ZCcKRlW9o9L2-9UMfzRA7uiy4VQtOemP0PTXp-E9RxNiMPOQXIRls9wTW_EkDT3dGy7JCZhj7_qib3T8k9m84SwU7wI2R_3IH4DcHSMAn1BRRMXZ1_wPhbP39laNtdJgbDjGCqUccGhLUaoo2WGkZ52eb7NPqamp0K1Dh2jwTIJQ",
|
||||
"e": "AQAB",
|
||||
"kid": "kid-key-1"
|
||||
}
|
||||
]
|
||||
};
|
||||
return new Response(JSON.stringify(jwks), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
}),
|
||||
})
|
||||
export default http;
|
||||
30
convex/schema.ts
Normal file
30
convex/schema.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { defineSchema, defineTable } from "convex/server";
|
||||
import { v } from "convex/values";
|
||||
|
||||
export default defineSchema({
|
||||
// Other tables here...
|
||||
|
||||
github_starred: defineTable({
|
||||
author: v.string(),
|
||||
auto: v.string(),
|
||||
description: v.string(),
|
||||
last_updated: v.string(),
|
||||
link: v.string(),
|
||||
repo_id: v.float64(),
|
||||
stars: v.float64(),
|
||||
summary: v.string(),
|
||||
title: v.string(),
|
||||
}),
|
||||
users: defineTable({
|
||||
userId: v.string(), // 外部系统的用户 ID
|
||||
name: v.string(),
|
||||
createdAt: v.string(),
|
||||
lastLoginAt: v.optional(v.string()),
|
||||
}).index("userId", ["userId"]),
|
||||
sessions: defineTable({
|
||||
userId: v.id("users"),
|
||||
createdAt: v.string(),
|
||||
expiresAt: v.optional(v.string()),
|
||||
token: v.optional(v.string()),
|
||||
}).index("token", ["token"]),
|
||||
});
|
||||
@@ -90,6 +90,7 @@
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"archiver": "^7.0.1",
|
||||
"better-sqlite3": "^12.6.2",
|
||||
"convex": "^1.31.6",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.19",
|
||||
"dotenv": "^17.2.3",
|
||||
|
||||
299
pnpm-lock.yaml
generated
299
pnpm-lock.yaml
generated
@@ -136,6 +136,9 @@ importers:
|
||||
better-sqlite3:
|
||||
specifier: ^12.6.2
|
||||
version: 12.6.2
|
||||
convex:
|
||||
specifier: ^1.31.6
|
||||
version: 1.31.6
|
||||
crypto-js:
|
||||
specifier: ^4.2.0
|
||||
version: 4.2.0
|
||||
@@ -214,6 +217,12 @@ packages:
|
||||
cpu: [ppc64]
|
||||
os: [aix]
|
||||
|
||||
'@esbuild/aix-ppc64@0.27.0':
|
||||
resolution: {integrity: sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [aix]
|
||||
|
||||
'@esbuild/android-arm64@0.18.20':
|
||||
resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -226,6 +235,12 @@ packages:
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-arm@0.18.20':
|
||||
resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -238,6 +253,12 @@ packages:
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-arm@0.27.0':
|
||||
resolution: {integrity: sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-x64@0.18.20':
|
||||
resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -250,6 +271,12 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-x64@0.27.0':
|
||||
resolution: {integrity: sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/darwin-arm64@0.18.20':
|
||||
resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -262,6 +289,12 @@ packages:
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/darwin-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/darwin-x64@0.18.20':
|
||||
resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -274,6 +307,12 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/darwin-x64@0.27.0':
|
||||
resolution: {integrity: sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/freebsd-arm64@0.18.20':
|
||||
resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -286,6 +325,12 @@ packages:
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/freebsd-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/freebsd-x64@0.18.20':
|
||||
resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -298,6 +343,12 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/freebsd-x64@0.27.0':
|
||||
resolution: {integrity: sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/linux-arm64@0.18.20':
|
||||
resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -310,6 +361,12 @@ packages:
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-arm@0.18.20':
|
||||
resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -322,6 +379,12 @@ packages:
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-arm@0.27.0':
|
||||
resolution: {integrity: sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ia32@0.18.20':
|
||||
resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -334,6 +397,12 @@ packages:
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ia32@0.27.0':
|
||||
resolution: {integrity: sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-loong64@0.18.20':
|
||||
resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -346,6 +415,12 @@ packages:
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-loong64@0.27.0':
|
||||
resolution: {integrity: sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-mips64el@0.18.20':
|
||||
resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -358,6 +433,12 @@ packages:
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-mips64el@0.27.0':
|
||||
resolution: {integrity: sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ppc64@0.18.20':
|
||||
resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -370,6 +451,12 @@ packages:
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ppc64@0.27.0':
|
||||
resolution: {integrity: sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-riscv64@0.18.20':
|
||||
resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -382,6 +469,12 @@ packages:
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-riscv64@0.27.0':
|
||||
resolution: {integrity: sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-s390x@0.18.20':
|
||||
resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -394,6 +487,12 @@ packages:
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-s390x@0.27.0':
|
||||
resolution: {integrity: sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-x64@0.18.20':
|
||||
resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -406,12 +505,24 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-x64@0.27.0':
|
||||
resolution: {integrity: sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/netbsd-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/netbsd-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/netbsd-x64@0.18.20':
|
||||
resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -424,12 +535,24 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/netbsd-x64@0.27.0':
|
||||
resolution: {integrity: sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/openbsd-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openbsd-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openbsd-x64@0.18.20':
|
||||
resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -442,12 +565,24 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openbsd-x64@0.27.0':
|
||||
resolution: {integrity: sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openharmony-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@esbuild/openharmony-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@esbuild/sunos-x64@0.18.20':
|
||||
resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -460,6 +595,12 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
|
||||
'@esbuild/sunos-x64@0.27.0':
|
||||
resolution: {integrity: sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
|
||||
'@esbuild/win32-arm64@0.18.20':
|
||||
resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -472,6 +613,12 @@ packages:
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-arm64@0.27.0':
|
||||
resolution: {integrity: sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-ia32@0.18.20':
|
||||
resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -484,6 +631,12 @@ packages:
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-ia32@0.27.0':
|
||||
resolution: {integrity: sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-x64@0.18.20':
|
||||
resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -496,6 +649,12 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-x64@0.27.0':
|
||||
resolution: {integrity: sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@ioredis/commands@1.5.0':
|
||||
resolution: {integrity: sha512-eUgLqrMf8nJkZxT24JvVRrQya1vZkQh8BBeYNwGDqa5I0VUi8ACx7uFvAaLxintokpTenkK6DASvo/bvNbBGow==}
|
||||
|
||||
@@ -886,6 +1045,22 @@ packages:
|
||||
concat-map@0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
|
||||
convex@1.31.6:
|
||||
resolution: {integrity: sha512-9cIsOzepa3s9DURRF+fZHxbNuzLgilg9XGQCc45v0Xx4FemqeIezpPFSJF9WHC9ckk43TDUUXLecvLVt9djPkw==}
|
||||
engines: {node: '>=18.0.0', npm: '>=7.0.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@auth0/auth0-react': ^2.0.1
|
||||
'@clerk/clerk-react': ^4.12.8 || ^5.0.0
|
||||
react: ^18.0.0 || ^19.0.0-0 || ^19.0.0
|
||||
peerDependenciesMeta:
|
||||
'@auth0/auth0-react':
|
||||
optional: true
|
||||
'@clerk/clerk-react':
|
||||
optional: true
|
||||
react:
|
||||
optional: true
|
||||
|
||||
cookie@0.4.2:
|
||||
resolution: {integrity: sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -1179,6 +1354,11 @@ packages:
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
esbuild@0.27.0:
|
||||
resolution: {integrity: sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
escape-html@1.0.3:
|
||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||
|
||||
@@ -1801,6 +1981,11 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
prettier@3.8.1:
|
||||
resolution: {integrity: sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
|
||||
process-nextick-args@2.0.1:
|
||||
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||
|
||||
@@ -2288,147 +2473,225 @@ snapshots:
|
||||
'@esbuild/aix-ppc64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/aix-ppc64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-arm64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-arm64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ia32@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ia32@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ia32@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-loong64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-loong64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-loong64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-mips64el@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-mips64el@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-mips64el@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ppc64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ppc64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ppc64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-riscv64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-riscv64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-riscv64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-s390x@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-s390x@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-s390x@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openharmony-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openharmony-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/sunos-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/sunos-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/sunos-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-arm64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-arm64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-ia32@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-ia32@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-ia32@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-x64@0.18.20':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-x64@0.27.0':
|
||||
optional: true
|
||||
|
||||
'@ioredis/commands@1.5.0': {}
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
@@ -2946,6 +3209,11 @@ snapshots:
|
||||
|
||||
concat-map@0.0.1: {}
|
||||
|
||||
convex@1.31.6:
|
||||
dependencies:
|
||||
esbuild: 0.27.0
|
||||
prettier: 3.8.1
|
||||
|
||||
cookie@0.4.2: {}
|
||||
|
||||
cookie@1.1.1: {}
|
||||
@@ -3171,6 +3439,35 @@ snapshots:
|
||||
'@esbuild/win32-ia32': 0.25.12
|
||||
'@esbuild/win32-x64': 0.25.12
|
||||
|
||||
esbuild@0.27.0:
|
||||
optionalDependencies:
|
||||
'@esbuild/aix-ppc64': 0.27.0
|
||||
'@esbuild/android-arm': 0.27.0
|
||||
'@esbuild/android-arm64': 0.27.0
|
||||
'@esbuild/android-x64': 0.27.0
|
||||
'@esbuild/darwin-arm64': 0.27.0
|
||||
'@esbuild/darwin-x64': 0.27.0
|
||||
'@esbuild/freebsd-arm64': 0.27.0
|
||||
'@esbuild/freebsd-x64': 0.27.0
|
||||
'@esbuild/linux-arm': 0.27.0
|
||||
'@esbuild/linux-arm64': 0.27.0
|
||||
'@esbuild/linux-ia32': 0.27.0
|
||||
'@esbuild/linux-loong64': 0.27.0
|
||||
'@esbuild/linux-mips64el': 0.27.0
|
||||
'@esbuild/linux-ppc64': 0.27.0
|
||||
'@esbuild/linux-riscv64': 0.27.0
|
||||
'@esbuild/linux-s390x': 0.27.0
|
||||
'@esbuild/linux-x64': 0.27.0
|
||||
'@esbuild/netbsd-arm64': 0.27.0
|
||||
'@esbuild/netbsd-x64': 0.27.0
|
||||
'@esbuild/openbsd-arm64': 0.27.0
|
||||
'@esbuild/openbsd-x64': 0.27.0
|
||||
'@esbuild/openharmony-arm64': 0.27.0
|
||||
'@esbuild/sunos-x64': 0.27.0
|
||||
'@esbuild/win32-arm64': 0.27.0
|
||||
'@esbuild/win32-ia32': 0.27.0
|
||||
'@esbuild/win32-x64': 0.27.0
|
||||
|
||||
escape-html@1.0.3: {}
|
||||
|
||||
escape-string-regexp@4.0.0: {}
|
||||
@@ -3836,6 +4133,8 @@ snapshots:
|
||||
tar-fs: 2.1.4
|
||||
tunnel-agent: 0.6.0
|
||||
|
||||
prettier@3.8.1: {}
|
||||
|
||||
process-nextick-args@2.0.1: {}
|
||||
|
||||
process@0.11.10: {}
|
||||
|
||||
@@ -253,7 +253,6 @@ export const kvContainer = pgTable("kv_container", {
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
uid: uuid(),
|
||||
publish: json().default({}),
|
||||
tags: json().default([]),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
hash: text().default(''),
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
import './list.ts';
|
||||
@@ -1,108 +0,0 @@
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { app } from '../../app.ts';
|
||||
import { ContainerModel, ContainerData, Container } from './models/index.ts';
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'container',
|
||||
key: 'list',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const list = await ContainerModel.findAll({
|
||||
order: [['updatedAt', 'DESC']],
|
||||
where: {
|
||||
uid: tokenUser.id,
|
||||
},
|
||||
attributes: { exclude: ['code'] },
|
||||
});
|
||||
ctx.body = list;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'container',
|
||||
key: 'get',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
const container = await ContainerModel.findByPk(id);
|
||||
if (!container) {
|
||||
throw new CustomError('container not found');
|
||||
}
|
||||
if (container.uid !== tokenUser.id) {
|
||||
throw new CustomError('container not found');
|
||||
}
|
||||
ctx.body = container;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'container',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const data = ctx.query.data;
|
||||
const { id, ...container } = data;
|
||||
let containerModel: ContainerModel | null = null;
|
||||
if (id) {
|
||||
containerModel = await ContainerModel.findByPk(id);
|
||||
if (containerModel) {
|
||||
containerModel.update({
|
||||
...container,
|
||||
publish: {
|
||||
...containerModel.publish,
|
||||
...container.publish,
|
||||
},
|
||||
});
|
||||
await containerModel.save();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
containerModel = await ContainerModel.create({
|
||||
...container,
|
||||
uid: tokenUser.id,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
}
|
||||
console.log('containerModel', container);
|
||||
}
|
||||
ctx.body = containerModel;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'container',
|
||||
key: 'delete',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
const container = await ContainerModel.findByPk(id);
|
||||
if (!container) {
|
||||
throw new CustomError('container not found');
|
||||
}
|
||||
if (container.uid !== tokenUser.id) {
|
||||
throw new CustomError('container not found');
|
||||
}
|
||||
await container.destroy();
|
||||
ctx.body = container;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -1,101 +0,0 @@
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
import crypto from 'crypto';
|
||||
export interface ContainerData {}
|
||||
export type ContainerPublish = {
|
||||
key: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
fileName?: string;
|
||||
version?: string;
|
||||
};
|
||||
export type Container = Partial<InstanceType<typeof ContainerModel>>;
|
||||
|
||||
/**
|
||||
* 用户代码容器
|
||||
*/
|
||||
export class ContainerModel extends Model {
|
||||
declare id: string;
|
||||
// 标题
|
||||
declare title: string;
|
||||
// 描述
|
||||
declare description: string;
|
||||
// 类型
|
||||
declare type: string;
|
||||
// 标签
|
||||
declare tags: string[];
|
||||
// 代码
|
||||
declare code: string;
|
||||
// hash 值
|
||||
declare hash: string;
|
||||
// 数据
|
||||
declare data: ContainerData;
|
||||
// 发布
|
||||
declare publish: ContainerPublish;
|
||||
// 用户 id
|
||||
declare uid: string;
|
||||
declare updatedAt: Date;
|
||||
declare createdAt: Date;
|
||||
createHash() {
|
||||
const { code } = this;
|
||||
const hash = crypto.createHash('md5');
|
||||
hash.update(code);
|
||||
this.hash = hash.digest('hex');
|
||||
}
|
||||
}
|
||||
ContainerModel.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: [],
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING, // 代码类型, html, js, render-js
|
||||
defaultValue: 'render-js',
|
||||
},
|
||||
code: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
hash: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
publish: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'kv_container',
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
// ContainerModel.sync({ alter: true, logging: false }).catch((e) => {
|
||||
// console.error('ContainerModel sync', e);
|
||||
// });
|
||||
@@ -1,11 +0,0 @@
|
||||
import { ContainerModel } from '../models/index.ts';
|
||||
|
||||
export const getContainerById = async (id: string) => {
|
||||
const container = await ContainerModel.findByPk(id);
|
||||
const code = container?.code;
|
||||
return {
|
||||
code,
|
||||
id: container?.id,
|
||||
updatedAt: new Date(container?.updatedAt).getTime(),
|
||||
};
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
import { ContainerData } from './models/index.ts';
|
||||
|
||||
export { ContainerData };
|
||||
@@ -1,3 +0,0 @@
|
||||
import './list.ts'
|
||||
|
||||
import './publish.ts'
|
||||
@@ -1,312 +0,0 @@
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { app } from '../../app.ts';
|
||||
import { PageModel } from './models/index.ts';
|
||||
import { nanoid, customAlphabet } from 'nanoid'
|
||||
import { ContainerModel } from '../container/models/index.ts';
|
||||
import { Op } from 'sequelize';
|
||||
import { getDeck } from './module/cache-file.ts';
|
||||
export const clearBlank = (newStyle: any) => {
|
||||
for (let key in newStyle) {
|
||||
if (newStyle[key] === '' || newStyle[key] === undefined || newStyle[key] === null) {
|
||||
delete newStyle[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
const uuidv4 = () => {
|
||||
const alphabet = '0123456789abcdef';
|
||||
const nanoidCustom = customAlphabet(alphabet, 36);
|
||||
return nanoidCustom();
|
||||
}
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'get',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
try {
|
||||
const page = await PageModel.findByPk(id);
|
||||
ctx.body = page;
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw new CustomError(e.message || 'get error');
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'list',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
ctx.body = await PageModel.findAll({
|
||||
order: [['updatedAt', 'DESC']],
|
||||
where: {
|
||||
uid: tokenUser.id,
|
||||
},
|
||||
});
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { data, id, publish, ...rest } = ctx.query.data;
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
let needUpdate = { ...rest };
|
||||
if (data) {
|
||||
needUpdate = { ...needUpdate, data };
|
||||
}
|
||||
if (publish) {
|
||||
needUpdate = { ...needUpdate, publish };
|
||||
}
|
||||
|
||||
if (id) {
|
||||
const page = await PageModel.findByPk(id);
|
||||
// if (!page?.publish && publish) {
|
||||
// needUpdate = { ...needUpdate, publish };
|
||||
// }
|
||||
if (page) {
|
||||
const newPage = await page.update({ ...needUpdate });
|
||||
ctx.body = newPage;
|
||||
} else {
|
||||
throw new CustomError('page not found');
|
||||
}
|
||||
} else if (data) {
|
||||
const page = await PageModel.create({ ...needUpdate, uid: tokenUser.id });
|
||||
ctx.body = page;
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
app
|
||||
.route('page', 'updateNode')
|
||||
.define(async (ctx) => {
|
||||
const { id, nodeData } = ctx.query.data;
|
||||
const force = ctx.query.force;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
const page = await PageModel.findByPk(id);
|
||||
if (!page) {
|
||||
throw new CustomError('page not found');
|
||||
}
|
||||
const { data } = page;
|
||||
const { nodes = [] } = data;
|
||||
let flag = false;
|
||||
const newNodes = nodes.map((item) => {
|
||||
const nodeItem = nodeData;
|
||||
if (item.id === nodeItem.id) {
|
||||
flag = true;
|
||||
const { data, ...rest } = nodeItem;
|
||||
const { style, ...restData } = data || {};
|
||||
let newStyle = force ? { ...style } : { ...item?.data?.style, ...style };
|
||||
clearBlank(newStyle);
|
||||
console.log('newStyle', newStyle);
|
||||
const newNodeItem = {
|
||||
...item,
|
||||
...rest,
|
||||
data: {
|
||||
...item?.data,
|
||||
...restData,
|
||||
style: newStyle,
|
||||
},
|
||||
};
|
||||
console.log('newNodeItem', newNodeItem);
|
||||
return newNodeItem;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
if (!flag) {
|
||||
newNodes.push(nodeData);
|
||||
}
|
||||
const newData = { ...data, nodes: newNodes };
|
||||
const newPage = await page.update({ data: newData });
|
||||
ctx.body = newPage;
|
||||
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'delete',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const id = ctx.query.id;
|
||||
const page = await PageModel.findByPk(id);
|
||||
if (page) {
|
||||
await page.destroy();
|
||||
}
|
||||
ctx.body = page;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'addDemo',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const id = uuidv4();
|
||||
const data = {
|
||||
// id: 'container-1',
|
||||
id,
|
||||
title: 'demo',
|
||||
description: 'demo',
|
||||
type: 'conainer',
|
||||
data: {
|
||||
edges: [
|
||||
{
|
||||
id: 'e1',
|
||||
// source: 'container-1',
|
||||
source: id,
|
||||
target: 'container-2',
|
||||
},
|
||||
{
|
||||
id: 'e2',
|
||||
// source: 'container-1',
|
||||
source: id,
|
||||
target: 'container-3',
|
||||
},
|
||||
{
|
||||
id: 'e3',
|
||||
source: 'container-2',
|
||||
target: 'container-4',
|
||||
},
|
||||
],
|
||||
nodes: [
|
||||
{
|
||||
// id: 'container-1',
|
||||
id,
|
||||
type: 'container',
|
||||
data: {
|
||||
label: '开始',
|
||||
title: 'demo-hello-world',
|
||||
cid: 'a6652ce0-82fb-432a-a6b0-2033a655b02c',
|
||||
root: true,
|
||||
style: {
|
||||
border: '1px solid black',
|
||||
},
|
||||
},
|
||||
position: {
|
||||
x: 50,
|
||||
y: 125,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'container-2',
|
||||
type: 'container',
|
||||
data: {
|
||||
label: '容器',
|
||||
title: 'demo-child-01',
|
||||
cid: '67e5b2ff-98dc-43ab-8ad9-9b062096f8eb',
|
||||
style: {
|
||||
color: 'green',
|
||||
position: 'absolute',
|
||||
border: '1px solid black',
|
||||
top: '100px',
|
||||
left: '100px',
|
||||
width: '200px',
|
||||
height: '200px',
|
||||
},
|
||||
shadowRoot: true,
|
||||
},
|
||||
position: {
|
||||
x: 350,
|
||||
y: 125,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'container-3',
|
||||
type: 'container',
|
||||
data: {
|
||||
label: '容器',
|
||||
title: 'demo-child-03',
|
||||
cid: '208c3e36-dc7d-46af-b2f0-81d5f43c974d',
|
||||
style: {
|
||||
color: 'green',
|
||||
position: 'absolute',
|
||||
border: '1px solid green',
|
||||
top: '100px',
|
||||
left: '100px',
|
||||
width: '200px',
|
||||
height: '200px',
|
||||
},
|
||||
},
|
||||
position: {
|
||||
x: 350,
|
||||
y: 325,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'container-4',
|
||||
type: 'container',
|
||||
data: {
|
||||
label: '容器',
|
||||
title: 'demo-child-04',
|
||||
cid: '170c0b55-8c13-4d6e-bf35-3f935d979a0d',
|
||||
style: {
|
||||
color: 'green',
|
||||
position: 'absolute',
|
||||
border: '1px solid green',
|
||||
top: '100px',
|
||||
left: '400px',
|
||||
width: '200px',
|
||||
height: '200px',
|
||||
},
|
||||
},
|
||||
position: {
|
||||
x: 650,
|
||||
y: 125,
|
||||
},
|
||||
},
|
||||
],
|
||||
viewport: {},
|
||||
},
|
||||
};
|
||||
try {
|
||||
const page = await PageModel.create(data);
|
||||
ctx.body = page;
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw new CustomError('addDemo error');
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'getDeck',
|
||||
})
|
||||
.define<any>(async (ctx) => {
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
|
||||
try {
|
||||
const page = await PageModel.findByPk(id);
|
||||
if (!page) {
|
||||
throw new CustomError(404, 'panel not found');
|
||||
}
|
||||
const pageData = await getDeck(page);
|
||||
ctx.body = pageData;
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw new CustomError(e.message || 'get error');
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -1,88 +0,0 @@
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
|
||||
type PageNodeData = {
|
||||
id: string;
|
||||
type: string;
|
||||
data: {
|
||||
label?: string; // 容器 开始 结束
|
||||
root?: boolean; // 是否是根节点
|
||||
|
||||
// 容器上的属性
|
||||
cid?: string; // 容器id
|
||||
style?: { [key: string]: string };
|
||||
className?: string;
|
||||
showChild?: boolean;
|
||||
shadowRoot?: boolean;
|
||||
};
|
||||
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export interface PageData {
|
||||
edges: any[];
|
||||
nodes: PageNodeData[];
|
||||
viewport: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
export type Publish = {
|
||||
id?: string; // resource id
|
||||
description?: string;
|
||||
key?: string;
|
||||
version?: string;
|
||||
};
|
||||
/**
|
||||
* 页面数据
|
||||
*/
|
||||
export class PageModel extends Model {
|
||||
declare id: string;
|
||||
declare title: string;
|
||||
declare description: string;
|
||||
declare type: string;
|
||||
declare data: PageData;
|
||||
declare publish: Publish;
|
||||
declare uid: string;
|
||||
}
|
||||
PageModel.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
publish: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'kv_page',
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
// PageModel.sync({ alter: true, logging: false }).catch((e) => {
|
||||
// console.error('PageModel sync', e);
|
||||
// });
|
||||
@@ -1,193 +0,0 @@
|
||||
import { useFileStore } from '@kevisual/use-config';
|
||||
import { PageModel } from '../models/index.ts';
|
||||
import { ContainerModel } from '@/old-apps/container/models/index.ts';
|
||||
import { Op } from 'sequelize';
|
||||
import { getContainerData } from './get-container.ts';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { getHTML, getDataJs, getOneHTML } from './file-template.ts';
|
||||
import { minioClient } from '@/app.ts';
|
||||
import { bucketName } from '@/modules/minio.ts';
|
||||
import { getContentType } from '@/utils/get-content-type.ts';
|
||||
import archiver from 'archiver';
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export const cacheFile = useFileStore('cache-file', {
|
||||
needExists: true,
|
||||
});
|
||||
|
||||
export const getDeck = async (page: PageModel) => {
|
||||
const { data } = page;
|
||||
const { nodes = [], edges } = data;
|
||||
const containerList = nodes
|
||||
.map((item) => {
|
||||
const { data } = item;
|
||||
return data?.cid;
|
||||
})
|
||||
.filter((item) => item);
|
||||
const quchong = Array.from(new Set(containerList));
|
||||
const containers = await ContainerModel.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: quchong,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const pageData = {
|
||||
page,
|
||||
containerList: containers,
|
||||
};
|
||||
return pageData;
|
||||
};
|
||||
|
||||
export const cachePage = async (page: PageModel, opts: { tokenUser: any; key; version }) => {
|
||||
const _result = await getDeck(page);
|
||||
const result = getContainerData(_result);
|
||||
const key = 'data-' + nanoid(6);
|
||||
const html = getHTML({ rootId: page.id, title: page?.publish?.key, dataKey: key });
|
||||
const dataJs = getDataJs(result);
|
||||
const htmlPath = path.resolve(cacheFile, `${page.id}.html`);
|
||||
const dataJsPath = path.resolve(cacheFile, `${page.id}.js`);
|
||||
fs.writeFileSync(htmlPath, html);
|
||||
fs.writeFileSync(dataJsPath, dataJs);
|
||||
const minioHTML = await uploadMinio({ ...opts, path: `index.html`, filePath: htmlPath });
|
||||
const minioData = await uploadMinio({ ...opts, path: `${key || 'data'}.js`, filePath: dataJsPath });
|
||||
return [
|
||||
{
|
||||
name: 'index.html',
|
||||
path: minioHTML,
|
||||
},
|
||||
{
|
||||
name: `${key || 'data'}.js`,
|
||||
path: minioData,
|
||||
},
|
||||
];
|
||||
};
|
||||
export const uploadMinioContainer = async ({ tokenUser, key, version, code, filePath, saveHTML }) => {
|
||||
if ((filePath as string).includes('..')) {
|
||||
throw new CustomError('file path is invalid');
|
||||
}
|
||||
const uploadFiles = [];
|
||||
const minioKeyVersion = `${tokenUser.username}/${key}/${version}`;
|
||||
const minioPath = path.join(minioKeyVersion, filePath);
|
||||
const minioFileName = path.basename(minioPath);
|
||||
if (!minioFileName.endsWith('.js')) {
|
||||
saveHTML = false;
|
||||
}
|
||||
console.log('minioPath', minioPath);
|
||||
// const isHTML = filePath.endsWith('.html');
|
||||
const name = minioPath.replace(minioKeyVersion + '/', '');
|
||||
await minioClient.putObject(bucketName, minioPath, code, code.length, {
|
||||
'Content-Type': getContentType(filePath),
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': 'no-cache', // no-cache
|
||||
});
|
||||
uploadFiles.push({
|
||||
name,
|
||||
path: minioPath,
|
||||
});
|
||||
if (saveHTML) {
|
||||
const htmlPath = minioPath.replace('.js', '.html');
|
||||
const code = getOneHTML({ title: 'Kevisual', file: minioFileName.replace('.js', '') });
|
||||
await minioClient.putObject(bucketName, htmlPath, code, code.length, {
|
||||
'Content-Type': 'text/html',
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': 'max-age=31536000, immutable',
|
||||
});
|
||||
uploadFiles.push({
|
||||
name: 'index.html',
|
||||
path: htmlPath,
|
||||
});
|
||||
}
|
||||
return uploadFiles;
|
||||
};
|
||||
export const uploadMinio = async ({ tokenUser, key, version, path, filePath }) => {
|
||||
const minioPath = `${tokenUser.username}/${key}/${version}/${path}`;
|
||||
const isHTML = filePath.endsWith('.html');
|
||||
await minioClient.fPutObject(bucketName, minioPath, filePath, {
|
||||
'Content-Type': getContentType(filePath),
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': isHTML ? 'no-cache' : 'max-age=31536000, immutable', // 缓存一年
|
||||
});
|
||||
fs.unlinkSync(filePath); // 删除临时文件
|
||||
return minioPath;
|
||||
};
|
||||
export const uploadMinioTemp = async ({ tokenUser, filePath, path }) => {
|
||||
const minioPath = `${tokenUser.username}/temp/${path}`;
|
||||
const isHTML = filePath.endsWith('.html');
|
||||
await minioClient.fPutObject(bucketName, minioPath, filePath, {
|
||||
'Content-Type': getContentType(filePath),
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': isHTML ? 'no-cache' : 'max-age=31536000, immutable', // 缓存一年
|
||||
});
|
||||
fs.unlinkSync(filePath); // 删除临时文件
|
||||
return minioPath;
|
||||
};
|
||||
export const getZip = async (page: PageModel, opts: { tokenUser: any }) => {
|
||||
const _result = await getDeck(page);
|
||||
const result = getContainerData(_result);
|
||||
const html = getHTML({ rootId: page.id, title: page?.publish?.key });
|
||||
const dataJs = getDataJs(result);
|
||||
const zip = archiver('zip', {
|
||||
zlib: { level: 9 },
|
||||
});
|
||||
// 创建 zip 文件的输出流
|
||||
const zipCache = path.join(cacheFile, `${page.id}.zip`);
|
||||
if (checkFileExistsSync(zipCache)) {
|
||||
throw new CustomError('page is on uploading');
|
||||
}
|
||||
return await new Promise((resolve, reject) => {
|
||||
const output = fs.createWriteStream(zipCache);
|
||||
// 监听事件
|
||||
output.on('close', async () => {
|
||||
console.log(`Zip file has been created successfully. Total size: ${zip.pointer()} bytes.`);
|
||||
let time = (new Date().getTime() / 1000).toFixed(0);
|
||||
const name = page.title || page.id;
|
||||
const minioPath = await uploadMinioTemp({ ...opts, filePath: zipCache, path: `${name + '-' + time}.zip` });
|
||||
resolve(minioPath);
|
||||
});
|
||||
|
||||
output.on('end', () => {
|
||||
console.log('Data has been drained.'); // 数据已被耗尽
|
||||
throw new CustomError('Data has been drained.');
|
||||
});
|
||||
|
||||
zip.on('warning', (err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
console.warn('File not found:', err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
zip.on('error', (err) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// 通过管道将 zip 数据流输出到指定文件
|
||||
zip.pipe(output);
|
||||
|
||||
// 添加 HTML 字符串作为文件到 zip 中
|
||||
zip.append(html, { name: 'index.html' });
|
||||
|
||||
// 添加 JavaScript 字符串作为文件到 zip 中
|
||||
zip.append(dataJs, { name: 'data.js' });
|
||||
zip.append(JSON.stringify(page), { name: 'app.config.json' });
|
||||
// 可以继续添加更多内容,文件或目录等
|
||||
// zip.append('Another content', { name: 'other.txt' });
|
||||
|
||||
// 结束归档(必须调用,否则 zip 文件无法完成)
|
||||
zip.finalize();
|
||||
});
|
||||
};
|
||||
export const checkFileExistsSync = (filePath: string) => {
|
||||
try {
|
||||
// 使用 F_OK 检查文件或目录是否存在
|
||||
fs.accessSync(filePath, fs.constants.F_OK);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -1,102 +0,0 @@
|
||||
type HTMLOptions = {
|
||||
title?: string;
|
||||
rootId: string;
|
||||
dataKey?: string;
|
||||
};
|
||||
/**
|
||||
* data list
|
||||
* @param opts
|
||||
* @returns
|
||||
*/
|
||||
export const getHTML = (opts: HTMLOptions) => {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${opts.title || 'Kevisual'}</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
<script src="https://kevisual.xiongxiao.me/system/lib/app.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import { Container } from 'https://kevisual.xiongxiao.me/root/container/index.js'
|
||||
import { data } from './${opts.dataKey || 'data'}.js'
|
||||
const container = new Container({
|
||||
root: 'root',
|
||||
data: data
|
||||
});
|
||||
container.render('${opts.rootId}');
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>`;
|
||||
};
|
||||
|
||||
export const getDataJs = (result: any) => {
|
||||
return 'export const data=' + JSON.stringify(result);
|
||||
};
|
||||
|
||||
type OneHTMLOptions = {
|
||||
title?: string;
|
||||
file: string;
|
||||
}
|
||||
/**
|
||||
* one data
|
||||
* @param opts
|
||||
* @returns
|
||||
*/
|
||||
export const getOneHTML = (opts: OneHTMLOptions) => {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" href="https://envision.xiongxiao.me/resources/root/avatar.png"/>
|
||||
<title>${opts.title || 'Kevisual'}</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
<script src="https://kevisual.xiongxiao.me/system/lib/app.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import { ContainerOne } from 'https://kevisual.xiongxiao.me/system/lib/container.js'
|
||||
import { render, unmount } from './${opts.file}.js'
|
||||
const container = new ContainerOne({
|
||||
root: '#root',
|
||||
});
|
||||
container.renderOne({
|
||||
code: {render, unmount}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>`;
|
||||
};
|
||||
@@ -1,143 +0,0 @@
|
||||
// import { RenderData } from '@abearxiong/container';
|
||||
type RenderData = any;
|
||||
|
||||
type Page = {
|
||||
data: {
|
||||
edges: { id: string; source: string; target: string }[];
|
||||
nodes: { id: string; type: string; position: { x: number; y: number }; data: any }[];
|
||||
};
|
||||
id: string;
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
type Container = {
|
||||
code: string;
|
||||
id: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
type PageEditData = {
|
||||
page: Page;
|
||||
containerList: Container[];
|
||||
};
|
||||
export const getContainerData = (pageEditData: any) => {
|
||||
const { page, containerList } = pageEditData;
|
||||
const containerObj = containerList.reduce((acc, container) => {
|
||||
acc[container.id] = container;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const { edges, nodes } = page.data;
|
||||
const nodesObj = nodes.reduce((acc, node) => {
|
||||
acc[node.id] = node;
|
||||
return acc;
|
||||
}, {});
|
||||
const treeArray = getTreeFromEdges(edges);
|
||||
const floatNodes = nodes.filter((node) => !treeArray.find((item) => item.id === node.id));
|
||||
const treeNodes = nodes.filter((node) => treeArray.find((item) => item.id === node.id));
|
||||
const renderData: RenderData[] = [];
|
||||
for (let tree of treeArray) {
|
||||
const node = nodesObj[tree.id];
|
||||
const container = containerObj[node.data?.cid];
|
||||
const style = node.data?.style ?? {
|
||||
position: 'absolute',
|
||||
width: 100,
|
||||
height: 100,
|
||||
};
|
||||
const data = {
|
||||
node: { ...node },
|
||||
container: { ...container },
|
||||
};
|
||||
renderData.push({
|
||||
id: node.id,
|
||||
children: tree.children,
|
||||
parents: tree.parents,
|
||||
code: container?.code || '',
|
||||
codeId: container?.id,
|
||||
data: data || {},
|
||||
className: node.data?.className,
|
||||
shadowRoot: node.data?.shadowRoot,
|
||||
showChild: node.data?.showChild,
|
||||
style,
|
||||
});
|
||||
}
|
||||
for (let node of floatNodes) {
|
||||
const container = containerObj[node.data?.cid];
|
||||
const style = node.data?.style ?? {
|
||||
position: 'absolute',
|
||||
width: 100,
|
||||
height: 100,
|
||||
};
|
||||
const data = {
|
||||
node: { ...node },
|
||||
container: { ...container },
|
||||
};
|
||||
renderData.push({
|
||||
id: node.id,
|
||||
children: [],
|
||||
parents: [],
|
||||
code: container?.code || '',
|
||||
codeId: container?.id,
|
||||
data: data || {},
|
||||
className: node.data?.className,
|
||||
shadowRoot: node.data?.shadowRoot,
|
||||
showChild: node.data?.showChild,
|
||||
style,
|
||||
});
|
||||
}
|
||||
return renderData;
|
||||
};
|
||||
const getTreeFromEdges = (
|
||||
edges: { id: string; source: string; target: string }[],
|
||||
): {
|
||||
id: string;
|
||||
parents: string[];
|
||||
children: string[];
|
||||
}[] => {
|
||||
// 构建树形结构
|
||||
function buildNodeTree(edges) {
|
||||
const nodeMap = {};
|
||||
|
||||
// 初始化每个节点的子节点列表和父节点列表
|
||||
edges.forEach((edge) => {
|
||||
if (!nodeMap[edge.source]) {
|
||||
nodeMap[edge.source] = { id: edge.source, parents: [], children: [] };
|
||||
}
|
||||
if (!nodeMap[edge.target]) {
|
||||
nodeMap[edge.target] = { id: edge.target, parents: [], children: [] };
|
||||
}
|
||||
|
||||
// 连接父节点和子节点
|
||||
nodeMap[edge.source].children.push(nodeMap[edge.target]);
|
||||
nodeMap[edge.target].parents.push(nodeMap[edge.source]);
|
||||
});
|
||||
|
||||
return nodeMap;
|
||||
}
|
||||
|
||||
const nodeTree = buildNodeTree(edges);
|
||||
|
||||
// 递归获取所有父节点,按顺序
|
||||
function getAllParents(node) {
|
||||
const parents: string[] = [];
|
||||
function traverseParents(currentNode) {
|
||||
if (currentNode.parents.length > 0) {
|
||||
currentNode.parents.forEach((parent: any) => {
|
||||
parents.push(parent.id);
|
||||
traverseParents(parent);
|
||||
});
|
||||
}
|
||||
}
|
||||
traverseParents(node);
|
||||
return parents.reverse(); // 确保顺序从最顶层到直接父节点
|
||||
}
|
||||
|
||||
function getNodeInfo(nodeMap) {
|
||||
return Object.values(nodeMap).map((node: any) => ({
|
||||
id: node.id,
|
||||
parents: getAllParents(node),
|
||||
children: node.children.map((child) => child.id),
|
||||
}));
|
||||
}
|
||||
const result = getNodeInfo(nodeTree);
|
||||
return result;
|
||||
};
|
||||
@@ -1,89 +0,0 @@
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { app } from '../../app.ts';
|
||||
import { PageModel } from './models/index.ts';
|
||||
import { AppListModel, AppModel } from '../../routes/app-manager/index.ts';
|
||||
import { cachePage, getZip } from './module/cache-file.ts';
|
||||
import { uniqBy } from 'es-toolkit';
|
||||
import semver from 'semver';
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'publish',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { data, id, publish, ...rest } = ctx.query.data;
|
||||
let needUpdate = { ...rest };
|
||||
if (data) {
|
||||
needUpdate = { ...needUpdate, data };
|
||||
}
|
||||
if (publish) {
|
||||
needUpdate = { ...needUpdate, publish };
|
||||
}
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
const page = await PageModel.findByPk(id);
|
||||
if (!page) {
|
||||
throw new CustomError('page not found');
|
||||
}
|
||||
await page.update(needUpdate);
|
||||
|
||||
const _publish = page.publish || {};
|
||||
if (!_publish.key) {
|
||||
throw new CustomError('publish key is required');
|
||||
}
|
||||
try {
|
||||
const { key, description } = _publish;
|
||||
const version = _publish.version || '0.0.0';
|
||||
let app = await AppModel.findOne({ where: { key, uid: tokenUser.id } });
|
||||
if (!app) {
|
||||
app = await AppModel.create({ title: key, key, uid: tokenUser.id, description, user: tokenUser.username });
|
||||
}
|
||||
const _version = semver.inc(version, 'patch');
|
||||
let appList = await AppListModel.findOne({ where: { key, version: _version, uid: tokenUser.id } });
|
||||
if (!appList) {
|
||||
appList = await AppListModel.create({ key, version: _version, uid: tokenUser.id, data: {} });
|
||||
}
|
||||
// 上传文件
|
||||
const res = await cachePage(page, { tokenUser, key, version: _version });
|
||||
const appFiles = appList?.data?.files || [];
|
||||
const newFiles = uniqBy([...appFiles, ...res], (item) => item.name);
|
||||
appList.data = {
|
||||
...appList?.data,
|
||||
files: newFiles,
|
||||
};
|
||||
await appList.save();
|
||||
await page.update({ publish: { ..._publish, id: app.id, version: _version } });
|
||||
ctx.body = page;
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw new CustomError(e.message || 'publish error');
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'page',
|
||||
key: 'download',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id } = ctx.query;
|
||||
const page = await PageModel.findByPk(id);
|
||||
if (!page) {
|
||||
throw new CustomError('page not found');
|
||||
}
|
||||
try {
|
||||
const files = await getZip(page, { tokenUser });
|
||||
ctx.body = files;
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw new CustomError(e.message || 'download error');
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -7,7 +7,6 @@ import { app, minioClient } from '@/app.ts';
|
||||
import { bucketName } from '@/modules/minio.ts';
|
||||
import { getContentType } from '@/utils/get-content-type.ts';
|
||||
import { User } from '@/models/user.ts';
|
||||
import { getContainerById } from '@/old-apps/container/module/get-container-file.ts';
|
||||
import { router, error, checkAuth, writeEvents } from './router.ts';
|
||||
import './index.ts';
|
||||
import { handleRequest as PageProxy } from './page-proxy.ts';
|
||||
@@ -190,30 +189,6 @@ router.post('/api/app/upload', async (req, res) => {
|
||||
pipeBusboy(req, res, busboy);
|
||||
});
|
||||
|
||||
router.get('/api/container/file/:id', async (req, res) => {
|
||||
const id = req.params.id;
|
||||
if (!id) {
|
||||
res.end(error('id is required'));
|
||||
return;
|
||||
}
|
||||
const container = await getContainerById(id);
|
||||
if (container.id) {
|
||||
const code = container.code;
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/javascript; charset=utf-8',
|
||||
'container-id': container.id,
|
||||
});
|
||||
res.end(code);
|
||||
} else {
|
||||
res.end(error('Container not found'));
|
||||
}
|
||||
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
res.end(JSON.stringify(container));
|
||||
});
|
||||
|
||||
router.all('/api/nocodb-test/router', async (req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import './config/index.ts';
|
||||
|
||||
// import './file-listener/index.ts';
|
||||
|
||||
import './light-code/index.ts';
|
||||
|
||||
import './ai/index.ts';
|
||||
|
||||
|
||||
1
src/routes/light-code/index.ts
Normal file
1
src/routes/light-code/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
import './list.ts'
|
||||
151
src/routes/light-code/list.ts
Normal file
151
src/routes/light-code/list.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
import { eq, desc, and, like, or } from 'drizzle-orm';
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { app, db, schema } from '../../app.ts';
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'light-code',
|
||||
key: 'list',
|
||||
description: `获取轻代码列表,参数
|
||||
type: 代码类型light-code, ts`,
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { type, search } = ctx.query || {};
|
||||
const conditions = [eq(schema.kvContainer.uid, tokenUser.id)];
|
||||
if (type) {
|
||||
conditions.push(eq(schema.kvContainer.type, type as string));
|
||||
}
|
||||
if (search) {
|
||||
const searchTerm = `%${search}%`;
|
||||
conditions.push(
|
||||
or(
|
||||
like(schema.kvContainer.title, searchTerm),
|
||||
like(schema.kvContainer.description, searchTerm),
|
||||
),
|
||||
);
|
||||
}
|
||||
const list = await db
|
||||
.select({
|
||||
id: schema.kvContainer.id,
|
||||
title: schema.kvContainer.title,
|
||||
description: schema.kvContainer.description,
|
||||
type: schema.kvContainer.type,
|
||||
tags: schema.kvContainer.tags,
|
||||
data: schema.kvContainer.data,
|
||||
uid: schema.kvContainer.uid,
|
||||
createdAt: schema.kvContainer.createdAt,
|
||||
updatedAt: schema.kvContainer.updatedAt,
|
||||
hash: schema.kvContainer.hash,
|
||||
})
|
||||
.from(schema.kvContainer)
|
||||
.where(and(...conditions))
|
||||
.orderBy(desc(schema.kvContainer.updatedAt));
|
||||
ctx.body = list;
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'light-code',
|
||||
key: 'get',
|
||||
description: '获取轻代码详情',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
const result = await db
|
||||
.select()
|
||||
.from(schema.kvContainer)
|
||||
.where(eq(schema.kvContainer.id, id))
|
||||
.limit(1);
|
||||
const container = result[0];
|
||||
if (!container) {
|
||||
ctx.throw('未发现该代码内容');
|
||||
}
|
||||
if (container.uid !== tokenUser.id) {
|
||||
ctx.throw('没有权限访问该代码内容');
|
||||
}
|
||||
ctx.body = container;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'light-code',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const data = ctx.query.data;
|
||||
const { id, ...container } = data;
|
||||
if (id) {
|
||||
const result = await db
|
||||
.select()
|
||||
.from(schema.kvContainer)
|
||||
.where(eq(schema.kvContainer.id, id))
|
||||
.limit(1);
|
||||
const existing = result[0];
|
||||
if (existing) {
|
||||
await db
|
||||
.update(schema.kvContainer)
|
||||
.set({
|
||||
...container,
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
.where(eq(schema.kvContainer.id, id));
|
||||
const updated = await db
|
||||
.select()
|
||||
.from(schema.kvContainer)
|
||||
.where(eq(schema.kvContainer.id, id))
|
||||
.limit(1);
|
||||
ctx.body = updated[0];
|
||||
} else {
|
||||
ctx.body = null;
|
||||
}
|
||||
} else {
|
||||
const [created] = await db
|
||||
.insert(schema.kvContainer)
|
||||
.values({
|
||||
...container,
|
||||
uid: tokenUser.id,
|
||||
})
|
||||
.returning();
|
||||
ctx.body = created;
|
||||
}
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'container',
|
||||
key: 'delete',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
const result = await db
|
||||
.select()
|
||||
.from(schema.kvContainer)
|
||||
.where(eq(schema.kvContainer.id, id))
|
||||
.limit(1);
|
||||
const container = result[0];
|
||||
if (!container) {
|
||||
ctx.throw('未发现该容器');
|
||||
}
|
||||
if (container.uid !== tokenUser.id) {
|
||||
ctx.throw('没有权限访问该容器');
|
||||
}
|
||||
await db.delete(schema.kvContainer).where(eq(schema.kvContainer.id, id));
|
||||
ctx.body = container;
|
||||
})
|
||||
.addTo(app);
|
||||
Reference in New Issue
Block a user