tetrons 2.3.72 → 2.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/api/ai-action/route.cjs +9 -34
- package/dist/app/api/ai-action/route.d.mts +9 -0
- package/dist/app/api/ai-action/route.d.ts +9 -0
- package/dist/app/api/export/route.cjs +4 -29
- package/dist/app/api/export/route.d.mts +3 -0
- package/dist/app/api/export/route.d.ts +3 -0
- package/dist/app/api/register/route.cjs +14 -76
- package/dist/app/api/register/route.d.mts +10 -0
- package/dist/app/api/register/route.d.ts +10 -0
- package/dist/app/api/register/route.mjs +5 -32
- package/dist/app/api/save/route.cjs +13 -48
- package/dist/app/api/save/route.d.mts +9 -0
- package/dist/app/api/save/route.d.ts +9 -0
- package/dist/app/api/transcribe/route.cjs +12 -38
- package/dist/app/api/transcribe/route.d.mts +10 -0
- package/dist/app/api/transcribe/route.d.ts +10 -0
- package/dist/app/api/validate/route.cjs +14 -79
- package/dist/app/api/validate/route.d.mts +13 -0
- package/dist/app/api/validate/route.d.ts +13 -0
- package/dist/app/api/validate/route.mjs +5 -34
- package/dist/chunk-37LFEKRW.cjs +36 -0
- package/dist/chunk-M2F2EU6B.mjs +36 -0
- package/dist/components/tetrons/EditorContent.tsx +17 -5
- package/dist/{browser.browser.js → index.cjs} +525 -440
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/{node.node.mjs → index.mjs} +51 -68
- package/package.json +9 -19
- package/dist/browser.d.mts +0 -8
- package/dist/node.node.cjs +0 -17090
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/app/api/ai-action/route.ts
|
|
21
|
-
var route_exports = {};
|
|
22
|
-
__export(route_exports, {
|
|
23
|
-
POST: () => POST
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(route_exports);
|
|
26
|
-
var import_server = require("next/server");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/app/api/ai-action/route.ts
|
|
2
|
+
var _server = require('next/server');
|
|
27
3
|
async function POST(req) {
|
|
28
4
|
try {
|
|
29
5
|
const { content } = await req.json();
|
|
@@ -41,21 +17,20 @@ async function POST(req) {
|
|
|
41
17
|
});
|
|
42
18
|
const data = await response.json();
|
|
43
19
|
if (!response.ok) {
|
|
44
|
-
return
|
|
20
|
+
return _server.NextResponse.json({ error: data.error.message }, { status: 500 });
|
|
45
21
|
}
|
|
46
|
-
return
|
|
22
|
+
return _server.NextResponse.json({ response: data.choices[0].message.content });
|
|
47
23
|
} catch (error) {
|
|
48
24
|
console.error("AI generation error:", error);
|
|
49
25
|
if (error instanceof Error) {
|
|
50
|
-
return
|
|
26
|
+
return _server.NextResponse.json({ error: error.message }, { status: 500 });
|
|
51
27
|
}
|
|
52
|
-
return
|
|
28
|
+
return _server.NextResponse.json(
|
|
53
29
|
{ error: "Unknown error occurred." },
|
|
54
30
|
{ status: 500 }
|
|
55
31
|
);
|
|
56
32
|
}
|
|
57
33
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.POST = POST;
|
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/app/api/export/route.ts
|
|
21
|
-
var route_exports = {};
|
|
22
|
-
__export(route_exports, {
|
|
23
|
-
GET: () => GET
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(route_exports);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/app/api/export/route.ts
|
|
26
2
|
function GET(req) {
|
|
27
3
|
console.log(req.method);
|
|
28
4
|
return new Response("Hello, world!", { status: 200 });
|
|
29
5
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.GET = GET;
|
|
@@ -1,74 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
2
|
|
|
30
|
-
// src/app/api/register/route.ts
|
|
31
|
-
var route_exports = {};
|
|
32
|
-
__export(route_exports, {
|
|
33
|
-
POST: () => POST
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(route_exports);
|
|
36
|
-
var import_server = require("next/server");
|
|
37
3
|
|
|
38
|
-
|
|
39
|
-
var import_mongoose = __toESM(require("mongoose"));
|
|
40
|
-
var MONGO_URL = process.env.MONGO_URL;
|
|
41
|
-
var connectDB = async () => {
|
|
42
|
-
if (import_mongoose.default.connection.readyState >= 1) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
await import_mongoose.default.connect(MONGO_URL);
|
|
47
|
-
console.log("Connected to MongoDB \u{1F44D}");
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error("MongoDB connection failed \u274C", error);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
4
|
+
var _chunk37LFEKRWcjs = require('../../../chunk-37LFEKRW.cjs');
|
|
53
5
|
|
|
54
|
-
// src/
|
|
55
|
-
var
|
|
56
|
-
var ApiKeySchema = new import_mongoose2.default.Schema({
|
|
57
|
-
email: { type: String, required: true },
|
|
58
|
-
organization: { type: String, required: true },
|
|
59
|
-
version: {
|
|
60
|
-
type: String,
|
|
61
|
-
enum: ["free", "pro", "premium", "platinum"],
|
|
62
|
-
required: true
|
|
63
|
-
},
|
|
64
|
-
apiKey: { type: String, required: true, unique: true },
|
|
65
|
-
createdAt: { type: Date, default: Date.now },
|
|
66
|
-
expiresAt: { type: Date }
|
|
67
|
-
});
|
|
68
|
-
var ApiKey = import_mongoose2.default.models.ApiKey || import_mongoose2.default.model("ApiKey", ApiKeySchema);
|
|
6
|
+
// src/app/api/register/route.ts
|
|
7
|
+
var _server = require('next/server');
|
|
69
8
|
|
|
70
9
|
// src/utils/apiKeyUtils.ts
|
|
71
|
-
var
|
|
10
|
+
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
72
11
|
var FREE_API_KEY = process.env.TETRONS_FREE_KEY || "TETRONS_FREE_KEY";
|
|
73
12
|
var SECRET_KEY = process.env.API_KEY_SECRET || "default-secret-key";
|
|
74
13
|
function getFreeApiKey() {
|
|
@@ -81,7 +20,7 @@ var VERSION_PREFIXES = {
|
|
|
81
20
|
};
|
|
82
21
|
function generateUserApiKey(email, organization, version) {
|
|
83
22
|
const input = `${email.trim().toLowerCase()}:${organization.trim().toLowerCase()}`;
|
|
84
|
-
const hash =
|
|
23
|
+
const hash = _crypto2.default.createHmac("sha256", SECRET_KEY).update(input).digest("hex").toUpperCase();
|
|
85
24
|
const prefix = VERSION_PREFIXES[version];
|
|
86
25
|
return `${prefix}${hash.slice(0, 48 - prefix.length)}`;
|
|
87
26
|
}
|
|
@@ -91,12 +30,12 @@ async function POST(req) {
|
|
|
91
30
|
const body = await req.json();
|
|
92
31
|
const { email, organization, version } = body;
|
|
93
32
|
if (!email || !organization || !version) {
|
|
94
|
-
return
|
|
33
|
+
return _server.NextResponse.json({ error: "Missing fields" }, { status: 400 });
|
|
95
34
|
}
|
|
96
|
-
await connectDB();
|
|
35
|
+
await _chunk37LFEKRWcjs.connectDB.call(void 0, );
|
|
97
36
|
const lowerEmail = email.trim().toLowerCase();
|
|
98
37
|
const lowerOrg = organization.trim().toLowerCase();
|
|
99
|
-
await ApiKey.deleteMany({ email: lowerEmail, version });
|
|
38
|
+
await _chunk37LFEKRWcjs.ApiKey.deleteMany({ email: lowerEmail, version });
|
|
100
39
|
let apiKey;
|
|
101
40
|
let expiresAt = null;
|
|
102
41
|
if (version === "free") {
|
|
@@ -105,16 +44,15 @@ async function POST(req) {
|
|
|
105
44
|
} else {
|
|
106
45
|
apiKey = generateUserApiKey(lowerEmail, lowerOrg, version);
|
|
107
46
|
}
|
|
108
|
-
await ApiKey.create({
|
|
47
|
+
await _chunk37LFEKRWcjs.ApiKey.create({
|
|
109
48
|
email: lowerEmail,
|
|
110
49
|
organization: lowerOrg,
|
|
111
50
|
version,
|
|
112
51
|
apiKey,
|
|
113
52
|
expiresAt
|
|
114
53
|
});
|
|
115
|
-
return
|
|
54
|
+
return _server.NextResponse.json({ apiKey, expiresAt });
|
|
116
55
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
exports.POST = POST;
|
|
@@ -1,38 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiKey,
|
|
3
|
+
connectDB
|
|
4
|
+
} from "../../../chunk-M2F2EU6B.mjs";
|
|
5
|
+
|
|
1
6
|
// src/app/api/register/route.ts
|
|
2
7
|
import { NextResponse } from "next/server";
|
|
3
8
|
|
|
4
|
-
// src/lib/db.js
|
|
5
|
-
import mongoose from "mongoose";
|
|
6
|
-
var MONGO_URL = process.env.MONGO_URL;
|
|
7
|
-
var connectDB = async () => {
|
|
8
|
-
if (mongoose.connection.readyState >= 1) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
await mongoose.connect(MONGO_URL);
|
|
13
|
-
console.log("Connected to MongoDB \u{1F44D}");
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.error("MongoDB connection failed \u274C", error);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// src/models/ApiKey.ts
|
|
21
|
-
import mongoose2 from "mongoose";
|
|
22
|
-
var ApiKeySchema = new mongoose2.Schema({
|
|
23
|
-
email: { type: String, required: true },
|
|
24
|
-
organization: { type: String, required: true },
|
|
25
|
-
version: {
|
|
26
|
-
type: String,
|
|
27
|
-
enum: ["free", "pro", "premium", "platinum"],
|
|
28
|
-
required: true
|
|
29
|
-
},
|
|
30
|
-
apiKey: { type: String, required: true, unique: true },
|
|
31
|
-
createdAt: { type: Date, default: Date.now },
|
|
32
|
-
expiresAt: { type: Date }
|
|
33
|
-
});
|
|
34
|
-
var ApiKey = mongoose2.models.ApiKey || mongoose2.model("ApiKey", ApiKeySchema);
|
|
35
|
-
|
|
36
9
|
// src/utils/apiKeyUtils.ts
|
|
37
10
|
import crypto from "crypto";
|
|
38
11
|
var FREE_API_KEY = process.env.TETRONS_FREE_KEY || "TETRONS_FREE_KEY";
|
|
@@ -1,53 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/app/api/save/route.ts
|
|
31
|
-
var route_exports = {};
|
|
32
|
-
__export(route_exports, {
|
|
33
|
-
POST: () => POST
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(route_exports);
|
|
36
|
-
var import_server = require("next/server");
|
|
37
|
-
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/app/api/save/route.ts
|
|
2
|
+
var _server = require('next/server');
|
|
3
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
4
|
+
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
|
|
39
5
|
async function POST(request) {
|
|
40
6
|
try {
|
|
41
7
|
const json = await request.json();
|
|
42
|
-
const publicDir =
|
|
43
|
-
const filePath =
|
|
44
|
-
await
|
|
45
|
-
return
|
|
46
|
-
} catch {
|
|
47
|
-
return
|
|
8
|
+
const publicDir = _path2.default.join(process.cwd(), "public");
|
|
9
|
+
const filePath = _path2.default.join(publicDir, "editor-content.json");
|
|
10
|
+
await _promises2.default.writeFile(filePath, JSON.stringify(json, null, 2), "utf-8");
|
|
11
|
+
return _server.NextResponse.json({ message: "File saved successfully" });
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return _server.NextResponse.json({ error: "Failed to save file" }, { status: 500 });
|
|
48
14
|
}
|
|
49
15
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.POST = POST;
|
|
@@ -1,37 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/app/api/transcribe/route.ts
|
|
21
|
-
var route_exports = {};
|
|
22
|
-
__export(route_exports, {
|
|
23
|
-
POST: () => POST,
|
|
24
|
-
runtime: () => runtime
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(route_exports);
|
|
27
|
-
var import_server = require("next/server");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/app/api/transcribe/route.ts
|
|
2
|
+
var _server = require('next/server');
|
|
28
3
|
var runtime = "edge";
|
|
29
4
|
async function POST(req) {
|
|
30
5
|
try {
|
|
31
6
|
const formData = await req.formData();
|
|
32
7
|
const file = formData.get("file");
|
|
33
8
|
if (!file) {
|
|
34
|
-
return
|
|
9
|
+
return _server.NextResponse.json({ error: "No file uploaded" }, { status: 400 });
|
|
35
10
|
}
|
|
36
11
|
const arrayBuffer = await file.arrayBuffer();
|
|
37
12
|
const buffer = Buffer.from(arrayBuffer);
|
|
@@ -47,26 +22,25 @@ async function POST(req) {
|
|
|
47
22
|
{
|
|
48
23
|
method: "POST",
|
|
49
24
|
headers: {
|
|
50
|
-
Authorization: `Bearer ${process.env.OPENAI_API_KEY
|
|
25
|
+
Authorization: `Bearer ${_nullishCoalesce(process.env.OPENAI_API_KEY, () => ( ""))}`
|
|
51
26
|
},
|
|
52
27
|
body: whisperFormData
|
|
53
28
|
}
|
|
54
29
|
);
|
|
55
30
|
const result = await whisperRes.json();
|
|
56
31
|
if (!whisperRes.ok) {
|
|
57
|
-
return
|
|
58
|
-
{ error: result
|
|
32
|
+
return _server.NextResponse.json(
|
|
33
|
+
{ error: _optionalChain([result, 'optionalAccess', _ => _.error, 'optionalAccess', _2 => _2.message]) || "Transcription failed" },
|
|
59
34
|
{ status: 500 }
|
|
60
35
|
);
|
|
61
36
|
}
|
|
62
|
-
return
|
|
37
|
+
return _server.NextResponse.json({ transcript: result.text });
|
|
63
38
|
} catch (error) {
|
|
64
39
|
const message = error instanceof Error ? error.message : "Unknown server error";
|
|
65
|
-
return
|
|
40
|
+
return _server.NextResponse.json({ error: message }, { status: 500 });
|
|
66
41
|
}
|
|
67
42
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports.POST = POST; exports.runtime = runtime;
|
|
@@ -1,74 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
29
2
|
|
|
30
|
-
// src/app/api/validate/route.ts
|
|
31
|
-
var route_exports = {};
|
|
32
|
-
__export(route_exports, {
|
|
33
|
-
OPTIONS: () => OPTIONS,
|
|
34
|
-
POST: () => POST
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(route_exports);
|
|
37
|
-
var import_server = require("next/server");
|
|
38
|
-
|
|
39
|
-
// src/lib/db.js
|
|
40
|
-
var import_mongoose = __toESM(require("mongoose"));
|
|
41
|
-
var MONGO_URL = process.env.MONGO_URL;
|
|
42
|
-
var connectDB = async () => {
|
|
43
|
-
if (import_mongoose.default.connection.readyState >= 1) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
await import_mongoose.default.connect(MONGO_URL);
|
|
48
|
-
console.log("Connected to MongoDB \u{1F44D}");
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error("MongoDB connection failed \u274C", error);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
3
|
|
|
55
|
-
|
|
56
|
-
var import_mongoose2 = __toESM(require("mongoose"));
|
|
57
|
-
var ApiKeySchema = new import_mongoose2.default.Schema({
|
|
58
|
-
email: { type: String, required: true },
|
|
59
|
-
organization: { type: String, required: true },
|
|
60
|
-
version: {
|
|
61
|
-
type: String,
|
|
62
|
-
enum: ["free", "pro", "premium", "platinum"],
|
|
63
|
-
required: true
|
|
64
|
-
},
|
|
65
|
-
apiKey: { type: String, required: true, unique: true },
|
|
66
|
-
createdAt: { type: Date, default: Date.now },
|
|
67
|
-
expiresAt: { type: Date }
|
|
68
|
-
});
|
|
69
|
-
var ApiKey = import_mongoose2.default.models.ApiKey || import_mongoose2.default.model("ApiKey", ApiKeySchema);
|
|
4
|
+
var _chunk37LFEKRWcjs = require('../../../chunk-37LFEKRW.cjs');
|
|
70
5
|
|
|
71
6
|
// src/app/api/validate/route.ts
|
|
7
|
+
var _server = require('next/server');
|
|
72
8
|
var corsHeaders = {
|
|
73
9
|
"Access-Control-Allow-Origin": "*",
|
|
74
10
|
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
@@ -85,7 +21,7 @@ async function POST(req) {
|
|
|
85
21
|
const body = await req.json();
|
|
86
22
|
const apiKey = body.apiKey;
|
|
87
23
|
if (!apiKey) {
|
|
88
|
-
return
|
|
24
|
+
return _server.NextResponse.json(
|
|
89
25
|
{ error: "API key required" },
|
|
90
26
|
{
|
|
91
27
|
status: 400,
|
|
@@ -93,10 +29,10 @@ async function POST(req) {
|
|
|
93
29
|
}
|
|
94
30
|
);
|
|
95
31
|
}
|
|
96
|
-
await connectDB();
|
|
97
|
-
const keyEntry = await ApiKey.findOne({ apiKey });
|
|
32
|
+
await _chunk37LFEKRWcjs.connectDB.call(void 0, );
|
|
33
|
+
const keyEntry = await _chunk37LFEKRWcjs.ApiKey.findOne({ apiKey });
|
|
98
34
|
if (!keyEntry) {
|
|
99
|
-
return
|
|
35
|
+
return _server.NextResponse.json(
|
|
100
36
|
{ error: "Invalid API key" },
|
|
101
37
|
{
|
|
102
38
|
status: 401,
|
|
@@ -105,7 +41,7 @@ async function POST(req) {
|
|
|
105
41
|
);
|
|
106
42
|
}
|
|
107
43
|
if (keyEntry.version === "free" && keyEntry.expiresAt && /* @__PURE__ */ new Date() > new Date(keyEntry.expiresAt)) {
|
|
108
|
-
return
|
|
44
|
+
return _server.NextResponse.json(
|
|
109
45
|
{ error: "Free trial expired" },
|
|
110
46
|
{
|
|
111
47
|
status: 403,
|
|
@@ -113,7 +49,7 @@ async function POST(req) {
|
|
|
113
49
|
}
|
|
114
50
|
);
|
|
115
51
|
}
|
|
116
|
-
return
|
|
52
|
+
return _server.NextResponse.json(
|
|
117
53
|
{
|
|
118
54
|
valid: true,
|
|
119
55
|
version: keyEntry.version,
|
|
@@ -127,7 +63,7 @@ async function POST(req) {
|
|
|
127
63
|
);
|
|
128
64
|
} catch (err) {
|
|
129
65
|
console.error("Validation Error:", err);
|
|
130
|
-
return
|
|
66
|
+
return _server.NextResponse.json(
|
|
131
67
|
{ error: "Server error" },
|
|
132
68
|
{
|
|
133
69
|
status: 500,
|
|
@@ -136,8 +72,7 @@ async function POST(req) {
|
|
|
136
72
|
);
|
|
137
73
|
}
|
|
138
74
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
exports.OPTIONS = OPTIONS; exports.POST = POST;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
declare function OPTIONS(): Promise<Response>;
|
|
4
|
+
declare function POST(req: NextRequest): Promise<NextResponse<{
|
|
5
|
+
error: string;
|
|
6
|
+
}> | NextResponse<{
|
|
7
|
+
valid: boolean;
|
|
8
|
+
version: any;
|
|
9
|
+
email: any;
|
|
10
|
+
organization: any;
|
|
11
|
+
}>>;
|
|
12
|
+
|
|
13
|
+
export { OPTIONS, POST };
|