oc-server 0.1.0 → 0.2.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/dist/Server.d.ts +3 -3
- package/dist/Server.js +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -2
package/dist/Server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type
|
|
3
|
-
export type Action<I, O, E> = (params: I, ctx:
|
|
1
|
+
import { DataContext, DataProvider } from './types';
|
|
2
|
+
type ServerContext<E> = Omit<DataContext<any, E>, 'params' | 'action' | 'setEmptyResponse'>;
|
|
3
|
+
export type Action<I, O, E> = (params: I, ctx: ServerContext<E>) => Promise<O> | O;
|
|
4
4
|
type AnyAction = Action<any, any, any>;
|
|
5
5
|
export declare class Server<E, A extends Record<string, AnyAction> = {}, InitialInput = any, InitialOutput = any> {
|
|
6
6
|
private initial;
|
package/dist/Server.js
CHANGED
|
@@ -12,7 +12,7 @@ class Server {
|
|
|
12
12
|
return this;
|
|
13
13
|
}
|
|
14
14
|
getData() {
|
|
15
|
-
return async ({ action: actionName, params, ...context }, cb) => {
|
|
15
|
+
return async ({ action: actionName, params, setEmptyResponse, ...context }, cb) => {
|
|
16
16
|
let res;
|
|
17
17
|
try {
|
|
18
18
|
if (actionName && this.actions[actionName]) {
|
package/dist/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface Template {
|
|
|
19
19
|
version: string;
|
|
20
20
|
externals: External[];
|
|
21
21
|
}
|
|
22
|
-
export interface
|
|
22
|
+
export interface DataContext<T = any, E = Env> {
|
|
23
23
|
action?: string;
|
|
24
24
|
acceptLanguage: AcceptLanguage[];
|
|
25
25
|
baseUrl: string;
|
|
@@ -34,5 +34,5 @@ export interface Context<T = any, E = Env> {
|
|
|
34
34
|
templates: Template[];
|
|
35
35
|
}
|
|
36
36
|
type Callback<D, E = Error> = (error: E | null, data?: D) => void;
|
|
37
|
-
export type DataProvider<Parameters = any, Return = any, Environment = Env> = (context:
|
|
37
|
+
export type DataProvider<Parameters = any, Return = any, Environment = Env> = (context: DataContext<Parameters, Environment>, callback: Callback<Return>) => void;
|
|
38
38
|
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"prepare": "npm run build",
|
|
10
9
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
11
10
|
},
|
|
12
11
|
"keywords": [
|