node-ts-screeps-api 0.0.14 → 0.0.15

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.
@@ -15,6 +15,21 @@ export declare class RawApi<T extends AuthType> {
15
15
  auth(): Promise<RawApiReturnData<"signinByPassword">>;
16
16
  getSegment(args: RawApiPostData<"getSegment">): Promise<RawApiReturnData<"getSegment">>;
17
17
  postSegment(args: RawApiPostData<"postSegment">): Promise<RawApiReturnData<"postSegment">>;
18
+ getMemory(args: {
19
+ path?: string;
20
+ shard?: string;
21
+ }): Promise<{
22
+ ok: number;
23
+ data?: string;
24
+ }>;
25
+ postMemory(args: {
26
+ path?: string;
27
+ value: any;
28
+ shard?: string;
29
+ }): Promise<{
30
+ ok: number;
31
+ data?: string;
32
+ }>;
18
33
  findUser(username: string): Promise<{
19
34
  ok: number;
20
35
  user: {
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ts-screeps-api",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "node-ts-screeps-api",
5
5
  "main": "dist/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
package/src/rawApi.ts CHANGED
@@ -94,15 +94,15 @@ export class RawApi<T extends AuthType> {
94
94
  return this.req("POST", "/api/user/memory-segment", args);
95
95
  }
96
96
 
97
- public async getMemory(args: { path?: string; shard?: string }): Promise<{ ok: number; data: string }> {
97
+ public async getMemory(args: { path?: string; shard?: string }): Promise<{ ok: number; data?: string }> {
98
98
  return this.req("GET", "/api/user/memory", args);
99
99
  }
100
100
 
101
101
  public async postMemory(args: {
102
102
  path?: string;
103
- value: string;
103
+ value: any;
104
104
  shard?: string;
105
- }): Promise<{ ok: number; data: string }> {
105
+ }): Promise<{ ok: number; data?: string }> {
106
106
  return this.req("POST", "/api/user/memory", args);
107
107
  }
108
108
 
@@ -29,5 +29,27 @@ describe("api", () => {
29
29
  const name = "memory-creeps";
30
30
  writeFileSync(`test/data/roomObjects/${name}.json`, JSON.stringify(data, null, 4));
31
31
  });
32
+
33
+ it("test getMemory with invalid path", async () => {
34
+ const data = await rawApi.getMemory({ path: "__path_not_exist", shard: "shard3" });
35
+ const name = "memory-invalid-path";
36
+ writeFileSync(`test/data/roomObjects/${name}.json`, JSON.stringify(data, null, 4));
37
+ });
38
+
39
+ it("test postMemory", async () => {
40
+ const data = await rawApi.postMemory({ value: { testValue: 1 }, path: "__test__", shard: "shard3" });
41
+ const name = "post-memory";
42
+ writeFileSync(`test/data/roomObjects/${name}.json`, JSON.stringify(data, null, 4));
43
+ });
44
+
45
+ it("test postMemory with modify", async () => {
46
+ const data = await rawApi.postMemory({
47
+ value: { testValue: 2, anotherValue: 3 },
48
+ path: "__test__",
49
+ shard: "shard3"
50
+ });
51
+ const name = "post-memory-modify";
52
+ writeFileSync(`test/data/roomObjects/${name}.json`, JSON.stringify(data, null, 4));
53
+ });
32
54
  });
33
55
  });