@listeningkit/treg 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/README.md +249 -0
- package/client.ts +141 -0
- package/convex.config.ts +11 -0
- package/dist/_generated/api.d.ts +36 -0
- package/dist/_generated/api.d.ts.map +1 -0
- package/dist/_generated/api.js +31 -0
- package/dist/_generated/api.js.map +1 -0
- package/dist/_generated/dataModel.d.ts +46 -0
- package/dist/_generated/dataModel.d.ts.map +1 -0
- package/dist/_generated/dataModel.js +11 -0
- package/dist/_generated/dataModel.js.map +1 -0
- package/dist/_generated/server.d.ts +135 -0
- package/dist/_generated/server.d.ts.map +1 -0
- package/dist/_generated/server.js +80 -0
- package/dist/_generated/server.js.map +1 -0
- package/dist/client.d.ts +112 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +64 -0
- package/dist/client.js.map +1 -0
- package/dist/convex.config.d.ts +6 -0
- package/dist/convex.config.d.ts.map +1 -0
- package/dist/convex.config.js +11 -0
- package/dist/convex.config.js.map +1 -0
- package/dist/lib/treg.d.ts +20 -0
- package/dist/lib/treg.d.ts.map +1 -0
- package/dist/lib/treg.js +30 -0
- package/dist/lib/treg.js.map +1 -0
- package/dist/schema.d.ts +22 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +18 -0
- package/dist/schema.js.map +1 -0
- package/dist/treg.d.ts +43 -0
- package/dist/treg.d.ts.map +1 -0
- package/dist/treg.js +109 -0
- package/dist/treg.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/lib/treg.ts +34 -0
- package/package.json +66 -0
- package/schema.ts +18 -0
- package/treg.ts +116 -0
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# @listeningkit/treg (Convex Treg Component)
|
|
2
|
+
|
|
3
|
+
> A production-ready [Convex Component](https://docs.convex.dev/components) adapting [treg](https://github.com/superdesigndev/treg) — the open-source **"OpenRouter for developer tools"**.
|
|
4
|
+
|
|
5
|
+
[](https://docs.convex.dev/components)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
[](https://treg.to)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
[`superdesigndev/treg`](https://github.com/superdesigndev/treg) is an open-source tool execution proxy and registry designed as the *OpenRouter for developer tools*. It enables developers and AI agents to route, run, and pay for 2,600+ external tools and APIs (including SpyFu, Firecrawl, SE Ranking, SerpApi, Perplexity, GitHub, Stripe, Resend, and more) through a single unified API, unified billing, and self-hosted proxy with BYOK, OAuth token refreshing, and per-call spend guardrails.
|
|
14
|
+
|
|
15
|
+
This package (`@listeningkit/treg`) provides the native, fully sandboxed **Convex Component** extension for `treg`. It allows any Convex backend to execute tools directly from Convex actions with zero client credentials on device, automatic spend ceilings, fresh idempotency keys, privacy-preserving attribution, and an isolated audit ledger.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Convex Component Architecture
|
|
20
|
+
|
|
21
|
+
This package is authored according to the [Convex Component Specification](https://docs.convex.dev/components/authoring):
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
treg/
|
|
25
|
+
├── convex.config.ts # Component definition & typed environment variables
|
|
26
|
+
├── schema.ts # Encapsulated database schema (spend receipts ledger)
|
|
27
|
+
├── treg.ts # Component actions, mutations, and queries
|
|
28
|
+
├── client.ts # Type-safe client wrapper for host applications
|
|
29
|
+
├── lib/
|
|
30
|
+
│ └── treg.ts # Pure helper utilities (URL builder, error parser)
|
|
31
|
+
├── dist/ # Compiled JavaScript and TypeScript declarations
|
|
32
|
+
└── package.json # Component exports, peerDependencies, and scripts
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 1. Sandboxed Database Isolation
|
|
36
|
+
Components in Convex run inside an isolated boundary. The component defines its own `schema.ts` with a `calls` table. Spend receipts logged by the component remain strictly encapsulated within the component's internal database partition and never conflict with or pollute the host application's data model.
|
|
37
|
+
|
|
38
|
+
### 2. Typed Environment Injection
|
|
39
|
+
The component declares its required environment variables in [`convex.config.ts`](./convex.config.ts):
|
|
40
|
+
- `TREG_TOKEN` — Your team bearer token from [treg.to](https://treg.to) or your self-hosted treg instance.
|
|
41
|
+
- `TREG_BASE_URL` — Optional base URL (defaults to `https://treg.to`).
|
|
42
|
+
|
|
43
|
+
Because these are bound in the component configuration, host action callers never need to pass API secrets as function arguments.
|
|
44
|
+
|
|
45
|
+
### 3. Ergonomic Client Wrapper Pattern
|
|
46
|
+
Directly invoking component functions via `ctx.runAction(components.treg.treg.call, ...)` requires tedious and fragile type assertions. This package exports a first-class `Treg` client wrapper class from the package root:
|
|
47
|
+
```ts
|
|
48
|
+
import { Treg } from "@listeningkit/treg";
|
|
49
|
+
import { components } from "./_generated/api";
|
|
50
|
+
|
|
51
|
+
export const treg = new Treg(components.treg);
|
|
52
|
+
```
|
|
53
|
+
The wrapper provides strongly typed methods, auto-hashing of owner identifiers, and transparent context forwarding.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Installation & Setup
|
|
58
|
+
|
|
59
|
+
### 1. Install the Package
|
|
60
|
+
|
|
61
|
+
Install `@listeningkit/treg` in your Convex application:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# npm
|
|
65
|
+
npm install @listeningkit/treg
|
|
66
|
+
|
|
67
|
+
# pnpm
|
|
68
|
+
pnpm add @listeningkit/treg
|
|
69
|
+
|
|
70
|
+
# yarn
|
|
71
|
+
yarn add @listeningkit/treg
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
*(Ensure `convex` version `>=1.45.0` is installed as a peer dependency).*
|
|
75
|
+
|
|
76
|
+
### 2. Register the Component
|
|
77
|
+
|
|
78
|
+
Register the component inside your host application's `convex/convex.config.ts`:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { defineApp } from "convex/server";
|
|
82
|
+
import treg from "@listeningkit/treg/convex.config";
|
|
83
|
+
|
|
84
|
+
const app = defineApp();
|
|
85
|
+
app.use(treg);
|
|
86
|
+
|
|
87
|
+
export default app;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Configure Deployment Environment Variables
|
|
91
|
+
|
|
92
|
+
Configure your team token on your Convex deployment via the CLI or Convex Dashboard:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npx convex env set TREG_TOKEN="your-treg-team-token"
|
|
96
|
+
|
|
97
|
+
# Optional: if using a self-hosted treg instance
|
|
98
|
+
npx convex env set TREG_BASE_URL="https://treg.your-domain.com"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
*(Note: Environment variables are optional at install/codegen time so they never block local builds or type checking).*
|
|
102
|
+
|
|
103
|
+
### 4. Regenerate Types
|
|
104
|
+
|
|
105
|
+
Run Convex codegen to generate component bindings:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx convex dev --once
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## How to Use in Production
|
|
114
|
+
|
|
115
|
+
### In Host Convex Actions
|
|
116
|
+
|
|
117
|
+
Wrap tool calls in your host application (e.g. `convex/tools.ts`) to authenticate your users, apply business logic, and forward calls to the component:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { v } from "convex/values";
|
|
121
|
+
import { action } from "./_generated/server";
|
|
122
|
+
import { components } from "./_generated/api";
|
|
123
|
+
import { Treg } from "@listeningkit/treg";
|
|
124
|
+
|
|
125
|
+
// Instantiate the component client
|
|
126
|
+
const treg = new Treg(components.treg);
|
|
127
|
+
|
|
128
|
+
export const searchDomainCompetitors = action({
|
|
129
|
+
args: {
|
|
130
|
+
domain: v.string(),
|
|
131
|
+
pageSize: v.optional(v.number()),
|
|
132
|
+
},
|
|
133
|
+
handler: async (ctx, args) => {
|
|
134
|
+
// 1. Authenticate caller in your host app
|
|
135
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
136
|
+
if (!identity) throw new Error("Unauthorized");
|
|
137
|
+
|
|
138
|
+
// 2. Call any tool catalogued on treg.to
|
|
139
|
+
const result = await treg.call(ctx, {
|
|
140
|
+
owner: identity.subject, // Automatically hashed server-side into customer attribution
|
|
141
|
+
endpoint: "spyfu.google.domain.competitors",
|
|
142
|
+
params: {
|
|
143
|
+
domain: args.domain,
|
|
144
|
+
pageSize: args.pageSize ?? 5,
|
|
145
|
+
},
|
|
146
|
+
maxCostUsd: 0.05, // Spend ceiling: treg rejects upfront if cost exceeds this reserve
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return result;
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Reading Spend Receipts & Audit Trail
|
|
155
|
+
|
|
156
|
+
Every successful tool invocation records a receipt in the component's internal `calls` table using the response headers (`X-Treg-Call-Id`, `X-Treg-Cost-Micro`, and `X-Treg-Served-Via`).
|
|
157
|
+
|
|
158
|
+
To query the logged receipts from your host application:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { query } from "./_generated/server";
|
|
162
|
+
import { components } from "./_generated/api";
|
|
163
|
+
import { Treg } from "@listeningkit/treg";
|
|
164
|
+
|
|
165
|
+
const treg = new Treg(components.treg);
|
|
166
|
+
|
|
167
|
+
export const getMyToolUsage = query({
|
|
168
|
+
args: {},
|
|
169
|
+
handler: async (ctx) => {
|
|
170
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
171
|
+
if (!identity) throw new Error("Unauthorized");
|
|
172
|
+
|
|
173
|
+
// Returns recent receipts for this user
|
|
174
|
+
return await treg.getCalls(ctx, {
|
|
175
|
+
owner: identity.subject,
|
|
176
|
+
limit: 20,
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Production Guardrails
|
|
185
|
+
|
|
186
|
+
| Guardrail | Mechanism | Benefit |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| **Max Cost Ceiling** | `X-Treg-Route-Max-Cost` header | Treg refuses the call upfront (HTTP 402) if reserve exceeds max cost; zero funds charged. |
|
|
189
|
+
| **Idempotency Guarantee** | Fresh `crypto.randomUUID()` header per call | Upstream retries or network replays are never double-billed. |
|
|
190
|
+
| **Privacy Attribution** | SHA-256 hashed owner (`customer=<hash>`) | Per-tenant spend ledger and multi-tenant scoping without leaking raw user IDs or PII upstream. |
|
|
191
|
+
| **Audit Ledger** | Isolated `calls` table in component schema | Automatically stores `callId`, `ownerHash`, `endpoint`, `costMicro`, `servedVia`, and `at`. |
|
|
192
|
+
| **Fail-Safe Timeout** | `AbortSignal.timeout(55_000)` | Prevents hung actions from consuming backend execution budget. |
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Catalog & Failover Strategy
|
|
197
|
+
|
|
198
|
+
Search the full catalog of 2,600+ tools at [treg.to/catalog](https://treg.to/catalog) or via the unauthenticated search API:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
curl "https://treg.to/catalog/search?q=competitors"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Failover Pattern Example (SEO Competitors)
|
|
205
|
+
|
|
206
|
+
When building resilient AI workflows, implement failover between provider rows:
|
|
207
|
+
|
|
208
|
+
| Provider | Endpoint ID | Approx. Cost | Role |
|
|
209
|
+
|---|---|---|---|
|
|
210
|
+
| **SpyFu** | `spyfu.google.domain.competitors` | ~$0.0002 / row | Primary (fast, keyword-overlap ranking) |
|
|
211
|
+
| **SE Ranking** | `seranking.google.domain.competitors` | ~$0.0179 / call | Failover (rich metrics: domain relevance, traffic) |
|
|
212
|
+
| **SerpApi** | `serpstat.google.domain.competitors` | ~$0.0005 / result | Alternate |
|
|
213
|
+
|
|
214
|
+
> **Failover Policy**: On HTTP `429` (rate limit), `503` (provider temporarily down), or timeout, retry with the next catalog provider row. Never failover on `4xx` client errors (invalid domain/parameters will fail across all providers and waste credit).
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Component Development & Publishing
|
|
219
|
+
|
|
220
|
+
### Build from Source
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Install dependencies
|
|
224
|
+
pnpm install
|
|
225
|
+
|
|
226
|
+
# Compile TypeScript declarations and JavaScript bundles
|
|
227
|
+
pnpm run build
|
|
228
|
+
|
|
229
|
+
# Type check
|
|
230
|
+
pnpm run typecheck
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Publishing to NPM
|
|
234
|
+
|
|
235
|
+
1. Ensure clean build and type generation:
|
|
236
|
+
```bash
|
|
237
|
+
pnpm run build:clean
|
|
238
|
+
```
|
|
239
|
+
2. Publish to npm:
|
|
240
|
+
```bash
|
|
241
|
+
npm publish --access public
|
|
242
|
+
```
|
|
243
|
+
3. Submit to the official [Convex Components Directory](https://www.convex.dev/components).
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
Apache 2.0. See [superdesigndev/treg](https://github.com/superdesigndev/treg) for upstream engine details.
|
package/client.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { GenericActionCtx, GenericQueryCtx, FunctionReference } from "convex/server";
|
|
2
|
+
import { buildCallUrl, callFailureReason, TREG_DEFAULT_BASE_URL, type CatalogCall } from "./lib/treg.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing the internal API exposed by the Treg Convex component.
|
|
6
|
+
*/
|
|
7
|
+
export type TregComponentApi = {
|
|
8
|
+
treg: {
|
|
9
|
+
call: FunctionReference<
|
|
10
|
+
"action",
|
|
11
|
+
"internal",
|
|
12
|
+
{
|
|
13
|
+
owner: string;
|
|
14
|
+
endpoint: string;
|
|
15
|
+
params?: Record<string, string | number | boolean>;
|
|
16
|
+
maxCostUsd?: number;
|
|
17
|
+
},
|
|
18
|
+
any
|
|
19
|
+
>;
|
|
20
|
+
getCalls: FunctionReference<
|
|
21
|
+
"query",
|
|
22
|
+
"internal",
|
|
23
|
+
{
|
|
24
|
+
ownerHash: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
},
|
|
27
|
+
Array<{
|
|
28
|
+
_id: string;
|
|
29
|
+
_creationTime: number;
|
|
30
|
+
callId: string;
|
|
31
|
+
ownerHash: string;
|
|
32
|
+
endpoint: string;
|
|
33
|
+
costMicro: number;
|
|
34
|
+
servedVia?: string;
|
|
35
|
+
at: number;
|
|
36
|
+
}>
|
|
37
|
+
>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export interface TregCallArgs {
|
|
42
|
+
/**
|
|
43
|
+
* The owner identifier from your host application (e.g. user id, team id).
|
|
44
|
+
* Automatically hashed into a privacy-preserving attribution tag before leaving your backend.
|
|
45
|
+
*/
|
|
46
|
+
owner: string;
|
|
47
|
+
/**
|
|
48
|
+
* Catalog endpoint identifier on treg.to (e.g. "spyfu.google.domain.competitors").
|
|
49
|
+
*/
|
|
50
|
+
endpoint: string;
|
|
51
|
+
/**
|
|
52
|
+
* Flat key-value parameters passed to the catalog endpoint query string.
|
|
53
|
+
*/
|
|
54
|
+
params?: Record<string, string | number | boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional spend ceiling for this call in USD (defaults to $0.05).
|
|
57
|
+
* Treg refuses the call upfront (HTTP 402, charged nothing) if estimated cost exceeds this limit.
|
|
58
|
+
*/
|
|
59
|
+
maxCostUsd?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface TregCallRecord {
|
|
63
|
+
_id: string;
|
|
64
|
+
_creationTime: number;
|
|
65
|
+
callId: string;
|
|
66
|
+
ownerHash: string;
|
|
67
|
+
endpoint: string;
|
|
68
|
+
costMicro: number;
|
|
69
|
+
servedVia?: string;
|
|
70
|
+
at: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Computes a 16-character SHA-256 hex hash for customer attribution tags.
|
|
75
|
+
*/
|
|
76
|
+
export async function hashOwner(owner: string): Promise<string> {
|
|
77
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(owner));
|
|
78
|
+
return [...new Uint8Array(digest)]
|
|
79
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
80
|
+
.join("")
|
|
81
|
+
.slice(0, 16);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Client wrapper for the Treg Convex component.
|
|
86
|
+
*
|
|
87
|
+
* Provides a type-safe, ergonomic API for invoking tools in the treg.to catalog
|
|
88
|
+
* and reading spent call receipts.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { Treg } from "@superdesign/convex-treg";
|
|
93
|
+
* import { components } from "./_generated/api";
|
|
94
|
+
*
|
|
95
|
+
* export const treg = new Treg(components.treg);
|
|
96
|
+
*
|
|
97
|
+
* // Inside a Convex action:
|
|
98
|
+
* export const findCompetitors = action({
|
|
99
|
+
* args: { domain: v.string() },
|
|
100
|
+
* handler: async (ctx, args) => {
|
|
101
|
+
* const user = await auth.getUser(ctx);
|
|
102
|
+
* return await treg.call(ctx, {
|
|
103
|
+
* owner: user._id,
|
|
104
|
+
* endpoint: "spyfu.google.domain.competitors",
|
|
105
|
+
* params: { domain: args.domain, pageSize: 5 },
|
|
106
|
+
* maxCostUsd: 0.05,
|
|
107
|
+
* });
|
|
108
|
+
* },
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export class Treg {
|
|
113
|
+
constructor(public readonly component: TregComponentApi | any) {}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Proxies a tool call to https://treg.to with automatic spend guardrails,
|
|
117
|
+
* fresh idempotency key, and hashed customer attribution.
|
|
118
|
+
*/
|
|
119
|
+
async call<T = unknown>(
|
|
120
|
+
ctx: { runAction: GenericActionCtx<any>["runAction"] },
|
|
121
|
+
args: TregCallArgs,
|
|
122
|
+
): Promise<T> {
|
|
123
|
+
return (await ctx.runAction(this.component.treg.call, args)) as T;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves logged spend receipts for a specific owner from the component's internal database.
|
|
128
|
+
*/
|
|
129
|
+
async getCalls(
|
|
130
|
+
ctx: { runQuery: GenericQueryCtx<any>["runQuery"] },
|
|
131
|
+
args: { owner: string; limit?: number },
|
|
132
|
+
): Promise<TregCallRecord[]> {
|
|
133
|
+
const ownerHash = await hashOwner(args.owner);
|
|
134
|
+
return (await ctx.runQuery(this.component.treg.getCalls, {
|
|
135
|
+
ownerHash,
|
|
136
|
+
limit: args.limit,
|
|
137
|
+
})) as TregCallRecord[];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { buildCallUrl, callFailureReason, TREG_DEFAULT_BASE_URL, type CatalogCall };
|
package/convex.config.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineComponent } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
|
|
4
|
+
export default defineComponent("treg", {
|
|
5
|
+
env: {
|
|
6
|
+
// Optional so install never blocks codegen: the action throws
|
|
7
|
+
// "not switched on yet" when no token is bound, same as FIRECRAWL_API_KEY.
|
|
8
|
+
TREG_TOKEN: v.optional(v.string()),
|
|
9
|
+
TREG_BASE_URL: v.optional(v.string()),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated `api` utility.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type * as lib_treg from "../lib/treg.js";
|
|
10
|
+
import type * as treg from "../treg.js";
|
|
11
|
+
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
12
|
+
declare const fullApi: ApiFromModules<{
|
|
13
|
+
"lib/treg": typeof lib_treg;
|
|
14
|
+
treg: typeof treg;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* ```js
|
|
21
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
25
|
+
/**
|
|
26
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* ```js
|
|
30
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
34
|
+
export declare const components: {};
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,UAAU,EAAE,OAAO,QAAQ,CAAC;IAC5B,IAAI,EAAE,OAAO,IAAI,CAAC;CACnB,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
11
|
+
const fullApi = anyApi;
|
|
12
|
+
/**
|
|
13
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```js
|
|
17
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const api = anyApi;
|
|
21
|
+
/**
|
|
22
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```js
|
|
26
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export const internal = anyApi;
|
|
30
|
+
export const components = componentsGeneric();
|
|
31
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAUH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAGR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated data model types.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { DataModelFromSchemaDefinition, DocumentByName, TableNamesInDataModel, SystemTableNames } from "convex/server";
|
|
10
|
+
import type { GenericId } from "convex/values";
|
|
11
|
+
import schema from "../schema.js";
|
|
12
|
+
/**
|
|
13
|
+
* The names of all of your Convex tables.
|
|
14
|
+
*/
|
|
15
|
+
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
16
|
+
/**
|
|
17
|
+
* The type of a document stored in Convex.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
20
|
+
*/
|
|
21
|
+
export type Doc<TableName extends TableNames> = DocumentByName<DataModel, TableName>;
|
|
22
|
+
/**
|
|
23
|
+
* An identifier for a document in Convex.
|
|
24
|
+
*
|
|
25
|
+
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
26
|
+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
27
|
+
*
|
|
28
|
+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
|
29
|
+
*
|
|
30
|
+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
31
|
+
* strings when type checking.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
34
|
+
*/
|
|
35
|
+
export type Id<TableName extends TableNames | SystemTableNames> = GenericId<TableName>;
|
|
36
|
+
/**
|
|
37
|
+
* A type describing your Convex data model.
|
|
38
|
+
*
|
|
39
|
+
* This type includes information about what tables you have, the type of
|
|
40
|
+
* documents stored in those tables, and the indexes defined on them.
|
|
41
|
+
*
|
|
42
|
+
* This type is used to parameterize methods like `queryGeneric` and
|
|
43
|
+
* `mutationGeneric` to make them type-safe.
|
|
44
|
+
*/
|
|
45
|
+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
46
|
+
//# sourceMappingURL=dataModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.d.ts","sourceRoot":"","sources":["../../_generated/dataModel.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,SAAS,SAAS,UAAU,IAAI,cAAc,CAC5D,SAAS,EACT,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,EAAE,CAAC,SAAS,SAAS,UAAU,GAAG,gBAAgB,IAC5D,SAAS,CAAC,SAAS,CAAC,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.js","sourceRoot":"","sources":["../../_generated/dataModel.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
10
|
+
import type { DataModel } from "./dataModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Typesafe environment variables.
|
|
13
|
+
*
|
|
14
|
+
* This includes platform-provided env vars and any variables declared in
|
|
15
|
+
* `convex.config.ts`.
|
|
16
|
+
*/
|
|
17
|
+
type Env = {
|
|
18
|
+
readonly CONVEX_CLOUD_URL: string;
|
|
19
|
+
readonly CONVEX_SITE_URL: string;
|
|
20
|
+
readonly TREG_BASE_URL: string | undefined;
|
|
21
|
+
readonly TREG_TOKEN: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Define a query in this Convex app's public API.
|
|
25
|
+
*
|
|
26
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
27
|
+
*
|
|
28
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
29
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
30
|
+
*/
|
|
31
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
32
|
+
/**
|
|
33
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
34
|
+
*
|
|
35
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
36
|
+
*
|
|
37
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
38
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
39
|
+
*/
|
|
40
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
41
|
+
/**
|
|
42
|
+
* Define a mutation in this Convex app's public API.
|
|
43
|
+
*
|
|
44
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
45
|
+
*
|
|
46
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
47
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
48
|
+
*/
|
|
49
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
50
|
+
/**
|
|
51
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
52
|
+
*
|
|
53
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
54
|
+
*
|
|
55
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
56
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
57
|
+
*/
|
|
58
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
59
|
+
/**
|
|
60
|
+
* Define an action in this Convex app's public API.
|
|
61
|
+
*
|
|
62
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
63
|
+
* code and code with side-effects, like calling third-party services.
|
|
64
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
65
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
66
|
+
*
|
|
67
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
68
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
69
|
+
*/
|
|
70
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
71
|
+
/**
|
|
72
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
73
|
+
*
|
|
74
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
75
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
76
|
+
*/
|
|
77
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
78
|
+
/**
|
|
79
|
+
* Define an HTTP action.
|
|
80
|
+
*
|
|
81
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
82
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
83
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
84
|
+
*
|
|
85
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
86
|
+
* and a Fetch API `Request` object as its second.
|
|
87
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
88
|
+
*/
|
|
89
|
+
export declare const httpAction: HttpActionBuilder;
|
|
90
|
+
export declare const env: Env;
|
|
91
|
+
/**
|
|
92
|
+
* A set of services for use within Convex query functions.
|
|
93
|
+
*
|
|
94
|
+
* The query context is passed as the first argument to any Convex query
|
|
95
|
+
* function run on the server.
|
|
96
|
+
*
|
|
97
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
98
|
+
*/
|
|
99
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
100
|
+
/**
|
|
101
|
+
* A set of services for use within Convex mutation functions.
|
|
102
|
+
*
|
|
103
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
104
|
+
* function run on the server.
|
|
105
|
+
*
|
|
106
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
107
|
+
*/
|
|
108
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
109
|
+
/**
|
|
110
|
+
* A set of services for use within Convex action functions.
|
|
111
|
+
*
|
|
112
|
+
* The action context is passed as the first argument to any Convex action
|
|
113
|
+
* function run on the server.
|
|
114
|
+
*/
|
|
115
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
116
|
+
/**
|
|
117
|
+
* An interface to read from the database within Convex query functions.
|
|
118
|
+
*
|
|
119
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
120
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
121
|
+
* building a query.
|
|
122
|
+
*/
|
|
123
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
124
|
+
/**
|
|
125
|
+
* An interface to read from and write to the database within Convex mutation
|
|
126
|
+
* functions.
|
|
127
|
+
*
|
|
128
|
+
* Convex guarantees that all writes within a single mutation are
|
|
129
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
130
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
131
|
+
* for the guarantees Convex provides your functions.
|
|
132
|
+
*/
|
|
133
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,KAAK,GAAG,GAAG;IACT,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAgB,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAmB,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,SAAS,EAAE,UAAU,CAC3C,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAiB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CACzC,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAqC,CAAC;AAC/D,eAAO,MAAM,GAAG,EAAE,GACJ,CAAC;AAEf;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
|