@modern-js/bff-core 1.21.2-beta.1 → 1.21.2-beta.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 (55) hide show
  1. package/dist/js/modern/api.js +54 -0
  2. package/dist/js/modern/client/generate-client.js +63 -0
  3. package/dist/js/modern/client/index.js +1 -0
  4. package/dist/js/modern/client/result.js +20 -0
  5. package/dist/js/modern/errors/http.js +22 -0
  6. package/dist/js/modern/index.js +7 -0
  7. package/dist/js/modern/operators/http.js +187 -0
  8. package/dist/js/modern/router/constants.js +14 -0
  9. package/dist/js/modern/router/index.js +299 -0
  10. package/dist/js/modern/router/types.js +1 -0
  11. package/dist/js/modern/router/utils.js +99 -0
  12. package/dist/js/modern/types.js +47 -0
  13. package/dist/js/modern/utils/alias.js +91 -0
  14. package/dist/js/modern/utils/debug.js +2 -0
  15. package/dist/js/modern/utils/index.js +5 -0
  16. package/dist/js/modern/utils/meta.js +4 -0
  17. package/dist/js/modern/utils/storage.js +48 -0
  18. package/dist/js/modern/utils/validate.js +49 -0
  19. package/dist/js/node/api.js +66 -0
  20. package/dist/js/node/client/generate-client.js +81 -0
  21. package/dist/js/node/client/index.js +18 -0
  22. package/dist/js/node/client/result.js +32 -0
  23. package/dist/js/node/errors/http.js +34 -0
  24. package/dist/js/node/index.js +125 -0
  25. package/dist/js/node/operators/http.js +226 -0
  26. package/dist/js/node/router/constants.js +29 -0
  27. package/dist/js/node/router/index.js +345 -0
  28. package/dist/js/node/router/types.js +5 -0
  29. package/dist/js/node/router/utils.js +121 -0
  30. package/dist/js/node/types.js +59 -0
  31. package/dist/js/node/utils/alias.js +115 -0
  32. package/dist/js/node/utils/debug.js +11 -0
  33. package/dist/js/node/utils/index.js +72 -0
  34. package/dist/js/node/utils/meta.js +14 -0
  35. package/dist/js/node/utils/storage.js +59 -0
  36. package/dist/js/node/utils/validate.js +68 -0
  37. package/dist/types/api.d.ts +3 -0
  38. package/dist/types/client/generate-client.d.ts +24 -0
  39. package/dist/types/client/index.d.ts +1 -0
  40. package/dist/types/client/result.d.ts +15 -0
  41. package/dist/types/errors/http.d.ts +8 -0
  42. package/dist/types/index.d.ts +7 -0
  43. package/dist/types/operators/http.d.ts +39 -0
  44. package/dist/types/router/constants.d.ts +17 -0
  45. package/dist/types/router/index.d.ts +51 -0
  46. package/dist/types/router/types.d.ts +17 -0
  47. package/dist/types/router/utils.d.ts +10 -0
  48. package/dist/types/types.d.ts +58 -0
  49. package/dist/types/utils/alias.d.ts +7 -0
  50. package/dist/types/utils/debug.d.ts +1 -0
  51. package/dist/types/utils/index.d.ts +5 -0
  52. package/dist/types/utils/meta.d.ts +2 -0
  53. package/dist/types/utils/storage.d.ts +5 -0
  54. package/dist/types/utils/validate.d.ts +5 -0
  55. package/package.json +2 -1
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ debug: true
8
+ };
9
+ Object.defineProperty(exports, "debug", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _debug.debug;
13
+ }
14
+ });
15
+
16
+ var _storage = require("./storage");
17
+
18
+ Object.keys(_storage).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _storage[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _storage[key];
26
+ }
27
+ });
28
+ });
29
+
30
+ var _alias = require("./alias");
31
+
32
+ Object.keys(_alias).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ if (key in exports && exports[key] === _alias[key]) return;
36
+ Object.defineProperty(exports, key, {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _alias[key];
40
+ }
41
+ });
42
+ });
43
+
44
+ var _debug = require("./debug");
45
+
46
+ var _meta = require("./meta");
47
+
48
+ Object.keys(_meta).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
51
+ if (key in exports && exports[key] === _meta[key]) return;
52
+ Object.defineProperty(exports, key, {
53
+ enumerable: true,
54
+ get: function () {
55
+ return _meta[key];
56
+ }
57
+ });
58
+ });
59
+
60
+ var _validate = require("./validate");
61
+
62
+ Object.keys(_validate).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
65
+ if (key in exports && exports[key] === _validate[key]) return;
66
+ Object.defineProperty(exports, key, {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _validate[key];
70
+ }
71
+ });
72
+ });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWithMetaHandler = exports.HANDLER_WITH_META = void 0;
7
+ const HANDLER_WITH_META = 'HANDLER_WITH_META';
8
+ exports.HANDLER_WITH_META = HANDLER_WITH_META;
9
+
10
+ const isWithMetaHandler = handler => {
11
+ return typeof handler === 'function' && handler[HANDLER_WITH_META];
12
+ };
13
+
14
+ exports.isWithMetaHandler = isWithMetaHandler;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createStorage = void 0;
7
+
8
+ var ah = _interopRequireWildcard(require("async_hooks"));
9
+
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+
14
+ const createStorage = () => {
15
+ let storage;
16
+
17
+ if (typeof ah.AsyncLocalStorage !== 'undefined') {
18
+ storage = new ah.AsyncLocalStorage();
19
+ }
20
+
21
+ const run = (context, cb) => {
22
+ if (!storage) {
23
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
24
+ `);
25
+ }
26
+
27
+ return new Promise((resolve, reject) => {
28
+ storage.run(context, () => {
29
+ try {
30
+ return resolve(cb());
31
+ } catch (error) {
32
+ return reject(error);
33
+ }
34
+ });
35
+ });
36
+ };
37
+
38
+ const useContext = () => {
39
+ if (!storage) {
40
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
41
+ `);
42
+ }
43
+
44
+ const context = storage.getStore();
45
+
46
+ if (!context) {
47
+ throw new Error(`Can't call useContext out of scope, it should be placed in the bff function`);
48
+ }
49
+
50
+ return context;
51
+ };
52
+
53
+ return {
54
+ run,
55
+ useContext
56
+ };
57
+ };
58
+
59
+ exports.createStorage = createStorage;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateFunction = exports.getTypeErrorMessage = exports.ERR_INVALID_ARG_TYPE = void 0;
7
+
8
+ var _util = _interopRequireDefault(require("util"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ // fork from https://github.com/nodejs/node/blob/master/lib/internal/errors.js
13
+ const getTypeErrorMessage = actual => {
14
+ let msg = '';
15
+
16
+ if (actual == null) {
17
+ msg += `. Received ${actual}`;
18
+ } else if (typeof actual === 'function' && actual.name) {
19
+ msg += `. Received function ${actual.name}`;
20
+ } else if (typeof actual === 'object') {
21
+ var _actual$constructor;
22
+
23
+ if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
24
+ msg += `. Received an instance of ${actual.constructor.name}`;
25
+ } else {
26
+ const inspected = _util.default.inspect(actual, {
27
+ depth: -1
28
+ });
29
+
30
+ msg += `. Received ${inspected}`;
31
+ }
32
+ } else {
33
+ let inspected = _util.default.inspect(actual, {
34
+ colors: false
35
+ });
36
+
37
+ if (inspected.length > 25) {
38
+ inspected = `${inspected.slice(0, 25)}...`;
39
+ }
40
+
41
+ msg += `. Received type ${typeof actual} (${inspected})`;
42
+ }
43
+
44
+ return msg;
45
+ }; // eslint-disable-next-line @typescript-eslint/naming-convention
46
+
47
+
48
+ exports.getTypeErrorMessage = getTypeErrorMessage;
49
+
50
+ class ERR_INVALID_ARG_TYPE extends Error {
51
+ constructor(funcName, expectedType, actual) {
52
+ const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(actual)}`;
53
+ super(message);
54
+ }
55
+
56
+ }
57
+
58
+ exports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
59
+
60
+ const validateFunction = (maybeFunc, name) => {
61
+ if (typeof maybeFunc !== 'function') {
62
+ throw new ERR_INVALID_ARG_TYPE(name, 'function', maybeFunc);
63
+ }
64
+
65
+ return true;
66
+ };
67
+
68
+ exports.validateFunction = validateFunction;
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import type { ApiRunner, ArrayToObject, ExtractInputType, ExtractOuputType, Operator, MaybeAsync } from './types';
3
+ export declare function Api<Operators extends Operator<any, any>[], Res extends MaybeAsync<any>>(...args: [...operators: Operators, handler: (arg: ArrayToObject<ExtractOuputType<Operators>>) => Res]): ApiRunner<ExtractInputType<Operators> extends void[] ? void : ArrayToObject<ExtractInputType<Operators>>, Res>;
@@ -0,0 +1,24 @@
1
+ import { Result } from './result';
2
+ export declare type GenClientResult = Result<string>;
3
+ export declare type GenClientOptions = {
4
+ resourcePath: string;
5
+ source: string;
6
+ apiDir: string;
7
+ prefix: string;
8
+ port: number;
9
+ requestCreator?: string;
10
+ fetcher?: string;
11
+ target?: string;
12
+ requireResolve?: typeof require.resolve;
13
+ };
14
+ export declare const DEFAULT_CLIENT_REQUEST_CREATOR = "@modern-js/create-request";
15
+ export declare const generateClient: ({
16
+ resourcePath,
17
+ apiDir,
18
+ prefix,
19
+ port,
20
+ target,
21
+ requestCreator,
22
+ fetcher,
23
+ requireResolve
24
+ }: GenClientOptions) => Promise<GenClientResult>;
@@ -0,0 +1 @@
1
+ export * from './generate-client';
@@ -0,0 +1,15 @@
1
+ export declare type Err<T = unknown> = {
2
+ kind: 'Err';
3
+ value: T;
4
+ isErr: true;
5
+ isOk: false;
6
+ };
7
+ export declare type Ok<T = unknown> = {
8
+ kind: 'Ok';
9
+ value: T;
10
+ isErr: false;
11
+ isOk: true;
12
+ };
13
+ export declare type Result<T = unknown, E = string> = Err<E> | Ok<T>;
14
+ export declare const Err: <E = string>(value: E) => Err<E>;
15
+ export declare const Ok: <T, E = string>(value: T) => Result<T, E>;
@@ -0,0 +1,8 @@
1
+ export declare class HttpError extends Error {
2
+ status: number;
3
+ constructor(status: number, message: string);
4
+ }
5
+ export declare class ValidationError extends HttpError {
6
+ private code;
7
+ constructor(status: number, message: string);
8
+ }
@@ -0,0 +1,7 @@
1
+ export { Api } from './api';
2
+ export { HttpError, ValidationError } from './errors/http';
3
+ export * from './router';
4
+ export * from './types';
5
+ export * from './client';
6
+ export * from './operators/http';
7
+ export { getRelativeRuntimePath, HANDLER_WITH_META, isWithMetaHandler, createStorage, registerPaths } from './utils';
@@ -0,0 +1,39 @@
1
+ import type { z } from 'zod';
2
+ import { Operator, HttpMethod, ResponseMetaType } from '../types';
3
+ export interface ResponseMeta {
4
+ type: ResponseMetaType;
5
+ value: unknown;
6
+ }
7
+ export declare const createHttpOperator: (method: HttpMethod) => (urlPath: string) => Operator<void>;
8
+ export declare const Get: (urlPath: string) => Operator<void>;
9
+ export declare const Post: (urlPath: string) => Operator<void>;
10
+ export declare const Put: (urlPath: string) => Operator<void>;
11
+ export declare const Delete: (urlPath: string) => Operator<void>;
12
+ export declare const Connect: (urlPath: string) => Operator<void>;
13
+ export declare const Trace: (urlPath: string) => Operator<void>;
14
+ export declare const Patch: (urlPath: string) => Operator<void>;
15
+ export declare const Option: (urlPath: string) => Operator<void>;
16
+ export declare const Head: (urlPath: string) => Operator<void>;
17
+ export declare const Data: <Schema extends z.ZodType<any, z.ZodTypeDef, any>>(schema: Schema) => Operator<{
18
+ data: z.input<Schema>;
19
+ }, {
20
+ data: z.output<Schema>;
21
+ }>;
22
+ export declare const Query: <Schema extends z.ZodType<any, z.ZodTypeDef, any>>(schema: Schema) => Operator<{
23
+ query: z.input<Schema>;
24
+ }, {
25
+ query: z.output<Schema>;
26
+ }>;
27
+ export declare const Params: <Schema extends z.ZodType<any, z.ZodTypeDef, any>>(schema: Schema) => Operator<{
28
+ params: z.input<Schema>;
29
+ }, {
30
+ params: z.output<Schema>;
31
+ }>;
32
+ export declare const Headers: <Schema extends z.ZodType<any, z.ZodTypeDef, any>>(schema: Schema) => Operator<{
33
+ headers: z.input<Schema>;
34
+ }, {
35
+ headers: z.output<Schema>;
36
+ }>;
37
+ export declare const HttpCode: (statusCode: number) => Operator<void>;
38
+ export declare const SetHeaders: (headers: Record<string, string>) => Operator<void>;
39
+ export declare const Redirect: (url: string) => Operator<void>;
@@ -0,0 +1,17 @@
1
+ export declare const AllHttpMethods: string[];
2
+ export declare enum APIMode {
3
+ /**
4
+ * 框架模式
5
+ */
6
+ FARMEWORK = "framework",
7
+
8
+ /**
9
+ * 函数模式
10
+ */
11
+ FUNCTION = "function",
12
+ }
13
+ export declare const FRAMEWORK_MODE_LAMBDA_DIR = "lambda";
14
+ export declare const FRAMEWORK_MODE_APP_DIR = "app";
15
+ export declare const INDEX_SUFFIX = "index";
16
+ export declare const API_DIR = "api";
17
+ export declare const API_FILE_RULES: string[];
@@ -0,0 +1,51 @@
1
+ import 'reflect-metadata';
2
+ import { HttpMethod } from '../types';
3
+ import { APIMode } from './constants';
4
+ import { ApiHandler, APIHandlerInfo } from './types';
5
+ export * from './types';
6
+ export * from './constants';
7
+ export declare class ApiRouter {
8
+ private apiMode;
9
+ private apiDir;
10
+ private existLambdaDir;
11
+ private lambdaDir;
12
+ private prefix;
13
+ private apiFiles;
14
+ constructor({
15
+ apiDir,
16
+ lambdaDir,
17
+ prefix
18
+ }: {
19
+ apiDir: string;
20
+ lambdaDir?: string;
21
+ prefix?: string;
22
+ });
23
+ isExistLambda(): boolean;
24
+ getApiMode(): APIMode;
25
+ getLambdaDir(): string;
26
+ isApiFile(filename: string): boolean;
27
+ getSingleModuleHandlers(filename: string): APIHandlerInfo[] | null;
28
+ getHandlerInfo(filename: string, originFuncName: string, handler: ApiHandler): APIHandlerInfo | null;
29
+ getSafeRoutePath(filename: string, handler?: ApiHandler): string;
30
+ getRouteName(filename: string, handler?: ApiHandler): string;
31
+ getHttpMethod(originHandlerName: string, handler?: ApiHandler): HttpMethod | null;
32
+ loadApiFiles(): string[];
33
+ getApiFiles(): string[];
34
+ getApiHandlers(): APIHandlerInfo[];
35
+ /**
36
+ * 如果用户未传入或传入空串,默认为 /api
37
+ * 如果传入 /,则 prefix 为 /
38
+ */
39
+
40
+ private initPrefix;
41
+ private validateAbsolute;
42
+ private getExactApiMode;
43
+ private createExistChecker;
44
+ private getExactLambdaDir;
45
+ private getModuleInfos;
46
+ private getModuleInfo;
47
+ private getHandlerInfos;
48
+ private getModuleHandlerInfos;
49
+ private validateValidApifile;
50
+ private getRoutePath;
51
+ }
@@ -0,0 +1,17 @@
1
+ import { HttpMethod } from '../types';
2
+ export declare type ModuleInfo = {
3
+ filename: string;
4
+ module: HandlerModule;
5
+ };
6
+ declare type Handler = (...args: any) => any | Promise<any>;
7
+ export declare type ApiHandler = Handler;
8
+ export declare type HandlerModule = Record<string, ApiHandler>;
9
+ export declare type APIHandlerInfo = {
10
+ handler: ApiHandler;
11
+ name: string;
12
+ httpMethod: HttpMethod;
13
+ filename: string;
14
+ routeName: string;
15
+ routePath: string;
16
+ };
17
+ export {};
@@ -0,0 +1,10 @@
1
+ import { APIHandlerInfo, HandlerModule } from './types';
2
+ declare type MaybeAsync<I> = I | Promise<I>;
3
+ export declare type NormalHandler = (...args: any[]) => any;
4
+ export declare type Handler<I, O> = (input: I) => MaybeAsync<O>;
5
+ export declare const getFiles: (lambdaDir: string, rules: string | string[]) => string[];
6
+ export declare const getPathFromFilename: (baseDir: string, filename: string) => string;
7
+ export declare const isHandler: (input: any) => input is Handler<any, any>;
8
+ export declare const requireHandlerModule: (modulePath: string) => HandlerModule;
9
+ export declare const sortRoutes: (apiHandlers: APIHandlerInfo[]) => APIHandlerInfo[];
10
+ export {};
@@ -0,0 +1,58 @@
1
+ import { Merge } from 'type-fest';
2
+ export declare enum OperatorType {
3
+ Trigger = 0,
4
+ Middleware = 1,
5
+ }
6
+ export declare enum TriggerType {
7
+ Http = 0,
8
+ }
9
+ export declare enum HttpMetadata {
10
+ Method = "METHOD",
11
+ Data = "DATA",
12
+ Query = "QUERY",
13
+ Params = "PARAMS",
14
+ Headers = "HEADERS",
15
+ Response = "RESPONSE",
16
+ }
17
+ export declare enum ResponseMetaType {
18
+ StatusCode = 0,
19
+ Redirect = 1,
20
+ Headers = 2,
21
+ }
22
+ export declare enum HttpMethod {
23
+ Get = "GET",
24
+ Post = "POST",
25
+ Put = "PUT",
26
+ Delete = "DELETE",
27
+ Connect = "CONNECT",
28
+ Trace = "TRACE",
29
+ Patch = "PATCH",
30
+ Option = "OPTION",
31
+ Head = "HEAD",
32
+ }
33
+ export declare type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
34
+ export declare type ExecuteFunc<Outputs> = (helper: ExecuteHelper<Outputs>, next: () => Promise<any>) => Promise<any>;
35
+ export declare type ExecuteHelper<Outputs> = {
36
+ result?: any;
37
+ inputs: Outputs;
38
+ };
39
+ export declare type MetadataHelper = {
40
+ setMetadata: <T = any>(key: any, value: T) => void;
41
+ getMetadata: <T = any>(key: any) => T;
42
+ };
43
+ export declare type Operator<Input = any, Output = Input> = {
44
+ name: string;
45
+ inputType?: Input;
46
+ outputType?: Output;
47
+ metadata?: (helper: MetadataHelper) => void;
48
+ validate?: ExecuteFunc<Output>;
49
+ execute?: ExecuteFunc<Output>;
50
+ };
51
+ export declare type MaybeAsync<T> = Promise<T> | T;
52
+ export declare type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? never : [input: Input]) => Output;
53
+ export declare type NonNullable<T> = Exclude<T, null | undefined>;
54
+ export declare type ExtractInputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['inputType']> : void };
55
+ export declare type ExtractOuputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['outputType']> : void };
56
+ export declare type ArrayToObject<T, R = {}> = T extends [infer First, ...infer Rest] ? First extends PromiseLike<infer PromiseValue> ? PromiseValue : First extends object ? Merge<First, ArrayToObject<Rest, R>> : ArrayToObject<Rest, R> : R;
57
+ export declare type AsyncFunction = (...args: any[]) => Promise<any>;
58
+ export declare const httpMethods: HttpMethod[];
@@ -0,0 +1,7 @@
1
+ interface Paths {
2
+ [key: string]: string[] | string;
3
+ }
4
+ export declare const getRelativeRuntimePath: (appDirectory: string, serverRuntimePath: string) => string;
5
+ export declare const createMatchPath: (paths: Paths) => (request: string) => string | null;
6
+ export declare const registerPaths: (paths: Paths) => () => void;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare const debug: import("@modern-js/utils/compiled/debug").Debugger;
@@ -0,0 +1,5 @@
1
+ export * from './storage';
2
+ export * from './alias';
3
+ export { debug } from './debug';
4
+ export * from './meta';
5
+ export * from './validate';
@@ -0,0 +1,2 @@
1
+ export declare const HANDLER_WITH_META = "HANDLER_WITH_META";
2
+ export declare const isWithMetaHandler: (handler: any) => any;
@@ -0,0 +1,5 @@
1
+ declare const createStorage: <T>() => {
2
+ run: <O>(context: T, cb: () => O | Promise<O>) => Promise<O>;
3
+ useContext: () => T;
4
+ };
5
+ export { createStorage };
@@ -0,0 +1,5 @@
1
+ export declare const getTypeErrorMessage: (actual: unknown) => string;
2
+ export declare class ERR_INVALID_ARG_TYPE extends Error {
3
+ constructor(funcName: string, expectedType: string, actual: unknown);
4
+ }
5
+ export declare const validateFunction: (maybeFunc: unknown, name: string) => boolean;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.2-beta.1",
14
+ "version": "1.21.2-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -20,6 +20,7 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "jsnext:source": "./src/index.ts",
23
+ "types": "./dist/types/index.d.ts",
23
24
  "default": "./dist/js/node/index.js"
24
25
  }
25
26
  },