Skip to content

Commit

Permalink
Generate API bindings directly from endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Jun 6, 2024
1 parent 5d43174 commit 697dd78
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1,285 deletions.
2 changes: 1 addition & 1 deletion kubb.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
root: ".",

input: {
path: "./src/common/api/potlock/index.yaml",
path: "https://dev.potlock.io/api/schema",
},

output: {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"lint": "next lint",
"generate:api": "kubb --config kubb.config.ts",
"test:unit": "vitest run",
"dev:test": "yarn && vitest watch",
"dev": "yarn && next dev",
"build": "next build",
"dev:test": "yarn && yarn generate:api && vitest watch",
"dev": "yarn && yarn generate:api && next dev",
"build": "yarn generate:api && next build",
"start": "next start"
},
"dependencies": {
Expand Down Expand Up @@ -109,4 +109,4 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
}
}
2 changes: 1 addition & 1 deletion src/common/api/potlock/generated/schemas/Account.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type":"object","properties":{"id":{"description":"On-chain account address.","type":"string","maxLength":64,"title":"Address"},"total_donations_in_usd":{"description":"Total donations received in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total donations received in USD"},"total_donations_out_usd":{"description":"Total donated in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total donations sent in USD"},"total_matching_pool_allocations_usd":{"description":"Total matching pool allocations in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total matching pool allocations in USD"},"donors_count":{"description":"Number of donors.","type":"integer","maximum":2147483647,"minimum":0}},"required":["id"],"x-readme-ref-name":"Account"}
{"type":"object","properties":{"id":{"description":"On-chain account address.","type":"string","maxLength":64,"title":"Address"},"total_donations_in_usd":{"description":"Total donations received in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total donations received in USD"},"total_donations_out_usd":{"description":"Total donated in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total donations sent in USD"},"total_matching_pool_allocations_usd":{"description":"Total matching pool allocations in USD.","type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total matching pool allocations in USD"},"donors_count":{"description":"Number of donors.","type":"integer","maximum":2147483647,"minimum":0},"near_social_profile_data":{"description":"NEAR social data contained under 'profile' key.","nullable":true}},"required":["id"],"x-readme-ref-name":"Account"}
2 changes: 1 addition & 1 deletion src/common/api/potlock/generated/zod/accountSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod";


export const accountSchema = z.object({ "id": z.string().max(64).describe("On-chain account address."), "total_donations_in_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total donations received in USD.").optional(), "total_donations_out_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total donated in USD.").optional(), "total_matching_pool_allocations_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total matching pool allocations in USD.").optional(), "donors_count": z.number().min(0).max(2147483647).describe("Number of donors.").optional() });
export const accountSchema = z.object({ "id": z.string().max(64).describe("On-chain account address."), "total_donations_in_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total donations received in USD.").optional(), "total_donations_out_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total donated in USD.").optional(), "total_matching_pool_allocations_usd": z.string().regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")).describe("Total matching pool allocations in USD.").optional(), "donors_count": z.number().min(0).max(2147483647).describe("Number of donors.").optional(), "near_social_profile_data": z.any().nullish() });
Loading

0 comments on commit 697dd78

Please sign in to comment.