@beepbox.net/gofetch-client 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +153 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,157 @@
|
|
|
1
1
|
// src/runtime.ts
|
|
2
2
|
import { treaty } from "@elysiajs/eden";
|
|
3
|
+
|
|
4
|
+
// src/fetcher.ts
|
|
5
|
+
function makeBeep(api) {
|
|
6
|
+
const root = api.v1.beep;
|
|
7
|
+
return {
|
|
8
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
9
|
+
get: (id, query, opts = {}) => api.v1.beep({ id }).get({ query, ...opts }),
|
|
10
|
+
forks: (id, query, opts = {}) => api.v1.beep({ id }).forks.get({ query, ...opts }),
|
|
11
|
+
original: (id, query, opts = {}) => api.v1.beep({ id }).original.get({ query, ...opts }),
|
|
12
|
+
authors: (id, opts = {}) => api.v1.beep({ id }).authors.get(opts),
|
|
13
|
+
create: (body, opts = {}) => root.post(body, opts),
|
|
14
|
+
update: (id, body, opts = {}) => api.v1.beep({ id }).patch(body, opts),
|
|
15
|
+
delete: (id, opts = {}) => api.v1.beep({ id }).delete(undefined, opts)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function makeEvent(api) {
|
|
19
|
+
const root = api.v1.event;
|
|
20
|
+
const item = (id) => api.v1.event({ id });
|
|
21
|
+
return {
|
|
22
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
23
|
+
get: (id, query, opts = {}) => item(id).get({ query, ...opts }),
|
|
24
|
+
create: (body, opts = {}) => root.post(body, opts),
|
|
25
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
26
|
+
delete: (id, opts = {}) => item(id).delete(undefined, opts),
|
|
27
|
+
hosts: (id, opts = {}) => item(id).hosts.get(opts),
|
|
28
|
+
addHosts: (id, body, opts = {}) => item(id).hosts.post(body, opts),
|
|
29
|
+
removeHost: (id, userId, opts = {}) => item(id).hosts({ userId }).delete(undefined, opts),
|
|
30
|
+
participants: (id, opts = {}) => item(id).participants.get(opts),
|
|
31
|
+
addParticipants: (id, body, opts = {}) => item(id).participants.post(body, opts),
|
|
32
|
+
removeParticipant: (id, userId, opts = {}) => item(id).participants({ userId }).delete(undefined, opts),
|
|
33
|
+
join: (id, opts = {}) => item(id).join.post(undefined, opts),
|
|
34
|
+
leave: (id, opts = {}) => item(id).leave.post(undefined, opts),
|
|
35
|
+
openRegistration: (id, opts = {}) => item(id)["open-registration"].post(undefined, opts),
|
|
36
|
+
start: (id, opts = {}) => item(id).start.post(undefined, opts),
|
|
37
|
+
close: (id, opts = {}) => item(id).close.post(undefined, opts),
|
|
38
|
+
archive: (id, opts = {}) => item(id).archive.post(undefined, opts)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function makePlatform(api) {
|
|
42
|
+
const root = api.v1.platform;
|
|
43
|
+
const item = (id) => api.v1.platform({ id });
|
|
44
|
+
return {
|
|
45
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
46
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
47
|
+
beeps: (id, query, opts = {}) => item(id).beeps.get({ query, ...opts }),
|
|
48
|
+
tree: (id, opts = {}) => item(id).tree.get(opts),
|
|
49
|
+
create: (body, opts = {}) => root.post(body, opts),
|
|
50
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function makeSource(api) {
|
|
54
|
+
const root = api.v1.source;
|
|
55
|
+
const item = (id) => api.v1.source({ id });
|
|
56
|
+
return {
|
|
57
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
58
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
59
|
+
beeps: (id, query, opts = {}) => item(id).beeps.get({ query, ...opts }),
|
|
60
|
+
create: (body, opts = {}) => root.post(body, opts),
|
|
61
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
62
|
+
delete: (id, opts = {}) => item(id).delete(undefined, opts)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function makeForum(api) {
|
|
66
|
+
const item = (id) => api.v1.forum({ id });
|
|
67
|
+
return {
|
|
68
|
+
listForEvent: (eventId, opts = {}) => api.v1.forum.event({ eventId }).get(opts),
|
|
69
|
+
createForEvent: (eventId, body, opts = {}) => api.v1.forum.event({ eventId }).post(body, opts),
|
|
70
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
71
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
72
|
+
delete: (id, opts = {}) => item(id).delete(undefined, opts),
|
|
73
|
+
archive: (id, opts = {}) => item(id).archive.post(undefined, opts),
|
|
74
|
+
unarchive: (id, opts = {}) => item(id).unarchive.post(undefined, opts)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function makeSubmission(api) {
|
|
78
|
+
const item = (id) => api.v1.submission({ id });
|
|
79
|
+
return {
|
|
80
|
+
listForForum: (forumId, query, opts = {}) => api.v1.submission.forum({ forumId }).get({ query, ...opts }),
|
|
81
|
+
createForForum: (forumId, body, opts = {}) => api.v1.submission.forum({ forumId }).post(body, opts),
|
|
82
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
83
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
84
|
+
delete: (id, opts = {}) => item(id).delete(undefined, opts),
|
|
85
|
+
setState: (id, body, opts = {}) => item(id).state.post(body, opts),
|
|
86
|
+
myScore: (id, opts = {}) => item(id).scores.mine.get(opts),
|
|
87
|
+
computeScore: (id, opts = {}) => item(id)["compute-score"].get(opts),
|
|
88
|
+
scores: (id, opts = {}) => item(id).scores.get(opts),
|
|
89
|
+
submitScore: (id, body, opts = {}) => item(id).scores.post(body, opts),
|
|
90
|
+
deleteMyScore: (id, opts = {}) => item(id).scores.mine.delete(undefined, opts),
|
|
91
|
+
adjustments: (id, opts = {}) => item(id).adjustments.get(opts),
|
|
92
|
+
createAdjustment: (id, body, opts = {}) => item(id).adjustments.post(body, opts),
|
|
93
|
+
deleteAdjustment: (adjustmentId, opts = {}) => api.v1.submission.adjustments({ adjustmentId }).delete(undefined, opts),
|
|
94
|
+
forBeep: (beepId, opts = {}) => api.v1.submission.beep({ beepId }).get(opts)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function makeWeightGroup(api) {
|
|
98
|
+
const item = (id) => api.v1.weightGroup({ id });
|
|
99
|
+
return {
|
|
100
|
+
listForEvent: (eventId, opts = {}) => api.v1.event({ id: eventId }).weightGroup.get(opts),
|
|
101
|
+
createForEvent: (eventId, body, opts = {}) => api.v1.event({ id: eventId }).weightGroup.post(body, opts),
|
|
102
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
103
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
104
|
+
delete: (id, opts = {}) => item(id).delete(undefined, opts),
|
|
105
|
+
members: (id, opts = {}) => item(id).members.get(opts),
|
|
106
|
+
addMembers: (id, body, opts = {}) => item(id).members.post(body, opts),
|
|
107
|
+
removeMember: (id, userId, opts = {}) => item(id).members({ userId }).delete(undefined, opts)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function makeXp(api) {
|
|
111
|
+
const root = api.v1.xp;
|
|
112
|
+
return {
|
|
113
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
114
|
+
mine: (opts = {}) => root.mine.get(opts),
|
|
115
|
+
grant: (body, opts = {}) => root.grant.post(body, opts),
|
|
116
|
+
retract: (id, body, opts = {}) => api.v1.xp({ id }).retract.post(body, opts)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function makeUser(api) {
|
|
120
|
+
const root = api.v1.user;
|
|
121
|
+
const item = (id) => api.v1.user({ id });
|
|
122
|
+
return {
|
|
123
|
+
me: (opts = {}) => root.me.get(opts),
|
|
124
|
+
list: (query, opts = {}) => root.get({ query, ...opts }),
|
|
125
|
+
get: (id, opts = {}) => item(id).get(opts),
|
|
126
|
+
update: (id, body, opts = {}) => item(id).patch(body, opts),
|
|
127
|
+
setRole: (id, body, opts = {}) => item(id).role.post(body, opts),
|
|
128
|
+
disable: (id, opts = {}) => item(id).disable.post(undefined, opts)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function makeUtil(api) {
|
|
132
|
+
return {
|
|
133
|
+
resolveShortUrl: (url, opts = {}) => api.v1.util.resolve.short.get({ query: { url }, ...opts }),
|
|
134
|
+
resolvePlatform: (url, opts = {}) => api.v1.util.resolve.platform.get({ query: { url }, ...opts })
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function createFetcher(options = {}) {
|
|
138
|
+
const api = createClient(options);
|
|
139
|
+
return {
|
|
140
|
+
raw: api,
|
|
141
|
+
beep: makeBeep(api),
|
|
142
|
+
event: makeEvent(api),
|
|
143
|
+
platform: makePlatform(api),
|
|
144
|
+
source: makeSource(api),
|
|
145
|
+
forum: makeForum(api),
|
|
146
|
+
submission: makeSubmission(api),
|
|
147
|
+
weightGroup: makeWeightGroup(api),
|
|
148
|
+
xp: makeXp(api),
|
|
149
|
+
user: makeUser(api),
|
|
150
|
+
util: makeUtil(api)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/runtime.ts
|
|
3
155
|
var defaultBaseUrl = "https://gofetch.blaqat.net";
|
|
4
156
|
function createClient(options = {}) {
|
|
5
157
|
return treaty(options.baseUrl ?? defaultBaseUrl, {
|
|
@@ -9,5 +161,6 @@ function createClient(options = {}) {
|
|
|
9
161
|
export {
|
|
10
162
|
treaty,
|
|
11
163
|
defaultBaseUrl,
|
|
164
|
+
createFetcher,
|
|
12
165
|
createClient
|
|
13
166
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beepbox.net/gofetch-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Typesafe Eden treaty client for the gofetch API",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build:js": "rm -rf dist && bun build src/runtime.ts --outfile dist/index.js --target browser --external @elysiajs/eden",
|
|
21
|
-
"build:types": "bun run scripts/generate-types.ts",
|
|
21
|
+
"build:types": "bun run scripts/generate-types.ts && bun run scripts/validate-wire-output.ts",
|
|
22
|
+
"audit:morphs": "bun run scripts/audit-morph-schemas.ts",
|
|
22
23
|
"build": "bun run build:js && bun run build:types",
|
|
23
24
|
"prepublishOnly": "bun run build"
|
|
24
25
|
},
|