@pc-nexus/core 0.0.1-next.1 → 0.0.1-next.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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Nexus Core API
2
+
3
+ API methods exposed during runtime in Nexus apps.
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./lib/common.js";
2
+ export * from "./lib/context.js";
3
+ export * from "./lib/handler.js";
4
+ export * from "./lib/resolver.js";
5
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ declare const NEXUS_CONTEXT_TOKEN_HEADER_KEY = "x-nexus-context-token";
2
+ declare const hook: (name: string) => any;
3
+ export { hook, NEXUS_CONTEXT_TOKEN_HEADER_KEY };
4
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/lib/common.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,8BAA8B,0BAA0B,CAAC;AAE/D,QAAA,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,GAA2C,CAAC;AAEzE,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC"}
package/lib/common.js ADDED
@@ -0,0 +1,4 @@
1
+ const NEXUS_RUNTIME = "__nexus_runtime__";
2
+ const NEXUS_CONTEXT_TOKEN_HEADER_KEY = "x-nexus-context-token";
3
+ const hook = (name) => global[NEXUS_RUNTIME][name];
4
+ export { hook, NEXUS_CONTEXT_TOKEN_HEADER_KEY };
@@ -0,0 +1,36 @@
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
+ id: string;
17
+ environment_id: string;
18
+ environment_type: string;
19
+ installation_id: string;
20
+ }
21
+ export declare enum ExtensionType {
22
+ pjmProjectPage = "pjm:project-page"
23
+ }
24
+ export interface ExtensionData {
25
+ type: ExtensionType;
26
+ [key: string]: unknown;
27
+ }
28
+ export interface NexusContext {
29
+ appId: string;
30
+ appVersion: string;
31
+ team: Team;
32
+ user: User;
33
+ extension: Extension;
34
+ extensionData: ExtensionData;
35
+ }
36
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
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,EAAE,EAAE,MAAM,CAAC;IAEX,cAAc,EAAE,MAAM,CAAC;IAEvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,oBAAY,aAAa;IACrB,cAAc,qBAAqB;CACtC;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,aAAa,CAAC;IAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IAEd,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,IAAI,CAAC;IAEX,IAAI,EAAE,IAAI,CAAC;IAEX,SAAS,EAAE,SAAS,CAAC;IAErB,aAAa,EAAE,aAAa,CAAC;CAChC"}
package/lib/context.js ADDED
@@ -0,0 +1,4 @@
1
+ export var ExtensionType;
2
+ (function (ExtensionType) {
3
+ ExtensionType["pjmProjectPage"] = "pjm:project-page";
4
+ })(ExtensionType || (ExtensionType = {}));
@@ -0,0 +1,16 @@
1
+ import type { NexusContext } from "./context.js";
2
+ export interface HandlerFunctionEvent {
3
+ id: string;
4
+ type: string;
5
+ payload: unknown;
6
+ }
7
+ export interface HandlerFunction {
8
+ (context: NexusContext, event: HandlerFunctionEvent): Promise<void>;
9
+ }
10
+ export declare class Handler {
11
+ #private;
12
+ constructor();
13
+ define(key: string, fn: HandlerFunction): this;
14
+ invoke(key: string, context: NexusContext, event: HandlerFunctionEvent): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/lib/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,qBAAa,OAAO;;;IAOT,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,GAAG,IAAI;IAKxC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAOtG"}
package/lib/handler.js ADDED
@@ -0,0 +1,17 @@
1
+ export class Handler {
2
+ #handlers;
3
+ constructor() {
4
+ this.#handlers = {};
5
+ }
6
+ define(key, fn) {
7
+ this.#handlers[key] = fn;
8
+ return this;
9
+ }
10
+ async invoke(key, context, event) {
11
+ const fn = this.#handlers[key];
12
+ if (!fn) {
13
+ throw new Error(`Cannot find function by key "${key}"`);
14
+ }
15
+ await fn(context, event);
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { NexusContext } from "./context.js";
2
+ export interface ResolverFunction<P, R> {
3
+ (context: NexusContext, payload: P): Promise<R>;
4
+ }
5
+ export declare class Resolver {
6
+ #private;
7
+ constructor();
8
+ define<P, R>(key: string, fn: ResolverFunction<P, R>): this;
9
+ invoke<P, R>(key: string, context: NexusContext, payload: P): Promise<R>;
10
+ }
11
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/lib/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAClC,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACnD;AAED,qBAAa,QAAQ;;;IAOV,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAKrD,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQxF"}
@@ -0,0 +1,18 @@
1
+ export class Resolver {
2
+ #functions;
3
+ constructor() {
4
+ this.#functions = {};
5
+ }
6
+ define(key, fn) {
7
+ this.#functions[key] = fn;
8
+ return this;
9
+ }
10
+ async invoke(key, context, payload) {
11
+ const fn = this.#functions[key];
12
+ if (!fn) {
13
+ throw new Error(`Cannot find function by key "${key}"`);
14
+ }
15
+ const result = await fn(context, payload);
16
+ return result;
17
+ }
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pc-nexus/core",
3
- "version": "0.0.1-next.1",
3
+ "version": "0.0.1-next.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,9 +19,6 @@
19
19
  "test": "test",
20
20
  "lib": "dist"
21
21
  },
22
- "files": [
23
- "dist"
24
- ],
25
22
  "types": "index.d.ts",
26
23
  "exports": {
27
24
  ".": {