phorge 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/LICENSE +201 -0
- package/dist/client.d.ts +20 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +187 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/models/maniphest.d.ts +182 -0
- package/dist/models/maniphest.d.ts.map +1 -0
- package/dist/models/maniphest.js +78 -0
- package/dist/models/maniphest.js.map +1 -0
- package/dist/models/phorge.d.ts +132 -0
- package/dist/models/phorge.d.ts.map +1 -0
- package/dist/models/phorge.js +18 -0
- package/dist/models/phorge.js.map +1 -0
- package/dist/models/project.d.ts +172 -0
- package/dist/models/project.d.ts.map +1 -0
- package/dist/models/project.js +80 -0
- package/dist/models/project.js.map +1 -0
- package/dist/models/transaction.d.ts +142 -0
- package/dist/models/transaction.d.ts.map +1 -0
- package/dist/models/transaction.js +36 -0
- package/dist/models/transaction.js.map +1 -0
- package/dist/models/user.d.ts +90 -0
- package/dist/models/user.d.ts.map +1 -0
- package/dist/models/user.js +43 -0
- package/dist/models/user.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +58 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -0
- package/src/client.ts +200 -0
- package/src/index.ts +6 -0
- package/src/models/maniphest.ts +93 -0
- package/src/models/phorge.ts +74 -0
- package/src/models/project.ts +100 -0
- package/src/models/transaction.ts +49 -0
- package/src/models/user.ts +55 -0
- package/src/utils.ts +59 -0
- package/tsconfig.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtE,eAAO,MAAM,sBAAsB;;;iBAGjC,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE3E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOnC,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E,eAAO,MAAM,kBAAkB;;;;;;;;;;;iBAS7B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;kBAU1B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC;IAAE,IAAI,EAAE,uBAAuB,EAAE,CAAA;CAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ObjectType } from "./phorge.js";
|
|
3
|
+
export const TransactionConstraints = z.object({
|
|
4
|
+
phids: z.custom().array().optional(),
|
|
5
|
+
authorPHIDs: z.custom().array().optional()
|
|
6
|
+
});
|
|
7
|
+
export const TransactionSearchOptions = z.object({
|
|
8
|
+
objectIdentifier: z.custom().optional(),
|
|
9
|
+
objectType: ObjectType.optional(),
|
|
10
|
+
constraints: z.custom().optional(),
|
|
11
|
+
before: z.number().optional(),
|
|
12
|
+
after: z.number().optional(),
|
|
13
|
+
limit: z.number().optional()
|
|
14
|
+
});
|
|
15
|
+
export const TransactionComment = z.object({
|
|
16
|
+
id: z.number(),
|
|
17
|
+
phid: z.string(),
|
|
18
|
+
version: z.number(),
|
|
19
|
+
authorPHID: z.custom(),
|
|
20
|
+
dateCreated: z.number(),
|
|
21
|
+
dateModified: z.number(),
|
|
22
|
+
removed: z.boolean(),
|
|
23
|
+
content: z.object({ raw: z.string() })
|
|
24
|
+
});
|
|
25
|
+
export const SearchTransactionResult = z.object({
|
|
26
|
+
id: z.number(),
|
|
27
|
+
phid: z.string(),
|
|
28
|
+
type: z.string().nullable(),
|
|
29
|
+
authorPHID: z.custom(),
|
|
30
|
+
objectPHID: z.custom(),
|
|
31
|
+
dateCreated: z.number(),
|
|
32
|
+
dateModified: z.number(),
|
|
33
|
+
groupID: z.string(),
|
|
34
|
+
comments: TransactionComment.array()
|
|
35
|
+
}).array();
|
|
36
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,UAAU,EAA+B,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC1C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAgB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CAC3D,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAQ,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAA0B,CAAC,QAAQ,EAAE;IAC1D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
|
2
|
+
import type { ApiResponse, CreateObjectResult, PHID } from "./phorge.js";
|
|
3
|
+
export declare const UserConstraints: z.ZodObject<{
|
|
4
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
5
|
+
phids: z.ZodOptional<z.ZodArray<z.ZodCustom<PHID<"USER">, PHID<"USER">>>>;
|
|
6
|
+
usernames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
nameLike: z.ZodOptional<z.ZodString>;
|
|
8
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
isDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
isBot: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
isMailingList: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
needsApproval: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
mfa: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
createdStart: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
createdEnd: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
query: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type UserConstraints = z.infer<typeof UserConstraints>;
|
|
19
|
+
export declare const UserSearchOptions: z.ZodObject<{
|
|
20
|
+
queryKey: z.ZodOptional<z.ZodString>;
|
|
21
|
+
constraints: z.ZodOptional<z.ZodCustom<{
|
|
22
|
+
ids?: number[] | undefined;
|
|
23
|
+
phids?: PHID<"USER">[] | undefined;
|
|
24
|
+
usernames?: string[] | undefined;
|
|
25
|
+
nameLike?: string | undefined;
|
|
26
|
+
isAdmin?: boolean | undefined;
|
|
27
|
+
isDisabled?: boolean | undefined;
|
|
28
|
+
isBot?: boolean | undefined;
|
|
29
|
+
isMailingList?: boolean | undefined;
|
|
30
|
+
needsApproval?: boolean | undefined;
|
|
31
|
+
mfa?: boolean | undefined;
|
|
32
|
+
createdStart?: number | undefined;
|
|
33
|
+
createdEnd?: number | undefined;
|
|
34
|
+
query?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
ids?: number[] | undefined;
|
|
37
|
+
phids?: PHID<"USER">[] | undefined;
|
|
38
|
+
usernames?: string[] | undefined;
|
|
39
|
+
nameLike?: string | undefined;
|
|
40
|
+
isAdmin?: boolean | undefined;
|
|
41
|
+
isDisabled?: boolean | undefined;
|
|
42
|
+
isBot?: boolean | undefined;
|
|
43
|
+
isMailingList?: boolean | undefined;
|
|
44
|
+
needsApproval?: boolean | undefined;
|
|
45
|
+
mfa?: boolean | undefined;
|
|
46
|
+
createdStart?: number | undefined;
|
|
47
|
+
createdEnd?: number | undefined;
|
|
48
|
+
query?: string | undefined;
|
|
49
|
+
}>>;
|
|
50
|
+
attachments: z.ZodOptional<z.ZodUnknown>;
|
|
51
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
title: "title";
|
|
53
|
+
priority: "priority";
|
|
54
|
+
updated: "updated";
|
|
55
|
+
outdated: "outdated";
|
|
56
|
+
newest: "newest";
|
|
57
|
+
oldest: "oldest";
|
|
58
|
+
closed: "closed";
|
|
59
|
+
relevance: "relevance";
|
|
60
|
+
}>>;
|
|
61
|
+
before: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
after: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type UserSearchOptions = z.infer<typeof UserSearchOptions>;
|
|
66
|
+
export declare const SearchUserResult: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodNumber;
|
|
68
|
+
type: z.ZodLiteral<"USER">;
|
|
69
|
+
phid: z.ZodCustom<PHID<"USER">, PHID<"USER">>;
|
|
70
|
+
fields: z.ZodObject<{
|
|
71
|
+
username: z.ZodString;
|
|
72
|
+
realName: z.ZodString;
|
|
73
|
+
roles: z.ZodArray<z.ZodString>;
|
|
74
|
+
dateCreated: z.ZodNumber;
|
|
75
|
+
dateModified: z.ZodNumber;
|
|
76
|
+
policy: z.ZodObject<{
|
|
77
|
+
view: z.ZodString;
|
|
78
|
+
edit: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
attachments: z.ZodUnknown;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
export type SearchUserResult = z.infer<typeof SearchUserResult>;
|
|
84
|
+
export type CreateUserResponse = ApiResponse<{
|
|
85
|
+
object: CreateObjectResult;
|
|
86
|
+
}>;
|
|
87
|
+
export type SearchUserResponse = ApiResponse<{
|
|
88
|
+
data: SearchUserResult;
|
|
89
|
+
}>;
|
|
90
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAExE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;iBAc1B,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ5B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;kBAgBnB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/D,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAA;AAC5E,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const UserConstraints = z.object({
|
|
3
|
+
ids: z.number().array().nonempty().optional(),
|
|
4
|
+
phids: z.custom().array().nonempty().optional(),
|
|
5
|
+
usernames: z.string().array().nonempty().optional(),
|
|
6
|
+
nameLike: z.string().nonempty().optional(),
|
|
7
|
+
isAdmin: z.boolean().optional(),
|
|
8
|
+
isDisabled: z.boolean().optional(),
|
|
9
|
+
isBot: z.boolean().optional(),
|
|
10
|
+
isMailingList: z.boolean().optional(),
|
|
11
|
+
needsApproval: z.boolean().optional(),
|
|
12
|
+
mfa: z.boolean().optional(),
|
|
13
|
+
createdStart: z.number().optional(),
|
|
14
|
+
createdEnd: z.number().optional(),
|
|
15
|
+
query: z.string().nonempty().optional()
|
|
16
|
+
});
|
|
17
|
+
export const UserSearchOptions = z.object({
|
|
18
|
+
queryKey: z.string().optional(),
|
|
19
|
+
constraints: z.custom().optional(),
|
|
20
|
+
attachments: z.unknown().optional(),
|
|
21
|
+
order: z.enum(["priority", "updated", "outdated", "newest", "oldest", "closed", "title", "relevance"]).optional(),
|
|
22
|
+
before: z.number().optional(),
|
|
23
|
+
after: z.number().optional(),
|
|
24
|
+
limit: z.number().optional()
|
|
25
|
+
});
|
|
26
|
+
export const SearchUserResult = z.object({
|
|
27
|
+
id: z.number(),
|
|
28
|
+
type: z.literal("USER"),
|
|
29
|
+
phid: z.custom(),
|
|
30
|
+
fields: z.object({
|
|
31
|
+
username: z.string(),
|
|
32
|
+
realName: z.string(),
|
|
33
|
+
roles: z.string().array(),
|
|
34
|
+
dateCreated: z.number(),
|
|
35
|
+
dateModified: z.number(),
|
|
36
|
+
policy: z.object({
|
|
37
|
+
view: z.string(),
|
|
38
|
+
edit: z.string()
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
attach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E;SACnB,CAAC;KACL,CAAC;IACF,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE;CAC3B,CAAC,CAAC,KAAK,EAAE,CAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,SAAK,GAAG,eAAe,CAiB/F;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,SAAK,GAAG,eAAe,CAuChG"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function ConstraintObjectToParams(obj, prefix = "") {
|
|
2
|
+
const params = new URLSearchParams();
|
|
3
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
4
|
+
console.log(k, v);
|
|
5
|
+
if (Array.isArray(v)) {
|
|
6
|
+
let index = 0;
|
|
7
|
+
v.forEach((item, j) => {
|
|
8
|
+
const itemVal = typeof item === "string" ? item : JSON.stringify(item);
|
|
9
|
+
params.append(`constraints[${k}][${index}]`, itemVal);
|
|
10
|
+
index++;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const value = typeof v === "string" ? v : JSON.stringify(v);
|
|
15
|
+
params.append(`constraints[${k}]`, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return params;
|
|
19
|
+
}
|
|
20
|
+
export function TransactionObjectToParams(obj, prefix = "") {
|
|
21
|
+
const params = new URLSearchParams();
|
|
22
|
+
let index = 0;
|
|
23
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
24
|
+
let val = v;
|
|
25
|
+
let key = k;
|
|
26
|
+
if (["parents", "subtasks", "commits", "projects", "subscribers", "members"].includes(key)) {
|
|
27
|
+
if (Object.keys(v).includes("add")) {
|
|
28
|
+
key = `${key}.add`;
|
|
29
|
+
val = val["add"];
|
|
30
|
+
}
|
|
31
|
+
else if (Object.keys(v).includes("remove")) {
|
|
32
|
+
key = `${key}.remove`;
|
|
33
|
+
val = val["remove"];
|
|
34
|
+
}
|
|
35
|
+
else if (Object.keys(v).includes("set")) {
|
|
36
|
+
key = `${key}.set`;
|
|
37
|
+
val = val["set"];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const typeKey = `transactions[${index}][type]`;
|
|
41
|
+
const valueKey = `transactions[${index}][value]`;
|
|
42
|
+
params.append(typeKey, key);
|
|
43
|
+
if (Array.isArray(val)) {
|
|
44
|
+
val.forEach((item, j) => {
|
|
45
|
+
const itemKey = `${valueKey}[${j}]`;
|
|
46
|
+
const itemVal = typeof item === "string" ? item : JSON.stringify(item);
|
|
47
|
+
params.append(itemKey, itemVal);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const value = typeof v === "string" ? v : JSON.stringify(v);
|
|
52
|
+
params.append(valueKey, value);
|
|
53
|
+
}
|
|
54
|
+
index++;
|
|
55
|
+
}
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wBAAwB,CAAC,GAAwB,EAAE,MAAM,GAAG,EAAE;IAC1E,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACjB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACnB,IAAI,KA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C,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC;QAED,KAAK,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "phorge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"description": "",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^25.0.3",
|
|
16
|
+
"typescript": "^5.9.3"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^4.2.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { TaskSearchOptions, SearchTaskResult } from "./models/maniphest.js";
|
|
2
|
+
import { PhorgeError, CreateObjectResult } from "./models/phorge.js";
|
|
3
|
+
import { SearchProjectResult, ProjectTransaction, ProjectSearchOptions } from "./models/project.js";
|
|
4
|
+
import { SearchTransactionResult, TransactionSearchOptions } from "./models/transaction.js";
|
|
5
|
+
import { SearchUserResult, UserSearchOptions } from "./models/user.js";
|
|
6
|
+
import { ConstraintObjectToParams, TransactionObjectToParams } from "./utils.js";
|
|
7
|
+
|
|
8
|
+
// Import types only
|
|
9
|
+
import type { SearchTaskResponse, TaskTransactions, CreateTaskResponse } from "./models/maniphest.js";
|
|
10
|
+
import type { SearchProjectResponse, CreateProjectResponse } from "./models/project.js"
|
|
11
|
+
import type { SearchTransactionResponse } from "./models/transaction.js";
|
|
12
|
+
import type { SearchUserResponse } from "./models/user.js";
|
|
13
|
+
|
|
14
|
+
export class Client {
|
|
15
|
+
constructor(private uri: string, private token: string) { }
|
|
16
|
+
|
|
17
|
+
private async fetch<T>(input: RequestInfo | URL, init?: RequestInit) {
|
|
18
|
+
return await fetch(input, init)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private async call<T>(api: string, params: URLSearchParams): Promise<T> {
|
|
22
|
+
let resp = await fetch(`${this.uri}/api/${api}`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
body: params,
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return await resp.json();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async searchProject(options: ProjectSearchOptions): Promise<SearchProjectResult[]> {
|
|
34
|
+
let params = new URLSearchParams()
|
|
35
|
+
if (options !== undefined) {
|
|
36
|
+
if (options.queryKey) {
|
|
37
|
+
params.append("queryKey", options.queryKey)
|
|
38
|
+
}
|
|
39
|
+
if (options.constraints !== undefined) {
|
|
40
|
+
params = new URLSearchParams([...params, ...ConstraintObjectToParams(options.constraints)])
|
|
41
|
+
}
|
|
42
|
+
if (options.attachments !== undefined) {
|
|
43
|
+
//TODO: Implement attachments
|
|
44
|
+
}
|
|
45
|
+
if (options.order !== undefined) {
|
|
46
|
+
params.append("order", options.order)
|
|
47
|
+
}
|
|
48
|
+
if (options.before !== undefined) {
|
|
49
|
+
params.append("before", options.before.toString())
|
|
50
|
+
}
|
|
51
|
+
if (options.after !== undefined) {
|
|
52
|
+
params.append("after", options.after.toString())
|
|
53
|
+
}
|
|
54
|
+
if (options.limit !== undefined) {
|
|
55
|
+
params.append("limit", options.limit.toString())
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
params.append("api.token", this.token);
|
|
60
|
+
|
|
61
|
+
const resp = await this.call<SearchProjectResponse>("project.search", params);
|
|
62
|
+
if (resp.error_code !== null) {
|
|
63
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
64
|
+
} else {
|
|
65
|
+
return resp.result.data;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async createProject(transactions: ProjectTransaction): Promise<CreateObjectResult> {
|
|
70
|
+
let params = TransactionObjectToParams(transactions)
|
|
71
|
+
params.append("api.token", this.token);
|
|
72
|
+
|
|
73
|
+
const resp = await this.call<CreateProjectResponse>("project.edit", params);
|
|
74
|
+
console.log(JSON.stringify(resp, null, 4))
|
|
75
|
+
if (resp.error_code !== null) {
|
|
76
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
77
|
+
} else {
|
|
78
|
+
return resp.result.object;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async searchTask(options?: TaskSearchOptions): Promise<SearchTaskResult[]> {
|
|
83
|
+
let params = new URLSearchParams()
|
|
84
|
+
if (options !== undefined) {
|
|
85
|
+
if (options.queryKey) {
|
|
86
|
+
params.append("queryKey", options.queryKey)
|
|
87
|
+
}
|
|
88
|
+
if (options.constraints !== undefined) {
|
|
89
|
+
params = new URLSearchParams([...params, ...ConstraintObjectToParams(options.constraints)])
|
|
90
|
+
}
|
|
91
|
+
if (options.attachments !== undefined) {
|
|
92
|
+
//TODO: Implement attachments
|
|
93
|
+
}
|
|
94
|
+
if (options.order !== undefined) {
|
|
95
|
+
params.append("order", options.order)
|
|
96
|
+
}
|
|
97
|
+
if (options.before !== undefined) {
|
|
98
|
+
params.append("before", options.before.toString())
|
|
99
|
+
}
|
|
100
|
+
if (options.after !== undefined) {
|
|
101
|
+
params.append("after", options.after.toString())
|
|
102
|
+
}
|
|
103
|
+
if (options.limit !== undefined) {
|
|
104
|
+
params.append("limit", options.limit.toString())
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
params.append("api.token", this.token);
|
|
109
|
+
|
|
110
|
+
const resp = await this.call<SearchTaskResponse>("maniphest.search", params);
|
|
111
|
+
if (resp.error_code !== null) {
|
|
112
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
113
|
+
} else {
|
|
114
|
+
return resp.result.data;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async createTask(transaction: TaskTransactions): Promise<CreateObjectResult> {
|
|
119
|
+
let params = TransactionObjectToParams(transaction)
|
|
120
|
+
params.append("api.token", this.token);
|
|
121
|
+
|
|
122
|
+
const resp = await this.call<CreateTaskResponse>("maniphest.edit", params);
|
|
123
|
+
console.log(JSON.stringify(resp, null, 4))
|
|
124
|
+
if (resp.error_code !== null) {
|
|
125
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
126
|
+
} else {
|
|
127
|
+
return resp.result.object;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async searchUser(options?: UserSearchOptions): Promise<SearchUserResult> {
|
|
132
|
+
let params = new URLSearchParams()
|
|
133
|
+
params.append("api.token", this.token);
|
|
134
|
+
if (options !== undefined) {
|
|
135
|
+
if (options.queryKey) {
|
|
136
|
+
params.append("queryKey", options.queryKey);
|
|
137
|
+
}
|
|
138
|
+
if (options.constraints !== undefined) {
|
|
139
|
+
params = new URLSearchParams([...params, ...ConstraintObjectToParams(options.constraints)])
|
|
140
|
+
}
|
|
141
|
+
if (options.attachments) {
|
|
142
|
+
// TODO: Implement attachments
|
|
143
|
+
}
|
|
144
|
+
if (options.order) {
|
|
145
|
+
// TODO: Improve order type
|
|
146
|
+
}
|
|
147
|
+
if (options.before) {
|
|
148
|
+
params.append("before", options.before.toString());
|
|
149
|
+
}
|
|
150
|
+
if (options.after) {
|
|
151
|
+
params.append("after", options.after.toString());
|
|
152
|
+
}
|
|
153
|
+
if (options.limit) {
|
|
154
|
+
params.append("limit", options.limit.toString());
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
params.append("api.token", this.token);
|
|
159
|
+
|
|
160
|
+
let resp = await this.call<SearchUserResponse>("user.search", params);
|
|
161
|
+
if (resp.error_code !== null) {
|
|
162
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
163
|
+
} else {
|
|
164
|
+
return SearchUserResult.parse(resp.result.data);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async searchTransaction(options?: TransactionSearchOptions): Promise<SearchTransactionResult> {
|
|
169
|
+
let params = new URLSearchParams()
|
|
170
|
+
params.append("api.token", this.token);
|
|
171
|
+
if (options !== undefined) {
|
|
172
|
+
if (options.objectIdentifier) {
|
|
173
|
+
params.append("objectIdentifier", options.objectIdentifier);
|
|
174
|
+
}
|
|
175
|
+
if (options.objectType) {
|
|
176
|
+
params.append("objectType", options.objectType);
|
|
177
|
+
}
|
|
178
|
+
if (options.constraints !== undefined) {
|
|
179
|
+
params = new URLSearchParams([...params, ...ConstraintObjectToParams(options.constraints)])
|
|
180
|
+
}
|
|
181
|
+
if (options.before) {
|
|
182
|
+
params.append("before", options.before.toString());
|
|
183
|
+
}
|
|
184
|
+
if (options.after) {
|
|
185
|
+
params.append("after", options.after.toString());
|
|
186
|
+
}
|
|
187
|
+
if (options.limit) {
|
|
188
|
+
params.append("limit", options.limit.toString());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let resp = await this.call<SearchTransactionResponse>("transaction.search", params);
|
|
193
|
+
if (resp.error_code !== null) {
|
|
194
|
+
throw new PhorgeError(resp.error_code, resp.error_info);
|
|
195
|
+
} else {
|
|
196
|
+
console.log(resp.result.data)
|
|
197
|
+
return SearchTransactionResult.parse(resp.result.data);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Client } from "./client.js";
|
|
2
|
+
export { PhorgeError } from "./models/phorge.js";
|
|
3
|
+
export type { ProjectConstraints, SearchProjectResult, SearchProjectResponse, ProjectTransaction, CreateProjectResponse, ProjectSearchOptions } from "./models/project.js";
|
|
4
|
+
export type { SearchTransactionResponse, SearchTransactionResult, TransactionSearchOptions } from "./models/transaction.js";
|
|
5
|
+
export type { UserConstraints, SearchUserResult, SearchUserResponse, UserSearchOptions } from "./models/user.js";
|
|
6
|
+
export type { TaskSearchOptions, SearchTaskResult } from "./models/maniphest.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { ApiResponse, PHID, Policy } from "./phorge.js";
|
|
3
|
+
import { CreateObjectResult } from "./phorge.js";
|
|
4
|
+
|
|
5
|
+
export const TaskTransaction = z.object({
|
|
6
|
+
title: z.string().optional(),
|
|
7
|
+
description: z.string().optional(),
|
|
8
|
+
priority: z.enum(["unbreak", "triage", "high", "normal", "low", "wish"]).optional(),
|
|
9
|
+
ownerPHID: z.custom<PHID<"USER">>().optional(),
|
|
10
|
+
parents: z.custom<PHID<'TASK'>>().array().optional(),
|
|
11
|
+
subtasks: z.custom<PHID<'TASK'>>().array().optional(),
|
|
12
|
+
commits: z.custom<PHID<'CMIT'>>().array().optional(),
|
|
13
|
+
projects: z.custom<PHID<'PROJ'>>().array().optional(),
|
|
14
|
+
subscribers: z.custom<PHID<'USER'>>().array().optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type TaskTransactions = z.infer<typeof TaskTransaction>
|
|
18
|
+
|
|
19
|
+
export const TaskConstraints = z.object({
|
|
20
|
+
ids: z.number().array().optional(),
|
|
21
|
+
phids: z.custom<PHID<"TASK">>().array().optional(),
|
|
22
|
+
assigned: z.custom<PHID<"USER">>().array().optional(),
|
|
23
|
+
authorPHIDs: z.custom<PHID<"USER">>().array().optional(),
|
|
24
|
+
statuses: z.custom<string>().array().optional(),
|
|
25
|
+
priorities: z.custom<number>().array().optional(),
|
|
26
|
+
subtypes: z.custom<string>().array().optional(),
|
|
27
|
+
columnPHIDs: z.unknown().optional(),
|
|
28
|
+
hasParents: z.boolean().optional(),
|
|
29
|
+
hasSubtasks: z.boolean().optional(),
|
|
30
|
+
parentIDs: z.custom<PHID<"TASK">>().array().optional(),
|
|
31
|
+
subtaskIDs: z.custom<PHID<"TASK">>().array().optional(),
|
|
32
|
+
group: z.enum(["priority", "assigned", "status", "project", "none"]).optional(),
|
|
33
|
+
createdStart: z.number().optional(),
|
|
34
|
+
createdEnd: z.number().optional(),
|
|
35
|
+
modifiedStart: z.number().optional(),
|
|
36
|
+
modifiedEnd: z.number().optional(),
|
|
37
|
+
closedStart: z.number().optional(),
|
|
38
|
+
closedEnd: z.number().optional(),
|
|
39
|
+
closerPHIDs: z.custom<PHID<"USER">>().array().optional(),
|
|
40
|
+
query: z.string().optional(),
|
|
41
|
+
subscribers: z.custom<PHID<"USER">>().array().optional(),
|
|
42
|
+
projects: z.custom<PHID<"PROJ">>().array().optional(),
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export type TaskConstraints = z.infer<typeof TaskConstraints>
|
|
46
|
+
|
|
47
|
+
export const SearchTaskResult = z.object({
|
|
48
|
+
id: z.number(),
|
|
49
|
+
phid: z.custom<PHID<"TASK">>(),
|
|
50
|
+
fields: z.object({
|
|
51
|
+
name: z.string(),
|
|
52
|
+
description: z.object({ raw: z.string() }),
|
|
53
|
+
authorPHID: z.custom<PHID<"USER">>,
|
|
54
|
+
ownerPHID: z.custom<PHID<"USER">>,
|
|
55
|
+
status: z.object({
|
|
56
|
+
value: z.string(),
|
|
57
|
+
name: z.string(),
|
|
58
|
+
color: z.string().nullable()
|
|
59
|
+
}),
|
|
60
|
+
priority: z.object({
|
|
61
|
+
value: z.string(),
|
|
62
|
+
name: z.string(),
|
|
63
|
+
color: z.string().nullable()
|
|
64
|
+
}),
|
|
65
|
+
points: z.number(),
|
|
66
|
+
subtype: z.string(),
|
|
67
|
+
closePHID: z.custom<PHID<"USER">>,
|
|
68
|
+
dateClosed: z.number(),
|
|
69
|
+
groupByProjectPHID: z.unknown(), // TODO: Needs to be implemented
|
|
70
|
+
spacePHID: z.custom<PHID<"SPCE">>(), // TODO: Needs to be implemented
|
|
71
|
+
dateCreated: z.number(),
|
|
72
|
+
dateModified: z.number(),
|
|
73
|
+
policy: z.custom<Policy>(),
|
|
74
|
+
}),
|
|
75
|
+
attachments: z.unknown() // TODO: Needs to be implemented
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
export type SearchTaskResult = z.infer<typeof SearchTaskResult>
|
|
79
|
+
|
|
80
|
+
export const TaskSearchOptions = z.object({
|
|
81
|
+
queryKey: z.string().optional(),
|
|
82
|
+
constraints: z.custom<TaskConstraints>().optional(),
|
|
83
|
+
attachments: z.unknown().optional(),
|
|
84
|
+
order: z.enum(["priority", "updated", "outdated", "newest", "oldest", "closed", "title", "relevance"]).optional(),
|
|
85
|
+
before: z.number().optional(),
|
|
86
|
+
after: z.number().optional(),
|
|
87
|
+
limit: z.number().optional()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
export type TaskSearchOptions = z.infer<typeof TaskSearchOptions>
|
|
91
|
+
|
|
92
|
+
export type CreateTaskResponse = ApiResponse<{ object: CreateObjectResult }>
|
|
93
|
+
export type SearchTaskResponse = ApiResponse<{ data: SearchTaskResult[] }>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
export const ObjectType = z.enum(["ABND","ACNT","ADEV","AEML","AINT","AKEY","AMSG","ANAM","ANET","ANSW","APAS","APPE","ASRV","AUTH","BDGE","BLOG","BOOK","BULK","CART","CDTL","CDWN","CEVT","CEXP","CIMP","CMIT","CONF","CONP","CTNM","DIFF","DREV","DRYB","DSHB","DSHP","FBAK","FILE","FITV","FORM","FPRV","HMBB","HMBD","HMCP","HMCS","HRUL","HWBH","HWBR","LEGD","MCRO","MOCK","NUAI","NUAQ","NUAS","OASC","OPKG","PANL","PAYM","PCOL","PHPR","PHRL","PMRC","POLL","POST","PPAK","PPUB","PROJ","PRTL","PSET","PSTE","PSUB","PVAR","PVER","QUES","REPO","RIDT","RURI","SPCE","TASK","USER","WIKI","WTRG"]);
|
|
4
|
+
export type ObjectType = z.infer<typeof ObjectType>;
|
|
5
|
+
|
|
6
|
+
export type ObjectPHID<TYPE extends ObjectType | string = ObjectType> = `PHID-${TYPE}-${string}`
|
|
7
|
+
export type TransactionPHID<TYPE extends ObjectType | string = ObjectType> = `PHID-XACT-${TYPE}-${string}`
|
|
8
|
+
export type PHID<TYPE extends ObjectType | string = ObjectType> = ObjectPHID<TYPE> | TransactionPHID<TYPE>
|
|
9
|
+
|
|
10
|
+
export type ManiphestAPI = "maniphest.search"
|
|
11
|
+
export type ProjectAPI = "project.search"
|
|
12
|
+
|
|
13
|
+
export type PhorgeApis = ManiphestAPI | ProjectAPI
|
|
14
|
+
|
|
15
|
+
export type Policy = {
|
|
16
|
+
view: string
|
|
17
|
+
edit: string
|
|
18
|
+
join: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Cursor = {
|
|
22
|
+
limit: number;
|
|
23
|
+
after: string | null;
|
|
24
|
+
before: string | null;
|
|
25
|
+
order: string | null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Uncertain if this is correct at this moment
|
|
29
|
+
type Query = {
|
|
30
|
+
queryKey: string | null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Generic success result
|
|
34
|
+
export type SuccessResult<TData> = {
|
|
35
|
+
data: TData[];
|
|
36
|
+
maps: Record<string, unknown>;
|
|
37
|
+
query: Query;
|
|
38
|
+
cursor: Cursor;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// Success response
|
|
43
|
+
export type SuccessResponse<TData> = {
|
|
44
|
+
result: TData;
|
|
45
|
+
error_code: null;
|
|
46
|
+
error_info: null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Error response
|
|
50
|
+
export type ErrorResponse = {
|
|
51
|
+
result?: never;
|
|
52
|
+
error_code: string;
|
|
53
|
+
error_info: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Final API response type
|
|
57
|
+
export type ApiResponse<TData> =
|
|
58
|
+
| SuccessResponse<TData>
|
|
59
|
+
| ErrorResponse;
|
|
60
|
+
|
|
61
|
+
export const CreateObjectResult = z.object({
|
|
62
|
+
id: z.string(),
|
|
63
|
+
phid: z.custom<PHID>()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export type CreateObjectResult = z.infer<typeof CreateObjectResult>;
|
|
67
|
+
|
|
68
|
+
export class PhorgeError extends Error {
|
|
69
|
+
constructor(public error_code: ErrorResponse['error_code'], public error_info: ErrorResponse['error_info']) {
|
|
70
|
+
super(String(error_info ?? error_code ?? 'API Error'));
|
|
71
|
+
this.name = 'PhorgeError';
|
|
72
|
+
Object.setPrototypeOf(this, PhorgeError.prototype);
|
|
73
|
+
}
|
|
74
|
+
}
|