@thinkingdifferently/core 1.0.2 → 1.0.3-beta.1
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 +102 -17
- package/dist/index.mjs +101 -17
- 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;
|
|
@@ -65,35 +68,117 @@ var TDClient = class {
|
|
|
65
68
|
// src/index.ts
|
|
66
69
|
var ThinkingDifferently = class {
|
|
67
70
|
constructor(config) {
|
|
71
|
+
console.log("[ThinkingDifferently SDK] Initializing SDK");
|
|
68
72
|
this.client = new TDClient(config.apiKey);
|
|
69
73
|
}
|
|
70
74
|
async insert(key, data) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
console.log("\n================ INSERT REQUEST ================");
|
|
76
|
+
console.log("[SDK] Collection Key:", key);
|
|
77
|
+
console.log("[SDK] Incoming Data Type:", typeof data);
|
|
78
|
+
try {
|
|
79
|
+
if (data instanceof FormData) {
|
|
80
|
+
console.log("[SDK] FormData detected");
|
|
81
|
+
data.append("key", key);
|
|
82
|
+
console.log("[SDK] FormData Entries:");
|
|
83
|
+
for (const [formKey, value] of data.entries()) {
|
|
84
|
+
console.log(` ${formKey}:`, value);
|
|
85
|
+
}
|
|
86
|
+
const response2 = await this.client.request(
|
|
87
|
+
"POST",
|
|
88
|
+
data
|
|
89
|
+
);
|
|
90
|
+
console.log("[SDK] Insert Response:", response2);
|
|
91
|
+
return response2;
|
|
92
|
+
}
|
|
93
|
+
console.log("[SDK] JSON Payload:");
|
|
94
|
+
console.log({
|
|
95
|
+
key,
|
|
96
|
+
data
|
|
97
|
+
});
|
|
98
|
+
const response = await this.client.request(
|
|
99
|
+
"POST",
|
|
100
|
+
{
|
|
101
|
+
key,
|
|
102
|
+
data
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
console.log("[SDK] Insert Response:", response);
|
|
106
|
+
return response;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error("[SDK] INSERT ERROR");
|
|
109
|
+
console.error(error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
75
112
|
}
|
|
76
113
|
async get(key, options) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
114
|
+
console.log("\n================ GET REQUEST ================");
|
|
115
|
+
console.log("[SDK] Collection Key:", key);
|
|
116
|
+
console.log("[SDK] Options:", options);
|
|
117
|
+
try {
|
|
118
|
+
const response = await this.client.request(
|
|
119
|
+
"GET",
|
|
120
|
+
{
|
|
121
|
+
key,
|
|
122
|
+
...options
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
console.log("[SDK] Raw Response:", response);
|
|
126
|
+
const parsed = response.data.map(
|
|
127
|
+
(item) => item.data
|
|
128
|
+
);
|
|
129
|
+
console.log("[SDK] Parsed Data:", parsed);
|
|
130
|
+
return parsed;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error("[SDK] GET ERROR");
|
|
133
|
+
console.error(error);
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
81
136
|
}
|
|
82
137
|
async update(key, id, data) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
138
|
+
console.log("\n================ UPDATE REQUEST ================");
|
|
139
|
+
console.log("[SDK] Collection Key:", key);
|
|
140
|
+
console.log("[SDK] Document ID:", id);
|
|
141
|
+
console.log("[SDK] Update Data:", data);
|
|
142
|
+
try {
|
|
143
|
+
const response = await this.client.request(
|
|
144
|
+
"PATCH",
|
|
145
|
+
{
|
|
146
|
+
key,
|
|
147
|
+
id,
|
|
148
|
+
data
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
console.log("[SDK] Update Response:", response);
|
|
152
|
+
return response;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error("[SDK] UPDATE ERROR");
|
|
155
|
+
console.error(error);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
88
158
|
}
|
|
89
159
|
async delete(key, id) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
160
|
+
console.log("\n================ DELETE REQUEST ================");
|
|
161
|
+
console.log("[SDK] Collection Key:", key);
|
|
162
|
+
console.log("[SDK] Document ID:", id);
|
|
163
|
+
try {
|
|
164
|
+
const response = await this.client.request(
|
|
165
|
+
"DELETE",
|
|
166
|
+
{
|
|
167
|
+
key,
|
|
168
|
+
id
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
console.log("[SDK] Delete Response:", response);
|
|
172
|
+
return response;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error("[SDK] DELETE ERROR");
|
|
175
|
+
console.error(error);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
94
178
|
}
|
|
95
179
|
};
|
|
96
180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
181
|
0 && (module.exports = {
|
|
182
|
+
TDClient,
|
|
98
183
|
ThinkingDifferently
|
|
99
184
|
});
|
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;
|
|
@@ -29,34 +31,116 @@ var TDClient = class {
|
|
|
29
31
|
// src/index.ts
|
|
30
32
|
var ThinkingDifferently = class {
|
|
31
33
|
constructor(config) {
|
|
34
|
+
console.log("[ThinkingDifferently SDK] Initializing SDK");
|
|
32
35
|
this.client = new TDClient(config.apiKey);
|
|
33
36
|
}
|
|
34
37
|
async insert(key, data) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
console.log("\n================ INSERT REQUEST ================");
|
|
39
|
+
console.log("[SDK] Collection Key:", key);
|
|
40
|
+
console.log("[SDK] Incoming Data Type:", typeof data);
|
|
41
|
+
try {
|
|
42
|
+
if (data instanceof FormData) {
|
|
43
|
+
console.log("[SDK] FormData detected");
|
|
44
|
+
data.append("key", key);
|
|
45
|
+
console.log("[SDK] FormData Entries:");
|
|
46
|
+
for (const [formKey, value] of data.entries()) {
|
|
47
|
+
console.log(` ${formKey}:`, value);
|
|
48
|
+
}
|
|
49
|
+
const response2 = await this.client.request(
|
|
50
|
+
"POST",
|
|
51
|
+
data
|
|
52
|
+
);
|
|
53
|
+
console.log("[SDK] Insert Response:", response2);
|
|
54
|
+
return response2;
|
|
55
|
+
}
|
|
56
|
+
console.log("[SDK] JSON Payload:");
|
|
57
|
+
console.log({
|
|
58
|
+
key,
|
|
59
|
+
data
|
|
60
|
+
});
|
|
61
|
+
const response = await this.client.request(
|
|
62
|
+
"POST",
|
|
63
|
+
{
|
|
64
|
+
key,
|
|
65
|
+
data
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
console.log("[SDK] Insert Response:", response);
|
|
69
|
+
return response;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("[SDK] INSERT ERROR");
|
|
72
|
+
console.error(error);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
39
75
|
}
|
|
40
76
|
async get(key, options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
77
|
+
console.log("\n================ GET REQUEST ================");
|
|
78
|
+
console.log("[SDK] Collection Key:", key);
|
|
79
|
+
console.log("[SDK] Options:", options);
|
|
80
|
+
try {
|
|
81
|
+
const response = await this.client.request(
|
|
82
|
+
"GET",
|
|
83
|
+
{
|
|
84
|
+
key,
|
|
85
|
+
...options
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
console.log("[SDK] Raw Response:", response);
|
|
89
|
+
const parsed = response.data.map(
|
|
90
|
+
(item) => item.data
|
|
91
|
+
);
|
|
92
|
+
console.log("[SDK] Parsed Data:", parsed);
|
|
93
|
+
return parsed;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error("[SDK] GET ERROR");
|
|
96
|
+
console.error(error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
45
99
|
}
|
|
46
100
|
async update(key, id, data) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
101
|
+
console.log("\n================ UPDATE REQUEST ================");
|
|
102
|
+
console.log("[SDK] Collection Key:", key);
|
|
103
|
+
console.log("[SDK] Document ID:", id);
|
|
104
|
+
console.log("[SDK] Update Data:", data);
|
|
105
|
+
try {
|
|
106
|
+
const response = await this.client.request(
|
|
107
|
+
"PATCH",
|
|
108
|
+
{
|
|
109
|
+
key,
|
|
110
|
+
id,
|
|
111
|
+
data
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
console.log("[SDK] Update Response:", response);
|
|
115
|
+
return response;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error("[SDK] UPDATE ERROR");
|
|
118
|
+
console.error(error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
52
121
|
}
|
|
53
122
|
async delete(key, id) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
console.log("\n================ DELETE REQUEST ================");
|
|
124
|
+
console.log("[SDK] Collection Key:", key);
|
|
125
|
+
console.log("[SDK] Document ID:", id);
|
|
126
|
+
try {
|
|
127
|
+
const response = await this.client.request(
|
|
128
|
+
"DELETE",
|
|
129
|
+
{
|
|
130
|
+
key,
|
|
131
|
+
id
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
console.log("[SDK] Delete Response:", response);
|
|
135
|
+
return response;
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error("[SDK] DELETE ERROR");
|
|
138
|
+
console.error(error);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
58
141
|
}
|
|
59
142
|
};
|
|
60
143
|
export {
|
|
144
|
+
TDClient,
|
|
61
145
|
ThinkingDifferently
|
|
62
146
|
};
|
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.1",
|
|
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
|
],
|