@pc-nexus/core 0.5.0-next.0 → 0.5.0-next.10

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/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
+ export { EnvironmentType, NexusCode, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorType, Resolver, type Extension, type HandlerFunction, type HandlerFunctionEvent, type WebHookHandlerFunctionReturn, type NexusAppContext, type ResolverFunction, type Team, type User, } from "@pc-nexus/internal";
1
2
  export * from "./lib/common.js";
2
- export * from "./lib/context.js";
3
- export * from "./lib/handler.js";
4
- export * from "./lib/resolver.js";
5
- export * from "./lib/error.js";
6
- export * from "./lib/code.js";
7
- export * from "./lib/error-type.js";
8
3
  export * from "./lib/i18n/index.js";
9
4
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,IAAI,GACZ,MAAM,oBAAoB,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
package/index.js CHANGED
@@ -1,8 +1,3 @@
1
+ export { EnvironmentType, NexusCode, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorType, Resolver, } from "@pc-nexus/internal";
1
2
  export * from "./lib/common.js";
2
- export * from "./lib/context.js";
3
- export * from "./lib/handler.js";
4
- export * from "./lib/resolver.js";
5
- export * from "./lib/error.js";
6
- export * from "./lib/code.js";
7
- export * from "./lib/error-type.js";
8
3
  export * from "./lib/i18n/index.js";
package/lib/common.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { NexusAppContext } from "./context.js";
2
- export declare const NEXUS_CONTEXT_TOKEN_HEADER_KEY = "x-nexus-context-token";
3
- export declare const invoke: (gateway: string, endpoint: string, payload: unknown) => Promise<Response>;
4
- export declare const getAppContext: () => NexusAppContext;
1
+ import type { NexusAppContext } from "@pc-nexus/internal";
2
+ export declare const app: {
3
+ getContext: () => NexusAppContext;
4
+ };
5
5
  export declare const I18nResourcesAccessor: {
6
6
  getI18nInfoConfig: () => any;
7
7
  getTranslationResource: (locale: string) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/lib/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AAEtE,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CACb,CAAC;AAEjF,eAAO,MAAM,aAAa,QAAO,eAEhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;qCAEG,MAAM;CAC1C,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/lib/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,GAAG;sBACI,eAAe;CAGlC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;qCAEG,MAAM;CAC1C,CAAC"}
package/lib/common.js CHANGED
@@ -1,8 +1,8 @@
1
- const GLOBAL_KEY_NEXUS_RUNTIME = "__nexus_runtime__";
2
- export const NEXUS_CONTEXT_TOKEN_HEADER_KEY = "x-nexus-context-token";
3
- export const invoke = (gateway, endpoint, payload) => global[GLOBAL_KEY_NEXUS_RUNTIME].invoke(gateway, endpoint, payload);
4
- export const getAppContext = () => {
5
- return global[GLOBAL_KEY_NEXUS_RUNTIME].getAppContext();
1
+ import { GLOBAL_KEY_NEXUS_RUNTIME } from "@pc-nexus/internal";
2
+ export const app = {
3
+ getContext: () => {
4
+ return global[GLOBAL_KEY_NEXUS_RUNTIME].app.getContext();
5
+ },
6
6
  };
7
7
  export const I18nResourcesAccessor = {
8
8
  getI18nInfoConfig: () => global[GLOBAL_KEY_NEXUS_RUNTIME].i18n?.getI18nInfoConfig(),
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/main.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+B,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkDxG,eAAO,MAAM,IAAI;yBAhCJ,MAAM,SACR,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,cAC1B,MAAM,KACnB,OAAO,CAAC,MAAM,GAAG,0BAA0B,CAAC;kCAqBJ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAAC;CAW7E,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkDxG,eAAO,MAAM,IAAI;yBAhCJ,MAAM,SACR,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,cAC1B,MAAM,KACnB,OAAO,CAAC,MAAM,GAAG,0BAA0B,CAAC;kCAqBJ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAAC;CAW7E,CAAC"}
package/lib/i18n/main.js CHANGED
@@ -1,6 +1,4 @@
1
- import { NexusCode } from "../code.js";
2
- import { NexusInnerErrorType } from "../error-type.js";
3
- import { NexusInnerError } from "../error.js";
1
+ import { NexusCode, NexusInnerError, NexusInnerErrorType } from "@pc-nexus/internal";
4
2
  import { TranslationLoader } from "./translation-loader.js";
5
3
  import { NexusSupportLocales } from "./types.js";
6
4
  import _ from "lodash";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pc-nexus/core",
3
- "version": "0.5.0-next.0",
3
+ "version": "0.5.0-next.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,7 +28,10 @@
28
28
  }
29
29
  },
30
30
  "type": "module",
31
- "dependencies": {},
31
+ "dependencies": {
32
+ "@pc-nexus/internal": "0.5.0-next.10",
33
+ "lodash": "^4.17.21"
34
+ },
32
35
  "devDependencies": {},
33
36
  "peerDependencies": {}
34
37
  }
package/lib/code.d.ts DELETED
@@ -1,18 +0,0 @@
1
- declare enum NexusCode {
2
- ok = 200,
3
- invalidInput = 400,
4
- unauthorized = 401,
5
- forbidden = 403,
6
- internalError = 500
7
- }
8
- export declare enum NexusHttpStatusCode {
9
- ok = 200,
10
- badRequest = 400,
11
- unauthorized = 401,
12
- notFound = 404,
13
- methodNotAllowed = 405,
14
- internalError = 500,
15
- noContent = 204
16
- }
17
- export { NexusCode };
18
- //# sourceMappingURL=code.d.ts.map
package/lib/code.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/lib/code.ts"],"names":[],"mappings":"AAAA,aAAK,SAAS;IACV,EAAE,MAAM;IACR,YAAY,MAAM;IAClB,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,aAAa,MAAM;CACtB;AAED,oBAAY,mBAAmB;IAC3B,EAAE,MAAM;IACR,UAAU,MAAM;IAChB,YAAY,MAAM;IAClB,QAAQ,MAAM;IACd,gBAAgB,MAAM;IACtB,aAAa,MAAM;IACnB,SAAS,MAAM;CAClB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
package/lib/code.js DELETED
@@ -1,19 +0,0 @@
1
- var NexusCode;
2
- (function (NexusCode) {
3
- NexusCode[NexusCode["ok"] = 200] = "ok";
4
- NexusCode[NexusCode["invalidInput"] = 400] = "invalidInput";
5
- NexusCode[NexusCode["unauthorized"] = 401] = "unauthorized";
6
- NexusCode[NexusCode["forbidden"] = 403] = "forbidden";
7
- NexusCode[NexusCode["internalError"] = 500] = "internalError";
8
- })(NexusCode || (NexusCode = {}));
9
- export var NexusHttpStatusCode;
10
- (function (NexusHttpStatusCode) {
11
- NexusHttpStatusCode[NexusHttpStatusCode["ok"] = 200] = "ok";
12
- NexusHttpStatusCode[NexusHttpStatusCode["badRequest"] = 400] = "badRequest";
13
- NexusHttpStatusCode[NexusHttpStatusCode["unauthorized"] = 401] = "unauthorized";
14
- NexusHttpStatusCode[NexusHttpStatusCode["notFound"] = 404] = "notFound";
15
- NexusHttpStatusCode[NexusHttpStatusCode["methodNotAllowed"] = 405] = "methodNotAllowed";
16
- NexusHttpStatusCode[NexusHttpStatusCode["internalError"] = 500] = "internalError";
17
- NexusHttpStatusCode[NexusHttpStatusCode["noContent"] = 204] = "noContent";
18
- })(NexusHttpStatusCode || (NexusHttpStatusCode = {}));
19
- export { NexusCode };
package/lib/context.d.ts DELETED
@@ -1,54 +0,0 @@
1
- export interface Team {
2
- _id: string;
3
- name: string;
4
- domain: string;
5
- locale: string;
6
- timezone: string;
7
- }
8
- export interface User {
9
- uid: string;
10
- name: string;
11
- display_name: string;
12
- locale: string;
13
- timezone: string;
14
- }
15
- export interface Extension {
16
- environment_id: string;
17
- environment_type: string;
18
- installation_id: string;
19
- }
20
- export interface ExtensionData {
21
- type: string;
22
- [key: string]: unknown;
23
- }
24
- export declare enum EnvironmentType {
25
- development = "development",
26
- production = "production"
27
- }
28
- export interface NexusContext {
29
- teamId: string;
30
- environmentId: string;
31
- environmentName: string;
32
- environmentType: EnvironmentType;
33
- installationId: string;
34
- }
35
- export interface NexusAppContext extends NexusContext {
36
- appId: string;
37
- appVersion: string;
38
- invocationId: string;
39
- extensionKey: string;
40
- }
41
- export type NexusExecContextUserType = "licensed" | "unlicensed" | "customer" | "anonymous";
42
- export interface NexusExecContext extends NexusContext {
43
- uid: string;
44
- userType: NexusExecContextUserType;
45
- localId: string;
46
- installContext: string;
47
- extension: ExtensionData;
48
- }
49
- export interface NexusRequestContext extends NexusExecContext, NexusAppContext {
50
- functionsKeyHandlerMap: Record<string, string>;
51
- }
52
- export type NexusRequestContextRaw = Omit<NexusRequestContext, "invocationId" | "invocationRemainingTimeInMillis">;
53
- export type NexusRequestEventContextRaw = Omit<NexusRequestContextRaw, "extension" | "extensionKey">;
54
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/lib/context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACjB,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACjB,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,EAAE,MAAM,CAAC;IAErB,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACtB,cAAc,EAAE,MAAM,CAAC;IAEvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IAEb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,oBAAY,eAAe;IACvB,WAAW,gBAAgB;IAE3B,UAAU,eAAe;CAC5B;AAED,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IAEf,aAAa,EAAE,MAAM,CAAC;IAEtB,eAAe,EAAE,MAAM,CAAC;IAExB,eAAe,EAAE,eAAe,CAAC;IAEjC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACjD,KAAK,EAAE,MAAM,CAAC;IAEd,UAAU,EAAE,MAAM,CAAC;IAGnB,YAAY,EAAE,MAAM,CAAC;IAErB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE5F,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IAClD,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,wBAAwB,CAAC;IAEnC,OAAO,EAAE,MAAM,CAAC;IAGhB,cAAc,EAAE,MAAM,CAAC;IAEvB,SAAS,EAAE,aAAa,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,EAAE,eAAe;IAC1E,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClD;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,iCAAiC,CAAC,CAAC;AAEnH,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,GAAG,cAAc,CAAC,CAAC"}
package/lib/context.js DELETED
@@ -1,5 +0,0 @@
1
- export var EnvironmentType;
2
- (function (EnvironmentType) {
3
- EnvironmentType["development"] = "development";
4
- EnvironmentType["production"] = "production";
5
- })(EnvironmentType || (EnvironmentType = {}));
@@ -1,11 +0,0 @@
1
- /**
2
- * SDK 内部的错误类型码
3
- */
4
- export declare enum NexusInnerErrorType {
5
- invalidInput = "NEXUS_INNER_ERROR_TYPE_INVALID_INPUT",
6
- networkInvalidInput = "NEXUS_INNER_ERROR_TYPE_NETWORK_INVALID_INPUT",
7
- storageConditionBuilder = "NEXUS_INNER_ERROR_TYPE_STORAGE_CONDITION_BUILDER",
8
- i18nTranslationLoaderError = "NEXUS_INNER_ERROR_TYPE_TRANSLATION_GETTER",
9
- i18nTranslationLocaleInvalid = "NEXUS_INNER_ERROR_TYPE_TRANSLATION_LOCALE_INVALID"
10
- }
11
- //# sourceMappingURL=error-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-type.d.ts","sourceRoot":"","sources":["../../src/lib/error-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,mBAAmB;IAC3B,YAAY,yCAAyC;IACrD,mBAAmB,iDAAiD;IACpE,uBAAuB,qDAAqD;IAC5E,0BAA0B,8CAA8C;IACxE,4BAA4B,sDAAsD;CACrF"}
package/lib/error-type.js DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * SDK 内部的错误类型码
3
- */
4
- export var NexusInnerErrorType;
5
- (function (NexusInnerErrorType) {
6
- NexusInnerErrorType["invalidInput"] = "NEXUS_INNER_ERROR_TYPE_INVALID_INPUT";
7
- NexusInnerErrorType["networkInvalidInput"] = "NEXUS_INNER_ERROR_TYPE_NETWORK_INVALID_INPUT";
8
- NexusInnerErrorType["storageConditionBuilder"] = "NEXUS_INNER_ERROR_TYPE_STORAGE_CONDITION_BUILDER";
9
- NexusInnerErrorType["i18nTranslationLoaderError"] = "NEXUS_INNER_ERROR_TYPE_TRANSLATION_GETTER";
10
- NexusInnerErrorType["i18nTranslationLocaleInvalid"] = "NEXUS_INNER_ERROR_TYPE_TRANSLATION_LOCALE_INVALID";
11
- })(NexusInnerErrorType || (NexusInnerErrorType = {}));
package/lib/error.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { NexusCode } from "./code.js";
2
- import { NexusInnerErrorType } from "./error-type.js";
3
- /**
4
- * NexusError 异常类
5
- */
6
- export declare abstract class NexusError extends Error {
7
- #private;
8
- get code(): NexusCode;
9
- get type(): string;
10
- constructor(code: NexusCode, type: string, message: string);
11
- }
12
- export declare class NexusInnerError extends NexusError {
13
- constructor(code: NexusCode, type: NexusInnerErrorType, message: string);
14
- }
15
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;GAEG;AACH,8BAAsB,UAAW,SAAQ,KAAK;;IAE1C,IAAW,IAAI,IAAI,SAAS,CAE3B;IAGD,IAAW,IAAI,IAAI,MAAM,CAExB;gBAEkB,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKpE;AAED,qBAAa,eAAgB,SAAQ,UAAU;gBACxB,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM;CAGjF"}
package/lib/error.js DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * NexusError 异常类
3
- */
4
- export class NexusError extends Error {
5
- #code;
6
- get code() {
7
- return this.#code;
8
- }
9
- #type;
10
- get type() {
11
- return this.#type;
12
- }
13
- constructor(code, type, message) {
14
- super(message);
15
- this.#code = code;
16
- this.#type = type;
17
- }
18
- }
19
- export class NexusInnerError extends NexusError {
20
- constructor(code, type, message) {
21
- super(code, type, message);
22
- }
23
- }
package/lib/handler.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { NexusExecContext } from "./context.js";
2
- export interface HandlerFunctionEvent<T = unknown> {
3
- type: string;
4
- payload: T;
5
- }
6
- export interface HandlerFunction<TPayload = unknown, TReturn = void> {
7
- (context: NexusExecContext, event: HandlerFunctionEvent<TPayload>): Promise<TReturn>;
8
- }
9
- //# sourceMappingURL=handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/lib/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC7C,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,CAAC,CAAC;CACd;AAED,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI;IAC/D,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxF"}
package/lib/handler.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/resolver.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { NexusExecContext } from "./context.js";
2
- export interface ResolverFunction<P, R> {
3
- (context: NexusExecContext, payload: P): Promise<R>;
4
- }
5
- export declare class Resolver {
6
- #private;
7
- constructor();
8
- define<P, R = unknown>(key: string, fn: ResolverFunction<P, R>): this;
9
- invoke<P, R>(key: string, context: NexusExecContext, payload: P): Promise<R>;
10
- }
11
- //# sourceMappingURL=resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/lib/resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAClC,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACvD;AAQD,qBAAa,QAAQ;;;IAOV,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAK/D,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQ5F"}
package/lib/resolver.js DELETED
@@ -1,26 +0,0 @@
1
- import { NexusCode } from "./code.js";
2
- import { NexusError } from "./error.js";
3
- import { NexusInnerErrorType } from "./error-type.js";
4
- class ResolverError extends NexusError {
5
- constructor(message) {
6
- super(NexusCode.invalidInput, NexusInnerErrorType.invalidInput, message);
7
- }
8
- }
9
- export class Resolver {
10
- #functions;
11
- constructor() {
12
- this.#functions = {};
13
- }
14
- define(key, fn) {
15
- this.#functions[key] = fn;
16
- return this;
17
- }
18
- async invoke(key, context, payload) {
19
- const fn = this.#functions[key];
20
- if (!fn) {
21
- throw new ResolverError(`Cannot find function by key "${key}"`);
22
- }
23
- const result = await fn(context, payload);
24
- return result;
25
- }
26
- }