@evanston/plankton-core 0.1.0 → 0.2.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/README.md +21 -6
- package/dist/client.d.ts +5 -5
- package/dist/client.js +99 -77
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +9 -5
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/references.d.ts +1 -1
- package/dist/references.js +27 -7
- package/dist/references.js.map +1 -1
- package/dist/schemas.d.ts +207 -11
- package/dist/schemas.js +51 -11
- package/dist/schemas.js.map +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +9 -8
- package/dist/session.js.map +1 -1
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +17 -24
- package/dist/transport.js.map +1 -1
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
# @evanston/plankton-core
|
|
2
2
|
|
|
3
|
-
Provider-independent TypeScript client for Planka 2.0.0-rc.4. Requires Node.js 22+. Original code is MIT licensed.
|
|
3
|
+
Provider-independent TypeScript client for Planka 2.0.0-rc.4. Requires Node.js 22+. Original code is MIT licensed. Version 0.2.0 accompanies the CLI release. Validation covers source contracts and fixtures against rc.4, not live production testing.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @evanston/plankton-core@latest
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
For the command-line application, install [`@evanston/plankton`](https://www.npmjs.com/package/@evanston/plankton) globally instead.
|
|
4
10
|
|
|
5
11
|
```ts
|
|
6
|
-
import { PlankaClient, errorResult } from
|
|
7
|
-
const client = new PlankaClient({
|
|
12
|
+
import { PlankaClient, errorResult } from "@evanston/plankton-core";
|
|
13
|
+
const client = new PlankaClient({
|
|
14
|
+
url: "https://planka.example",
|
|
15
|
+
session: await yourVault.read(),
|
|
16
|
+
});
|
|
8
17
|
try {
|
|
9
|
-
const result = await client.execute(
|
|
10
|
-
board:
|
|
18
|
+
const result = await client.execute("create_card", {
|
|
19
|
+
board: "Product",
|
|
20
|
+
list: "Todo",
|
|
21
|
+
name: "Review onboarding",
|
|
11
22
|
});
|
|
12
23
|
console.log(result.item);
|
|
13
|
-
} catch (error) {
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(errorResult(error));
|
|
26
|
+
}
|
|
14
27
|
```
|
|
15
28
|
|
|
16
29
|
Session input is `{ accessToken, httpOnlyToken? }`; keep it in a credential vault. Core uses native fetch and Zod. It has no browser, MCP, keyring or AI-provider dependency.
|
|
17
30
|
|
|
18
31
|
`account()` verifies the current user. `execute(operation, input)` exposes projects, boards, lists, find_cards, read_card, create_card, edit_card, move_card, task_lists, create_task_list, edit_task_list, add_task and complete_task. Exported `operationSchemas` define each input. Board/card IDs and same-instance links work directly; names are scoped and ambiguous matches return choices. Card search is bounded and returns `truncated` when incomplete. Error results are safe to share; write uncertainty is never retried automatically. Moving/creating cards in trash is excluded.
|
|
32
|
+
|
|
33
|
+
`OperationResults` maps each operation to its typed result; `OperationResult` is their union. Responses validate the resource and collections consumed by each request. Malformed reads fail rather than appearing as empty results; malformed write responses remain `UNCERTAIN_WRITE`. Exact card-name resolution uses the full collected set independently of display limits, while refusing resolution if the underlying scan is incomplete.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type Operation, type OperationInput } from
|
|
2
|
-
import { type ClientOptions } from
|
|
1
|
+
import { type OperationResults, type Operation, type OperationInput } from "./schemas.js";
|
|
2
|
+
import { type ClientOptions } from "./transport.js";
|
|
3
3
|
export declare class PlankaClient {
|
|
4
4
|
readonly url: string;
|
|
5
5
|
private readonly transport;
|
|
6
6
|
constructor(options: ClientOptions);
|
|
7
|
-
private item;
|
|
8
7
|
private board;
|
|
9
8
|
private card;
|
|
10
9
|
private writableList;
|
|
@@ -12,10 +11,11 @@ export declare class PlankaClient {
|
|
|
12
11
|
account(): Promise<{
|
|
13
12
|
id: string;
|
|
14
13
|
name: string | undefined;
|
|
15
|
-
username:
|
|
14
|
+
username: string | undefined;
|
|
16
15
|
}>;
|
|
16
|
+
private collectCards;
|
|
17
17
|
private search;
|
|
18
|
-
execute<K extends Operation>(operation: K, input: OperationInput<K>): Promise<
|
|
18
|
+
execute<K extends Operation>(operation: K, input: OperationInput<K>): Promise<OperationResults[K]>;
|
|
19
19
|
private writeItem;
|
|
20
20
|
private executeCard;
|
|
21
21
|
private executeTask;
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PlanktonError } from
|
|
2
|
-
import { referenceId, resolveReference } from
|
|
3
|
-
import { operationSchemas, } from
|
|
4
|
-
import { PlankaTransport } from
|
|
1
|
+
import { PlanktonError } from "./errors.js";
|
|
2
|
+
import { referenceId, resolveReference } from "./references.js";
|
|
3
|
+
import { operationSchemas, boardResponseSchema, cardResponseSchema, itemResponseSchema, itemsResponseSchema, projectsResponseSchema, } from "./schemas.js";
|
|
4
|
+
import { PlankaTransport } from "./transport.js";
|
|
5
5
|
export class PlankaClient {
|
|
6
6
|
url;
|
|
7
7
|
transport;
|
|
@@ -9,58 +9,52 @@ export class PlankaClient {
|
|
|
9
9
|
this.transport = new PlankaTransport(options);
|
|
10
10
|
this.url = this.transport.url;
|
|
11
11
|
}
|
|
12
|
-
item(data) {
|
|
13
|
-
if (!data.item) {
|
|
14
|
-
throw new PlanktonError('API', 'Planka response is missing the expected resource.');
|
|
15
|
-
}
|
|
16
|
-
return data.item;
|
|
17
|
-
}
|
|
18
12
|
async board(value) {
|
|
19
|
-
const id = referenceId(this.url, value,
|
|
20
|
-
resolveReference(this.url, value, (await this.transport.request(
|
|
21
|
-
|
|
13
|
+
const id = referenceId(this.url, value, "boards") ??
|
|
14
|
+
resolveReference(this.url, value, (await this.transport.request("projects", projectsResponseSchema))
|
|
15
|
+
.included.boards, "boards").id;
|
|
16
|
+
return this.transport.request(`boards/${id}`, boardResponseSchema);
|
|
22
17
|
}
|
|
23
18
|
async card(value, board) {
|
|
24
|
-
let id = referenceId(this.url, value,
|
|
19
|
+
let id = referenceId(this.url, value, "cards");
|
|
25
20
|
if (!id) {
|
|
26
21
|
if (!board) {
|
|
27
|
-
throw new PlanktonError(
|
|
22
|
+
throw new PlanktonError("VALIDATION", "Supply a board to resolve a card name, or use a card ID/link.");
|
|
28
23
|
}
|
|
29
|
-
const found = await this.
|
|
30
|
-
if (found.
|
|
31
|
-
throw new PlanktonError(
|
|
24
|
+
const found = await this.collectCards(board);
|
|
25
|
+
if (!found.complete) {
|
|
26
|
+
throw new PlanktonError("VALIDATION", "Card search is incomplete. Use a card ID/link to avoid resolving the wrong card.");
|
|
32
27
|
}
|
|
33
|
-
id = resolveReference(this.url, value, found.items,
|
|
28
|
+
id = resolveReference(this.url, value, found.items, "cards").id;
|
|
34
29
|
}
|
|
35
|
-
return this.transport.request(`cards/${id}
|
|
30
|
+
return this.transport.request(`cards/${id}`, cardResponseSchema);
|
|
36
31
|
}
|
|
37
32
|
writableList(list) {
|
|
38
|
-
if (list.type ===
|
|
39
|
-
throw new PlanktonError(
|
|
33
|
+
if (list.type === "trash") {
|
|
34
|
+
throw new PlanktonError("VALIDATION", "Moving or creating cards in trash is outside the initial scope.");
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
|
-
link(item, kind =
|
|
37
|
+
link(item, kind = "cards") {
|
|
43
38
|
return { ...item, url: `${this.url}/${kind}/${item.id}` };
|
|
44
39
|
}
|
|
45
40
|
async account() {
|
|
46
|
-
const item =
|
|
41
|
+
const { item } = await this.transport.request("users/me", itemResponseSchema);
|
|
47
42
|
return { id: item.id, name: item.name, username: item.username };
|
|
48
43
|
}
|
|
49
|
-
async
|
|
44
|
+
async collectCards(board) {
|
|
50
45
|
const data = await this.board(board);
|
|
51
|
-
const lists = data.included
|
|
52
|
-
const cards = new Map(
|
|
53
|
-
let
|
|
46
|
+
const lists = data.included.lists;
|
|
47
|
+
const cards = new Map(data.included.cards.map((c) => [c.id, c]));
|
|
48
|
+
let complete = true;
|
|
54
49
|
// Endless lists have separate pages; cap work and disclose incomplete results.
|
|
55
|
-
for (const list of lists.filter((l) => l.type ===
|
|
50
|
+
for (const list of lists.filter((l) => l.type === "archive" || l.type === "trash")) {
|
|
56
51
|
let before;
|
|
57
52
|
for (let page = 0; page < 10; page++) {
|
|
58
53
|
const params = new URLSearchParams();
|
|
59
54
|
if (before) {
|
|
60
|
-
params.set(
|
|
55
|
+
params.set("before", JSON.stringify(before));
|
|
61
56
|
}
|
|
62
|
-
const rows = (await this.transport.request(`lists/${list.id}/cards${params.size ? `?${params}` :
|
|
63
|
-
.items ?? [];
|
|
57
|
+
const rows = (await this.transport.request(`lists/${list.id}/cards${params.size ? `?${params}` : ""}`, itemsResponseSchema)).items;
|
|
64
58
|
if (!rows.length) {
|
|
65
59
|
break;
|
|
66
60
|
}
|
|
@@ -69,51 +63,68 @@ export class PlankaClient {
|
|
|
69
63
|
}
|
|
70
64
|
const last = rows.at(-1);
|
|
71
65
|
if (!last.listChangedAt || page === 9) {
|
|
72
|
-
|
|
66
|
+
complete = false;
|
|
73
67
|
break;
|
|
74
68
|
}
|
|
75
69
|
const next = { id: last.id, listChangedAt: last.listChangedAt };
|
|
76
|
-
if (
|
|
77
|
-
|
|
70
|
+
if (next.id === before?.id &&
|
|
71
|
+
next.listChangedAt === before.listChangedAt) {
|
|
72
|
+
complete = false;
|
|
78
73
|
break;
|
|
79
74
|
}
|
|
80
75
|
before = next;
|
|
81
76
|
}
|
|
82
77
|
}
|
|
83
|
-
const matches = [...cards.values()].filter((c) => c.name?.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
|
|
84
78
|
return {
|
|
85
|
-
items:
|
|
86
|
-
|
|
79
|
+
items: [...cards.values()].map((c) => this.link({
|
|
80
|
+
...c,
|
|
81
|
+
boardId: c.boardId ?? data.item.id,
|
|
82
|
+
boardName: data.item.name,
|
|
83
|
+
listName: lists.find((l) => l.id === c.listId)?.name,
|
|
84
|
+
})),
|
|
85
|
+
complete,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async search(board, query, limit) {
|
|
89
|
+
const found = await this.collectCards(board);
|
|
90
|
+
const needle = query.toLocaleLowerCase();
|
|
91
|
+
const matches = found.items.filter((card) => card.name?.toLocaleLowerCase().includes(needle));
|
|
92
|
+
return {
|
|
93
|
+
items: matches.slice(0, limit),
|
|
94
|
+
truncated: !found.complete || matches.length > limit,
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
97
|
async execute(operation, input) {
|
|
90
|
-
// The public method validates
|
|
91
|
-
const args = {
|
|
98
|
+
// The public method validates for all callers.
|
|
99
|
+
const args = {
|
|
100
|
+
...operationSchemas[operation].parse(input),
|
|
101
|
+
operation,
|
|
102
|
+
};
|
|
92
103
|
switch (args.operation) {
|
|
93
|
-
case
|
|
104
|
+
case "projects":
|
|
94
105
|
return {
|
|
95
|
-
items: (
|
|
106
|
+
items: (await this.transport.request("projects", itemsResponseSchema)).items.map((i) => this.link(i, "projects")),
|
|
96
107
|
};
|
|
97
|
-
case
|
|
98
|
-
const data = await this.transport.request(
|
|
108
|
+
case "boards": {
|
|
109
|
+
const data = await this.transport.request("projects", projectsResponseSchema);
|
|
99
110
|
const projectId = args.project
|
|
100
|
-
? resolveReference(this.url, args.project, data.items
|
|
111
|
+
? resolveReference(this.url, args.project, data.items, "projects").id
|
|
101
112
|
: undefined;
|
|
102
113
|
return {
|
|
103
|
-
items:
|
|
114
|
+
items: data.included.boards
|
|
104
115
|
.filter((b) => !projectId || b.projectId === projectId)
|
|
105
|
-
.map((b) => this.link(b,
|
|
116
|
+
.map((b) => this.link(b, "boards")),
|
|
106
117
|
};
|
|
107
118
|
}
|
|
108
|
-
case
|
|
109
|
-
return { items: (await this.board(args.board)).included
|
|
110
|
-
case
|
|
119
|
+
case "lists":
|
|
120
|
+
return { items: (await this.board(args.board)).included.lists };
|
|
121
|
+
case "find_cards":
|
|
111
122
|
return this.search(args.board, args.query, args.limit);
|
|
112
|
-
case
|
|
123
|
+
case "create_card": {
|
|
113
124
|
const board = await this.board(args.board);
|
|
114
|
-
const list = resolveReference(this.url, args.list, board.included
|
|
125
|
+
const list = resolveReference(this.url, args.list, board.included.lists, "lists");
|
|
115
126
|
this.writableList(list);
|
|
116
|
-
const item = await this.writeItem(`lists/${list.id}/cards`,
|
|
127
|
+
const item = await this.writeItem(`lists/${list.id}/cards`, "POST", {
|
|
117
128
|
name: args.name,
|
|
118
129
|
description: args.description,
|
|
119
130
|
type: args.type,
|
|
@@ -126,41 +137,48 @@ export class PlankaClient {
|
|
|
126
137
|
}
|
|
127
138
|
}
|
|
128
139
|
async writeItem(path, method, body) {
|
|
129
|
-
return
|
|
140
|
+
return (await this.transport.request(path, itemResponseSchema, method, body)).item;
|
|
130
141
|
}
|
|
131
142
|
async executeCard(args) {
|
|
132
143
|
const data = await this.card(args.card, args.board);
|
|
133
|
-
const card =
|
|
144
|
+
const card = data.item;
|
|
134
145
|
const url = this.link(card).url;
|
|
135
146
|
switch (args.operation) {
|
|
136
|
-
case
|
|
147
|
+
case "read_card":
|
|
137
148
|
return {
|
|
138
149
|
item: this.link(card),
|
|
139
|
-
taskLists: data.included
|
|
140
|
-
tasks: data.included
|
|
150
|
+
taskLists: data.included.taskLists,
|
|
151
|
+
tasks: data.included.tasks,
|
|
141
152
|
};
|
|
142
|
-
case
|
|
143
|
-
const item = await this.writeItem(`cards/${card.id}`,
|
|
153
|
+
case "edit_card": {
|
|
154
|
+
const item = await this.writeItem(`cards/${card.id}`, "PATCH", {
|
|
144
155
|
name: args.name,
|
|
145
156
|
description: args.description,
|
|
146
157
|
});
|
|
147
158
|
return { item: this.link(item) };
|
|
148
159
|
}
|
|
149
|
-
case
|
|
150
|
-
const
|
|
151
|
-
|
|
160
|
+
case "move_card": {
|
|
161
|
+
const destination = args.destinationBoard ?? card.boardId ?? args.board;
|
|
162
|
+
if (!destination)
|
|
163
|
+
throw new PlanktonError("VALIDATION", "Cannot determine the current board. Supply --to-board.");
|
|
164
|
+
const board = await this.board(destination);
|
|
165
|
+
const list = resolveReference(this.url, args.list, board.included.lists, "lists");
|
|
152
166
|
this.writableList(list);
|
|
153
|
-
const item = await this.writeItem(`cards/${card.id}`,
|
|
154
|
-
boardId:
|
|
167
|
+
const item = await this.writeItem(`cards/${card.id}`, "PATCH", {
|
|
168
|
+
boardId: board.item.id,
|
|
155
169
|
listId: list.id,
|
|
156
170
|
position: args.position,
|
|
157
171
|
});
|
|
158
172
|
return { item: this.link(item) };
|
|
159
173
|
}
|
|
160
|
-
case
|
|
161
|
-
return {
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
case "task_lists":
|
|
175
|
+
return {
|
|
176
|
+
items: data.included.taskLists,
|
|
177
|
+
tasks: data.included.tasks,
|
|
178
|
+
url,
|
|
179
|
+
};
|
|
180
|
+
case "create_task_list": {
|
|
181
|
+
const item = await this.writeItem(`cards/${card.id}/task-lists`, "POST", {
|
|
164
182
|
name: args.name,
|
|
165
183
|
position: args.position,
|
|
166
184
|
});
|
|
@@ -171,18 +189,22 @@ export class PlankaClient {
|
|
|
171
189
|
}
|
|
172
190
|
}
|
|
173
191
|
async executeTask(args, data) {
|
|
174
|
-
const taskList = resolveReference(this.url, args.taskList, data.included
|
|
192
|
+
const taskList = resolveReference(this.url, args.taskList, data.included.taskLists, "task-lists");
|
|
175
193
|
switch (args.operation) {
|
|
176
|
-
case
|
|
177
|
-
return this.writeItem(`task-lists/${taskList.id}`,
|
|
178
|
-
|
|
179
|
-
|
|
194
|
+
case "edit_task_list":
|
|
195
|
+
return this.writeItem(`task-lists/${taskList.id}`, "PATCH", {
|
|
196
|
+
name: args.name,
|
|
197
|
+
});
|
|
198
|
+
case "add_task":
|
|
199
|
+
return this.writeItem(`task-lists/${taskList.id}/tasks`, "POST", {
|
|
180
200
|
name: args.name,
|
|
181
201
|
position: args.position,
|
|
182
202
|
});
|
|
183
|
-
case
|
|
184
|
-
const task = resolveReference(this.url, args.task,
|
|
185
|
-
return this.writeItem(`tasks/${task.id}`,
|
|
203
|
+
case "complete_task": {
|
|
204
|
+
const task = resolveReference(this.url, args.task, data.included.tasks.filter((task) => task.taskListId === taskList.id), "tasks");
|
|
205
|
+
return this.writeItem(`tasks/${task.id}`, "PATCH", {
|
|
206
|
+
isCompleted: args.isCompleted,
|
|
207
|
+
});
|
|
186
208
|
}
|
|
187
209
|
}
|
|
188
210
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAEhB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GAOvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAErE,MAAM,OAAO,YAAY;IACd,GAAG,CAAS;IACJ,SAAS,CAAkB;IAE5C,YAAY,OAAsB;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;IAChC,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,KAAa;QAC/B,MAAM,EAAE,GACN,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EA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,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,EAAE,CAAC,EACrE,OAAO,CACR,CAAC;gBACF,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE;oBACjD,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ErrorCode =
|
|
1
|
+
export type ErrorCode = "AUTHENTICATION" | "PERMISSION" | "VALIDATION" | "NOT_FOUND" | "AMBIGUOUS" | "NETWORK" | "UNCERTAIN_WRITE" | "API" | "STORAGE" | "LOGIN";
|
|
2
2
|
export declare class PlanktonError extends Error {
|
|
3
3
|
code: ErrorCode;
|
|
4
4
|
details?: Record<string, unknown> | undefined;
|
package/dist/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export class PlanktonError extends Error {
|
|
3
3
|
code;
|
|
4
4
|
details;
|
|
@@ -6,18 +6,22 @@ export class PlanktonError extends Error {
|
|
|
6
6
|
super(message);
|
|
7
7
|
this.code = code;
|
|
8
8
|
this.details = details;
|
|
9
|
-
this.name =
|
|
9
|
+
this.name = "PlanktonError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export function errorResult(error) {
|
|
13
13
|
const e = error instanceof PlanktonError
|
|
14
14
|
? error
|
|
15
15
|
: error instanceof z.ZodError
|
|
16
|
-
? new PlanktonError(
|
|
17
|
-
: new PlanktonError(
|
|
16
|
+
? new PlanktonError("VALIDATION", "Invalid input. Check field types, lengths and required references.", { fields: error.issues.map((i) => i.path.join(".")) })
|
|
17
|
+
: new PlanktonError("API", "Operation failed. Run plankton doctor for connection diagnostics.");
|
|
18
18
|
return {
|
|
19
19
|
ok: false,
|
|
20
|
-
error: {
|
|
20
|
+
error: {
|
|
21
|
+
code: e.code,
|
|
22
|
+
message: e.message,
|
|
23
|
+
...(e.details ? { details: e.details } : {}),
|
|
24
|
+
},
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,MAAM,OAAO,aAAc,SAAQ,KAAK;IAE7B;IAEA;IAHT,YACS,IAAe,EACtB,OAAe,EACR,OAAiC;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAW;QAEf,YAAO,GAAP,OAAO,CAA0B;QAGxC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,CAAC,GACL,KAAK,YAAY,aAAa;QAC5B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,QAAQ;YAC3B,CAAC,CAAC,IAAI,aAAa,CACf,YAAY,EACZ,oEAAoE,EACpE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CACtD;YACH,CAAC,CAAC,IAAI,aAAa,CACf,KAAK,EACL,mEAAmE,CACpE,CAAC;IACV,OAAO;QACL,EAAE,EAAE,KAAc;QAClB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,MAAM,OAAO,aAAc,SAAQ,KAAK;IAE7B;IAEA;IAHT,YACS,IAAe,EACtB,OAAe,EACR,OAAiC;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAW;QAEf,YAAO,GAAP,OAAO,CAA0B;QAGxC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,CAAC,GACL,KAAK,YAAY,aAAa;QAC5B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,QAAQ;YAC3B,CAAC,CAAC,IAAI,aAAa,CACf,YAAY,EACZ,oEAAoE,EACpE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CACtD;YACH,CAAC,CAAC,IAAI,aAAa,CACf,KAAK,EACL,mEAAmE,CACpE,CAAC;IACV,OAAO;QACL,EAAE,EAAE,KAAc;QAClB,KAAK,EAAE;YACL,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PlankaClient } from
|
|
2
|
-
export { PlanktonError, errorResult, type ErrorCode } from
|
|
3
|
-
export { normalizeUrl, sessionSchema, type Session } from
|
|
4
|
-
export { operationSchemas, type Entity, type Operation, type OperationInput } from
|
|
1
|
+
export { PlankaClient } from "./client.js";
|
|
2
|
+
export { PlanktonError, errorResult, type ErrorCode } from "./errors.js";
|
|
3
|
+
export { normalizeUrl, sessionSchema, type Session } from "./session.js";
|
|
4
|
+
export { operationSchemas, type Entity, type Operation, type OperationInput, type OperationResult, type OperationResults, } from "./schemas.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PlankaClient } from
|
|
2
|
-
export { PlanktonError, errorResult } from
|
|
3
|
-
export { normalizeUrl, sessionSchema } from
|
|
4
|
-
export { operationSchemas } from
|
|
1
|
+
export { PlankaClient } from "./client.js";
|
|
2
|
+
export { PlanktonError, errorResult } from "./errors.js";
|
|
3
|
+
export { normalizeUrl, sessionSchema } from "./session.js";
|
|
4
|
+
export { operationSchemas, } from "./schemas.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,gBAAgB,GAMjB,MAAM,cAAc,CAAC"}
|
package/dist/references.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Entity } from
|
|
1
|
+
import type { Entity } from "./schemas.js";
|
|
2
2
|
export declare function referenceId(baseUrl: string, value: string, kind: string): string | undefined;
|
|
3
3
|
export declare function resolveReference(baseUrl: string, value: string, items: Entity[], kind: string): Entity;
|
package/dist/references.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlanktonError } from
|
|
1
|
+
import { PlanktonError } from "./errors.js";
|
|
2
2
|
export function referenceId(baseUrl, value, kind) {
|
|
3
3
|
if (/^\d+$/.test(value)) {
|
|
4
4
|
return value;
|
|
@@ -6,11 +6,11 @@ export function referenceId(baseUrl, value, kind) {
|
|
|
6
6
|
if (/^https?:\/\//i.test(value)) {
|
|
7
7
|
const url = new URL(value);
|
|
8
8
|
const base = new URL(baseUrl);
|
|
9
|
-
const prefix = `${base.pathname.replace(/\/$/,
|
|
9
|
+
const prefix = `${base.pathname.replace(/\/$/, "")}/${kind}/`;
|
|
10
10
|
if (url.origin !== base.origin ||
|
|
11
11
|
!url.pathname.startsWith(prefix) ||
|
|
12
12
|
!/^\d+$/.test(url.pathname.slice(prefix.length))) {
|
|
13
|
-
throw new PlanktonError(
|
|
13
|
+
throw new PlanktonError("VALIDATION", `Use a ${kind} link from the active Planka instance.`);
|
|
14
14
|
}
|
|
15
15
|
return url.pathname.slice(prefix.length);
|
|
16
16
|
}
|
|
@@ -18,13 +18,33 @@ export function referenceId(baseUrl, value, kind) {
|
|
|
18
18
|
}
|
|
19
19
|
export function resolveReference(baseUrl, value, items, kind) {
|
|
20
20
|
const id = referenceId(baseUrl, value, kind);
|
|
21
|
-
const matches = items.filter((i) => id
|
|
21
|
+
const matches = items.filter((i) => id
|
|
22
|
+
? i.id === id
|
|
23
|
+
: i.name?.toLocaleLowerCase() === value.toLocaleLowerCase());
|
|
22
24
|
if (!matches.length) {
|
|
23
|
-
throw new PlanktonError(
|
|
25
|
+
throw new PlanktonError("NOT_FOUND", `No matching ${kind} in this scope.`);
|
|
24
26
|
}
|
|
25
27
|
if (matches.length > 1) {
|
|
26
|
-
throw new PlanktonError(
|
|
27
|
-
choices: matches
|
|
28
|
+
throw new PlanktonError("AMBIGUOUS", `Multiple ${kind} match. Choose an ID.`, {
|
|
29
|
+
choices: matches
|
|
30
|
+
.slice(0, 25)
|
|
31
|
+
.map((i) => Object.fromEntries([
|
|
32
|
+
"id",
|
|
33
|
+
"name",
|
|
34
|
+
"projectId",
|
|
35
|
+
"boardId",
|
|
36
|
+
"boardName",
|
|
37
|
+
"listId",
|
|
38
|
+
"listName",
|
|
39
|
+
"cardId",
|
|
40
|
+
"taskListId",
|
|
41
|
+
"url",
|
|
42
|
+
]
|
|
43
|
+
.filter((key) => i[key] !== undefined)
|
|
44
|
+
.map((key) => [key, i[key]]))),
|
|
45
|
+
...(matches.length > 25
|
|
46
|
+
? { truncated: true, total: matches.length }
|
|
47
|
+
: {}),
|
|
28
48
|
});
|
|
29
49
|
}
|
|
30
50
|
return matches[0];
|
package/dist/references.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,KAAa,EACb,IAAY;IAEZ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,K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EAAE,CACT,MAAM,CAAC,WAAW,CAChB;gBACE,IAAI;gBACJ,MAAM;gBACN,WAAW;gBACX,SAAS;gBACT,WAAW;gBACX,QAAQ;gBACR,UAAU;gBACV,QAAQ;gBACR,YAAY;gBACZ,KAAK;aACN;iBACE,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;iBACrC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAC/B,CACF;YACH,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE;gBACrB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;gBAC5C,CAAC,CAAC,EAAE,CAAC;SACR,CACF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC;AACrB,CAAC"}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,24 +1,221 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
declare const entitySchema: z.ZodObject<{
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const entitySchema: z.ZodObject<{
|
|
3
3
|
id: z.ZodString;
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
username: z.ZodOptional<z.ZodString>;
|
|
6
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
type: z.ZodOptional<z.ZodString>;
|
|
12
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
5
16
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
6
17
|
export type Entity = z.infer<typeof entitySchema>;
|
|
7
|
-
export declare const
|
|
8
|
-
item: z.
|
|
18
|
+
export declare const itemResponseSchema: z.ZodObject<{
|
|
19
|
+
item: z.ZodObject<{
|
|
9
20
|
id: z.ZodString;
|
|
10
21
|
name: z.ZodOptional<z.ZodString>;
|
|
22
|
+
username: z.ZodOptional<z.ZodString>;
|
|
23
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
26
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
27
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
type: z.ZodOptional<z.ZodString>;
|
|
29
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const itemsResponseSchema: z.ZodObject<{
|
|
36
|
+
items: z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
username: z.ZodOptional<z.ZodString>;
|
|
40
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
type: z.ZodOptional<z.ZodString>;
|
|
46
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
11
50
|
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
12
|
-
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const projectsResponseSchema: z.ZodObject<{
|
|
53
|
+
items: z.ZodArray<z.ZodObject<{
|
|
13
54
|
id: z.ZodString;
|
|
14
55
|
name: z.ZodOptional<z.ZodString>;
|
|
15
|
-
|
|
16
|
-
|
|
56
|
+
username: z.ZodOptional<z.ZodString>;
|
|
57
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
58
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
61
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
type: z.ZodOptional<z.ZodString>;
|
|
63
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
68
|
+
included: z.ZodObject<{
|
|
69
|
+
boards: z.ZodArray<z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
name: z.ZodOptional<z.ZodString>;
|
|
72
|
+
username: z.ZodOptional<z.ZodString>;
|
|
73
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
78
|
+
type: z.ZodOptional<z.ZodString>;
|
|
79
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
81
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export declare const boardResponseSchema: z.ZodObject<{
|
|
87
|
+
item: z.ZodObject<{
|
|
17
88
|
id: z.ZodString;
|
|
18
89
|
name: z.ZodOptional<z.ZodString>;
|
|
19
|
-
|
|
90
|
+
username: z.ZodOptional<z.ZodString>;
|
|
91
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
93
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
95
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
96
|
+
type: z.ZodOptional<z.ZodString>;
|
|
97
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
102
|
+
included: z.ZodObject<{
|
|
103
|
+
lists: z.ZodArray<z.ZodObject<{
|
|
104
|
+
id: z.ZodString;
|
|
105
|
+
name: z.ZodOptional<z.ZodString>;
|
|
106
|
+
username: z.ZodOptional<z.ZodString>;
|
|
107
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
108
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
109
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
110
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
111
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
112
|
+
type: z.ZodOptional<z.ZodString>;
|
|
113
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
118
|
+
cards: z.ZodArray<z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
name: z.ZodOptional<z.ZodString>;
|
|
121
|
+
username: z.ZodOptional<z.ZodString>;
|
|
122
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
123
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
124
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
125
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
126
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
127
|
+
type: z.ZodOptional<z.ZodString>;
|
|
128
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
131
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
133
|
+
}, z.core.$strip>;
|
|
20
134
|
}, z.core.$strip>;
|
|
21
|
-
export
|
|
135
|
+
export declare const cardResponseSchema: z.ZodObject<{
|
|
136
|
+
item: z.ZodObject<{
|
|
137
|
+
id: z.ZodString;
|
|
138
|
+
name: z.ZodOptional<z.ZodString>;
|
|
139
|
+
username: z.ZodOptional<z.ZodString>;
|
|
140
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
141
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
142
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
144
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
145
|
+
type: z.ZodOptional<z.ZodString>;
|
|
146
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
149
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
151
|
+
included: z.ZodObject<{
|
|
152
|
+
taskLists: z.ZodArray<z.ZodObject<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
name: z.ZodOptional<z.ZodString>;
|
|
155
|
+
username: z.ZodOptional<z.ZodString>;
|
|
156
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
157
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
158
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
159
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
161
|
+
type: z.ZodOptional<z.ZodString>;
|
|
162
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
167
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
168
|
+
id: z.ZodString;
|
|
169
|
+
name: z.ZodOptional<z.ZodString>;
|
|
170
|
+
username: z.ZodOptional<z.ZodString>;
|
|
171
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
172
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
173
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
174
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
175
|
+
taskListId: z.ZodOptional<z.ZodString>;
|
|
176
|
+
type: z.ZodOptional<z.ZodString>;
|
|
177
|
+
listChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
178
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
179
|
+
isCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
181
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type CardResponse = z.infer<typeof cardResponseSchema>;
|
|
185
|
+
export type CollectionResult = {
|
|
186
|
+
items: Entity[];
|
|
187
|
+
};
|
|
188
|
+
export type SearchResult = CollectionResult & {
|
|
189
|
+
truncated: boolean;
|
|
190
|
+
};
|
|
191
|
+
export type ItemResult = {
|
|
192
|
+
item: Entity;
|
|
193
|
+
url?: string;
|
|
194
|
+
};
|
|
195
|
+
export type CardResult = ItemResult & {
|
|
196
|
+
taskLists: Entity[];
|
|
197
|
+
tasks: Entity[];
|
|
198
|
+
};
|
|
199
|
+
export type TaskListsResult = CollectionResult & {
|
|
200
|
+
tasks: Entity[];
|
|
201
|
+
url: string;
|
|
202
|
+
};
|
|
203
|
+
export interface OperationResults {
|
|
204
|
+
projects: CollectionResult;
|
|
205
|
+
boards: CollectionResult;
|
|
206
|
+
lists: CollectionResult;
|
|
207
|
+
find_cards: SearchResult;
|
|
208
|
+
read_card: CardResult;
|
|
209
|
+
create_card: ItemResult;
|
|
210
|
+
edit_card: ItemResult;
|
|
211
|
+
move_card: ItemResult;
|
|
212
|
+
task_lists: TaskListsResult;
|
|
213
|
+
create_task_list: ItemResult;
|
|
214
|
+
edit_task_list: ItemResult;
|
|
215
|
+
add_task: ItemResult;
|
|
216
|
+
complete_task: ItemResult;
|
|
217
|
+
}
|
|
218
|
+
export type OperationResult = OperationResults[Operation];
|
|
22
219
|
export declare const operationSchemas: {
|
|
23
220
|
projects: z.ZodObject<{}, z.core.$strict>;
|
|
24
221
|
boards: z.ZodObject<{
|
|
@@ -56,7 +253,7 @@ export declare const operationSchemas: {
|
|
|
56
253
|
move_card: z.ZodObject<{
|
|
57
254
|
card: z.ZodString;
|
|
58
255
|
board: z.ZodOptional<z.ZodString>;
|
|
59
|
-
destinationBoard: z.ZodString
|
|
256
|
+
destinationBoard: z.ZodOptional<z.ZodString>;
|
|
60
257
|
list: z.ZodString;
|
|
61
258
|
position: z.ZodDefault<z.ZodNumber>;
|
|
62
259
|
}, z.core.$strict>;
|
|
@@ -98,4 +295,3 @@ export type ParsedOperation = {
|
|
|
98
295
|
operation: K;
|
|
99
296
|
};
|
|
100
297
|
}[Operation];
|
|
101
|
-
export {};
|
package/dist/schemas.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const id = z.string().regex(/^\d+$/);
|
|
3
|
+
export const entitySchema = z
|
|
4
|
+
.object({
|
|
5
|
+
id,
|
|
6
|
+
name: z.string().optional(),
|
|
7
|
+
username: z.string().optional(),
|
|
8
|
+
projectId: id.optional(),
|
|
9
|
+
boardId: id.optional(),
|
|
10
|
+
listId: id.optional(),
|
|
11
|
+
cardId: id.optional(),
|
|
12
|
+
taskListId: id.optional(),
|
|
13
|
+
type: z.string().optional(),
|
|
14
|
+
listChangedAt: z.string().nullable().optional(),
|
|
15
|
+
description: z.string().nullable().optional(),
|
|
16
|
+
isCompleted: z.boolean().optional(),
|
|
17
|
+
position: z.number().finite().optional(),
|
|
18
|
+
})
|
|
4
19
|
.catchall(z.unknown());
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
included: z.
|
|
20
|
+
export const itemResponseSchema = z.object({ item: entitySchema });
|
|
21
|
+
export const itemsResponseSchema = z.object({ items: z.array(entitySchema) });
|
|
22
|
+
export const projectsResponseSchema = itemsResponseSchema.extend({
|
|
23
|
+
included: z.object({ boards: z.array(entitySchema) }),
|
|
24
|
+
});
|
|
25
|
+
export const boardResponseSchema = itemResponseSchema.extend({
|
|
26
|
+
included: z.object({
|
|
27
|
+
lists: z.array(entitySchema),
|
|
28
|
+
cards: z.array(entitySchema),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
export const cardResponseSchema = itemResponseSchema.extend({
|
|
32
|
+
included: z.object({
|
|
33
|
+
taskLists: z.array(entitySchema),
|
|
34
|
+
tasks: z.array(entitySchema),
|
|
35
|
+
}),
|
|
9
36
|
});
|
|
10
37
|
const ref = z.string().trim().min(1).max(2048);
|
|
11
38
|
const name = z.string().trim().min(1).max(1024);
|
|
@@ -29,7 +56,7 @@ export const operationSchemas = {
|
|
|
29
56
|
list: ref,
|
|
30
57
|
name,
|
|
31
58
|
description: description.optional(),
|
|
32
|
-
type: z.enum([
|
|
59
|
+
type: z.enum(["project", "story"]).default("project"),
|
|
33
60
|
position,
|
|
34
61
|
})
|
|
35
62
|
.strict(),
|
|
@@ -43,16 +70,29 @@ export const operationSchemas = {
|
|
|
43
70
|
.strict()
|
|
44
71
|
.refine((v) => v.name !== undefined || v.description !== undefined),
|
|
45
72
|
move_card: z
|
|
46
|
-
.object({
|
|
73
|
+
.object({
|
|
74
|
+
card: ref,
|
|
75
|
+
board: ref.optional(),
|
|
76
|
+
destinationBoard: ref.optional(),
|
|
77
|
+
list: ref,
|
|
78
|
+
position,
|
|
79
|
+
})
|
|
47
80
|
.strict(),
|
|
48
81
|
task_lists: z.object({ card: ref, board: ref.optional() }).strict(),
|
|
49
82
|
create_task_list: z
|
|
50
83
|
.object({ card: ref, board: ref.optional(), name: name.max(128), position })
|
|
51
84
|
.strict(),
|
|
52
85
|
edit_task_list: z
|
|
53
|
-
.object({
|
|
86
|
+
.object({
|
|
87
|
+
card: ref,
|
|
88
|
+
board: ref.optional(),
|
|
89
|
+
taskList: ref,
|
|
90
|
+
name: name.max(128),
|
|
91
|
+
})
|
|
92
|
+
.strict(),
|
|
93
|
+
add_task: z
|
|
94
|
+
.object({ card: ref, board: ref.optional(), taskList: ref, name, position })
|
|
54
95
|
.strict(),
|
|
55
|
-
add_task: z.object({ card: ref, board: ref.optional(), taskList: ref, name, position }).strict(),
|
|
56
96
|
complete_task: z
|
|
57
97
|
.object({
|
|
58
98
|
card: ref,
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,MAAM,YAAY,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,EAAE;IACF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,EAAE,CAAC,QAAQ,EAAE;IACxB,OAAO,EAAE,EAAE,CAAC,QAAQ,EAAE;IACtB,MAAM,EAAE,EAAE,CAAC,QAAQ,EAAE;IACrB,MAAM,EAAE,EAAE,CAAC,QAAQ,EAAE;IACrB,UAAU,EAAE,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CA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EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC;SAC3E,MAAM,EAAE;IACX,cAAc,EAAE,CAAC;SACd,MAAM,CAAC;QACN,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE;QACrB,QAAQ,EAAE,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;KACpB,CAAC;SACD,MAAM,EAAE;IACX,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAC3E,MAAM,EAAE;IACX,aAAa,EAAE,CAAC;SACb,MAAM,CAAC;QACN,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE;QACrB,QAAQ,EAAE,GAAG;QACb,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;KACvC,CAAC;SACD,MAAM,EAAE;CACZ,CAAC"}
|
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { PlanktonError } from
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PlanktonError } from "./errors.js";
|
|
3
3
|
const token = z
|
|
4
4
|
.string()
|
|
5
5
|
.min(1)
|
|
@@ -14,18 +14,19 @@ export function normalizeUrl(value) {
|
|
|
14
14
|
url = new URL(value);
|
|
15
15
|
}
|
|
16
16
|
catch {
|
|
17
|
-
throw new PlanktonError(
|
|
17
|
+
throw new PlanktonError("VALIDATION", "Enter an absolute Planka URL.");
|
|
18
18
|
}
|
|
19
|
-
if (![
|
|
19
|
+
if (!["http:", "https:"].includes(url.protocol) ||
|
|
20
20
|
url.username ||
|
|
21
21
|
url.password ||
|
|
22
22
|
url.search ||
|
|
23
23
|
url.hash) {
|
|
24
|
-
throw new PlanktonError(
|
|
24
|
+
throw new PlanktonError("VALIDATION", "Use an HTTP(S) Planka URL without credentials, query or fragment.");
|
|
25
25
|
}
|
|
26
|
-
if (url.protocol !==
|
|
27
|
-
|
|
26
|
+
if (url.protocol !== "https:" &&
|
|
27
|
+
!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)) {
|
|
28
|
+
throw new PlanktonError("VALIDATION", "Use HTTPS for remote Planka instances.");
|
|
28
29
|
}
|
|
29
|
-
return url.href.replace(/\/+$/,
|
|
30
|
+
return url.href.replace(/\/+$/, "");
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=session.js.map
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,KAAK,CAAC;KACV,KAAK,CAAC,wBAAwB,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;KAC/D,MAAM,EAAE,CAAC;AAGZ,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,aAAa,CAAC,YAAY,EAAE,+BAA+B,CAAC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a,CACrB,YAAY,EACZ,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,IACE,GAAG,CAAC,QAAQ,KAAK,QAAQ;QACzB,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAC3D,CAAC;QACD,MAAM,IAAI,aAAa,CACrB,YAAY,EACZ,wCAAwC,CACzC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Session } from
|
|
2
|
-
import {
|
|
1
|
+
import { type Session } from "./session.js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
3
|
export interface ClientOptions {
|
|
4
4
|
url: string;
|
|
5
5
|
session: Session;
|
|
@@ -12,5 +12,5 @@ export declare class PlankaTransport {
|
|
|
12
12
|
private readonly fetcher;
|
|
13
13
|
private readonly timeoutMs;
|
|
14
14
|
constructor(options: ClientOptions);
|
|
15
|
-
request(path: string, method?: string, body?: unknown): Promise<
|
|
15
|
+
request<T>(path: string, schema: z.ZodType<T>, method?: string, body?: unknown): Promise<T>;
|
|
16
16
|
}
|
package/dist/transport.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PlanktonError } from
|
|
2
|
-
import { normalizeUrl, sessionSchema } from
|
|
3
|
-
import { envelopeSchema } from './schemas.js';
|
|
1
|
+
import { PlanktonError } from "./errors.js";
|
|
2
|
+
import { normalizeUrl, sessionSchema } from "./session.js";
|
|
4
3
|
export class PlankaTransport {
|
|
5
4
|
url;
|
|
6
5
|
session;
|
|
@@ -12,55 +11,49 @@ export class PlankaTransport {
|
|
|
12
11
|
this.fetcher = options.fetch ?? fetch;
|
|
13
12
|
this.timeoutMs = options.timeoutMs ?? 15000;
|
|
14
13
|
}
|
|
15
|
-
async request(path, method =
|
|
16
|
-
const write = method !==
|
|
14
|
+
async request(path, schema, method = "GET", body) {
|
|
15
|
+
const write = method !== "GET";
|
|
17
16
|
try {
|
|
18
17
|
const response = await this.fetcher(`${this.url}/api/${path}`, {
|
|
19
18
|
method,
|
|
20
|
-
redirect:
|
|
19
|
+
redirect: "error",
|
|
21
20
|
signal: AbortSignal.timeout(this.timeoutMs),
|
|
22
21
|
headers: {
|
|
23
|
-
Accept:
|
|
22
|
+
Accept: "application/json",
|
|
24
23
|
Authorization: `Bearer ${this.session.accessToken}`,
|
|
25
24
|
...(this.session.httpOnlyToken
|
|
26
25
|
? { Cookie: `httpOnlyToken=${this.session.httpOnlyToken}` }
|
|
27
26
|
: {}),
|
|
28
|
-
...(body === undefined ? {} : {
|
|
27
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
29
28
|
},
|
|
30
29
|
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
31
30
|
});
|
|
32
31
|
if (response.status === 401) {
|
|
33
|
-
throw new PlanktonError(
|
|
32
|
+
throw new PlanktonError("AUTHENTICATION", "Planka session expired or invalid. Run plankton login.");
|
|
34
33
|
}
|
|
35
34
|
if (response.status === 403) {
|
|
36
|
-
throw new PlanktonError(
|
|
35
|
+
throw new PlanktonError("PERMISSION", "Planka denied this operation. Check the account’s board permissions.");
|
|
37
36
|
}
|
|
38
37
|
if (response.status === 404) {
|
|
39
|
-
throw new PlanktonError(
|
|
38
|
+
throw new PlanktonError("NOT_FOUND", "Resource not found or not accessible to this account.");
|
|
40
39
|
}
|
|
41
40
|
if ([400, 422].includes(response.status)) {
|
|
42
|
-
throw new PlanktonError(
|
|
41
|
+
throw new PlanktonError("VALIDATION", "Planka rejected the fields. Check the resource type and values.");
|
|
43
42
|
}
|
|
44
43
|
if (!response.ok) {
|
|
45
|
-
throw new PlanktonError(write && response.status >= 500 ?
|
|
46
|
-
?
|
|
44
|
+
throw new PlanktonError(write && response.status >= 500 ? "UNCERTAIN_WRITE" : "API", write && response.status >= 500
|
|
45
|
+
? "Planka failed during a write. Read the resource before trying again; the change may have completed."
|
|
47
46
|
: `Planka returned HTTP ${response.status}.`, { status: response.status });
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
if (!parsed.success ||
|
|
51
|
-
(write && !parsed.data.item) ||
|
|
52
|
-
(path === 'projects' && !parsed.data.items)) {
|
|
53
|
-
throw new Error('Invalid response');
|
|
54
|
-
}
|
|
55
|
-
return parsed.data;
|
|
48
|
+
return schema.parse(await response.json());
|
|
56
49
|
}
|
|
57
50
|
catch (error) {
|
|
58
51
|
if (error instanceof PlanktonError) {
|
|
59
52
|
throw error;
|
|
60
53
|
}
|
|
61
|
-
throw new PlanktonError(write ?
|
|
62
|
-
?
|
|
63
|
-
:
|
|
54
|
+
throw new PlanktonError(write ? "UNCERTAIN_WRITE" : "NETWORK", write
|
|
55
|
+
? "The write outcome is unknown. Read the resource before retrying; do not repeat the write blindly."
|
|
56
|
+
: "Could not read Planka. Check the URL, network and server response.");
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
}
|
package/dist/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AAUzE,MAAM,OAAO,eAAe;IACjB,GAAG,CAAS;IACJ,OAAO,CAAU;IACjB,OAAO,CAAe;IACtB,SAAS,CAAS;IAEnC,YAAY,OAAsB;QAChC,IAAI,CAAC,GAAG,GAAG,YAA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mG;gBACrG,CAAC,CAAC,oEAAoE,CACzE,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Evan Kim",
|
|
3
3
|
"name": "@evanston/plankton-core",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Local Planka integration core",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,6 +22,18 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^4.0.0"
|
|
24
24
|
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Evanston09/plankton.git",
|
|
28
|
+
"directory": "packages/core"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/Evanston09/plankton#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/Evanston09/plankton/issues"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
25
37
|
"scripts": {
|
|
26
38
|
"build": "tsc -p tsconfig.json",
|
|
27
39
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|