@0xobelisk/graphql-server 1.2.0-pre.100

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 (87) hide show
  1. package/.turbo/turbo-build.log +8 -0
  2. package/DUAL_POOL_CONFIG.md +188 -0
  3. package/Dockerfile +35 -0
  4. package/LICENSE +92 -0
  5. package/README.md +487 -0
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +206 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/config/subscription-config.d.ts +80 -0
  11. package/dist/config/subscription-config.d.ts.map +1 -0
  12. package/dist/config/subscription-config.js +158 -0
  13. package/dist/config/subscription-config.js.map +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +11 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/plugins/all-fields-filter-plugin.d.ts +4 -0
  19. package/dist/plugins/all-fields-filter-plugin.d.ts.map +1 -0
  20. package/dist/plugins/all-fields-filter-plugin.js +132 -0
  21. package/dist/plugins/all-fields-filter-plugin.js.map +1 -0
  22. package/dist/plugins/database-introspector.d.ts +23 -0
  23. package/dist/plugins/database-introspector.d.ts.map +1 -0
  24. package/dist/plugins/database-introspector.js +96 -0
  25. package/dist/plugins/database-introspector.js.map +1 -0
  26. package/dist/plugins/enhanced-playground.d.ts +9 -0
  27. package/dist/plugins/enhanced-playground.d.ts.map +1 -0
  28. package/dist/plugins/enhanced-playground.js +113 -0
  29. package/dist/plugins/enhanced-playground.js.map +1 -0
  30. package/dist/plugins/enhanced-server-manager.d.ts +29 -0
  31. package/dist/plugins/enhanced-server-manager.d.ts.map +1 -0
  32. package/dist/plugins/enhanced-server-manager.js +262 -0
  33. package/dist/plugins/enhanced-server-manager.js.map +1 -0
  34. package/dist/plugins/index.d.ts +9 -0
  35. package/dist/plugins/index.d.ts.map +1 -0
  36. package/dist/plugins/index.js +26 -0
  37. package/dist/plugins/index.js.map +1 -0
  38. package/dist/plugins/postgraphile-config.d.ts +94 -0
  39. package/dist/plugins/postgraphile-config.d.ts.map +1 -0
  40. package/dist/plugins/postgraphile-config.js +138 -0
  41. package/dist/plugins/postgraphile-config.js.map +1 -0
  42. package/dist/plugins/query-filter.d.ts +4 -0
  43. package/dist/plugins/query-filter.d.ts.map +1 -0
  44. package/dist/plugins/query-filter.js +42 -0
  45. package/dist/plugins/query-filter.js.map +1 -0
  46. package/dist/plugins/simple-naming.d.ts +4 -0
  47. package/dist/plugins/simple-naming.d.ts.map +1 -0
  48. package/dist/plugins/simple-naming.js +79 -0
  49. package/dist/plugins/simple-naming.js.map +1 -0
  50. package/dist/plugins/welcome-page.d.ts +11 -0
  51. package/dist/plugins/welcome-page.d.ts.map +1 -0
  52. package/dist/plugins/welcome-page.js +203 -0
  53. package/dist/plugins/welcome-page.js.map +1 -0
  54. package/dist/server.d.ts +21 -0
  55. package/dist/server.d.ts.map +1 -0
  56. package/dist/server.js +265 -0
  57. package/dist/server.js.map +1 -0
  58. package/dist/universal-subscriptions.d.ts +32 -0
  59. package/dist/universal-subscriptions.d.ts.map +1 -0
  60. package/dist/universal-subscriptions.js +318 -0
  61. package/dist/universal-subscriptions.js.map +1 -0
  62. package/dist/utils/logger/index.d.ts +80 -0
  63. package/dist/utils/logger/index.d.ts.map +1 -0
  64. package/dist/utils/logger/index.js +230 -0
  65. package/dist/utils/logger/index.js.map +1 -0
  66. package/docker-compose.yml +46 -0
  67. package/eslint.config.mjs +3 -0
  68. package/package.json +78 -0
  69. package/src/cli.ts +232 -0
  70. package/src/config/subscription-config.ts +243 -0
  71. package/src/index.ts +11 -0
  72. package/src/plugins/README.md +138 -0
  73. package/src/plugins/all-fields-filter-plugin.ts +158 -0
  74. package/src/plugins/database-introspector.ts +126 -0
  75. package/src/plugins/enhanced-playground.ts +121 -0
  76. package/src/plugins/enhanced-server-manager.ts +314 -0
  77. package/src/plugins/index.ts +9 -0
  78. package/src/plugins/postgraphile-config.ts +182 -0
  79. package/src/plugins/query-filter.ts +50 -0
  80. package/src/plugins/simple-naming.ts +105 -0
  81. package/src/plugins/welcome-page.ts +218 -0
  82. package/src/server.ts +324 -0
  83. package/src/universal-subscriptions.ts +397 -0
  84. package/src/utils/logger/README.md +209 -0
  85. package/src/utils/logger/index.ts +275 -0
  86. package/sui-indexer-schema.graphql +3691 -0
  87. package/tsconfig.json +28 -0
@@ -0,0 +1,80 @@
1
+ import pino from 'pino';
2
+ export interface LoggerConfig {
3
+ level?: string;
4
+ service?: string;
5
+ component?: string;
6
+ enableFileLogging?: boolean;
7
+ logsDir?: string;
8
+ }
9
+ export interface ComponentLoggerMethods {
10
+ debug: (message: string, meta?: any) => void;
11
+ info: (message: string, meta?: any) => void;
12
+ warn: (message: string, meta?: any) => void;
13
+ error: (message: string, error?: any, meta?: any) => void;
14
+ }
15
+ /**
16
+ * High-performance logging system based on Pino
17
+ */
18
+ export declare class Logger {
19
+ private pinoInstance;
20
+ private config;
21
+ constructor(config?: LoggerConfig);
22
+ /**
23
+ * Ensure logs directory exists
24
+ */
25
+ private ensureLogsDirectory;
26
+ /**
27
+ * Create Pino instance
28
+ */
29
+ private createPinoInstance;
30
+ /**
31
+ * Setup exception handlers
32
+ */
33
+ private setupExceptionHandlers;
34
+ /**
35
+ * Create component logger with context
36
+ */
37
+ createComponentLogger(component: string): ComponentLoggerMethods;
38
+ /**
39
+ * Get raw Pino instance
40
+ */
41
+ getPinoInstance(): pino.Logger;
42
+ /**
43
+ * Log performance metrics
44
+ */
45
+ logPerformance(operation: string, startTime: number, meta?: any): void;
46
+ /**
47
+ * Log Express HTTP requests
48
+ */
49
+ logExpress(method: string, path: string, statusCode: number, startTime: number, meta?: any): void;
50
+ /**
51
+ * Log database operations
52
+ */
53
+ logDatabaseOperation(operation: string, table?: string, meta?: any): void;
54
+ /**
55
+ * Log WebSocket events
56
+ */
57
+ logWebSocketEvent(event: string, clientCount?: number, meta?: any): void;
58
+ /**
59
+ * Log GraphQL queries
60
+ */
61
+ logGraphQLQuery(operation: string, query?: string, variables?: any): void;
62
+ }
63
+ export declare const dbLogger: ComponentLoggerMethods;
64
+ export declare const serverLogger: ComponentLoggerMethods;
65
+ export declare const httpLogger: ComponentLoggerMethods;
66
+ export declare const wsLogger: ComponentLoggerMethods;
67
+ export declare const gqlLogger: ComponentLoggerMethods;
68
+ export declare const subscriptionLogger: ComponentLoggerMethods;
69
+ export declare const systemLogger: ComponentLoggerMethods;
70
+ export declare const authLogger: ComponentLoggerMethods;
71
+ export declare const perfLogger: ComponentLoggerMethods;
72
+ export declare const createComponentLogger: (component: string) => ComponentLoggerMethods;
73
+ export declare const logPerformance: (operation: string, startTime: number, meta?: any) => void;
74
+ export declare const logExpress: (method: string, path: string, statusCode: number, startTime: number, meta?: any) => void;
75
+ export declare const logDatabaseOperation: (operation: string, table?: string, meta?: any) => void;
76
+ export declare const logWebSocketEvent: (event: string, clientCount?: number, meta?: any) => void;
77
+ export declare const logGraphQLQuery: (operation: string, query?: string, variables?: any) => void;
78
+ declare const _default: pino.Logger<never>;
79
+ export default _default;
80
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC7C,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC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E,GAAG,GAAG,IAAI;CAOjF;AAMD,eAAO,MAAM,QAAQ,wBAAkD,CAAC;AACxE,eAAO,MAAM,YAAY,wBAAgD,CAAC;AAC1E,eAAO,MAAM,UAAU,wBAAiD,CAAC;AACzE,eAAO,MAAM,QAAQ,wBAAmD,CAAC;AACzE,eAAO,MAAM,SAAS,wBAAiD,CAAC;AACxE,eAAO,MAAM,kBAAkB,wBAAsD,CAAC;AACtF,eAAO,MAAM,YAAY,wBAAgD,CAAC;AAC1E,eAAO,MAAM,UAAU,wBAA8C,CAAC;AACtE,eAAO,MAAM,UAAU,wBAAqD,CAAC;AAG7E,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,2BACP,CAAC;AAEjD,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,EAAE,WAAW,MAAM,EAAE,OAAO,GAAG,SACrB,CAAC;AAE3D,eAAO,MAAM,UAAU,GACrB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,OAAO,GAAG,SAC4D,CAAC;AAEzE,eAAO,MAAM,oBAAoB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,GAAG,SACtB,CAAC;AAE7D,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,cAAc,MAAM,EAAE,OAAO,GAAG,SACtB,CAAC;AAE5D,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,EAAE,YAAY,GAAG,SACtB,CAAC;;AAG7D,wBAA+C"}
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logGraphQLQuery = exports.logWebSocketEvent = exports.logDatabaseOperation = exports.logExpress = exports.logPerformance = exports.createComponentLogger = exports.perfLogger = exports.authLogger = exports.systemLogger = exports.subscriptionLogger = exports.gqlLogger = exports.wsLogger = exports.httpLogger = exports.serverLogger = exports.dbLogger = exports.Logger = void 0;
7
+ const pino_1 = __importDefault(require("pino"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ /**
11
+ * High-performance logging system based on Pino
12
+ */
13
+ class Logger {
14
+ pinoInstance;
15
+ config;
16
+ constructor(config = {}) {
17
+ this.config = {
18
+ level: config.level || process.env.LOG_LEVEL || 'info',
19
+ service: config.service || 'dubhe-graphql-server',
20
+ component: config.component || 'default',
21
+ enableFileLogging: config.enableFileLogging !== false,
22
+ logsDir: config.logsDir || path_1.default.join(process.cwd(), 'logs')
23
+ };
24
+ this.ensureLogsDirectory();
25
+ this.pinoInstance = this.createPinoInstance();
26
+ this.setupExceptionHandlers();
27
+ }
28
+ /**
29
+ * Ensure logs directory exists
30
+ */
31
+ ensureLogsDirectory() {
32
+ if (this.config.enableFileLogging && !fs_1.default.existsSync(this.config.logsDir)) {
33
+ fs_1.default.mkdirSync(this.config.logsDir, { recursive: true });
34
+ }
35
+ }
36
+ /**
37
+ * Create Pino instance
38
+ */
39
+ createPinoInstance() {
40
+ const pinoOptions = {
41
+ level: this.config.level,
42
+ base: {
43
+ service: this.config.service,
44
+ pid: process.pid
45
+ },
46
+ timestamp: pino_1.default.stdTimeFunctions.isoTime,
47
+ formatters: {
48
+ level(label) {
49
+ return { level: label };
50
+ }
51
+ },
52
+ serializers: {
53
+ error: pino_1.default.stdSerializers.err
54
+ }
55
+ };
56
+ // If file logging is enabled, use multistream
57
+ if (this.config.enableFileLogging) {
58
+ const streams = [
59
+ // Pretty print to console
60
+ {
61
+ stream: pino_1.default.transport({
62
+ target: 'pino-pretty',
63
+ options: {
64
+ colorize: true,
65
+ translateTime: 'yyyy-mm-dd HH:MM:ss.l',
66
+ ignore: 'pid,hostname,service,component',
67
+ messageFormat: '[{component}]: {msg}',
68
+ singleLine: true,
69
+ hideObject: false
70
+ }
71
+ })
72
+ },
73
+ // JSON format to file
74
+ {
75
+ stream: pino_1.default.destination({
76
+ dest: path_1.default.join(this.config.logsDir, 'combined.log'),
77
+ sync: false
78
+ })
79
+ }
80
+ ];
81
+ return (0, pino_1.default)(pinoOptions, pino_1.default.multistream(streams));
82
+ }
83
+ // Only output to console in pretty format
84
+ return (0, pino_1.default)({
85
+ ...pinoOptions,
86
+ transport: {
87
+ target: 'pino-pretty',
88
+ options: {
89
+ colorize: true,
90
+ translateTime: 'yyyy-mm-dd HH:MM:ss.l',
91
+ ignore: 'pid,hostname,service',
92
+ messageFormat: '[{component}]: {msg}',
93
+ singleLine: true,
94
+ hideObject: false
95
+ }
96
+ }
97
+ });
98
+ }
99
+ /**
100
+ * Setup exception handlers
101
+ */
102
+ setupExceptionHandlers() {
103
+ process.on('uncaughtException', (error) => {
104
+ this.pinoInstance.fatal({ error }, 'Uncaught Exception');
105
+ process.exit(1);
106
+ });
107
+ process.on('unhandledRejection', (reason, promise) => {
108
+ this.pinoInstance.fatal({ reason, promise }, 'Unhandled Promise Rejection');
109
+ process.exit(1);
110
+ });
111
+ }
112
+ /**
113
+ * Create component logger with context
114
+ */
115
+ createComponentLogger(component) {
116
+ const componentLogger = this.pinoInstance.child({ component });
117
+ return {
118
+ debug: (message, meta) => componentLogger.debug(meta || {}, message),
119
+ info: (message, meta) => componentLogger.info(meta || {}, message),
120
+ warn: (message, meta) => componentLogger.warn(meta || {}, message),
121
+ error: (message, error, meta) => {
122
+ const errorData = error instanceof Error
123
+ ? {
124
+ error: {
125
+ message: error.message,
126
+ stack: error.stack,
127
+ name: error.name
128
+ },
129
+ ...meta
130
+ }
131
+ : { error, ...meta };
132
+ componentLogger.error(errorData, message);
133
+ }
134
+ };
135
+ }
136
+ /**
137
+ * Get raw Pino instance
138
+ */
139
+ getPinoInstance() {
140
+ return this.pinoInstance;
141
+ }
142
+ /**
143
+ * Log performance metrics
144
+ */
145
+ logPerformance(operation, startTime, meta) {
146
+ const duration = Date.now() - startTime;
147
+ const perfLogger = this.createComponentLogger('performance');
148
+ perfLogger.info(operation, {
149
+ duration: `${duration}ms`,
150
+ ...meta
151
+ });
152
+ }
153
+ /**
154
+ * Log Express HTTP requests
155
+ */
156
+ logExpress(method, path, statusCode, startTime, meta) {
157
+ const duration = Date.now() - startTime;
158
+ const httpLogger = this.createComponentLogger('express');
159
+ const message = `${method} ${path} - ${statusCode} (${duration}ms)`;
160
+ // Choose log level based on status code
161
+ if (statusCode >= 500) {
162
+ httpLogger.error(message, meta);
163
+ }
164
+ else if (statusCode >= 400) {
165
+ httpLogger.warn(message, meta);
166
+ }
167
+ else {
168
+ httpLogger.info(message, meta);
169
+ }
170
+ }
171
+ /**
172
+ * Log database operations
173
+ */
174
+ logDatabaseOperation(operation, table, meta) {
175
+ const dbLogger = this.createComponentLogger('database');
176
+ dbLogger.info(`Database operation: ${operation}`, {
177
+ table,
178
+ ...meta
179
+ });
180
+ }
181
+ /**
182
+ * Log WebSocket events
183
+ */
184
+ logWebSocketEvent(event, clientCount, meta) {
185
+ const wsLogger = this.createComponentLogger('websocket');
186
+ wsLogger.info(`WebSocket event: ${event}`, {
187
+ clientCount,
188
+ ...meta
189
+ });
190
+ }
191
+ /**
192
+ * Log GraphQL queries
193
+ */
194
+ logGraphQLQuery(operation, query, variables) {
195
+ const gqlLogger = this.createComponentLogger('graphql');
196
+ gqlLogger.info(`GraphQL ${operation}`, {
197
+ query: query?.substring(0, 200) + (query && query.length > 200 ? '...' : ''),
198
+ variableCount: variables ? Object.keys(variables).length : 0
199
+ });
200
+ }
201
+ }
202
+ exports.Logger = Logger;
203
+ // Create default logger instance
204
+ const defaultLogger = new Logger();
205
+ // Export predefined component loggers (maintain backward compatibility)
206
+ exports.dbLogger = defaultLogger.createComponentLogger('database');
207
+ exports.serverLogger = defaultLogger.createComponentLogger('server');
208
+ exports.httpLogger = defaultLogger.createComponentLogger('express');
209
+ exports.wsLogger = defaultLogger.createComponentLogger('websocket');
210
+ exports.gqlLogger = defaultLogger.createComponentLogger('graphql');
211
+ exports.subscriptionLogger = defaultLogger.createComponentLogger('subscription');
212
+ exports.systemLogger = defaultLogger.createComponentLogger('system');
213
+ exports.authLogger = defaultLogger.createComponentLogger('auth');
214
+ exports.perfLogger = defaultLogger.createComponentLogger('performance');
215
+ // Export utility functions (maintain backward compatibility)
216
+ const createComponentLogger = (component) => defaultLogger.createComponentLogger(component);
217
+ exports.createComponentLogger = createComponentLogger;
218
+ const logPerformance = (operation, startTime, meta) => defaultLogger.logPerformance(operation, startTime, meta);
219
+ exports.logPerformance = logPerformance;
220
+ const logExpress = (method, path, statusCode, startTime, meta) => defaultLogger.logExpress(method, path, statusCode, startTime, meta);
221
+ exports.logExpress = logExpress;
222
+ const logDatabaseOperation = (operation, table, meta) => defaultLogger.logDatabaseOperation(operation, table, meta);
223
+ exports.logDatabaseOperation = logDatabaseOperation;
224
+ const logWebSocketEvent = (event, clientCount, meta) => defaultLogger.logWebSocketEvent(event, clientCount, meta);
225
+ exports.logWebSocketEvent = logWebSocketEvent;
226
+ const logGraphQLQuery = (operation, query, variables) => defaultLogger.logGraphQLQuery(operation, query, variables);
227
+ exports.logGraphQLQuery = logGraphQLQuery;
228
+ // Default export (maintain backward compatibility)
229
+ exports.default = defaultLogger.getPinoInstance();
230
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logger/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,gDAAwB;AACxB,4CAAoB;AAiBpB;;GAEG;AACH,MAAa,MAAM;IACT,YAAY,CAAc;IAC1B,MAAM,CAAyB;IAEvC,YAAY,SAAuB,EAAE;QACnC,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;YACtD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,sBAAsB;YACjD,SAAS,EAAE,MAAM,CAAC,SAAS,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Ae,mBACiC;AAE7D,mDAAmD;AACnD,kBAAe,aAAa,CAAC,eAAe,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ postgres:
5
+ image: postgres:15-alpine
6
+ environment:
7
+ POSTGRES_DB: postgres
8
+ POSTGRES_USER: postgres
9
+ POSTGRES_PASSWORD: postgres
10
+ ports:
11
+ - '5432:5432'
12
+ volumes:
13
+ - ./data/postgres:/var/lib/postgresql/data
14
+ healthcheck:
15
+ test: ['CMD-SHELL', 'pg_isready -U postgres']
16
+ interval: 5s
17
+ timeout: 5s
18
+ retries: 5
19
+
20
+ graphql-server:
21
+ build:
22
+ context: .
23
+ dockerfile: Dockerfile
24
+ ports:
25
+ - '4000:4000'
26
+ environment:
27
+ DATABASE_URL: postgres://postgres:postgres@postgres:5432/dubhe_graphql
28
+ NODE_ENV: production
29
+ PORT: 4000
30
+ GRAPHQL_ENDPOINT: /graphql
31
+ PG_SCHEMA: public
32
+ ENABLE_CORS: 'true'
33
+ ENABLE_SUBSCRIPTIONS: 'true'
34
+ WATCH_PG: 'false'
35
+ depends_on:
36
+ postgres:
37
+ condition: service_healthy
38
+ redis:
39
+ condition: service_healthy
40
+ restart: unless-stopped
41
+ healthcheck:
42
+ test:
43
+ ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:4000/graphql']
44
+ interval: 30s
45
+ timeout: 10s
46
+ retries: 3
@@ -0,0 +1,3 @@
1
+ import baseConfig from '../../eslint.config.base.mjs';
2
+
3
+ export default baseConfig;
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@0xobelisk/graphql-server",
3
+ "version": "1.2.0-pre.100",
4
+ "description": "Tookit for interacting with dubhe graphql server",
5
+ "keywords": [
6
+ "graphql",
7
+ "postgraphile",
8
+ "database-adapter",
9
+ "websocket",
10
+ "subscription",
11
+ "postgresql",
12
+ "dynamic"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/0xobelisk/dubhe.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Dubhe Team",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "bin": {
23
+ "dubhe-graphql-server": "dist/cli.js"
24
+ },
25
+ "dependencies": {
26
+ "@graphile-contrib/pg-simplify-inflector": "^6.1.0",
27
+ "@graphile/pg-pubsub": "^4.14.1",
28
+ "@graphile/subscriptions-lds": "^4.14.1",
29
+ "cors": "^2.8.5",
30
+ "dotenv": "^16.3.1",
31
+ "express": "^4.21.2",
32
+ "graphile-utils": "^4.14.1",
33
+ "graphql": "^15.8.0",
34
+ "graphql-subscriptions": "^2.0.0",
35
+ "graphql-ws": "^5.16.2",
36
+ "node-fetch": "^3.3.2",
37
+ "pg": "^8.11.3",
38
+ "pino": "^8.16.2",
39
+ "pino-pretty": "^10.2.3",
40
+ "postgraphile": "^4.13.0",
41
+ "postgraphile-plugin-connection-filter": "^2.3.0",
42
+ "ws": "^8.14.2",
43
+ "yargs": "^17.7.2"
44
+ },
45
+ "devDependencies": {
46
+ "@types/cors": "^2.8.18",
47
+ "@types/express": "^4.17.23",
48
+ "@types/node": "^20.8.10",
49
+ "@types/pg": "^8.10.7",
50
+ "@types/ws": "^8.5.8",
51
+ "@types/yargs": "^17.0.24",
52
+ "@typescript-eslint/eslint-plugin": "^6.9.1",
53
+ "@typescript-eslint/parser": "^6.9.1",
54
+ "eslint": "^9.0.0",
55
+ "jest": "^29.7.0",
56
+ "nodemon": "^3.1.10",
57
+ "ts-node": "^10.9.1",
58
+ "tsx": "^3.12.10",
59
+ "typescript": "^5.2.2"
60
+ },
61
+ "engines": {
62
+ "node": ">=22.0.0"
63
+ },
64
+ "scripts": {
65
+ "build": "pnpm run type-check && tsc",
66
+ "dev": "ts-node src/cli.ts start",
67
+ "dev:cli": "ts-node src/cli.ts start",
68
+ "dev:watch": "nodemon --exec \"ts-node src/cli.ts start\"",
69
+ "lint": "eslint . --ext .ts",
70
+ "start": "pnpm start:cli",
71
+ "start:cli": "node dist/cli.js start",
72
+ "test": "jest",
73
+ "test:all": "node test_all_subscriptions.js",
74
+ "test:enhanced": "node test_enhanced_subscriptions.js",
75
+ "test:subscription": "node test-subscription.js",
76
+ "type-check": "tsc --noEmit"
77
+ }
78
+ }