magicrealmsshared 0.4.3 → 0.4.5

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.
@@ -1,18 +1,24 @@
1
1
  import { GameCharacter } from "../types/charcter";
2
- import { Auth_Token, Player, Well } from "../types/types";
2
+ import { Auth_Token, PlayerClientData, Well } from "../types/types";
3
+ import { z } from "zod";
4
+ export declare const GeoJSONPointSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<"Point">;
6
+ coordinates: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>;
7
+ }, z.core.$strict>;
3
8
  export declare const AUTH = "AUTH";
4
9
  export declare const AUTH_ACK = "AUTH_ACK";
5
10
  export declare const AUTH_INVALID = "AI";
6
11
  export declare const LOGIN_COMMAND = "LOGIN";
7
- export type LOGIN_DATA = {
8
- email: string;
9
- password: string;
10
- };
12
+ export declare const LOGIN_DATA_SCHEME: z.ZodObject<{
13
+ email: z.ZodEmail;
14
+ password: z.ZodString;
15
+ }, z.core.$strict>;
16
+ export type LOGIN_DATA = z.infer<typeof LOGIN_DATA_SCHEME>;
11
17
  export declare const LOGIN_RESPONSE_COMMAND = "NIGOL";
12
18
  export type LOGIN_RESPONSE_DATA<T> = {
13
19
  code: number;
14
20
  characterData?: GameCharacter<string, number>;
15
- playerData?: Player<T>;
21
+ playerData?: PlayerClientData;
16
22
  authToken?: Auth_Token<number, T>;
17
23
  };
18
24
  export declare const LOGIN_RESPONSE_CODE_SUCCESS = 0;
@@ -25,15 +31,14 @@ export type DATA_UPDATE<T> = {
25
31
  wells?: Well<T>[];
26
32
  };
27
33
  export declare const POSUPDATE_COMMAND = "POSUPDATE";
28
- export type POSUPDATE = {
29
- pos: GeoJSON.Point;
30
- /**
31
- * The precision of the pos.
32
- *
33
- * @type {number}
34
- */
35
- pre: number;
36
- };
34
+ export declare const POSUPDATE_SCHEME: z.ZodObject<{
35
+ pos: z.ZodObject<{
36
+ type: z.ZodLiteral<"Point">;
37
+ coordinates: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>;
38
+ }, z.core.$strict>;
39
+ pre: z.ZodNumber;
40
+ }, z.core.$strict>;
41
+ export type POSUPDATE = z.infer<typeof POSUPDATE_SCHEME>;
37
42
  export declare const ADMIN_WELL_CREATE_COMMAND = "ADMIN_WELL_CREATE";
38
43
  export type ADMIN_WELL_CREATE = Pick<Well<string>, "pos"> & Partial<Omit<Well<string>, "_id" | "pos">>;
39
44
  export declare const ADMIN_WELL_DELETE_COMMAND = "ADMIN_WELL_DELETE";
@@ -1,10 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ADMIN_WELL_DELETE_COMMAND = exports.ADMIN_WELL_CREATE_COMMAND = exports.POSUPDATE_COMMAND = exports.DATA_UPDATE_COMMAND = exports.LOGIN_RESPONSE_CODE_SERVER_ERROR = exports.LOGIN_RESPONSE_CODE_PASSWORD_INVALID = exports.LOGIN_RESPONSE_CODE_EMAIL_INVALID = exports.LOGIN_RESPONSE_CODE_SUCCESS = exports.LOGIN_RESPONSE_COMMAND = exports.LOGIN_COMMAND = exports.AUTH_INVALID = exports.AUTH_ACK = exports.AUTH = void 0;
3
+ exports.ADMIN_WELL_DELETE_COMMAND = exports.ADMIN_WELL_CREATE_COMMAND = exports.POSUPDATE_SCHEME = exports.POSUPDATE_COMMAND = exports.DATA_UPDATE_COMMAND = exports.LOGIN_RESPONSE_CODE_SERVER_ERROR = exports.LOGIN_RESPONSE_CODE_PASSWORD_INVALID = exports.LOGIN_RESPONSE_CODE_EMAIL_INVALID = exports.LOGIN_RESPONSE_CODE_SUCCESS = exports.LOGIN_RESPONSE_COMMAND = exports.LOGIN_DATA_SCHEME = exports.LOGIN_COMMAND = exports.AUTH_INVALID = exports.AUTH_ACK = exports.AUTH = exports.GeoJSONPointSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.GeoJSONPointSchema = zod_1.z.strictObject({
6
+ type: zod_1.z.literal("Point"),
7
+ coordinates: zod_1.z.tuple([
8
+ zod_1.z.number(), // longitude
9
+ zod_1.z.number(), // latitude
10
+ ]).or(zod_1.z.tuple([
11
+ zod_1.z.number(), // longitude
12
+ zod_1.z.number(), // latitude
13
+ zod_1.z.number(), // altitude (optional)
14
+ ])),
15
+ });
4
16
  exports.AUTH = "AUTH";
5
17
  exports.AUTH_ACK = "AUTH_ACK";
6
18
  exports.AUTH_INVALID = "AI";
7
19
  exports.LOGIN_COMMAND = "LOGIN";
20
+ exports.LOGIN_DATA_SCHEME = zod_1.z.strictObject({
21
+ email: zod_1.z.email(),
22
+ password: zod_1.z.string().max(128),
23
+ });
8
24
  exports.LOGIN_RESPONSE_COMMAND = "NIGOL";
9
25
  exports.LOGIN_RESPONSE_CODE_SUCCESS = 0;
10
26
  exports.LOGIN_RESPONSE_CODE_EMAIL_INVALID = 10;
@@ -12,5 +28,9 @@ exports.LOGIN_RESPONSE_CODE_PASSWORD_INVALID = 20;
12
28
  exports.LOGIN_RESPONSE_CODE_SERVER_ERROR = 1000;
13
29
  exports.DATA_UPDATE_COMMAND = "DATA_UPDATE";
14
30
  exports.POSUPDATE_COMMAND = "POSUPDATE";
31
+ exports.POSUPDATE_SCHEME = zod_1.z.strictObject({
32
+ pos: exports.GeoJSONPointSchema,
33
+ pre: zod_1.z.number(),
34
+ });
15
35
  exports.ADMIN_WELL_CREATE_COMMAND = "ADMIN_WELL_CREATE";
16
36
  exports.ADMIN_WELL_DELETE_COMMAND = "ADMIN_WELL_DELETE";
@@ -26,17 +26,18 @@ export type Auth_Token<DateFormat extends Date | number, T> = {
26
26
  e: DateFormat;
27
27
  playerId: T;
28
28
  };
29
- export type Player<T> = ObjectWithId<T> & {
29
+ export type Player<IDFormat, DateFormat> = ObjectWithId<IDFormat> & {
30
30
  email: string;
31
31
  passwordHash: string;
32
32
  passwordSalt: string;
33
- registerTime: Date;
34
- loginTime: Date;
35
- interactTime: Date;
33
+ registerTime: DateFormat;
34
+ loginTime: DateFormat;
35
+ interactTime: DateFormat;
36
36
  privileges?: Privileges;
37
37
  displayname: string;
38
38
  color: number;
39
39
  };
40
+ export type PlayerClientData = Omit<Player<string, number>, "passwordHash" | "passwordSalt">;
40
41
  export type Well<T> = WorldObject<T> & {
41
42
  name: string;
42
43
  color: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magicrealmsshared",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "exports": {
19
19
  ".": {
20
- "types":"./dist/index.d.ts",
20
+ "types": "./dist/index.d.ts",
21
21
  "default": "./dist/index.js"
22
22
  },
23
23
  "./charcter": {
@@ -44,5 +44,8 @@
44
44
  "types": "./dist/types/types.d.ts",
45
45
  "default": "./dist/types/types.js"
46
46
  }
47
+ },
48
+ "dependencies": {
49
+ "zod": "^4.2.1"
47
50
  }
48
51
  }