@xmobitea/gn-server 2.4.16 → 2.5.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.
Files changed (37) hide show
  1. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetCreateLeaderboardRequestHandler.d.ts +0 -1
  2. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetCurrencyLeaderboardRequestHandler.d.ts +0 -1
  3. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
  4. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetLastLoginLeaderboardRequestHandler.d.ts +22 -0
  5. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetStatisticsLeaderboardRequestHandler.d.ts +0 -1
  6. package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
  7. package/dist/GN-app-api/handler/controller/handler/dashboard/model/CharacterPlayerPermissionRulesParam.d.ts +1 -0
  8. package/dist/GN-app-api/handler/controller/handler/dashboard/model/StoreInventoryPermissionRulesParam.d.ts +2 -0
  9. package/dist/GN-app-api/handler/controller/handler/gamePlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
  10. package/dist/GN-app-api/handler/controller/handler/gamePlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
  11. package/dist/GN-app-api/handler/controller/handler/group/GetCurrencyLogRequestHandler.d.ts +0 -1
  12. package/dist/GN-app-api/handler/controller/handler/group/GetStatisticsLogRequestHandler.d.ts +0 -1
  13. package/dist/GN-app-api/handler/controller/handler/inventory/GetStatisticsLogRequestHandler.d.ts +0 -1
  14. package/dist/GN-app-api/handler/controller/handler/masterPlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
  15. package/dist/GN-app-api/handler/controller/handler/masterPlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
  16. package/dist/GN-app-api/handler/controller/handler/storeInventory/GetStoreUsedRequestHandler.d.ts +17 -0
  17. package/dist/GN-app-api/handler/controller/handler/storeInventory/RemoveStoreUsedRequestHandler.d.ts +18 -0
  18. package/dist/GN-app-api/handler/controller/handler/storeInventory/SetStoreItemInformationRequestHandler.d.ts +1 -0
  19. package/dist/GN-app-api/handler/controller/handler/storeInventory/StoreItemBaseRequestHandler.d.ts +1 -0
  20. package/dist/GN-app-api/handler/controller/handler/storeInventory/model/InfoRequestParam.d.ts +1 -0
  21. package/dist/GN-common/constant/OperationCode.d.ts +2 -0
  22. package/dist/GN-common/constant/enumType/StoreItemType.d.ts +4 -0
  23. package/dist/GN-common/constant/errorCode/GNErrorCode.d.ts +2 -0
  24. package/dist/GN-common/constant/parameterCode/GNParameterCode.d.ts +4 -0
  25. package/dist/GN-common/entity/SecretInfo.d.ts +3 -0
  26. package/dist/GN-library/xdatabase/lib/entity/pro/StoreInventory.d.ts +4 -0
  27. package/dist/GN-library/xdatabase/lib/entity/pro/findOptions/StoreInventoryFindOptions.d.ts +1 -0
  28. package/dist/GN-library/xdatabase/lib/xDatabase.d.ts +12 -0
  29. package/dist/GN-startup/cloudScript/eventCallbackCloudScriptData.json +17 -2
  30. package/dist/GN-startup/cloudScript/templateCloudScript.ts +171 -165
  31. package/dist/GN-startup/cloudScript/templateEventCallback.ts +231 -225
  32. package/dist/GN-startup/settings/ApplicationSettings.d.ts +3 -0
  33. package/dist/GNServer.d.ts +4 -2
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +1177 -441
  36. package/gn.sh +2 -2
  37. package/package.json +2 -5
@@ -1,5 +1,3 @@
1
- import { parentPort, workerData } from "worker_threads";
2
-
3
1
  import {
4
2
  GNNetwork,
5
3
  Action0,
@@ -62,9 +60,14 @@ import {
62
60
  GroupStatus,
63
61
  GNDebug,
64
62
  ItemType,
63
+ StoreItemType,
65
64
  LogType,
66
65
  GNSupport,
67
66
  PostType,
67
+ GetAuthInfoResponse,
68
+ PushPlatformType,
69
+ StoreReceiveType,
70
+ GNUtils,
68
71
  } from "@xmobitea/gn-typescript-client";
69
72
 
70
73
  import * as mongodb from "mongodb";
@@ -268,103 +271,109 @@ class CloudScriptSocket {
268
271
  }
269
272
 
270
273
  private async sendEvent(event: CloudScriptEvent) {
271
- parentPort?.postMessage(event);
274
+ if (process?.send)
275
+ process.send(event);
272
276
  }
273
277
  }
274
278
 
275
279
  class CloudScriptMail {
276
280
  public async send(email: string, subject: string, contentHtml: string) {
277
- parentPort?.postMessage({
278
- eventType: 20,
279
- receiver: null,
280
- operationEvent: {
281
- eventCode: 0,
282
- encrypted: false,
283
- parameters: {
284
- email: email,
285
- subject: subject,
286
- contentHtml: contentHtml,
287
- },
288
- },
289
- });
281
+ if (process?.send)
282
+ process.send({
283
+ eventType: 20,
284
+ receiver: null,
285
+ operationEvent: {
286
+ eventCode: 0,
287
+ encrypted: false,
288
+ parameters: {
289
+ email: email,
290
+ subject: subject,
291
+ contentHtml: contentHtml,
292
+ },
293
+ },
294
+ });
290
295
  }
291
296
 
292
297
  public async sendToMore(emails: string[], subject: string, contentHtml: string) {
293
- parentPort?.postMessage({
294
- eventType: 21,
295
- receiver: null,
296
- operationEvent: {
297
- eventCode: 0,
298
- encrypted: false,
299
- parameters: {
300
- emails: emails,
301
- subject: subject,
302
- contentHtml: contentHtml,
303
- },
304
- },
305
- });
298
+ if (process?.send)
299
+ process.send({
300
+ eventType: 21,
301
+ receiver: null,
302
+ operationEvent: {
303
+ eventCode: 0,
304
+ encrypted: false,
305
+ parameters: {
306
+ emails: emails,
307
+ subject: subject,
308
+ contentHtml: contentHtml,
309
+ },
310
+ },
311
+ });
306
312
  }
307
313
  }
308
314
 
309
315
  class CloudScriptPushNotification {
310
316
  public async send(token: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
311
- parentPort?.postMessage({
312
- eventType: 30,
313
- receiver: null,
314
- operationEvent: {
315
- eventCode: 0,
316
- encrypted: false,
317
- parameters: {
318
- token: token,
319
- title: title,
320
- body: body,
321
- badge: badge,
322
- sound: sound,
323
- icon: icon,
324
- data: data,
325
- },
326
- },
327
- });
317
+ if (process?.send)
318
+ process.send({
319
+ eventType: 30,
320
+ receiver: null,
321
+ operationEvent: {
322
+ eventCode: 0,
323
+ encrypted: false,
324
+ parameters: {
325
+ token: token,
326
+ title: title,
327
+ body: body,
328
+ badge: badge,
329
+ sound: sound,
330
+ icon: icon,
331
+ data: data,
332
+ },
333
+ },
334
+ });
328
335
  }
329
336
 
330
337
  public async sendToMore(tokens: string[], title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
331
- parentPort?.postMessage({
332
- eventType: 31,
333
- receiver: null,
334
- operationEvent: {
335
- eventCode: 0,
336
- encrypted: false,
337
- parameters: {
338
- tokens: tokens,
339
- title: title,
340
- body: body,
341
- badge: badge,
342
- sound: sound,
343
- icon: icon,
344
- data: data,
345
- },
346
- },
347
- });
338
+ if (process?.send)
339
+ process.send({
340
+ eventType: 31,
341
+ receiver: null,
342
+ operationEvent: {
343
+ eventCode: 0,
344
+ encrypted: false,
345
+ parameters: {
346
+ tokens: tokens,
347
+ title: title,
348
+ body: body,
349
+ badge: badge,
350
+ sound: sound,
351
+ icon: icon,
352
+ data: data,
353
+ },
354
+ },
355
+ });
348
356
  }
349
357
 
350
358
  public async sendToTopic(topic: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
351
- parentPort?.postMessage({
352
- eventType: 32,
353
- receiver: null,
354
- operationEvent: {
355
- eventCode: 0,
356
- encrypted: false,
357
- parameters: {
358
- topic: topic,
359
- title: title,
360
- body: body,
361
- badge: badge,
362
- sound: sound,
363
- icon: icon,
364
- data: data,
365
- },
366
- },
367
- });
359
+ if (process?.send)
360
+ process.send({
361
+ eventType: 32,
362
+ receiver: null,
363
+ operationEvent: {
364
+ eventCode: 0,
365
+ encrypted: false,
366
+ parameters: {
367
+ topic: topic,
368
+ title: title,
369
+ body: body,
370
+ badge: badge,
371
+ sound: sound,
372
+ icon: icon,
373
+ data: data,
374
+ },
375
+ },
376
+ });
368
377
  }
369
378
  }
370
379
 
@@ -459,85 +468,84 @@ const ConvertArray = (results: any[]) => {
459
468
  return answer;
460
469
  }
461
470
 
462
- if (parentPort) {
463
- parentPort.on("message", async (request: CloudScriptRequest) => {
464
- let startTime = performance.now();
465
- let startMemoryUsage = process.memoryUsage();
466
-
467
- let logs: string[] = [];
468
- let functionRequest: FunctionRequest = {
469
- userId: request.userId,
470
- name: request.name,
471
- parameters: request.parameters,
472
- context: {},
473
- customTags: request.customTags,
474
- log(log: any) {
475
- logs.push(JSON.stringify(log));
476
- },
477
- };
478
-
479
- let handleResponse = await ___handleFunction(functionRequest);
480
-
481
- if (handleResponse.result) {
482
- if (handleResponse.result instanceof GNHashtable) {
483
- handleResponse.result = (<GNHashtable>handleResponse.result).toData();
484
- }
485
- else if (handleResponse.result instanceof GNArray) {
486
- handleResponse.result = (<GNArray>handleResponse.result).toData();
487
- }
488
- else {
489
- let typeofResult = typeof (handleResponse.result);
490
-
491
- if (typeofResult == "boolean") {
492
-
493
- }
494
- else if (typeofResult == "number") {
495
-
496
- }
497
- else if (typeofResult == "object") {
498
- if (Array.isArray(handleResponse.result)) {
499
-
500
- handleResponse.result = ConvertArray(handleResponse.result as any[]);
501
- //answer.push(this.deserializeArray(gnArray.getGNArray(i), cls));
502
- }
503
- else {
504
- handleResponse.result = ConvertObject(handleResponse.result);
505
- }
506
- }
507
- else if (typeofResult == "string") {
508
-
509
- }
510
- else {
511
- handleResponse.result = null;
512
-
513
- handleResponse.errorMessage = "CloudScript must return void, number, string, boolean, null, json dictionary, json array, GNHashtable or GNArray";
514
- handleResponse.status = ExecuteResponseStatus.Exception;
515
- }
516
- }
517
- }
518
-
519
- let endTime = performance.now();
520
- let endMemoryUsage = process.memoryUsage();
521
-
522
- let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
523
- if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
524
- let executeTimeInMs = endTime - startTime;
525
-
526
- //let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
471
+ process?.on("message", async (request: CloudScriptRequest) => {
472
+ let startTime = performance.now();
473
+ let startMemoryUsage = process.memoryUsage();
474
+
475
+ let logs: string[] = [];
476
+ let functionRequest: FunctionRequest = {
477
+ userId: request.userId,
478
+ name: request.name,
479
+ parameters: request.parameters,
480
+ context: {},
481
+ customTags: request.customTags,
482
+ log(log: any) {
483
+ logs.push(JSON.stringify(log));
484
+ },
485
+ };
527
486
 
528
- let response: CloudScriptResponse = {
529
- responseId: request.requestId,
530
- response: handleResponse,
531
- stats: {
532
- executeTimeInMs: executeTimeInMs,
533
- memoryUsedInBytes: memoryUsedInBytes,
534
- },
535
- logs: logs,
536
- };
487
+ let handleResponse = await ___handleFunction(functionRequest);
488
+
489
+ if (handleResponse.result) {
490
+ if (handleResponse.result instanceof GNHashtable) {
491
+ handleResponse.result = (<GNHashtable>handleResponse.result).toData();
492
+ }
493
+ else if (handleResponse.result instanceof GNArray) {
494
+ handleResponse.result = (<GNArray>handleResponse.result).toData();
495
+ }
496
+ else {
497
+ let typeofResult = typeof (handleResponse.result);
498
+
499
+ if (typeofResult == "boolean") {
500
+
501
+ }
502
+ else if (typeofResult == "number") {
503
+
504
+ }
505
+ else if (typeofResult == "object") {
506
+ if (Array.isArray(handleResponse.result)) {
507
+
508
+ handleResponse.result = ConvertArray(handleResponse.result as any[]);
509
+ //answer.push(this.deserializeArray(gnArray.getGNArray(i), cls));
510
+ }
511
+ else {
512
+ handleResponse.result = ConvertObject(handleResponse.result);
513
+ }
514
+ }
515
+ else if (typeofResult == "string") {
516
+
517
+ }
518
+ else {
519
+ handleResponse.result = null;
520
+
521
+ handleResponse.errorMessage = "CloudScript must return void, number, string, boolean, null, json dictionary, json array, GNHashtable or GNArray";
522
+ handleResponse.status = ExecuteResponseStatus.Exception;
523
+ }
524
+ }
525
+ }
526
+
527
+ let endTime = performance.now();
528
+ let endMemoryUsage = process.memoryUsage();
529
+
530
+ let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
531
+ if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
532
+ let executeTimeInMs = endTime - startTime;
533
+
534
+ //let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
535
+
536
+ let response: CloudScriptResponse = {
537
+ responseId: request.requestId,
538
+ response: handleResponse,
539
+ stats: {
540
+ executeTimeInMs: executeTimeInMs,
541
+ memoryUsedInBytes: memoryUsedInBytes,
542
+ },
543
+ logs: logs,
544
+ };
537
545
 
538
- parentPort?.postMessage(response);
539
- });
540
- }
546
+ if (process?.send)
547
+ process.send(response);
548
+ });
541
549
 
542
550
  async function ___handleFunction(request: FunctionRequest): Promise<FunctionResponse> {
543
551
  let handler = handlers[request.name];
@@ -566,20 +574,18 @@ async function ___handleFunction(request: FunctionRequest): Promise<FunctionResp
566
574
  return answer;
567
575
  }
568
576
 
577
+ const gameId: string = process.env.gameId ?? "";
578
+
569
579
  {
570
- let gnServerSettingsOptions: GNServerSettingsOptions = workerData.gnServerSettingsOptions;
580
+ let gnServerSettingsOptions: GNServerSettingsOptions = JSON.parse(process.env.gnServerSettingsOptions ?? "");
571
581
 
572
582
  let gnServerSettings = new GNServerSettings();
573
583
  gnServerSettings.config(gnServerSettingsOptions);
574
584
 
575
585
  GNNetwork.init(gnServerSettings);
576
-
577
- let gameId = workerData.gameId;
578
586
  GNNetwork.setGameId(gameId);
579
587
  }
580
588
 
581
- const gameId: string = workerData.gameId;
582
-
583
589
  const admin = new CloudScriptAdmin();
584
590
  const database = new CloudScriptDatabase();
585
591
  const http = new CloudScriptHttp();
@@ -588,12 +594,12 @@ const mail = new CloudScriptMail();
588
594
  const pushNotification = new CloudScriptPushNotification();
589
595
 
590
596
  {
591
- let dbConnection = workerData.dbConnection;
597
+ let dbConnection = JSON.parse(process.env.dbConnection ?? "");
592
598
  database.init(dbConnection.url, dbConnection.dbName, dbConnection.options);
593
599
  }
594
600
 
595
- delete workerData.dbConnection;
596
- delete workerData.gnServerSettingsOptions;
601
+ process.env.dbConnection = "";
602
+ process.env.gnServerSettingsOptions = "";
597
603
 
598
604
  const handlers: Record<string, (args: any, context: { userId: string; customTags: { [k: string]: any } }, log: (log: any) => void) => any> = {};
599
605