miqro 6.3.0 → 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 (148) hide show
  1. package/README.md +9 -17
  2. package/build/editor.bundle.js +11601 -10129
  3. package/build/esm/editor/common/log-socket.js +1 -0
  4. package/build/esm/editor/common/templates.js +90 -90
  5. package/build/esm/editor/components/api-preview.js +2 -0
  6. package/build/esm/editor/components/editor.js +2 -0
  7. package/build/esm/editor/components/file-browser.js +1 -0
  8. package/build/esm/editor/components/file-editor-toolbar.js +2 -0
  9. package/build/esm/editor/components/file-editor.js +2 -0
  10. package/build/esm/editor/components/filter-query.js +1 -0
  11. package/build/esm/editor/components/highlight-text-area.js +2 -0
  12. package/build/esm/editor/components/log-viewer.js +2 -0
  13. package/build/esm/editor/components/new-file.js +2 -0
  14. package/build/esm/editor/components/scroll-query.js +1 -0
  15. package/build/esm/editor/components/start-page.js +2 -0
  16. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +2 -1
  17. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +2 -1
  18. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +2 -1
  19. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +2 -1
  20. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +2 -1
  21. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +2 -1
  22. package/build/esm/editor/http/admin/editor/editor.js +2 -1
  23. package/build/esm/editor/http/admin/editor/index.api.js +1 -0
  24. package/build/esm/src/bin/types.js +10 -5
  25. package/build/esm/src/cluster.js +1 -1
  26. package/build/esm/src/common/arguments.d.ts +1 -1
  27. package/build/esm/src/common/arguments.js +28 -14
  28. package/build/esm/src/common/assets.d.ts +1 -1
  29. package/build/esm/src/common/assets.js +34 -13
  30. package/build/esm/src/common/esbuild.d.ts +4 -1
  31. package/build/esm/src/common/esbuild.js +31 -26
  32. package/build/esm/src/common/exit.js +4 -4
  33. package/build/esm/src/common/help.d.ts +1 -1
  34. package/build/esm/src/common/help.js +0 -1
  35. package/build/esm/src/common/jsx.d.ts +2 -3
  36. package/build/esm/src/common/jsx.js +70 -75
  37. package/build/esm/src/common/paths.d.ts +0 -1
  38. package/build/esm/src/common/paths.js +3 -3
  39. package/build/esm/src/common/watch.d.ts +0 -1
  40. package/build/esm/src/common/watch.js +1 -1
  41. package/build/esm/src/inflate/inflate-sea.js +35 -24
  42. package/build/esm/src/inflate/inflate.js +4 -4
  43. package/build/esm/src/inflate/setup-auth.js +1 -1
  44. package/build/esm/src/inflate/setup-cors.js +1 -1
  45. package/build/esm/src/inflate/setup-db.js +2 -2
  46. package/build/esm/src/inflate/setup-error.js +1 -1
  47. package/build/esm/src/inflate/setup-http.js +16 -16
  48. package/build/esm/src/inflate/setup-log.js +1 -1
  49. package/build/esm/src/inflate/setup-middleware.js +1 -1
  50. package/build/esm/src/inflate/setup-server-config.js +1 -1
  51. package/build/esm/src/inflate/setup-ws.js +1 -1
  52. package/build/esm/src/inflate/setup.doc.d.ts +2 -2
  53. package/build/esm/src/inflate/setup.doc.js +23 -2
  54. package/build/esm/src/inflate/utils/sea-utils.js +2 -2
  55. package/build/esm/src/lib.d.ts +10 -1
  56. package/build/esm/src/lib.js +16 -1
  57. package/build/esm/src/main.js +1 -1
  58. package/build/esm/src/services/app.js +3 -4
  59. package/build/esm/src/services/migrations.js +2 -2
  60. package/build/esm/src/services/utils/jwt.d.ts +2 -0
  61. package/build/esm/src/services/utils/jwt.js +23 -0
  62. package/build/esm/src/services/utils/middleware.d.ts +9 -0
  63. package/build/esm/src/services/utils/middleware.js +9 -0
  64. package/build/esm/src/services/utils/server-interface.js +33 -4
  65. package/build/esm/src/types.d.ts +50 -83
  66. package/build/lib.cjs +15684 -15612
  67. package/editor/common/log-socket.tsx +2 -0
  68. package/editor/common/templates.ts +12 -12
  69. package/editor/components/api-preview.tsx +2 -0
  70. package/editor/components/editor.tsx +2 -0
  71. package/editor/components/file-browser.tsx +3 -0
  72. package/editor/components/file-editor-toolbar.tsx +3 -0
  73. package/editor/components/file-editor.tsx +3 -0
  74. package/editor/components/filter-query.tsx +4 -0
  75. package/editor/components/highlight-text-area.tsx +3 -0
  76. package/editor/components/log-viewer.tsx +3 -0
  77. package/editor/components/new-file.tsx +3 -0
  78. package/editor/components/scroll-query.tsx +3 -0
  79. package/editor/components/start-page.tsx +3 -0
  80. package/editor/http/admin/editor/api/fs/delete.api.tsx +2 -2
  81. package/editor/http/admin/editor/api/fs/read.api.tsx +2 -2
  82. package/editor/http/admin/editor/api/fs/rename.api.tsx +2 -2
  83. package/editor/http/admin/editor/api/fs/scan.api.tsx +2 -2
  84. package/editor/http/admin/editor/api/fs/write.api.tsx +2 -2
  85. package/editor/http/admin/editor/api/server/restart.api.tsx +2 -2
  86. package/editor/http/admin/editor/editor.tsx +3 -1
  87. package/editor/http/admin/editor/index.api.tsx +3 -0
  88. package/package.json +6 -8
  89. package/sea/basic-compile.base64.sh +1 -1
  90. package/sea/basic-compile.sh +1 -1
  91. package/sea/install-nodejs.sh +1 -1
  92. package/sea/node.version.tag +1 -1
  93. package/src/bin/types.ts +7 -2
  94. package/src/cluster.ts +1 -1
  95. package/src/common/arguments.ts +27 -10
  96. package/src/common/assets.ts +32 -12
  97. package/src/common/esbuild.ts +11 -3
  98. package/src/common/exit.ts +3 -3
  99. package/src/common/help.ts +0 -1
  100. package/src/common/jsx.ts +50 -35
  101. package/src/common/paths.ts +2 -2
  102. package/src/common/watch.ts +1 -1
  103. package/src/inflate/inflate-sea.ts +35 -24
  104. package/src/inflate/inflate.ts +4 -4
  105. package/src/inflate/setup-auth.ts +1 -1
  106. package/src/inflate/setup-cors.ts +1 -1
  107. package/src/inflate/setup-db.ts +2 -2
  108. package/src/inflate/setup-error.ts +1 -1
  109. package/src/inflate/setup-http.ts +16 -16
  110. package/src/inflate/setup-log.ts +1 -1
  111. package/src/inflate/setup-middleware.ts +1 -1
  112. package/src/inflate/setup-server-config.ts +1 -1
  113. package/src/inflate/setup-ws.ts +1 -1
  114. package/src/inflate/setup.doc.ts +27 -3
  115. package/src/inflate/utils/sea-utils.ts +2 -2
  116. package/src/lib.ts +17 -2
  117. package/src/main.ts +1 -1
  118. package/src/services/app.ts +4 -4
  119. package/src/services/migrations.ts +2 -2
  120. package/src/services/utils/jwt.ts +25 -0
  121. package/src/services/utils/middleware.ts +10 -0
  122. package/src/services/utils/server-interface.ts +37 -7
  123. package/src/types.ts +56 -53
  124. package/.eslintrc +0 -15
  125. package/build/esm/src/services/globals.d.ts +0 -3
  126. package/build/esm/src/services/globals.js +0 -182
  127. package/build/jsx.dom.js +0 -1587
  128. package/build/postject.base64.cjs +0 -1
  129. package/sea/types.json +0 -1
  130. package/src/types/@esbuild.d.ts +0 -1
  131. package/src/types/@miqro/core.d.ts +0 -2
  132. package/src/types/@miqro/jsx.d.ts +0 -2
  133. package/src/types/@miqro/parser.d.ts +0 -2
  134. package/src/types/@miqro/query.d.ts +0 -2
  135. package/src/types/@miqro/request.d.ts +0 -2
  136. package/src/types/@miqro/test.d.ts +0 -2
  137. package/src/types/@miqro.d.ts +0 -1
  138. package/src/types/@types.d.ts +0 -1
  139. package/src/types/browser.globals.d.ts +0 -1
  140. package/src/types/cookie.d.ts +0 -2
  141. package/src/types/globals.d.ts +0 -2
  142. package/src/types/jose.d.ts +0 -2
  143. package/src/types/jsx.globals.d.ts +0 -38
  144. package/src/types/miqro.d.ts +0 -228
  145. package/src/types/postject.d.ts +0 -1
  146. package/src/types/server.globals.d.ts +0 -47
  147. package/tsconfig.json +0 -35
  148. /package/src/services/{globals.ts → globals.ts.ignore} +0 -0
@@ -1 +0,0 @@
1
- import "../globals.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/core/lib.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/jsx/esm/lib.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/parser/lib.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/query/lib.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/request/lib.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "@miqro/test/dist/index.js";
@@ -1 +0,0 @@
1
- import "../globals.js";
@@ -1 +0,0 @@
1
- import "../globals.js";
@@ -1 +0,0 @@
1
- import "./jsx.globals.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "cookie/index.js";
@@ -1,2 +0,0 @@
1
- import "./browser.globals.js";
2
- import "./server.globals.js";
@@ -1,2 +0,0 @@
1
- import "../globals.js";
2
- export * from "jose/types/index.js";
@@ -1,38 +0,0 @@
1
- import * as jsxLib from "@miqro/jsx/esm/lib.js";
2
-
3
- declare global {
4
- // jsx only for the default value of tsconfig.json
5
- var React: {};
6
- var jsx: {
7
- define: (tagName: string, component: jsxLib.Component, options?: jsxLib.RuntimeElementDefinitionOptions) => void;
8
- useRuntime: typeof jsxLib.useRuntime;
9
- usePathname: typeof jsxLib.usePathname;
10
- Link: typeof jsxLib.Link;
11
- Router: typeof jsxLib.Router;
12
- createContext: typeof jsxLib.createContext;
13
- useContext: typeof jsxLib.useContext;
14
- useState: typeof jsxLib.useState;
15
- useEffect: typeof jsxLib.useEffect;
16
- useQuery: typeof jsxLib.useQuery;
17
- useRef: typeof jsxLib.useRef;
18
- useElement: typeof jsxLib.useElement;
19
- useRefresh: typeof jsxLib.useRefresh;
20
- }
21
- /*var useRuntime: typeof jsxLib.useRuntime;
22
- var usePathname: typeof jsxLib.usePathname;
23
- var Link: typeof jsxLib.Link;
24
- var Router: typeof jsxLib.Router;
25
- var createContext: typeof jsxLib.createContext;
26
- var useContext: typeof jsxLib.useContext;
27
- var useState: typeof jsxLib.useState;
28
- var useEffect: typeof jsxLib.useEffect;
29
- var useQuery: typeof jsxLib.useQuery;
30
- var useRef: typeof jsxLib.useRef;
31
- var useElement: typeof jsxLib.useElement;
32
- var useRefresh: typeof jsxLib.useRefresh;*/
33
- var JSX: {
34
- createElement: typeof jsxLib.createElement;
35
- Fragment: typeof jsxLib.Fragment;
36
- enableDebugLog: typeof jsxLib.enableDebugLog;
37
- }
38
- }
@@ -1,228 +0,0 @@
1
- import "./globals.js";
2
- import { Database, Migration } from "@miqro/query/lib.js";
3
- import { ReadBuffer, URLEncodedParser, JSONParser, TextParser, CORS, SessionHandler } from "@miqro/core/lib.js";
4
- import { ErrorHandler, HandlerWithOptions, CORSOptions, LogLevel, LoggerTransportWriteArgs, Request, Response, WebSocketServer, Logger, WebSocketServerOptions, SessionHandlerOptions, RouteOptions, Handler } from "@miqro/core/lib.js";
5
- import { Parser, ParserInterface } from "@miqro/parser/lib.js";
6
- import { ProtectedHeaderParameters, EncryptOptions, SignOptions, JWTPayload, JWTDecryptOptions, JWTDecryptResult, JWTVerifyResult, JWTVerifyOptions } from "jose/types/index.js";
7
- import { KeyObject } from "node:crypto";
8
-
9
- /*export * from "@miqro/core/lib.js";
10
- export * from "@miqro/query/lib.js";*/
11
-
12
- export interface AuthConfig extends SessionHandlerOptions {
13
-
14
- }
15
-
16
- export interface EncryptJWTOptions {
17
- alg?: string;
18
- enc?: string;
19
- iat?: number | string | Date;
20
- iss?: string;
21
- aud?: string;
22
- exp?: number | string | Date;
23
- options?: EncryptOptions;
24
- }
25
-
26
- export interface JWTSignOptions {
27
- alg?: string;
28
- iat?: number | string | Date;
29
- iss?: string;
30
- aud?: string;
31
- exp?: number | string | Date;
32
- options?: SignOptions;
33
- }
34
-
35
- export interface ServerGlobal {
36
- encodeHTML: (str: string) => string;
37
- inflateMDtoHTML: (str: string) => string;
38
- middleware: {
39
- buffer: typeof ReadBuffer;
40
- url: typeof URLEncodedParser;
41
- json: typeof JSONParser;
42
- text: typeof TextParser;
43
- cors: typeof CORS;
44
- session: typeof SessionHandler;
45
- };
46
- newParser(): Parser;
47
- newClusterCache: (name: string, logger?: Logger) => CacheInterface;
48
- newLocalCache: (name: string, logger?: Logger) => CacheInterface;
49
- createSecretKey: (key: string, encoding: BufferEncoding) => KeyObject;
50
- getWorkerCount: () => number;
51
- getWorkerNumber: () => number;
52
- isPrimaryWorker: () => boolean;
53
- jwt: {
54
- /**
55
- * creates a JWT encrypted token with jose
56
- *
57
- * @param payload the payload to encrypt
58
- * @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
59
- * @param options options like expiratation date, issuer and audience
60
- * @returns
61
- */
62
- encrypt: (payload: JWTPayload, secret: KeyObject, options?: Partial<EncryptJWTOptions>) => Promise<string>
63
- /**
64
- * decrypts a JWT token with jose
65
- * @param jwt the JWT token
66
- * @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
67
- * @param options options like issuer and audience
68
- * @returns
69
- */
70
- decrypt: <PayloadType = JWTPayload>(jwt: string, secret: KeyObject, options?: Partial<JWTDecryptOptions>) => Promise<JWTDecryptResult<PayloadType>>;
71
- /**
72
- * verify a JWT token with jose
73
- * @param jwt the JWT token
74
- * @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
75
- * @param options options like issuer and audience
76
- * @returns
77
- */
78
- verify: <PayloadType = JWTPayload>(jwt: string, secret: KeyObject, options?: Partial<JWTVerifyOptions>) => Promise<JWTVerifyResult<PayloadType>>;
79
- /**
80
- * creates a signed JWT with jose
81
- *
82
- * @param payload the payload to encrypt
83
- * @param secret the secret example. const secret = createSecretKey(process.env.JWT_SECRET, 'utf-8');
84
- * @param options options like expiratation date, issuer and audience
85
- * @returns
86
- */
87
- sign: (payload: JWTPayload, secret: KeyObject, options?: Partial<JWTSignOptions>) => Promise<string>;
88
- /**
89
- * decodes a protected header with jose
90
- * @param token
91
- * @returns
92
- */
93
- decodeProtectedHeader: (token: string | object) => ProtectedHeaderParameters;
94
- /**
95
- * decodes a jwt token
96
- * @param jwt
97
- * @returns
98
- */
99
- decode: <PayloadType = JWTPayload>(jwt: string) => PayloadType & JWTPayload;
100
- }
101
- }
102
-
103
- export interface MiddlewareConfig {
104
- middleware?: Array<HandlerWithOptions | Handler>;
105
- post?: Array<HandlerWithOptions | Handler>;
106
- }
107
-
108
- export interface CORSConfig extends CORSOptions {
109
-
110
- }
111
-
112
- export interface ErrorConfig {
113
- catch?: Array<ErrorHandler>;
114
- }
115
-
116
- export interface WSConfig extends WebSocketServerOptions {
117
- path: string;
118
- disabled?: boolean;
119
- }
120
-
121
- export interface DocConfig {
122
- publish: {
123
- [path: string]: {
124
- type?: "HTML" | "MD" | "JSON",
125
- all?: boolean;
126
- }
127
- }
128
- }
129
-
130
- export interface ServerConfig {
131
- start?: (server: ServerInterface) => Promise<void> | void;
132
- preload?: (server: ServerInterface) => Promise<void> | void;
133
- load?: (server: ServerInterface) => Promise<void> | void;
134
- unload?: (server: ServerInterface) => void;
135
- stop?: (server: ServerInterface) => void;
136
- }
137
-
138
- export interface DBConfig {
139
- dialect?: string;
140
- storage?: string;
141
- url?: string;
142
- disabled?: boolean;
143
- name: string;
144
- }
145
-
146
- export interface CacheInterface {
147
- get<T = any>(key: string): T | undefined;
148
- set: (key: string, value: unknown) => void;
149
- unset: (key: string) => void;
150
- has: (key: string) => boolean;
151
-
152
- set_add: (key: string, value: unknown) => void;
153
- set_delete: (key: string, value: unknown) => void;
154
- set_has: (key: string, value: unknown) => boolean;
155
- set_clear: (key: string) => void;
156
-
157
- array_push: (key: string, value: unknown) => void;
158
- array_clear: (key: string) => void;
159
- }
160
-
161
- export interface APIOptions extends Partial<RouteOptions> {
162
- basePath?: string;
163
- path?: string | string[];
164
- method?: string | string[];
165
- parser?: ParserInterface;
166
- middleware?: Handler | Handler[];
167
- session?: SessionHandlerOptions | Handler;
168
- }
169
-
170
- export interface NamedMigration {
171
- name: string;
172
- service: string;
173
- dbName: string;
174
- }
175
-
176
- export interface LogConfig {
177
- level?: LogLevel;
178
- replaceConsoleTransport?: boolean;
179
- replaceFileTransport?: boolean;
180
- write: (args: LoggerTransportWriteArgs) => Promise<void> | void;
181
- }
182
-
183
- export interface MigrateOptions {
184
- direction: "up" | "down";
185
- service?: string;
186
- dbName?: string;
187
- name?: string;
188
- }
189
-
190
- export interface ServerInterface extends ServerGlobal{
191
- // null values are if the feature has been disabled
192
- db: {
193
- get(name: string): Database | null;
194
- getMigrations(): NamedMigration[];
195
- migrate(options?: MigrateOptions): Promise<void>;
196
- },
197
- ws: {
198
- get(path: string): WebSocketServer | undefined;
199
- disconnectAll(path: string): void;
200
- };
201
- cache: CacheInterface;
202
- localCache: CacheInterface;
203
- logger: Logger;
204
- isPrimaryWorker: () => boolean;
205
- getWorkerNumber: () => number;
206
- getWorkerCount: () => number;
207
- openBrowser: (path: string) => void;
208
- getLogger: (identifier: string, options?: { level?: any; transports?: any[]; formatter?: any; }) => Logger;
209
- stop: () => Promise<void>;
210
- reload: () => Promise<null | {
211
- filePath: string;
212
- error: Error;
213
- }[]>;
214
- restart: () => Promise<null | {
215
- filePath: string;
216
- error: Error;
217
- }[]>;
218
- }
219
-
220
- export interface ServerRequest extends Request {
221
- server?: ServerInterface;
222
- }
223
-
224
- export interface ServerResponse extends Response {
225
- }
226
-
227
- export { App, LoggerHandler, Router, APIRoute } from "@miqro/core/lib.js";
228
- export { migration, Migration } from "@miqro/query/lib.js";
@@ -1 +0,0 @@
1
- import "../globals.js";
@@ -1,47 +0,0 @@
1
- import "./jsx.globals.js";
2
-
3
- import { Logger } from "./@miqro/core/lib.js";
4
- import { request } from "./@miqro/request/lib.js";
5
- import { RuntimeHTMLElement, Runtime, RuntimeContainer, RuntimeURL, RuntimeOptions, RuntimeShadowRootInit } from "./@miqro/jsx.js";
6
- import { ServerGlobal } from "./miqro.js";
7
-
8
- declare global {
9
- // only available server side
10
- var server: ServerGlobal;
11
-
12
- var test: {
13
- PORT: string;
14
- request: typeof request,
15
- logger: Logger,
16
- sleep: (ms: number) => Promise<void>,
17
- jsx: {
18
- createRuntime: (args?: {
19
- basePath?: string | null;
20
- url?: RuntimeURL;
21
- logger?: {
22
- log: Function,
23
- error: Function
24
- }
25
- }) => Runtime;
26
- test: (cb: (container: RuntimeContainer, root: RuntimeHTMLElement, runtime: Runtime) => (Promise<void> | void), args?: {
27
- runtimeOptions?: {
28
- basePath?: string | null;
29
- url?: RuntimeURL;
30
- logger?: {
31
- log: Function;
32
- error: Function;
33
- };
34
- },
35
- containerOptions?: {
36
- runtimeOptions?: RuntimeOptions;
37
- shadowInit?: boolean | RuntimeShadowRootInit;
38
- };
39
- }) => () => Promise<void>;
40
- }
41
- }
42
-
43
- var it: Function;
44
- var describe: Function;
45
- var before: Function;
46
- var after: Function;
47
- }
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "noEmit": false,
5
- "sourceMap": false,
6
- "declaration": true,
7
- "outDir": "./build/esm",
8
- "strict": false,
9
- "module": "NodeNext",
10
- "lib": ["es2021", "dom"],
11
- "jsx": "react",
12
- "jsxFactory": "JSX.createElement",
13
- "jsxFragmentFactory": "JSX.Fragment",
14
- "moduleResolution": "nodenext"
15
- /*"typeRoots": [
16
- "./.types",
17
- ".types",
18
- "./node_modules/",
19
- "./node_modules/@types"
20
- ]*/
21
- },
22
- "include": [
23
- "src/**/*",
24
- "editor/**/*"
25
- ],
26
- "exclude": [
27
- "node_modules",
28
- "sea",
29
- "test",
30
- ".types",
31
- "node_modules/@miqro/jsx/build/esm/jsx.d.ts",
32
- ".types/@miqro/jsx/esm/jsx.d.ts",
33
- "src/types/"
34
- ]
35
- }
File without changes