@thinkingdifferently/core 1.0.2 → 1.0.3-beta.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.
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +22 -5
- package/dist/index.mjs +21 -5
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,12 @@ interface GetOptions {
|
|
|
5
5
|
limit?: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare class TDClient {
|
|
9
|
+
private api;
|
|
10
|
+
constructor(apiKey: string);
|
|
11
|
+
request(method: "POST" | "GET" | "PATCH" | "DELETE", body?: any): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
declare class ThinkingDifferently {
|
|
9
15
|
private client;
|
|
10
16
|
constructor(config: SDKConfig);
|
|
@@ -14,4 +20,4 @@ declare class ThinkingDifferently {
|
|
|
14
20
|
delete(key: string, id: string): Promise<any>;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
export { ThinkingDifferently };
|
|
23
|
+
export { type GetOptions, type SDKConfig, TDClient, ThinkingDifferently };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ interface GetOptions {
|
|
|
5
5
|
limit?: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare class TDClient {
|
|
9
|
+
private api;
|
|
10
|
+
constructor(apiKey: string);
|
|
11
|
+
request(method: "POST" | "GET" | "PATCH" | "DELETE", body?: any): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
declare class ThinkingDifferently {
|
|
9
15
|
private client;
|
|
10
16
|
constructor(config: SDKConfig);
|
|
@@ -14,4 +20,4 @@ declare class ThinkingDifferently {
|
|
|
14
20
|
delete(key: string, id: string): Promise<any>;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
export { ThinkingDifferently };
|
|
23
|
+
export { type GetOptions, type SDKConfig, TDClient, ThinkingDifferently };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
TDClient: () => TDClient,
|
|
33
34
|
ThinkingDifferently: () => ThinkingDifferently
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -48,9 +49,11 @@ var TDClient = class {
|
|
|
48
49
|
}
|
|
49
50
|
async request(method, body) {
|
|
50
51
|
try {
|
|
52
|
+
const isFormData = body instanceof FormData;
|
|
51
53
|
const response = await this.api.request({
|
|
52
54
|
url: "/data",
|
|
53
55
|
method,
|
|
56
|
+
headers: isFormData ? {} : { "Content-Type": "application/json" },
|
|
54
57
|
...method === "GET" ? { params: body } : { data: body }
|
|
55
58
|
});
|
|
56
59
|
return response.data;
|
|
@@ -68,16 +71,29 @@ var ThinkingDifferently = class {
|
|
|
68
71
|
this.client = new TDClient(config.apiKey);
|
|
69
72
|
}
|
|
70
73
|
async insert(key, data) {
|
|
71
|
-
|
|
72
|
-
key,
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (data instanceof FormData) {
|
|
75
|
+
data.append("key", key);
|
|
76
|
+
return this.client.request(
|
|
77
|
+
"POST",
|
|
78
|
+
data
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return this.client.request(
|
|
82
|
+
"POST",
|
|
83
|
+
{
|
|
84
|
+
key,
|
|
85
|
+
data
|
|
86
|
+
}
|
|
87
|
+
);
|
|
75
88
|
}
|
|
76
89
|
async get(key, options) {
|
|
77
|
-
|
|
90
|
+
const response = await this.client.request("GET", {
|
|
78
91
|
key,
|
|
79
92
|
...options
|
|
80
93
|
});
|
|
94
|
+
return response.data.map(
|
|
95
|
+
(item) => item.data
|
|
96
|
+
);
|
|
81
97
|
}
|
|
82
98
|
async update(key, id, data) {
|
|
83
99
|
return this.client.request("PATCH", {
|
|
@@ -95,5 +111,6 @@ var ThinkingDifferently = class {
|
|
|
95
111
|
};
|
|
96
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
113
|
0 && (module.exports = {
|
|
114
|
+
TDClient,
|
|
98
115
|
ThinkingDifferently
|
|
99
116
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -12,9 +12,11 @@ var TDClient = class {
|
|
|
12
12
|
}
|
|
13
13
|
async request(method, body) {
|
|
14
14
|
try {
|
|
15
|
+
const isFormData = body instanceof FormData;
|
|
15
16
|
const response = await this.api.request({
|
|
16
17
|
url: "/data",
|
|
17
18
|
method,
|
|
19
|
+
headers: isFormData ? {} : { "Content-Type": "application/json" },
|
|
18
20
|
...method === "GET" ? { params: body } : { data: body }
|
|
19
21
|
});
|
|
20
22
|
return response.data;
|
|
@@ -32,16 +34,29 @@ var ThinkingDifferently = class {
|
|
|
32
34
|
this.client = new TDClient(config.apiKey);
|
|
33
35
|
}
|
|
34
36
|
async insert(key, data) {
|
|
35
|
-
|
|
36
|
-
key,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (data instanceof FormData) {
|
|
38
|
+
data.append("key", key);
|
|
39
|
+
return this.client.request(
|
|
40
|
+
"POST",
|
|
41
|
+
data
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return this.client.request(
|
|
45
|
+
"POST",
|
|
46
|
+
{
|
|
47
|
+
key,
|
|
48
|
+
data
|
|
49
|
+
}
|
|
50
|
+
);
|
|
39
51
|
}
|
|
40
52
|
async get(key, options) {
|
|
41
|
-
|
|
53
|
+
const response = await this.client.request("GET", {
|
|
42
54
|
key,
|
|
43
55
|
...options
|
|
44
56
|
});
|
|
57
|
+
return response.data.map(
|
|
58
|
+
(item) => item.data
|
|
59
|
+
);
|
|
45
60
|
}
|
|
46
61
|
async update(key, id, data) {
|
|
47
62
|
return this.client.request("PATCH", {
|
|
@@ -58,5 +73,6 @@ var ThinkingDifferently = class {
|
|
|
58
73
|
}
|
|
59
74
|
};
|
|
60
75
|
export {
|
|
76
|
+
TDClient,
|
|
61
77
|
ThinkingDifferently
|
|
62
78
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thinkingdifferently/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3-beta.0",
|
|
4
4
|
"description": "Official SDK for Thinking Differently API",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|