fusion-framework 1.2.6 → 2.0.0
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/README.md +3 -1
- package/fusion-node.darwin-arm64.node +0 -0
- package/fusion-node.linux-arm64-gnu.node +0 -0
- package/fusion-node.linux-x64-gnu.node +0 -0
- package/fusion-node.win32-x64-msvc.node +0 -0
- package/index.d.ts +82 -143
- package/index.js +976 -27
- package/package.json +46 -11
- package/static/swagger-ui/LICENSE +202 -0
- package/static/swagger-ui/VERSION +1 -0
- package/static/swagger-ui/favicon-32x32.png +0 -0
- package/static/swagger-ui/swagger-ui-bundle.js +2 -0
- package/static/swagger-ui/swagger-ui-standalone-preset.js +2 -0
- package/static/swagger-ui/swagger-ui.css +3 -0
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ From this repo:
|
|
|
16
16
|
cd crates/fusion-node && npm install && npm run build:debug
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
**Important:** `napi build` must use `--js false` so it does not overwrite `index.js` (the FusionApp / middleware layer). The npm scripts already pass this flag.
|
|
20
|
+
|
|
19
21
|
Scaffold with [Fusion Tool](https://github.com/cipherunits/fusion-tool):
|
|
20
22
|
|
|
21
23
|
```bash
|
|
@@ -35,7 +37,7 @@ export const ItemModule = route('/api/[module]/{id}')(
|
|
|
35
37
|
},
|
|
36
38
|
)
|
|
37
39
|
|
|
38
|
-
const MIDDLEWARE = [] //
|
|
40
|
+
const MIDDLEWARE = [] // add middleware explicitly, e.g. frameworkHeaders()
|
|
39
41
|
|
|
40
42
|
settings.ensureLoaded()
|
|
41
43
|
const app = new FusionApp(getSettings())
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -1,148 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly host: string
|
|
14
|
-
readonly port: number
|
|
15
|
-
readonly debug: boolean
|
|
16
|
-
readonly env: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class FusionBaseApi {
|
|
20
|
-
request: FusionRequest
|
|
21
|
-
constructor(request: FusionRequest)
|
|
22
|
-
readonly method: string
|
|
23
|
-
readonly path: string
|
|
24
|
-
readonly body: string
|
|
25
|
-
readonly headers: Record<string, string>
|
|
26
|
-
readonly params: Record<string, string>
|
|
27
|
-
readonly query: Record<string, string>
|
|
28
|
-
readonly state: Record<string, unknown>
|
|
29
|
-
response(body?: unknown, status?: number, headers?: Record<string, string>): FusionResponse
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export declare function getHttpMethods(): Array<string>
|
|
7
|
+
export declare function apiResourceNameJs(className: string): string
|
|
8
|
+
export declare function resolveRoutePathJs(template: string, className: string): string
|
|
9
|
+
export declare function coerceParamJs(raw: string, kind?: string | undefined | null): unknown
|
|
10
|
+
export interface HttpStatusCode {
|
|
11
|
+
name: string
|
|
12
|
+
code: number
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
headers: Record<string, string>
|
|
36
|
-
constructor(status: number, detail?: unknown, headers?: Record<string, string>)
|
|
37
|
-
toResponse(): FusionResponse
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class FusionApp {
|
|
41
|
-
constructor(settings?: Partial<FusionSettings>)
|
|
42
|
-
use(middleware: FusionMiddleware): void
|
|
43
|
-
mount(): void
|
|
44
|
-
listen(host?: string, port?: number): Promise<void>
|
|
14
|
+
export declare function getHttpStatusCodes(): Array<HttpStatusCode>
|
|
15
|
+
export interface HttpHeaderConstant {
|
|
16
|
+
name: string
|
|
17
|
+
value: string
|
|
45
18
|
}
|
|
46
|
-
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
19
|
+
export declare function getHttpHeaderConstants(): Array<HttpHeaderConstant>
|
|
20
|
+
export declare function headerAttachment(filename: string): Record<string, string>
|
|
21
|
+
export declare function headerInline(filename?: string | undefined | null): Record<string, string>
|
|
22
|
+
export declare function headerContentType(mediaType: string, charset?: string | undefined | null): Record<string, string>
|
|
23
|
+
export declare function headerLocation(url: string): Record<string, string>
|
|
24
|
+
export declare function headerCacheControl(value: string): Record<string, string>
|
|
25
|
+
export declare function headerDownload(filename: string, mediaType?: string | undefined | null): Record<string, string>
|
|
26
|
+
export declare function getFingerprintHeaders(): Record<string, string>
|
|
27
|
+
/** True when the client prefers JSON (`Accept` or `?format=json`). */
|
|
28
|
+
export declare function prefersJsonJs(accept?: string | undefined | null, formatQuery?: string | undefined | null): boolean
|
|
29
|
+
/** Render a Tera template file relative to `templates_root` (default `"templates"`). */
|
|
30
|
+
export declare function renderTemplateJs(templateName: string, context: JsJson, templatesRoot?: string | undefined | null): string
|
|
31
|
+
export interface PaginationParams {
|
|
32
|
+
page: number
|
|
33
|
+
pageSize: number
|
|
34
|
+
offset: number
|
|
57
35
|
}
|
|
58
|
-
|
|
59
|
-
export function
|
|
60
|
-
/**
|
|
61
|
-
export function
|
|
62
|
-
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export function
|
|
70
|
-
export function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
export function
|
|
83
|
-
|
|
84
|
-
export function
|
|
85
|
-
|
|
86
|
-
export function
|
|
87
|
-
|
|
88
|
-
):
|
|
89
|
-
|
|
90
|
-
export function
|
|
91
|
-
|
|
92
|
-
export function
|
|
93
|
-
export
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
LOCATION: string
|
|
105
|
-
AUTHORIZATION: string
|
|
106
|
-
APPLICATION_JSON: string
|
|
107
|
-
APPLICATION_OCTET_STREAM: string
|
|
108
|
-
APPLICATION_PDF: string
|
|
109
|
-
attachment(filename: string): Record<string, string>
|
|
110
|
-
inline(filename?: string | null): Record<string, string>
|
|
111
|
-
contentType(mediaType: string, charset?: string | null): Record<string, string>
|
|
112
|
-
location(url: string): Record<string, string>
|
|
113
|
-
cacheControl(value: string): Record<string, string>
|
|
114
|
-
download(filename: string, mediaType?: string | null): Record<string, string>
|
|
115
|
-
fingerprint(): Record<string, string>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface FusionSettings {
|
|
119
|
-
host: string
|
|
120
|
-
port: number
|
|
121
|
-
debug: boolean
|
|
122
|
-
env?: string
|
|
36
|
+
export declare function parsePagination(query: object, defaultPageSize?: number | undefined | null, maxPageSize?: number | undefined | null): PaginationParams
|
|
37
|
+
export declare function paginatedBody(items: unknown, total: number, params: PaginationParams): unknown
|
|
38
|
+
/** Apply `cache.*` from a Settings instance to the process-wide cache. */
|
|
39
|
+
export declare function cacheConfigure(settings: Settings): void
|
|
40
|
+
/** Install a driver explicitly (default moka). */
|
|
41
|
+
export declare function cacheConfigureDriver(driver?: string | undefined | null, maxCapacity?: number | undefined | null, defaultTtl?: number | undefined | null): void
|
|
42
|
+
export declare function cacheSet(key: string, value: JsJson, ttl?: number | undefined | null): void
|
|
43
|
+
export declare function cacheGet(key: string): unknown
|
|
44
|
+
export declare function cacheDelete(key: string): boolean
|
|
45
|
+
export declare function cacheExists(key: string): boolean
|
|
46
|
+
export declare function cacheGetOrSet(key: string, default: JsJson, ttl?: number | undefined | null): unknown
|
|
47
|
+
export declare function cacheDeleteOrSet(key: string, value: JsJson, ttl?: number | undefined | null): unknown
|
|
48
|
+
export declare function cacheExistsOrSet(key: string, value: JsJson, ttl?: number | undefined | null): boolean
|
|
49
|
+
export declare function cacheDriver(): string
|
|
50
|
+
export declare function cacheClear(): void
|
|
51
|
+
export declare function cacheReset(): void
|
|
52
|
+
export declare function cacheSnapshot(): unknown
|
|
53
|
+
export declare function cachePanelContext(): unknown
|
|
54
|
+
/**
|
|
55
|
+
* Spawn a JS function on the Tokio background runtime. Returns task id.
|
|
56
|
+
*
|
|
57
|
+
* Uses `call_async` so status becomes `done` only after the JS callback runs
|
|
58
|
+
* (sync `Blocking` can return before the Node event loop drains the TSFN).
|
|
59
|
+
*/
|
|
60
|
+
export declare function taskSpawn(callback: (...args: any[]) => any): string
|
|
61
|
+
/** Spawn a JS function after `delay_ms` milliseconds. */
|
|
62
|
+
export declare function taskSpawnAfter(delayMs: number, callback: (...args: any[]) => any): string
|
|
63
|
+
/** Cancel a background task by id. */
|
|
64
|
+
export declare function taskCancel(id: string): boolean
|
|
65
|
+
/** Status string for a task id, or null if unknown. */
|
|
66
|
+
export declare function taskStatus(id: string): string | null
|
|
67
|
+
/** Reset the task registry (tests). */
|
|
68
|
+
export declare function taskReset(): void
|
|
69
|
+
/** JSON snapshot of tracked background tasks. */
|
|
70
|
+
export declare function taskSnapshot(): unknown
|
|
71
|
+
export declare class Settings {
|
|
72
|
+
constructor()
|
|
73
|
+
loadJson(path?: string | undefined | null, envName?: string | undefined | null, extraRoots?: Array<string> | undefined | null): void
|
|
74
|
+
ensureLoaded(extraRoots?: Array<string> | undefined | null): void
|
|
75
|
+
merge(values: unknown): void
|
|
76
|
+
get(key: string, default?: unknown | undefined | null): unknown
|
|
77
|
+
get host(): string
|
|
78
|
+
get port(): number
|
|
79
|
+
get debug(): boolean
|
|
80
|
+
get reload(): boolean
|
|
81
|
+
get env(): string
|
|
123
82
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
method: string
|
|
127
|
-
|
|
128
|
-
body: string
|
|
129
|
-
headers: Record<string, string>
|
|
130
|
-
params: Record<string, string>
|
|
131
|
-
query: Record<string, string>
|
|
132
|
-
state?: Record<string, unknown>
|
|
83
|
+
export declare class App {
|
|
84
|
+
constructor()
|
|
85
|
+
route(method: string, path: string, handler: (...args: any[]) => any): void
|
|
86
|
+
listen(host: string, port: number): Promise<void>
|
|
133
87
|
}
|
|
134
|
-
|
|
135
|
-
export type FusionMiddleware = (
|
|
136
|
-
request: FusionRequest,
|
|
137
|
-
callNext: (request: FusionRequest) => unknown | Promise<unknown>,
|
|
138
|
-
) => unknown | Promise<unknown>
|
|
139
|
-
|
|
140
|
-
export function frameworkHeaders(): FusionMiddleware
|
|
141
|
-
|
|
142
|
-
export type FusionResponse =
|
|
143
|
-
| string
|
|
144
|
-
| {
|
|
145
|
-
status?: number
|
|
146
|
-
body?: unknown
|
|
147
|
-
headers?: Record<string, string>
|
|
148
|
-
}
|