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.
- package/README.md +6 -0
- package/dist/authInfo.d.ts +2 -1
- package/dist/authInfoSample.d.ts +2 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/src/rawApi.d.ts +15 -0
- package/dist/test/unit/officialServerApi.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/rawApi.ts +3 -3
- package/test/unit/officialServerApi.test.ts +22 -0
package/dist/src/rawApi.d.ts
CHANGED
|
@@ -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
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
|
|
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:
|
|
103
|
+
value: any;
|
|
104
104
|
shard?: string;
|
|
105
|
-
}): Promise<{ ok: number; data
|
|
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
|
});
|