@groupwisdom/sdk 0.1.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.cjs +65 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const DEFAULT_BASE_URL = "https://groupwisdom.up.railway.app";
|
|
2
|
+
class GroupWisdom {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
if (!options.apiKey)
|
|
5
|
+
throw new Error("GroupWisdom: apiKey is required.");
|
|
6
|
+
this.apiKey = options.apiKey;
|
|
7
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
8
|
+
}
|
|
9
|
+
async request(method, path, body) {
|
|
10
|
+
const res = await fetch(`${this.baseUrl}/v1${path}`, {
|
|
11
|
+
method,
|
|
12
|
+
headers: {
|
|
13
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
},
|
|
16
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
17
|
+
});
|
|
18
|
+
const data = await res.json();
|
|
19
|
+
if (!res.ok) {
|
|
20
|
+
throw new Error(`GroupWisdom API error ${res.status}: ${data?.error ?? res.statusText}`);
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
// ── Projects ────────────────────────────────────────────────────────────────
|
|
25
|
+
/** Create a new project. */
|
|
26
|
+
createProject(name, options) {
|
|
27
|
+
return this.request("POST", "/projects", { name, ...options });
|
|
28
|
+
}
|
|
29
|
+
/** List all projects you have access to. */
|
|
30
|
+
listProjects() {
|
|
31
|
+
return this.request("GET", "/projects");
|
|
32
|
+
}
|
|
33
|
+
/** Get a single project by ID. */
|
|
34
|
+
getProject(projectId) {
|
|
35
|
+
return this.request("GET", `/projects/${projectId}`);
|
|
36
|
+
}
|
|
37
|
+
/** Update a project's webhook URL. */
|
|
38
|
+
updateProject(projectId, updates) {
|
|
39
|
+
return this.request("PATCH", `/projects/${projectId}`, updates);
|
|
40
|
+
}
|
|
41
|
+
// ── Ingest ──────────────────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Send one or more items to a project. Triggers analysis automatically.
|
|
44
|
+
* Items can include contributed_by to attribute them to a specific person.
|
|
45
|
+
*/
|
|
46
|
+
ingest(projectId, items) {
|
|
47
|
+
const payload = Array.isArray(items) ? { items } : items;
|
|
48
|
+
return this.request("POST", `/projects/${projectId}/ingest`, payload);
|
|
49
|
+
}
|
|
50
|
+
// ── Read ────────────────────────────────────────────────────────────────────
|
|
51
|
+
/** List all items in a project. */
|
|
52
|
+
listItems(projectId) {
|
|
53
|
+
return this.request("GET", `/projects/${projectId}/items`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get insights for a project.
|
|
57
|
+
* Optionally filter by kind: connection | blind_spot | conflict | pattern | question | decision
|
|
58
|
+
*/
|
|
59
|
+
listInsights(projectId, kind) {
|
|
60
|
+
const qs = kind ? `?kind=${kind}` : "";
|
|
61
|
+
return this.request("GET", `/projects/${projectId}/insights${qs}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
module.exports = GroupWisdom;
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface GroupWisdomOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Project {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
created_at: string;
|
|
9
|
+
webhook_url: string | null;
|
|
10
|
+
counts: {
|
|
11
|
+
items: number;
|
|
12
|
+
insights: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface IngestItem {
|
|
16
|
+
title?: string;
|
|
17
|
+
content?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
type?: "link" | "note" | "file" | "thought";
|
|
20
|
+
contributed_by?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface IngestResponse {
|
|
23
|
+
accepted: number;
|
|
24
|
+
items: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}>;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Item {
|
|
32
|
+
id: string;
|
|
33
|
+
group_id: string;
|
|
34
|
+
member_id: string | null;
|
|
35
|
+
type: string;
|
|
36
|
+
title: string;
|
|
37
|
+
content: string;
|
|
38
|
+
url: string;
|
|
39
|
+
source: string;
|
|
40
|
+
created_at: string;
|
|
41
|
+
}
|
|
42
|
+
export interface Insight {
|
|
43
|
+
id: string;
|
|
44
|
+
group_id: string;
|
|
45
|
+
kind: "connection" | "blind_spot" | "conflict" | "pattern" | "question" | "decision";
|
|
46
|
+
title: string;
|
|
47
|
+
body: string;
|
|
48
|
+
status: string;
|
|
49
|
+
created_at: string;
|
|
50
|
+
}
|
|
51
|
+
export type InsightKind = Insight["kind"];
|
|
52
|
+
declare class GroupWisdom {
|
|
53
|
+
private apiKey;
|
|
54
|
+
private baseUrl;
|
|
55
|
+
constructor(options: GroupWisdomOptions);
|
|
56
|
+
private request;
|
|
57
|
+
/** Create a new project. */
|
|
58
|
+
createProject(name: string, options?: {
|
|
59
|
+
webhook_url?: string;
|
|
60
|
+
}): Promise<Project>;
|
|
61
|
+
/** List all projects you have access to. */
|
|
62
|
+
listProjects(): Promise<Project[]>;
|
|
63
|
+
/** Get a single project by ID. */
|
|
64
|
+
getProject(projectId: string): Promise<Project>;
|
|
65
|
+
/** Update a project's webhook URL. */
|
|
66
|
+
updateProject(projectId: string, updates: {
|
|
67
|
+
webhook_url?: string | null;
|
|
68
|
+
}): Promise<Project>;
|
|
69
|
+
/**
|
|
70
|
+
* Send one or more items to a project. Triggers analysis automatically.
|
|
71
|
+
* Items can include contributed_by to attribute them to a specific person.
|
|
72
|
+
*/
|
|
73
|
+
ingest(projectId: string, items: IngestItem | IngestItem[]): Promise<IngestResponse>;
|
|
74
|
+
/** List all items in a project. */
|
|
75
|
+
listItems(projectId: string): Promise<Item[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Get insights for a project.
|
|
78
|
+
* Optionally filter by kind: connection | blind_spot | conflict | pattern | question | decision
|
|
79
|
+
*/
|
|
80
|
+
listInsights(projectId: string, kind?: InsightKind): Promise<Insight[]>;
|
|
81
|
+
}
|
|
82
|
+
export default GroupWisdom;
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,EA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;IACtC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAM5F;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAOpF,mCAAmC;IACnC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAI7C;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAIxE;AAED,eAAe,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const DEFAULT_BASE_URL = "https://groupwisdom.up.railway.app";
|
|
2
|
+
class GroupWisdom {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
if (!options.apiKey)
|
|
5
|
+
throw new Error("GroupWisdom: apiKey is required.");
|
|
6
|
+
this.apiKey = options.apiKey;
|
|
7
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
8
|
+
}
|
|
9
|
+
async request(method, path, body) {
|
|
10
|
+
const res = await fetch(`${this.baseUrl}/v1${path}`, {
|
|
11
|
+
method,
|
|
12
|
+
headers: {
|
|
13
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
},
|
|
16
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
17
|
+
});
|
|
18
|
+
const data = await res.json();
|
|
19
|
+
if (!res.ok) {
|
|
20
|
+
throw new Error(`GroupWisdom API error ${res.status}: ${data?.error ?? res.statusText}`);
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
// ── Projects ────────────────────────────────────────────────────────────────
|
|
25
|
+
/** Create a new project. */
|
|
26
|
+
createProject(name, options) {
|
|
27
|
+
return this.request("POST", "/projects", { name, ...options });
|
|
28
|
+
}
|
|
29
|
+
/** List all projects you have access to. */
|
|
30
|
+
listProjects() {
|
|
31
|
+
return this.request("GET", "/projects");
|
|
32
|
+
}
|
|
33
|
+
/** Get a single project by ID. */
|
|
34
|
+
getProject(projectId) {
|
|
35
|
+
return this.request("GET", `/projects/${projectId}`);
|
|
36
|
+
}
|
|
37
|
+
/** Update a project's webhook URL. */
|
|
38
|
+
updateProject(projectId, updates) {
|
|
39
|
+
return this.request("PATCH", `/projects/${projectId}`, updates);
|
|
40
|
+
}
|
|
41
|
+
// ── Ingest ──────────────────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Send one or more items to a project. Triggers analysis automatically.
|
|
44
|
+
* Items can include contributed_by to attribute them to a specific person.
|
|
45
|
+
*/
|
|
46
|
+
ingest(projectId, items) {
|
|
47
|
+
const payload = Array.isArray(items) ? { items } : items;
|
|
48
|
+
return this.request("POST", `/projects/${projectId}/ingest`, payload);
|
|
49
|
+
}
|
|
50
|
+
// ── Read ────────────────────────────────────────────────────────────────────
|
|
51
|
+
/** List all items in a project. */
|
|
52
|
+
listItems(projectId) {
|
|
53
|
+
return this.request("GET", `/projects/${projectId}/items`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get insights for a project.
|
|
57
|
+
* Optionally filter by kind: connection | blind_spot | conflict | pattern | question | decision
|
|
58
|
+
*/
|
|
59
|
+
listInsights(projectId, kind) {
|
|
60
|
+
const qs = kind ? `?kind=${kind}` : "";
|
|
61
|
+
return this.request("GET", `/projects/${projectId}/insights${qs}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export default GroupWisdom;
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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dom/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official JavaScript/TypeScript SDK for the GroupWisdom API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc && node build-cjs.mjs",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"groupwisdom",
|
|
28
|
+
"sdk",
|
|
29
|
+
"api",
|
|
30
|
+
"knowledge",
|
|
31
|
+
"insights"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.6.0"
|
|
36
|
+
}
|
|
37
|
+
}
|