@pc-nexus/core 0.5.0 → 0.8.0-next.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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { EnvironmentType, NexusCode, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorType, Resolver, type Extension, type HandlerFunction, type HandlerFunctionEvent, type NexusAppContext, type ResolverFunction, type Team, type User, type WebHookHandlerFunctionReturn, } from "@pc-nexus/internal";
1
+ export { EnvironmentType, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorCode, Resolver, type Extension, type EventHandler, type EventHandlerEvent, type NexusAppContext, type ResolverFunction, type Team, type User, type WebhookEventResult, } from "@pc-nexus/internal";
2
2
  export * from "./lib/authorize.js";
3
- export * from "./lib/common.js";
4
3
  export * from "./lib/handler.js";
4
+ export { app } from "./lib/common.js";
5
5
  export * from "./lib/i18n/index.js";
6
6
  //# 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,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,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,4BAA4B,GACpC,MAAM,oBAAoB,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,kBAAkB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { EnvironmentType, NexusCode, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorType, Resolver, } from "@pc-nexus/internal";
1
+ export { EnvironmentType, NexusError, NexusHttpStatusCode, NexusInnerError, NexusInnerErrorCode, Resolver, } from "@pc-nexus/internal";
2
2
  export * from "./lib/authorize.js";
3
- export * from "./lib/common.js";
4
3
  export * from "./lib/handler.js";
4
+ export { app } from "./lib/common.js";
5
5
  export * from "./lib/i18n/index.js";
package/lib/handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { HandlerFunction, LifecycleEventPayload, ScheduledEventPayload, SystemEventPayload, WebHookHandlerFunctionReturn, WebhookPayload } from "@pc-nexus/internal";
2
- export type SystemEventHandlerFunction = HandlerFunction<SystemEventPayload, void>;
3
- export type LifecycleEventHandlerFunction = HandlerFunction<LifecycleEventPayload, void>;
4
- export type WebhokEventHandlerFunction = HandlerFunction<WebhookPayload, WebHookHandlerFunctionReturn>;
5
- export type ScheduledEventHandlerFunction = HandlerFunction<ScheduledEventPayload, void>;
1
+ import { EventHandler, LifecycleEventPayload, ScheduledEventPayload, SystemEventPayload, WebhookEventResult, WebhookEventPayload } from "@pc-nexus/internal";
2
+ export type SystemEventHandler = EventHandler<SystemEventPayload, void>;
3
+ export type LifecycleEventHandler = EventHandler<LifecycleEventPayload, void>;
4
+ export type WebhookEventHandler = EventHandler<WebhookEventPayload, WebhookEventResult>;
5
+ export type ScheduledEventHandler = EventHandler<ScheduledEventPayload, void>;
6
6
  //# sourceMappingURL=handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/lib/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,4BAA4B,EAC5B,cAAc,EACjB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,0BAA0B,GAAG,eAAe,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AAEnF,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;AAEzF,MAAM,MAAM,0BAA0B,GAAG,eAAe,CAAC,cAAc,EAAE,4BAA4B,CAAC,CAAC;AAEvG,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/lib/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;AAExF,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAuD,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzI,cAAM,IAAI;;;IAMO,eAAe,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAK7E,gBAAgB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;CA0DnF;AAED,eAAO,MAAM,IAAI,MAAa,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAuD,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzI,cAAM,IAAI;;;IAMO,eAAe,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAK7E,gBAAgB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;CAkDnF;AAED,eAAO,MAAM,IAAI,MAAa,CAAC"}
package/lib/i18n/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NexusCode, NexusInnerError, NexusInnerErrorType } from "@pc-nexus/internal";
1
+ import { NexusInnerError, NexusInnerErrorCode } from "@pc-nexus/internal";
2
2
  import { TranslationLoader } from "./translation-loader.js";
3
3
  import { SUPPORTED_LOCALE_CODES } from "./types.js";
4
4
  import _ from "lodash";
@@ -22,7 +22,7 @@ class I18n {
22
22
  }
23
23
  #translate(key, translations, params) {
24
24
  if (!key) {
25
- throw new NexusInnerError(NexusCode.InvalidInput, NexusInnerErrorType.I18nTranslationKeyRequired, `"key" is required in i18n translate.`);
25
+ throw new NexusInnerError(NexusInnerErrorCode.I18nTranslationKeyRequired, `"key" is required in i18n translate.`);
26
26
  }
27
27
  let value = _.get(translations, key);
28
28
  if (value == null) {
@@ -45,7 +45,7 @@ class I18n {
45
45
  #validateLocale(locale) {
46
46
  if (locale) {
47
47
  if (!SUPPORTED_LOCALE_CODES.includes(locale)) {
48
- throw new NexusInnerError(NexusCode.InvalidInput, NexusInnerErrorType.I18nTranslationLocaleInvalid, `locale "${locale}" is not supported`);
48
+ throw new NexusInnerError(NexusInnerErrorCode.I18nTranslationLocaleInvalid, `locale "${locale}" is not supported`);
49
49
  }
50
50
  }
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,6BAA8B,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,WAAW,qBAAqB;IAC1C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,EAAE,2BAA2B,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,2BAA2B;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,2BAA2B,CAAC;CACvD;AAED,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,2BAA2B,GAAG,MAAM,CAAC;CAClG"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/types.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,sBAAsB,6BAA8B,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,WAAW,qBAAqB;IAC1C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,EAAE,2BAA2B,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,2BAA2B;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,2BAA2B,CAAC;CACvD;AAED,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,2BAA2B,GAAG,MAAM,CAAC;CAClG"}
package/lib/i18n/types.js CHANGED
@@ -1 +1,2 @@
1
+ // 为了方便做类型检查,这里定义了支持的 locale 数组常量,并且避免导出过多内容没有引入 model 中的类型,重复声明了一遍
1
2
  export const SUPPORTED_LOCALE_CODES = ["zh-CN", "en-US"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pc-nexus/core",
3
- "version": "0.5.0",
3
+ "version": "0.8.0-next.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "type": "module",
31
31
  "dependencies": {
32
- "@pc-nexus/internal": "0.5.0",
32
+ "@pc-nexus/internal": "0.8.0-next.0",
33
33
  "lodash": "^4.17.21"
34
34
  },
35
35
  "devDependencies": {},