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