miqro 7.0.1 → 7.0.2

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 (145) hide show
  1. package/build/esm/editor/auth.d.ts +6 -0
  2. package/build/esm/editor/auth.js +41 -0
  3. package/build/esm/editor/common/admin-interface.d.ts +36 -0
  4. package/build/esm/editor/common/admin-interface.js +44 -0
  5. package/build/esm/editor/common/constants.d.ts +4 -0
  6. package/build/esm/editor/common/constants.js +20 -0
  7. package/build/esm/editor/common/constants.server.d.ts +2 -0
  8. package/build/esm/editor/common/constants.server.js +4 -0
  9. package/build/esm/editor/common/editor-index.d.ts +2 -0
  10. package/build/esm/editor/common/editor-index.js +14 -0
  11. package/build/esm/editor/common/html-encode.d.ts +1 -0
  12. package/build/esm/editor/common/html-encode.js +14 -0
  13. package/build/esm/editor/common/log-socket.d.ts +15 -0
  14. package/build/esm/editor/common/log-socket.js +71 -0
  15. package/build/esm/editor/common/templates.d.ts +11 -0
  16. package/build/esm/editor/common/templates.js +477 -0
  17. package/build/esm/editor/components/api-preview.d.ts +11 -0
  18. package/build/esm/editor/components/api-preview.js +92 -0
  19. package/build/esm/editor/components/editor.d.ts +16 -0
  20. package/build/esm/editor/components/editor.js +367 -0
  21. package/build/esm/editor/components/file-browser.d.ts +37 -0
  22. package/build/esm/editor/components/file-browser.js +127 -0
  23. package/build/esm/editor/components/file-editor-toolbar.d.ts +22 -0
  24. package/build/esm/editor/components/file-editor-toolbar.js +95 -0
  25. package/build/esm/editor/components/file-editor.d.ts +32 -0
  26. package/build/esm/editor/components/file-editor.js +61 -0
  27. package/build/esm/editor/components/filter-query.d.ts +1 -0
  28. package/build/esm/editor/components/filter-query.js +23 -0
  29. package/build/esm/editor/components/highlight-text-area.d.ts +11 -0
  30. package/build/esm/editor/components/highlight-text-area.js +127 -0
  31. package/build/esm/editor/components/log-viewer.d.ts +6 -0
  32. package/build/esm/editor/components/log-viewer.js +71 -0
  33. package/build/esm/editor/components/new-file.d.ts +10 -0
  34. package/build/esm/editor/components/new-file.js +119 -0
  35. package/build/esm/editor/components/scroll-query.d.ts +7 -0
  36. package/build/esm/editor/components/scroll-query.js +22 -0
  37. package/build/esm/editor/components/start-page.d.ts +13 -0
  38. package/build/esm/editor/components/start-page.js +32 -0
  39. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -0
  40. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +30 -0
  41. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +5 -0
  42. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +50 -0
  43. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -0
  44. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +40 -0
  45. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +26 -0
  46. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +150 -0
  47. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +3 -0
  48. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +39 -0
  49. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +10 -0
  50. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +46 -0
  51. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +10 -0
  52. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +46 -0
  53. package/build/esm/editor/http/admin/editor/editor.d.ts +1 -0
  54. package/build/esm/editor/http/admin/editor/editor.js +8 -0
  55. package/build/esm/editor/http/admin/editor/index.api.d.ts +3 -0
  56. package/build/esm/editor/http/admin/editor/index.api.js +22 -0
  57. package/build/esm/editor/server.d.ts +3 -0
  58. package/build/esm/editor/server.js +49 -0
  59. package/build/esm/editor/ws.d.ts +3 -0
  60. package/build/esm/editor/ws.js +11 -0
  61. package/editor/auth.ts +51 -0
  62. package/editor/common/admin-interface.ts +84 -0
  63. package/editor/common/constants.server.ts +5 -0
  64. package/editor/common/constants.ts +21 -0
  65. package/editor/common/editor-index.tsx +17 -0
  66. package/editor/common/html-encode.ts +14 -0
  67. package/editor/common/log-socket.tsx +87 -0
  68. package/editor/common/templates.ts +481 -0
  69. package/editor/components/api-preview.tsx +118 -0
  70. package/editor/components/editor.tsx +496 -0
  71. package/editor/components/file-browser.tsx +311 -0
  72. package/editor/components/file-editor-toolbar.tsx +194 -0
  73. package/editor/components/file-editor.tsx +125 -0
  74. package/editor/components/filter-query.tsx +26 -0
  75. package/editor/components/highlight-text-area.tsx +148 -0
  76. package/editor/components/log-viewer.tsx +113 -0
  77. package/editor/components/new-file.tsx +172 -0
  78. package/editor/components/scroll-query.tsx +25 -0
  79. package/editor/components/start-page.tsx +52 -0
  80. package/editor/http/admin/editor/api/fs/delete.api.tsx +32 -0
  81. package/editor/http/admin/editor/api/fs/read.api.tsx +55 -0
  82. package/editor/http/admin/editor/api/fs/rename.api.tsx +41 -0
  83. package/editor/http/admin/editor/api/fs/scan.api.tsx +181 -0
  84. package/editor/http/admin/editor/api/fs/write.api.tsx +41 -0
  85. package/editor/http/admin/editor/api/server/reload.api.ts +53 -0
  86. package/editor/http/admin/editor/api/server/restart.api.tsx +52 -0
  87. package/editor/http/admin/editor/editor.tsx +10 -0
  88. package/editor/http/admin/editor/index.api.tsx +42 -0
  89. package/editor/server.ts +57 -0
  90. package/editor/ws.ts +15 -0
  91. package/package.json +1 -1
  92. package/src/bin/compile.ts +35 -0
  93. package/src/bin/doc-md.ts +210 -0
  94. package/src/bin/generate-doc.ts +64 -0
  95. package/src/bin/test.ts +92 -0
  96. package/src/bin/types.ts +34 -0
  97. package/src/cluster.ts +27 -0
  98. package/src/common/arguments.ts +762 -0
  99. package/src/common/assets.ts +148 -0
  100. package/src/common/checksum.ts +58 -0
  101. package/src/common/constants.ts +18 -0
  102. package/src/common/content-type.ts +84 -0
  103. package/src/common/esbuild.ts +102 -0
  104. package/src/common/exit.ts +91 -0
  105. package/src/common/fs.ts +82 -0
  106. package/src/common/help.ts +60 -0
  107. package/src/common/jsx.ts +562 -0
  108. package/src/common/jwt.ts +85 -0
  109. package/src/common/paths.ts +107 -0
  110. package/src/common/watch.ts +88 -0
  111. package/src/inflate/inflate-sea.ts +237 -0
  112. package/src/inflate/inflate.ts +101 -0
  113. package/src/inflate/md.ts +25 -0
  114. package/src/inflate/setup-auth.ts +41 -0
  115. package/src/inflate/setup-cors.ts +41 -0
  116. package/src/inflate/setup-db.ts +117 -0
  117. package/src/inflate/setup-error.ts +44 -0
  118. package/src/inflate/setup-http.ts +704 -0
  119. package/src/inflate/setup-log.ts +45 -0
  120. package/src/inflate/setup-middleware.ts +47 -0
  121. package/src/inflate/setup-server-config.ts +48 -0
  122. package/src/inflate/setup-test.ts +23 -0
  123. package/src/inflate/setup-ws.ts +50 -0
  124. package/src/inflate/setup.doc.ts +92 -0
  125. package/src/inflate/utils/sea-utils.ts +14 -0
  126. package/src/lib.ts +34 -0
  127. package/src/main.ts +101 -0
  128. package/src/services/app.ts +699 -0
  129. package/src/services/editor.tsx +101 -0
  130. package/src/services/globals.ts.ignore +186 -0
  131. package/src/services/hot-reload.ts +51 -0
  132. package/src/services/migrations.ts +68 -0
  133. package/src/services/utils/admin-interface.ts +37 -0
  134. package/src/services/utils/cache.ts +88 -0
  135. package/src/services/utils/cluster-cache.ts +230 -0
  136. package/src/services/utils/cluster-ws.ts +202 -0
  137. package/src/services/utils/db-manager.ts +92 -0
  138. package/src/services/utils/get-route.ts +70 -0
  139. package/src/services/utils/jwt.ts +25 -0
  140. package/src/services/utils/log-transport.ts +81 -0
  141. package/src/services/utils/log.ts +92 -0
  142. package/src/services/utils/middleware.ts +10 -0
  143. package/src/services/utils/server-interface.ts +122 -0
  144. package/src/services/utils/websocketmanager.ts +157 -0
  145. package/src/types.ts +307 -0
@@ -0,0 +1,117 @@
1
+ import { Logger } from "@miqro/core";
2
+ import { Migration, migration } from "@miqro/query";
3
+ import { importDBConfigModule, importMigrationModule, InflateError, inflateJSX } from "../common/jsx.js";
4
+ import { getDBConfigPath, getMigrationsPath, getServicePath } from "../common/paths.js";
5
+ import { dirname, extname, relative, resolve } from "node:path";
6
+ import { mkdirSync, writeFileSync } from "node:fs";
7
+ import { cwd } from "node:process";
8
+ import { DBConfig, NamedMigration } from "../types.js";
9
+
10
+ export interface MigrationModule extends Migration, NamedMigration {
11
+
12
+ }
13
+
14
+ export async function inflateDBConfig(logger: Logger, service: string, dbConfigList: DBConfig[] | undefined, inflateDir: string | undefined | false, errors: InflateError[]) {
15
+ const servicePath = getServicePath(service);
16
+ const dbConfigPath = getDBConfigPath(servicePath);
17
+ if (dbConfigPath) {
18
+ try {
19
+ //logger.debug("loading DBConfig for service[%s]", service);
20
+ const config = await importDBConfigModule(dbConfigPath, logger);
21
+ if (config && dbConfigList && dbConfigList.filter(c => c.name === config.name).length > 0) {
22
+ throw new Error(`ws path [${config.name}] already defined! error from [${dbConfigPath}]`);
23
+ } else if (config) {
24
+ //logger.debug("DBConfig [%s] loaded from service [%s]", config.name, service);
25
+ if (dbConfigList) {
26
+ dbConfigList.push(config);
27
+ }
28
+ }
29
+
30
+
31
+ if (config) {
32
+ if (inflateDir) {
33
+ const inflatePath = resolve(inflateDir, service, "db.cjs");
34
+ mkdirSync(dirname(inflatePath), {
35
+ recursive: true
36
+ });
37
+ logger.log("writing [%s]", relative(cwd(), inflatePath));
38
+ writeFileSync(inflatePath, await inflateJSX(dbConfigPath, {
39
+ // embemedJSX: false,
40
+ minify: false,
41
+ useExport: true,
42
+ platform: "node",
43
+ logger
44
+ }));
45
+ }
46
+
47
+ //const db = await dbManager.setupDB(service, config);
48
+
49
+ //return db;
50
+ return config;
51
+ }
52
+ } catch (e) {
53
+ errors.push({
54
+ filePath: dbConfigPath,
55
+ error: e
56
+ });
57
+ logger.error("error with " + dbConfigPath);
58
+ logger.error(e);
59
+ return false;
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+
65
+ export async function inflateDBMigrations(logger: Logger, service: string, dbName: string, inflateDir: string | undefined | false, errors: InflateError[]) {
66
+ const servicePath = getServicePath(service);
67
+ const migrationsFolderPath = getMigrationsPath(servicePath);
68
+ if (migrationsFolderPath) {
69
+
70
+ logger?.trace("loading migrations from service [%s]", service);
71
+
72
+ const serviceMigrations = migration.getSortedMigrations(migrationsFolderPath);
73
+
74
+ const migrationModules: MigrationModule[] = [];
75
+
76
+ for (const migrationName of serviceMigrations) {
77
+ const migrationPath = resolve(migrationsFolderPath, migrationName);
78
+ try {
79
+ const migrationModule = await importMigrationModule(migrationPath);
80
+ migrationModules.push({
81
+ name: migrationName,
82
+ service,
83
+ dbName,
84
+ ...migrationModule
85
+ });
86
+
87
+ if (inflateDir) {
88
+ const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".cjs");
89
+ mkdirSync(dirname(inflatePath), {
90
+ recursive: true
91
+ });
92
+ logger?.log("writing [%s]", relative(cwd(), inflatePath));
93
+ writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migrationName), {
94
+ // embemedJSX: false,
95
+ minify: false,
96
+ useExport: true,
97
+ platform: "node",
98
+ logger
99
+ }));
100
+ }
101
+
102
+ } catch (e) {
103
+ errors.push({
104
+ filePath: migrationPath,
105
+ error: e
106
+ });
107
+ logger.error("error with " + migrationPath);
108
+ logger.error(e);
109
+ return false;
110
+ }
111
+ }
112
+
113
+ return migrationModules;
114
+
115
+ }
116
+ return false;
117
+ }
@@ -0,0 +1,44 @@
1
+ import { Logger, Router } from "@miqro/core";
2
+ import { importErrorConfigModule, InflateError, inflateJSX } from "../common/jsx.js";
3
+ import { getErrorConfigPath } from "../common/paths.js";
4
+ import { basename, dirname, join, relative, resolve } from "node:path";
5
+ import { mkdirSync, writeFileSync } from "node:fs";
6
+ import { cwd } from "node:process";
7
+
8
+ export async function setupError(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[]): Promise<void> {
9
+ const errorPath = getErrorConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
10
+
11
+ if (errorPath) {
12
+ try {
13
+ const errorModule = await importErrorConfigModule(errorPath, logger);
14
+ logger.debug("setting up error handling from [%s]", join(service, basename(errorPath)));
15
+ if (errorModule && errorModule.catch) {
16
+ for (const m of errorModule.catch) {
17
+ mainRouter.catch(m);
18
+ }
19
+ }
20
+ if (inflateDir && inflateSea) {
21
+ const inflatePath = resolve(inflateDir, service, "catch.cjs");
22
+ mkdirSync(dirname(inflatePath), {
23
+ recursive: true
24
+ });
25
+ logger.log("writing [%s]", relative(cwd(), inflatePath));
26
+ writeFileSync(inflatePath, await inflateJSX(errorPath, {
27
+ // embemedJSX: false,
28
+ minify: false,
29
+ useExport: true,
30
+ platform: "node",
31
+ logger
32
+ }));
33
+ }
34
+
35
+ } catch (e) {
36
+ errors.push({
37
+ filePath: errorPath,
38
+ error: e
39
+ });
40
+ logger.error("error with " + errorPath);
41
+ logger.error(e);
42
+ }
43
+ }
44
+ }