@thinkingdifferently/core 1.0.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 +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +99 -0
- package/dist/index.mjs +62 -0
- package/package.json +31 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface SDKConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
}
|
|
4
|
+
interface GetOptions {
|
|
5
|
+
limit?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare class ThinkingDifferently {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(config: SDKConfig);
|
|
11
|
+
insert(key: string, data: Record<string, any>): Promise<any>;
|
|
12
|
+
get(key: string, options?: GetOptions): Promise<any>;
|
|
13
|
+
update(key: string, id: string, data: Record<string, any>): Promise<any>;
|
|
14
|
+
delete(key: string, id: string): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { ThinkingDifferently };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface SDKConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
}
|
|
4
|
+
interface GetOptions {
|
|
5
|
+
limit?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare class ThinkingDifferently {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(config: SDKConfig);
|
|
11
|
+
insert(key: string, data: Record<string, any>): Promise<any>;
|
|
12
|
+
get(key: string, options?: GetOptions): Promise<any>;
|
|
13
|
+
update(key: string, id: string, data: Record<string, any>): Promise<any>;
|
|
14
|
+
delete(key: string, id: string): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { ThinkingDifferently };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ThinkingDifferently: () => ThinkingDifferently
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/client.ts
|
|
38
|
+
var import_axios = __toESM(require("axios"));
|
|
39
|
+
var TDClient = class {
|
|
40
|
+
constructor(apiKey) {
|
|
41
|
+
this.api = import_axios.default.create({
|
|
42
|
+
baseURL: "https://www.thinkingdifferently.dev/api/v1",
|
|
43
|
+
headers: {
|
|
44
|
+
"x-api-key": apiKey,
|
|
45
|
+
"Content-Type": "application/json"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async request(method, body) {
|
|
50
|
+
try {
|
|
51
|
+
const response = await this.api.request({
|
|
52
|
+
url: "/data",
|
|
53
|
+
method,
|
|
54
|
+
...method === "GET" ? { params: body } : { data: body }
|
|
55
|
+
});
|
|
56
|
+
return response.data;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
error?.response?.data?.message || "Something went wrong"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// src/index.ts
|
|
66
|
+
var ThinkingDifferently = class {
|
|
67
|
+
constructor(config) {
|
|
68
|
+
this.client = new TDClient(config.apiKey);
|
|
69
|
+
}
|
|
70
|
+
async insert(key, data) {
|
|
71
|
+
return this.client.request("POST", {
|
|
72
|
+
key,
|
|
73
|
+
data
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async get(key, options) {
|
|
77
|
+
return this.client.request("GET", {
|
|
78
|
+
key,
|
|
79
|
+
...options
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async update(key, id, data) {
|
|
83
|
+
return this.client.request("PATCH", {
|
|
84
|
+
key,
|
|
85
|
+
id,
|
|
86
|
+
data
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async delete(key, id) {
|
|
90
|
+
return this.client.request("DELETE", {
|
|
91
|
+
key,
|
|
92
|
+
id
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
ThinkingDifferently
|
|
99
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var TDClient = class {
|
|
4
|
+
constructor(apiKey) {
|
|
5
|
+
this.api = axios.create({
|
|
6
|
+
baseURL: "https://www.thinkingdifferently.dev/api/v1",
|
|
7
|
+
headers: {
|
|
8
|
+
"x-api-key": apiKey,
|
|
9
|
+
"Content-Type": "application/json"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async request(method, body) {
|
|
14
|
+
try {
|
|
15
|
+
const response = await this.api.request({
|
|
16
|
+
url: "/data",
|
|
17
|
+
method,
|
|
18
|
+
...method === "GET" ? { params: body } : { data: body }
|
|
19
|
+
});
|
|
20
|
+
return response.data;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
error?.response?.data?.message || "Something went wrong"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var ThinkingDifferently = class {
|
|
31
|
+
constructor(config) {
|
|
32
|
+
this.client = new TDClient(config.apiKey);
|
|
33
|
+
}
|
|
34
|
+
async insert(key, data) {
|
|
35
|
+
return this.client.request("POST", {
|
|
36
|
+
key,
|
|
37
|
+
data
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async get(key, options) {
|
|
41
|
+
return this.client.request("GET", {
|
|
42
|
+
key,
|
|
43
|
+
...options
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async update(key, id, data) {
|
|
47
|
+
return this.client.request("PATCH", {
|
|
48
|
+
key,
|
|
49
|
+
id,
|
|
50
|
+
data
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async delete(key, id) {
|
|
54
|
+
return this.client.request("DELETE", {
|
|
55
|
+
key,
|
|
56
|
+
id
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
ThinkingDifferently
|
|
62
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thinkingdifferently/core",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Official SDK for Thinking Differently API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sdk",
|
|
17
|
+
"api",
|
|
18
|
+
"nodejs",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"author": "Krrish Savlani",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "^1.16.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^25.6.2",
|
|
28
|
+
"tsup": "^8.5.1",
|
|
29
|
+
"typescript": "^6.0.3"
|
|
30
|
+
}
|
|
31
|
+
}
|