@shirokasoke/webapi-sdk 2.9.0-beta2-0.11-pre → 2.9.0-beta2-0.11-test1

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,6 +1,6 @@
1
1
  import Joi from "joi";
2
2
  import { ClassInfoSchema, CoordinatesSchema } from "./common";
3
- import { ItemStackSchema } from "./item";
3
+ import { ItemStackSchema, NBTCompoundSchema } from "./item";
4
4
  export const MaterialSchema = Joi.object({
5
5
  isLiquid: Joi.boolean().required(),
6
6
  isSolid: Joi.boolean().required(),
@@ -39,10 +39,11 @@ export const BlockDetailSchema = Joi.object({
39
39
  metadata: Joi.number().required(),
40
40
  isAir: Joi.boolean().required(),
41
41
  tileEntity: Joi.object({
42
+ nbt: NBTCompoundSchema.required(),
42
43
  class: ClassInfoSchema.optional(),
43
44
  inventorySize: Joi.number().optional(),
44
45
  items: Joi.array().items(ItemStackSchema.append({ slot: Joi.number().required() })).optional(),
45
- }).unknown().optional(),
46
+ }).optional(),
46
47
  });
47
48
  export const SetBlockBodySchema = Joi.object({
48
49
  id: Joi.number().required(),
@@ -1,6 +1,7 @@
1
1
  import Joi from "joi";
2
2
  import { ClassInfoSchema } from "./common";
3
3
  import { FluidSchema } from "./fluid";
4
+ import { NBTCompoundSchema } from "./item";
4
5
  // ========== GT5 Machine Base ==========
5
6
  export const GT5MachineTypeSchema = Joi.string().valid("MULTIBLOCK", "SINGLE", "GENERATOR", "HATCH", "UNKNOWN");
6
7
  export const GT5ShutDownReasonSchema = Joi.object({
@@ -111,7 +112,7 @@ export const GT5MachineInfoSchema = Joi.object({
111
112
  owner: Joi.string().required(),
112
113
  state: GT5MachineStateSchema.required(),
113
114
  class: ClassInfoSchema.optional(),
114
- nbt: Joi.object().unknown().required(),
115
+ nbt: NBTCompoundSchema.required(),
115
116
  }).concat(GT5MachineFieldsSchema);
116
117
  export const GT5BatchMachineCoordSchema = Joi.object({
117
118
  x: Joi.number().required(),
@@ -1,9 +1,11 @@
1
1
  import Joi from "joi";
2
2
  import { ClassInfoSchema } from "./common";
3
+ export const NBTCompoundSchema = Joi.object({
4
+ nbtstr: Joi.string().required(),
5
+ nbtWrite: Joi.string().required(),
6
+ }).unknown();
3
7
  export const NBTDataSchema = Joi.object({
4
- nbtstr: Joi.string().optional(),
5
- nbtWrite: Joi.string().optional(),
6
- nbt: Joi.object().unknown().optional(),
8
+ nbt: NBTCompoundSchema.optional(),
7
9
  });
8
10
  export const ItemSchema = Joi.object({
9
11
  class: ClassInfoSchema.optional(),
@@ -1,5 +1,5 @@
1
1
  import type { ClassInfo } from "./common";
2
- import type { ItemStack } from "./item";
2
+ import type { ItemStack, NBTCompound } from "./item";
3
3
  export interface Material {
4
4
  isLiquid: boolean;
5
5
  isSolid: boolean;
@@ -39,12 +39,13 @@ export interface BlockDetail {
39
39
  metadata: number;
40
40
  isAir: boolean;
41
41
  tileEntity?: {
42
+ nbt: NBTCompound;
42
43
  class?: ClassInfo;
43
44
  inventorySize?: number;
44
45
  items?: Array<ItemStack & {
45
46
  slot: number;
46
47
  }>;
47
- } & Record<string, unknown>;
48
+ };
48
49
  }
49
50
  export interface SetBlockBody {
50
51
  id: number;
@@ -1,5 +1,6 @@
1
1
  import type { ClassInfo } from "./common";
2
2
  import type { Fluid } from "./fluid";
3
+ import type { NBTCompound } from "./item";
3
4
  export type GT5MachineType = "MULTIBLOCK" | "SINGLE" | "GENERATOR" | "HATCH" | "UNKNOWN";
4
5
  export interface GT5ShutDownReason {
5
6
  id: string;
@@ -130,7 +131,7 @@ export type GT5MachineInfo = {
130
131
  owner: string;
131
132
  state: GT5MachineState;
132
133
  class?: ClassInfo;
133
- nbt: Record<string, unknown>;
134
+ nbt: NBTCompound;
134
135
  } & GT5Machine;
135
136
  export interface GT5BatchMachineCoord {
136
137
  x: number;
@@ -1,8 +1,15 @@
1
1
  import type { ClassInfo } from "./common";
2
+ export interface NBTCompound {
3
+ /** NBT 的 SNBT 字符串形式 */
4
+ nbtstr: string;
5
+ /** Base64 编码的 NBT 二进制数据 */
6
+ nbtWrite: string;
7
+ /** NBT 复合标签内的各键值 */
8
+ [key: string]: unknown;
9
+ }
10
+ /** 携带 NBT 的对象,NBT 为空时不输出 `nbt` */
2
11
  export interface NBTData {
3
- nbtstr?: string;
4
- nbtWrite?: string;
5
- nbt?: Record<string, unknown>;
12
+ nbt?: NBTCompound;
6
13
  }
7
14
  export interface Item {
8
15
  class?: ClassInfo;
@@ -45,10 +45,11 @@ exports.BlockDetailSchema = joi_1.default.object({
45
45
  metadata: joi_1.default.number().required(),
46
46
  isAir: joi_1.default.boolean().required(),
47
47
  tileEntity: joi_1.default.object({
48
+ nbt: item_1.NBTCompoundSchema.required(),
48
49
  class: common_1.ClassInfoSchema.optional(),
49
50
  inventorySize: joi_1.default.number().optional(),
50
51
  items: joi_1.default.array().items(item_1.ItemStackSchema.append({ slot: joi_1.default.number().required() })).optional(),
51
- }).unknown().optional(),
52
+ }).optional(),
52
53
  });
53
54
  exports.SetBlockBodySchema = joi_1.default.object({
54
55
  id: joi_1.default.number().required(),
@@ -7,6 +7,7 @@ exports.GT5ScanJobResultSchema = exports.GT5ScanJobStatusSchema = exports.GT5Sca
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const common_1 = require("./common");
9
9
  const fluid_1 = require("./fluid");
10
+ const item_1 = require("./item");
10
11
  // ========== GT5 Machine Base ==========
11
12
  exports.GT5MachineTypeSchema = joi_1.default.string().valid("MULTIBLOCK", "SINGLE", "GENERATOR", "HATCH", "UNKNOWN");
12
13
  exports.GT5ShutDownReasonSchema = joi_1.default.object({
@@ -117,7 +118,7 @@ exports.GT5MachineInfoSchema = joi_1.default.object({
117
118
  owner: joi_1.default.string().required(),
118
119
  state: exports.GT5MachineStateSchema.required(),
119
120
  class: common_1.ClassInfoSchema.optional(),
120
- nbt: joi_1.default.object().unknown().required(),
121
+ nbt: item_1.NBTCompoundSchema.required(),
121
122
  }).concat(GT5MachineFieldsSchema);
122
123
  exports.GT5BatchMachineCoordSchema = joi_1.default.object({
123
124
  x: joi_1.default.number().required(),
@@ -1,5 +1,6 @@
1
1
  import Joi from "joi";
2
2
  import type { AEItemDefinitions, Item, ItemDetail } from "../types/item";
3
+ export declare const NBTCompoundSchema: Joi.ObjectSchema<any>;
3
4
  export declare const NBTDataSchema: Joi.ObjectSchema<any>;
4
5
  export declare const ItemSchema: Joi.ObjectSchema<Item>;
5
6
  export declare const ItemStackSchema: Joi.ObjectSchema<{
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AEItemDefinitionsSchema = exports.ItemDetailSchema = exports.ItemStackSchema = exports.ItemSchema = exports.NBTDataSchema = void 0;
6
+ exports.AEItemDefinitionsSchema = exports.ItemDetailSchema = exports.ItemStackSchema = exports.ItemSchema = exports.NBTDataSchema = exports.NBTCompoundSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const common_1 = require("./common");
9
+ exports.NBTCompoundSchema = joi_1.default.object({
10
+ nbtstr: joi_1.default.string().required(),
11
+ nbtWrite: joi_1.default.string().required(),
12
+ }).unknown();
9
13
  exports.NBTDataSchema = joi_1.default.object({
10
- nbtstr: joi_1.default.string().optional(),
11
- nbtWrite: joi_1.default.string().optional(),
12
- nbt: joi_1.default.object().unknown().optional(),
14
+ nbt: exports.NBTCompoundSchema.optional(),
13
15
  });
14
16
  exports.ItemSchema = joi_1.default.object({
15
17
  class: common_1.ClassInfoSchema.optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shirokasoke/webapi-sdk",
3
- "version": "2.9.0-beta2-0.11-pre",
3
+ "version": "2.9.0-beta2-0.11-test1",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK for the love.shirokasoke.WebAPI Minecraft Mod",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,8 @@
26
26
  "build": "npm run build:cjs && npm run build:esm",
27
27
  "build:cjs": "tsc -p tsconfig.json",
28
28
  "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
29
- "test": "tsx --test test/*.test.ts"
29
+ "test": "tsx --test test/*.test.ts",
30
+ "web": "npm run build && cp -r /workspace/sdk/ts/dist/* /workspace/web/node_modules/@shirokasoke/webapi-sdk/dist/"
30
31
  },
31
32
  "keywords": [
32
33
  "gtnh",
@@ -46,4 +47,4 @@
46
47
  "@microsoft/fetch-event-source": "^2.0.1",
47
48
  "joi": "^18.2.1"
48
49
  }
49
- }
50
+ }