fdssdffsd

This commit is contained in:
Jacob Nguyen
2024-05-17 16:57:44 -05:00
parent b08f69edf2
commit e30734a750
8 changed files with 564 additions and 2239 deletions

View File

@@ -1,10 +1,10 @@
{
"name": "@sern/poster",
"version": "1.2.1",
"version": "1.2.5",
"description": "Post discord application commands",
"exports": {
".": "./dist/poster.mjs"
},
"types": "./dist/index.d.ts",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"scripts": {
"poster:debug": "npx squint compile",
"poster:prod": "npx squint compile",
@@ -14,11 +14,18 @@
"keywords": [],
"author": "",
"license": "ISC",
"files": [
"dist",
"README.md",
"src",
"LICENSE"
],
"publishConfig": {
"access": "public",
"tag": "latest"
},
"dependencies": {
"squint-cljs": "latest"
}
},
"type": "module"
}

View File

@@ -1,15 +0,0 @@
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[]
:builds
{:poster {:target :node-library
:output-to "dist/index.js"
:exports { :client core.poster/poster
:isOk core.poster/isOk?
:is4XX core.poster/is4XX? }
:build-hooks [(dev.mv/hook)]
}}}

View File

@@ -15,6 +15,7 @@
:guild/delete ["DELETE" "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}"]
:guild/put ["PUT" "/applications/{application.id}/guilds/{guild.id}/commands"]
:application/me ["GET" "/applications/@me"]
:user/get ["GET" "/users/{user.id}"]
})
(defn- request-init [v]

View File

@@ -8,12 +8,12 @@
(-> (str base remaining-url)
(s/replace #"\{application\.id\}" (or (.-app_id ^js opts) ""))
(s/replace #"\{guild\.id\}" (or (.-guild_id ^js opts) ""))
(s/replace #"\{user\.id\}" (or (.-guild_id ^js opts) ""))
(s/replace #"\{command\.id\}" (or (.-command_id ^js opts) ""))))
(defn- ?params [^js query]
(new js/URLSearchParams query))
(defn- fetch-application [headers]
(let [url (str base (first (get actions "application/me")))]
(-> (js/fetch url #js{ "headers" headers })

View File

@@ -1,4 +1,3 @@
declare module 'poster.*';
import type { paths } from './discord.d.ts'
@@ -13,6 +12,7 @@ export type GuildGet = paths["/applications/{application_id}/guilds/{guild_id}/c
export type GuildEdit = paths["/applications/{application_id}/guilds/{guild_id}/commands/{command_id}"]["patch"]
export type GuildDelete = paths["/applications/{application_id}/guilds/{guild_id}/commands/{command_id}"]["delete"]
export type GuildPut = paths["/applications/{application_id}/guilds/{guild_id}/commands"]["put"]
export type UserGet = paths["/users/{user_id}"]['get']
export type ApplicationMe = paths["/applications/@me"]['get']
type ResponsesForRoute<T> = T extends { responses: infer R } ? R : never;
@@ -57,7 +57,8 @@ interface RoutesOptions {
"guild/put": [{ body: GuildPut["requestBody"]["content"]['application/json']}
& GuildPut["parameters"]["path"]
& { application_id?: never }];
"application/me": []
"application/me": [];
"user/get" : [UserGet['parameters']['path'] & { application_id?: never } ]
}

View File

@@ -1,8 +1,8 @@
import poster from '../dist/poster.mjs';
import poster from '../dist/index.mjs';
const send = await poster.client("token");
const send = poster.client("token");
const req = await send("global/get-all", {
const req = await send("user/get", {
});

View File

@@ -1,11 +1,10 @@
import poster, { type GlobalPut, type TypedResponse } from '../dist/poster.js';
import poster, { type GlobalPut } from '../dist/index.js';
const send = await poster.client("token");
const req = await send("global/get-all", {
}) as TypedResponse<GlobalPut>; //cast for full typed safety
const req = await send("user/get", {
user_id: ""
}); //cast for full typed safety
if(poster.isOk<GlobalPut>(req)) {
req.json().then(s => s?.map(v => v.name))

2748
yarn.lock

File diff suppressed because it is too large Load Diff