@akanjs/devkit 0.0.89 → 0.0.91

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.
Files changed (68) hide show
  1. package/index.js +21 -1
  2. package/index.mjs +1 -0
  3. package/package.json +5 -4
  4. package/src/aiEditor.d.ts +14 -0
  5. package/src/aiEditor.js +110 -21
  6. package/src/aiEditor.mjs +124 -0
  7. package/src/auth.js +48 -18
  8. package/src/auth.mjs +42 -0
  9. package/src/capacitorApp.js +42 -9
  10. package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
  11. package/src/commandDecorators/argMeta.js +34 -3
  12. package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
  13. package/src/commandDecorators/command.js +68 -35
  14. package/src/commandDecorators/{command.cjs → command.mjs} +35 -68
  15. package/src/commandDecorators/commandMeta.js +25 -2
  16. package/src/commandDecorators/commandMeta.mjs +7 -0
  17. package/src/commandDecorators/index.js +29 -5
  18. package/src/commandDecorators/index.mjs +5 -0
  19. package/src/commandDecorators/targetMeta.js +26 -2
  20. package/src/commandDecorators/targetMeta.mjs +33 -0
  21. package/src/commandDecorators/types.js +15 -0
  22. package/src/commandDecorators/types.mjs +0 -0
  23. package/src/constants.d.ts +8 -1
  24. package/src/constants.js +34 -5
  25. package/src/constants.mjs +18 -0
  26. package/src/createTunnel.js +27 -4
  27. package/src/createTunnel.mjs +26 -0
  28. package/src/dependencyScanner.js +38 -5
  29. package/src/{dependencyScanner.cjs → dependencyScanner.mjs} +5 -38
  30. package/src/executors.d.ts +21 -1
  31. package/src/executors.js +172 -84
  32. package/src/{executors.cjs → executors.mjs} +138 -118
  33. package/src/extractDeps.js +25 -2
  34. package/src/{extractDeps.cjs → extractDeps.mjs} +2 -25
  35. package/src/getCredentials.js +39 -6
  36. package/src/getCredentials.mjs +11 -0
  37. package/src/getModelFileData.js +39 -6
  38. package/src/getModelFileData.mjs +33 -0
  39. package/src/getRelatedCnsts.d.ts +52 -8
  40. package/src/getRelatedCnsts.js +205 -54
  41. package/src/getRelatedCnsts.mjs +221 -0
  42. package/src/index.js +51 -16
  43. package/src/index.mjs +16 -0
  44. package/src/selectModel.js +39 -6
  45. package/src/selectModel.mjs +13 -0
  46. package/src/streamAi.js +30 -7
  47. package/src/streamAi.mjs +39 -0
  48. package/src/types.js +15 -0
  49. package/src/types.mjs +0 -0
  50. package/src/uploadRelease.js +48 -15
  51. package/src/uploadRelease.mjs +52 -0
  52. package/index.cjs +0 -21
  53. package/src/aiEditor.cjs +0 -92
  54. package/src/auth.cjs +0 -72
  55. package/src/commandDecorators/commandMeta.cjs +0 -30
  56. package/src/commandDecorators/index.cjs +0 -29
  57. package/src/commandDecorators/targetMeta.cjs +0 -57
  58. package/src/commandDecorators/types.cjs +0 -15
  59. package/src/constants.cjs +0 -47
  60. package/src/createTunnel.cjs +0 -49
  61. package/src/getCredentials.cjs +0 -44
  62. package/src/getModelFileData.cjs +0 -66
  63. package/src/getRelatedCnsts.cjs +0 -142
  64. package/src/index.cjs +0 -51
  65. package/src/selectModel.cjs +0 -46
  66. package/src/streamAi.cjs +0 -62
  67. package/src/types.cjs +0 -15
  68. package/src/uploadRelease.cjs +0 -85
@@ -0,0 +1,221 @@
1
+ import * as fs from "fs";
2
+ import ora from "ora";
3
+ import * as ts from "typescript";
4
+ const parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
5
+ const configFile = ts.readConfigFile(tsConfigPath, (path) => {
6
+ return ts.sys.readFile(path);
7
+ });
8
+ return ts.parseJsonConfigFileContent(
9
+ configFile.config,
10
+ ts.sys,
11
+ fs.realpathSync(tsConfigPath).replace(/[^/\\]+$/, "")
12
+ );
13
+ };
14
+ const collectImportedFiles = (constantFilePath, parsedConfig) => {
15
+ const allFilesToAnalyze = /* @__PURE__ */ new Set([constantFilePath]);
16
+ const analyzedFiles = /* @__PURE__ */ new Set();
17
+ const spinner = ora("Collecting related files...");
18
+ spinner.start();
19
+ function collectImported(filePath) {
20
+ if (analyzedFiles.has(filePath))
21
+ return;
22
+ analyzedFiles.add(filePath);
23
+ const tempProgram = ts.createProgram([filePath], parsedConfig.options);
24
+ const source = tempProgram.getSourceFile(filePath);
25
+ if (!source)
26
+ return;
27
+ function collectImports(node) {
28
+ if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
29
+ const importPath = node.moduleSpecifier.text;
30
+ if (importPath.startsWith(".")) {
31
+ const resolved = ts.resolveModuleName(importPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
32
+ if (resolved && !allFilesToAnalyze.has(resolved)) {
33
+ allFilesToAnalyze.add(resolved);
34
+ collectImported(resolved);
35
+ }
36
+ }
37
+ }
38
+ ts.forEachChild(node, collectImports);
39
+ }
40
+ collectImports(source);
41
+ }
42
+ collectImported(constantFilePath);
43
+ spinner.succeed(`Found ${allFilesToAnalyze.size} related files.`);
44
+ return {
45
+ allFilesToAnalyze,
46
+ analyzedFiles
47
+ };
48
+ };
49
+ const collectExportedFiles = (constantFilePath, parsedConfig) => {
50
+ const allFilesToAnalyze = /* @__PURE__ */ new Set([constantFilePath]);
51
+ const analyzedFiles = /* @__PURE__ */ new Set();
52
+ const spinner = ora("Collecting files from exports...");
53
+ spinner.start();
54
+ function collectExported(filePath) {
55
+ if (analyzedFiles.has(filePath))
56
+ return;
57
+ analyzedFiles.add(filePath);
58
+ const tempProgram = ts.createProgram([filePath], parsedConfig.options);
59
+ const source = tempProgram.getSourceFile(filePath);
60
+ if (!source)
61
+ return;
62
+ function collectExports(node) {
63
+ if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier) && !node.exportClause) {
64
+ const exportPath = node.moduleSpecifier.text;
65
+ if (exportPath.startsWith(".")) {
66
+ const resolved = ts.resolveModuleName(exportPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
67
+ if (resolved && !allFilesToAnalyze.has(resolved)) {
68
+ allFilesToAnalyze.add(resolved);
69
+ collectExported(resolved);
70
+ }
71
+ }
72
+ } else if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
73
+ const exportPath = node.moduleSpecifier.text;
74
+ if (exportPath.startsWith(".")) {
75
+ const resolved = ts.resolveModuleName(exportPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
76
+ if (resolved && !allFilesToAnalyze.has(resolved)) {
77
+ allFilesToAnalyze.add(resolved);
78
+ collectExported(resolved);
79
+ }
80
+ }
81
+ } else if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
82
+ const importPath = node.moduleSpecifier.text;
83
+ if (importPath.startsWith(".")) {
84
+ const resolved = ts.resolveModuleName(importPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
85
+ if (resolved && !allFilesToAnalyze.has(resolved)) {
86
+ allFilesToAnalyze.add(resolved);
87
+ collectExported(resolved);
88
+ }
89
+ }
90
+ }
91
+ if ((ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) && node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
92
+ }
93
+ ts.forEachChild(node, collectExports);
94
+ }
95
+ collectExports(source);
96
+ }
97
+ collectExported(constantFilePath);
98
+ spinner.succeed(`Found ${allFilesToAnalyze.size} related files from exports.`);
99
+ return {
100
+ allFilesToAnalyze,
101
+ analyzedFiles
102
+ };
103
+ };
104
+ const createTsProgram = (filePaths, options) => {
105
+ const spinner = ora("Creating TypeScript program for all files...");
106
+ spinner.start();
107
+ const program = ts.createProgram(Array.from(filePaths), options);
108
+ const checker = program.getTypeChecker();
109
+ spinner.succeed("TypeScript program created.");
110
+ return {
111
+ program,
112
+ checker
113
+ };
114
+ };
115
+ const createSymbolCache = (checker) => {
116
+ const symbolCache = /* @__PURE__ */ new Map();
117
+ return (node) => {
118
+ const cacheKey = `${node.getSourceFile().fileName}:${node.pos}:${node.end}`;
119
+ if (!symbolCache.has(cacheKey)) {
120
+ symbolCache.set(cacheKey, checker.getSymbolAtLocation(node));
121
+ }
122
+ return symbolCache.get(cacheKey);
123
+ };
124
+ };
125
+ const analyzeProperties = (filesToAnalyze, program, checker) => {
126
+ const propertyMap = /* @__PURE__ */ new Map();
127
+ const analyzedFiles = /* @__PURE__ */ new Set();
128
+ const sourceLineCache = /* @__PURE__ */ new Map();
129
+ const getCachedSymbol = createSymbolCache(checker);
130
+ const spinner = ora("Analyzing property relationships...");
131
+ spinner.start();
132
+ function analyzeFileProperties(filePath) {
133
+ if (analyzedFiles.has(filePath))
134
+ return;
135
+ analyzedFiles.add(filePath);
136
+ const source = program.getSourceFile(filePath);
137
+ if (!source)
138
+ return;
139
+ if (!sourceLineCache.has(filePath)) {
140
+ sourceLineCache.set(filePath, source.getFullText().split("\n"));
141
+ }
142
+ const sourceLines = sourceLineCache.get(filePath);
143
+ function visit(node) {
144
+ if (!source)
145
+ return;
146
+ if (ts.isPropertyAccessExpression(node)) {
147
+ const left = node.expression;
148
+ const right = node.name;
149
+ const { line } = ts.getLineAndCharacterOfPosition(source, node.getStart());
150
+ if (ts.isIdentifier(left) && sourceLines && sourceLines.length > line && (sourceLines[line].includes(`@Field.Prop(() => ${left.text}.${right.text}`) || sourceLines[line].includes(`base.Filter(${left.text}.${right.text},`))) {
151
+ const symbol = getCachedSymbol(right);
152
+ if (symbol?.declarations && symbol.declarations.length > 0) {
153
+ const key = symbol.declarations[0].getSourceFile().fileName.split("/").pop()?.split(".")[0] ?? "";
154
+ const property = propertyMap.get(key);
155
+ const isScalar = symbol.declarations[0].getSourceFile().fileName.includes("_");
156
+ const symbolFilePath = symbol.declarations[0].getSourceFile().fileName.replace(`${ts.sys.getCurrentDirectory()}/`, "");
157
+ if (property) {
158
+ propertyMap.set(`${left.text}.${right.text}`, {
159
+ filePath: symbolFilePath,
160
+ isLibModule: true,
161
+ isImport: false,
162
+ libName: left.text,
163
+ source: fs.readFileSync(symbolFilePath, "utf-8"),
164
+ isScalar
165
+ });
166
+ } else {
167
+ propertyMap.set(key, {
168
+ filePath: symbolFilePath,
169
+ isLibModule: true,
170
+ isImport: false,
171
+ libName: left.text,
172
+ isScalar,
173
+ source: fs.readFileSync(symbolFilePath, "utf-8")
174
+ });
175
+ }
176
+ }
177
+ }
178
+ } else if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
179
+ const importPath = node.moduleSpecifier.text;
180
+ if (importPath.startsWith(".")) {
181
+ const resolved = ts.resolveModuleName(importPath, filePath, program.getCompilerOptions(), ts.sys).resolvedModule?.resolvedFileName;
182
+ const moduleName = importPath.split("/").pop()?.split(".")[0] ?? "";
183
+ const property = propertyMap.get(moduleName);
184
+ const isScalar = importPath.includes("_");
185
+ if (moduleName && resolved && (!property || property.filePath !== resolved)) {
186
+ propertyMap.set(moduleName, {
187
+ filePath: resolved,
188
+ isLibModule: false,
189
+ isImport: true,
190
+ isScalar,
191
+ source: fs.readFileSync(resolved, "utf-8")
192
+ });
193
+ }
194
+ }
195
+ }
196
+ ts.forEachChild(node, visit);
197
+ }
198
+ visit(source);
199
+ }
200
+ for (const filePath of filesToAnalyze) {
201
+ analyzeFileProperties(filePath);
202
+ }
203
+ spinner.succeed(`Analysis complete. Found ${propertyMap.size} properties.`);
204
+ return propertyMap;
205
+ };
206
+ const getRelatedCnsts = (constantFilePath) => {
207
+ const parsedConfig = parseTsConfig();
208
+ const { allFilesToAnalyze } = collectImportedFiles(constantFilePath, parsedConfig);
209
+ const { program, checker } = createTsProgram(allFilesToAnalyze, parsedConfig.options);
210
+ const propertyMap = analyzeProperties(allFilesToAnalyze, program, checker);
211
+ return Array.from(propertyMap.entries()).map(([key, value]) => ({ key, ...value }));
212
+ };
213
+ export {
214
+ analyzeProperties,
215
+ collectExportedFiles,
216
+ collectImportedFiles,
217
+ createSymbolCache,
218
+ createTsProgram,
219
+ getRelatedCnsts,
220
+ parseTsConfig
221
+ };
package/src/index.js CHANGED
@@ -1,16 +1,51 @@
1
- export * from "./createTunnel";
2
- export * from "./getCredentials";
3
- export * from "./uploadRelease";
4
- export * from "./getModelFileData";
5
- export * from "./getRelatedCnsts";
6
- export * from "./selectModel";
7
- export * from "./streamAi";
8
- export * from "./executors";
9
- export * from "./dependencyScanner";
10
- export * from "./constants";
11
- export * from "./auth";
12
- export * from "./types";
13
- export * from "./capacitorApp";
14
- export * from "./extractDeps";
15
- export * from "./commandDecorators";
16
- export * from "./aiEditor";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./createTunnel"), module.exports);
18
+ __reExport(src_exports, require("./getCredentials"), module.exports);
19
+ __reExport(src_exports, require("./uploadRelease"), module.exports);
20
+ __reExport(src_exports, require("./getModelFileData"), module.exports);
21
+ __reExport(src_exports, require("./getRelatedCnsts"), module.exports);
22
+ __reExport(src_exports, require("./selectModel"), module.exports);
23
+ __reExport(src_exports, require("./streamAi"), module.exports);
24
+ __reExport(src_exports, require("./executors"), module.exports);
25
+ __reExport(src_exports, require("./dependencyScanner"), module.exports);
26
+ __reExport(src_exports, require("./constants"), module.exports);
27
+ __reExport(src_exports, require("./auth"), module.exports);
28
+ __reExport(src_exports, require("./types"), module.exports);
29
+ __reExport(src_exports, require("./capacitorApp"), module.exports);
30
+ __reExport(src_exports, require("./extractDeps"), module.exports);
31
+ __reExport(src_exports, require("./commandDecorators"), module.exports);
32
+ __reExport(src_exports, require("./aiEditor"), module.exports);
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ...require("./createTunnel"),
36
+ ...require("./getCredentials"),
37
+ ...require("./uploadRelease"),
38
+ ...require("./getModelFileData"),
39
+ ...require("./getRelatedCnsts"),
40
+ ...require("./selectModel"),
41
+ ...require("./streamAi"),
42
+ ...require("./executors"),
43
+ ...require("./dependencyScanner"),
44
+ ...require("./constants"),
45
+ ...require("./auth"),
46
+ ...require("./types"),
47
+ ...require("./capacitorApp"),
48
+ ...require("./extractDeps"),
49
+ ...require("./commandDecorators"),
50
+ ...require("./aiEditor")
51
+ });
package/src/index.mjs ADDED
@@ -0,0 +1,16 @@
1
+ export * from "./createTunnel";
2
+ export * from "./getCredentials";
3
+ export * from "./uploadRelease";
4
+ export * from "./getModelFileData";
5
+ export * from "./getRelatedCnsts";
6
+ export * from "./selectModel";
7
+ export * from "./streamAi";
8
+ export * from "./executors";
9
+ export * from "./dependencyScanner";
10
+ export * from "./constants";
11
+ export * from "./auth";
12
+ export * from "./types";
13
+ export * from "./capacitorApp";
14
+ export * from "./extractDeps";
15
+ export * from "./commandDecorators";
16
+ export * from "./aiEditor";
@@ -1,13 +1,46 @@
1
- import { select } from "@inquirer/prompts";
2
- import fs from "fs";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var selectModel_exports = {};
29
+ __export(selectModel_exports, {
30
+ selectModel: () => selectModel
31
+ });
32
+ module.exports = __toCommonJS(selectModel_exports);
33
+ var import_prompts = require("@inquirer/prompts");
34
+ var import_fs = __toESM(require("fs"));
3
35
  const selectModel = async (modulePath) => {
4
- const modelNames = fs.readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
5
- const modelName = await select({
36
+ const modelNames = import_fs.default.readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
37
+ const modelName = await (0, import_prompts.select)({
6
38
  message: "Select the model to create the unit for",
7
39
  choices: modelNames.map((name) => ({ name, value: name }))
8
40
  });
9
41
  return modelName;
10
42
  };
11
- export {
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
12
45
  selectModel
13
- };
46
+ });
@@ -0,0 +1,13 @@
1
+ import { select } from "@inquirer/prompts";
2
+ import fs from "fs";
3
+ const selectModel = async (modulePath) => {
4
+ const modelNames = fs.readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
5
+ const modelName = await select({
6
+ message: "Select the model to create the unit for",
7
+ choices: modelNames.map((name) => ({ name, value: name }))
8
+ });
9
+ return modelName;
10
+ };
11
+ export {
12
+ selectModel
13
+ };
package/src/streamAi.js CHANGED
@@ -1,13 +1,35 @@
1
- import { PromptTemplate } from "@langchain/core/prompts";
2
- import { RunnableSequence } from "@langchain/core/runnables";
3
- import { ChatOpenAI } from "@langchain/openai";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var streamAi_exports = {};
19
+ __export(streamAi_exports, {
20
+ streamAi: () => streamAi
21
+ });
22
+ module.exports = __toCommonJS(streamAi_exports);
23
+ var import_prompts = require("@langchain/core/prompts");
24
+ var import_runnables = require("@langchain/core/runnables");
25
+ var import_openai = require("@langchain/openai");
4
26
  const streamAi = async (question, callback = (chunk) => {
5
27
  process.stdout.write(chunk);
6
28
  }) => {
7
29
  const createStreamingModel = (apiKey = process.env.DEEPSEEK_API_KEY) => {
8
30
  if (!apiKey)
9
31
  throw new Error(`process.env.DEEPSEEK_API_KEY is not set`);
10
- return new ChatOpenAI({
32
+ return new import_openai.ChatOpenAI({
11
33
  modelName: "deepseek-reasoner",
12
34
  temperature: 0.7,
13
35
  streaming: true,
@@ -16,7 +38,7 @@ const streamAi = async (question, callback = (chunk) => {
16
38
  });
17
39
  };
18
40
  const createProcessingChain = () => {
19
- return RunnableSequence.from([PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
41
+ return import_runnables.RunnableSequence.from([import_prompts.PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
20
42
  };
21
43
  try {
22
44
  const chain = createProcessingChain();
@@ -34,6 +56,7 @@ const streamAi = async (question, callback = (chunk) => {
34
56
  throw new Error("Failed to stream response");
35
57
  }
36
58
  };
37
- export {
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
38
61
  streamAi
39
- };
62
+ });
@@ -0,0 +1,39 @@
1
+ import { PromptTemplate } from "@langchain/core/prompts";
2
+ import { RunnableSequence } from "@langchain/core/runnables";
3
+ import { ChatOpenAI } from "@langchain/openai";
4
+ const streamAi = async (question, callback = (chunk) => {
5
+ process.stdout.write(chunk);
6
+ }) => {
7
+ const createStreamingModel = (apiKey = process.env.DEEPSEEK_API_KEY) => {
8
+ if (!apiKey)
9
+ throw new Error(`process.env.DEEPSEEK_API_KEY is not set`);
10
+ return new ChatOpenAI({
11
+ modelName: "deepseek-reasoner",
12
+ temperature: 0.7,
13
+ streaming: true,
14
+ // Enable streaming
15
+ configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
16
+ });
17
+ };
18
+ const createProcessingChain = () => {
19
+ return RunnableSequence.from([PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
20
+ };
21
+ try {
22
+ const chain = createProcessingChain();
23
+ const stream = await chain.stream({ question });
24
+ let fullResponse = "";
25
+ for await (const chunk of stream) {
26
+ const content = chunk.content;
27
+ if (typeof content === "string") {
28
+ fullResponse += content;
29
+ callback(content);
30
+ }
31
+ }
32
+ return { content: fullResponse };
33
+ } catch (error) {
34
+ throw new Error("Failed to stream response");
35
+ }
36
+ };
37
+ export {
38
+ streamAi
39
+ };
package/src/types.js CHANGED
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
package/src/types.mjs ADDED
File without changes
@@ -1,6 +1,38 @@
1
- import axios from "axios";
2
- import FormData from "form-data";
3
- import fs from "fs";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var uploadRelease_exports = {};
29
+ __export(uploadRelease_exports, {
30
+ uploadRelease: () => uploadRelease
31
+ });
32
+ module.exports = __toCommonJS(uploadRelease_exports);
33
+ var import_axios = __toESM(require("axios"));
34
+ var import_form_data = __toESM(require("form-data"));
35
+ var import_fs = __toESM(require("fs"));
4
36
  const uploadRelease = async (projectName, {
5
37
  workspaceRoot,
6
38
  environment,
@@ -12,13 +44,13 @@ const uploadRelease = async (projectName, {
12
44
  const buildPath = `${workspaceRoot}/releases/builds/${projectName}-release.tar.gz`;
13
45
  const appBuildPath = `${workspaceRoot}/releases/builds/${projectName}-appBuild.zip`;
14
46
  const sourcePath = `${workspaceRoot}/releases/sources/${projectName}-source.tar.gz`;
15
- const formData = new FormData();
16
- const build = fs.readFileSync(buildPath);
17
- const source = fs.readFileSync(sourcePath);
18
- const appBuild = fs.readFileSync(appBuildPath);
19
- const buildStat = fs.statSync(buildPath);
20
- const sourceStat = fs.statSync(sourcePath);
21
- const appBuildStat = fs.statSync(appBuildPath);
47
+ const formData = new import_form_data.default();
48
+ const build = import_fs.default.readFileSync(buildPath);
49
+ const source = import_fs.default.readFileSync(sourcePath);
50
+ const appBuild = import_fs.default.readFileSync(appBuildPath);
51
+ const buildStat = import_fs.default.statSync(buildPath);
52
+ const sourceStat = import_fs.default.statSync(sourcePath);
53
+ const appBuildStat = import_fs.default.statSync(appBuildPath);
22
54
  formData.append("files", build, `${projectName}-release.tar.gz`);
23
55
  formData.append("files", source, `${projectName}-source.tar.gz`);
24
56
  formData.append("files", appBuild, `${projectName}-appBuild.zip`);
@@ -32,14 +64,14 @@ const uploadRelease = async (projectName, {
32
64
  );
33
65
  formData.append("type", "release");
34
66
  try {
35
- const [buildFile, sourceFile, appBuildFile] = (await axios.post(`${basePath}/file/addFilesRestApi`, formData)).data;
67
+ const [buildFile, sourceFile, appBuildFile] = (await import_axios.default.post(`${basePath}/file/addFilesRestApi`, formData)).data;
36
68
  const major = platformVersion ? parseInt(platformVersion.split(".")[0]) : 1;
37
69
  const minor = platformVersion ? parseInt(platformVersion.split(".")[1]) : 0;
38
70
  const patch = platformVersion ? parseInt(platformVersion.split(".")[2]) : 0;
39
- const latestRelease = await axios.get(
71
+ const latestRelease = await import_axios.default.get(
40
72
  `${basePath}/release/findVersionRelease?appName=${projectName}&branch=${environment}&major=${major}&minor=${minor}`
41
73
  );
42
- const release = (await axios.post(
74
+ const release = (await import_axios.default.post(
43
75
  `${basePath}/release/pushRelease/${projectName}/${environment}/${major}/${minor}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}`
44
76
  )).data;
45
77
  return release;
@@ -47,6 +79,7 @@ const uploadRelease = async (projectName, {
47
79
  return null;
48
80
  }
49
81
  };
50
- export {
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
51
84
  uploadRelease
52
- };
85
+ });
@@ -0,0 +1,52 @@
1
+ import axios from "axios";
2
+ import FormData from "form-data";
3
+ import fs from "fs";
4
+ const uploadRelease = async (projectName, {
5
+ workspaceRoot,
6
+ environment,
7
+ buildNum,
8
+ platformVersion,
9
+ local
10
+ }) => {
11
+ const basePath = local ? "http://localhost:8080/backend" : "https://akasys.akamir.com/backend";
12
+ const buildPath = `${workspaceRoot}/releases/builds/${projectName}-release.tar.gz`;
13
+ const appBuildPath = `${workspaceRoot}/releases/builds/${projectName}-appBuild.zip`;
14
+ const sourcePath = `${workspaceRoot}/releases/sources/${projectName}-source.tar.gz`;
15
+ const formData = new FormData();
16
+ const build = fs.readFileSync(buildPath);
17
+ const source = fs.readFileSync(sourcePath);
18
+ const appBuild = fs.readFileSync(appBuildPath);
19
+ const buildStat = fs.statSync(buildPath);
20
+ const sourceStat = fs.statSync(sourcePath);
21
+ const appBuildStat = fs.statSync(appBuildPath);
22
+ formData.append("files", build, `${projectName}-release.tar.gz`);
23
+ formData.append("files", source, `${projectName}-source.tar.gz`);
24
+ formData.append("files", appBuild, `${projectName}-appBuild.zip`);
25
+ formData.append(
26
+ "metas",
27
+ JSON.stringify([
28
+ { lastModifiedAt: buildStat.mtime, size: buildStat.size },
29
+ { lastModifiedAt: sourceStat.mtime, size: sourceStat.size },
30
+ { lastModifiedAt: appBuildStat.mtime, size: appBuildStat.size }
31
+ ])
32
+ );
33
+ formData.append("type", "release");
34
+ try {
35
+ const [buildFile, sourceFile, appBuildFile] = (await axios.post(`${basePath}/file/addFilesRestApi`, formData)).data;
36
+ const major = platformVersion ? parseInt(platformVersion.split(".")[0]) : 1;
37
+ const minor = platformVersion ? parseInt(platformVersion.split(".")[1]) : 0;
38
+ const patch = platformVersion ? parseInt(platformVersion.split(".")[2]) : 0;
39
+ const latestRelease = await axios.get(
40
+ `${basePath}/release/findVersionRelease?appName=${projectName}&branch=${environment}&major=${major}&minor=${minor}`
41
+ );
42
+ const release = (await axios.post(
43
+ `${basePath}/release/pushRelease/${projectName}/${environment}/${major}/${minor}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}`
44
+ )).data;
45
+ return release;
46
+ } catch (e) {
47
+ return null;
48
+ }
49
+ };
50
+ export {
51
+ uploadRelease
52
+ };
package/index.cjs DELETED
@@ -1,21 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var devkit_exports = {};
16
- module.exports = __toCommonJS(devkit_exports);
17
- __reExport(devkit_exports, require("./src"), module.exports);
18
- // Annotate the CommonJS export names for ESM import in node:
19
- 0 && (module.exports = {
20
- ...require("./src")
21
- });