@nordsym/apiclaw 2.1.0 → 2.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 +15 -2
- package/dist/bin-http.js +0 -0
- package/dist/bin.bundled.js +79288 -0
- package/dist/funnel-client.d.ts +24 -0
- package/dist/funnel-client.d.ts.map +1 -0
- package/dist/funnel-client.js +131 -0
- package/dist/funnel-client.js.map +1 -0
- package/dist/funnel.test.d.ts +2 -0
- package/dist/funnel.test.d.ts.map +1 -0
- package/dist/funnel.test.js +145 -0
- package/dist/funnel.test.js.map +1 -0
- package/dist/gateway-client.d.ts.map +1 -1
- package/dist/gateway-client.js +24 -2
- package/dist/gateway-client.js.map +1 -1
- package/dist/index.bundled.js +61263 -0
- package/dist/index.js +161 -74
- package/dist/index.js.map +1 -1
- package/dist/postinstall.d.ts +0 -5
- package/dist/postinstall.d.ts.map +1 -1
- package/dist/postinstall.js +24 -3
- package/dist/postinstall.js.map +1 -1
- package/dist/registration-guard.d.ts +29 -0
- package/dist/registration-guard.d.ts.map +1 -0
- package/dist/registration-guard.js +87 -0
- package/dist/registration-guard.js.map +1 -0
- package/package.json +7 -2
- package/.claude/settings.local.json +0 -9
- package/.env.prod +0 -1
- package/apiclaw-README.md +0 -494
- package/convex/_generated/api.d.ts +0 -137
- package/convex/_generated/api.js +0 -23
- package/convex/_generated/dataModel.d.ts +0 -60
- package/convex/_generated/server.d.ts +0 -143
- package/convex/_generated/server.js +0 -93
- package/convex/adminActivate.ts +0 -53
- package/convex/adminStats.ts +0 -306
- package/convex/agents.ts +0 -939
- package/convex/analytics.ts +0 -187
- package/convex/apiKeys.ts +0 -220
- package/convex/backfillAnalytics.ts +0 -272
- package/convex/backfillSearchLogs.ts +0 -35
- package/convex/billing.ts +0 -834
- package/convex/capabilities.ts +0 -157
- package/convex/chains.ts +0 -1318
- package/convex/credits.ts +0 -211
- package/convex/crons.ts +0 -50
- package/convex/debugFilestackLogs.ts +0 -16
- package/convex/debugGetToken.ts +0 -18
- package/convex/directCall.ts +0 -713
- package/convex/earnProgress.ts +0 -753
- package/convex/email.ts +0 -329
- package/convex/feedback.ts +0 -265
- package/convex/http.ts +0 -3430
- package/convex/inbound.ts +0 -32
- package/convex/logs.ts +0 -701
- package/convex/migrateFilestack.ts +0 -81
- package/convex/migratePartnersProd.ts +0 -174
- package/convex/migratePratham.ts +0 -126
- package/convex/migrateProviderWorkspaces.ts +0 -175
- package/convex/mou.ts +0 -91
- package/convex/providerKeys.ts +0 -289
- package/convex/providers.ts +0 -1135
- package/convex/purchases.ts +0 -183
- package/convex/ratelimit.ts +0 -104
- package/convex/schema.ts +0 -869
- package/convex/searchLogs.ts +0 -265
- package/convex/seedAPILayerAPIs.ts +0 -191
- package/convex/seedDirectCallConfigs.ts +0 -336
- package/convex/seedPratham.ts +0 -149
- package/convex/spendAlerts.ts +0 -442
- package/convex/stripeActions.ts +0 -607
- package/convex/teams.ts +0 -243
- package/convex/telemetry.ts +0 -81
- package/convex/tsconfig.json +0 -25
- package/convex/updateAPIStatus.ts +0 -44
- package/convex/usage.ts +0 -260
- package/convex/usageReports.ts +0 -357
- package/convex/waitlist.ts +0 -55
- package/convex/webhooks.ts +0 -494
- package/convex/workspaceSettings.ts +0 -143
- package/convex/workspaces.ts +0 -1331
- package/convex.json +0 -3
- package/direct-test.mjs +0 -51
- package/email-templates/filestack-provider-outreach.html +0 -162
- package/email-templates/partnership-template.html +0 -116
- package/email-templates/pratham-draft-preview.txt +0 -57
- package/email-templates/pratham-partnership-draft.html +0 -141
- package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
- package/reports/pipeline/PIPELINE-REPORT.json +0 -153
- package/reports/pipeline/acquire_apisguru.json +0 -17
- package/reports/pipeline/capabilities.json +0 -38
- package/reports/pipeline/discover_azure_recursive.json +0 -1551
- package/reports/pipeline/discover_github.json +0 -25
- package/reports/pipeline/discover_github_repos.json +0 -49
- package/reports/pipeline/discover_swaggerhub.json +0 -24
- package/reports/pipeline/discover_well_known.json +0 -23
- package/reports/pipeline/fetch_specs.json +0 -19
- package/reports/pipeline/generate_providers.json +0 -14
- package/reports/pipeline/match_registry.json +0 -11
- package/reports/pipeline/parse_specs.json +0 -17
- package/reports/pipeline/promote_candidates.json +0 -34
- package/reports/pipeline/validate.json +0 -30
- package/reports/pipeline/validate_smoke_details.json +0 -3835
- package/reports/session-report-2026-04-05.html +0 -433
- package/seed-apis-direct.mjs +0 -106
- package/src/access-control.ts +0 -174
- package/src/adapters/base.ts +0 -364
- package/src/adapters/claude-desktop.ts +0 -41
- package/src/adapters/cline.ts +0 -88
- package/src/adapters/continue.ts +0 -91
- package/src/adapters/cursor.ts +0 -43
- package/src/adapters/custom.ts +0 -188
- package/src/adapters/detect.ts +0 -202
- package/src/adapters/index.ts +0 -47
- package/src/adapters/windsurf.ts +0 -44
- package/src/bin-http.ts +0 -45
- package/src/bin.ts +0 -34
- package/src/capability-router.ts +0 -331
- package/src/chainExecutor.ts +0 -730
- package/src/chainResolver.test.ts +0 -246
- package/src/chainResolver.ts +0 -658
- package/src/cli/commands/demo.ts +0 -109
- package/src/cli/commands/doctor.ts +0 -435
- package/src/cli/commands/index.ts +0 -9
- package/src/cli/commands/login.ts +0 -203
- package/src/cli/commands/mcp-install.ts +0 -373
- package/src/cli/commands/restore.ts +0 -333
- package/src/cli/commands/setup.ts +0 -297
- package/src/cli/commands/uninstall.ts +0 -240
- package/src/cli/index.ts +0 -148
- package/src/cli.ts +0 -370
- package/src/confirmation.ts +0 -296
- package/src/credentials.ts +0 -455
- package/src/credits.ts +0 -329
- package/src/crypto.ts +0 -75
- package/src/discovery.ts +0 -568
- package/src/enterprise/env.ts +0 -156
- package/src/enterprise/index.ts +0 -7
- package/src/enterprise/script-generator.ts +0 -481
- package/src/execute-dynamic.ts +0 -617
- package/src/execute.ts +0 -2386
- package/src/gateway-client.ts +0 -192
- package/src/hivr-whitelist.ts +0 -110
- package/src/http-api.ts +0 -286
- package/src/http-server-minimal.ts +0 -154
- package/src/index.ts +0 -2611
- package/src/intelligent-gateway.ts +0 -339
- package/src/mcp-analytics.ts +0 -156
- package/src/metered.ts +0 -149
- package/src/open-apis-generated.ts +0 -157
- package/src/open-apis.ts +0 -558
- package/src/postinstall.ts +0 -18
- package/src/product-whitelist.ts +0 -246
- package/src/proxy.ts +0 -36
- package/src/session.ts +0 -129
- package/src/stripe.ts +0 -497
- package/src/telemetry.ts +0 -71
- package/src/test.ts +0 -135
- package/src/types/convex-api.d.ts +0 -20
- package/src/types/convex-api.ts +0 -21
- package/src/types.ts +0 -109
- package/src/ui/colors.ts +0 -219
- package/src/ui/errors.ts +0 -394
- package/src/ui/index.ts +0 -17
- package/src/ui/prompts.ts +0 -390
- package/src/ui/spinner.ts +0 -325
- package/src/utils/backup.ts +0 -224
- package/src/utils/config.ts +0 -318
- package/src/utils/os.ts +0 -124
- package/src/utils/paths.ts +0 -203
- package/src/webhook.ts +0 -107
- package/test-10-working.cjs +0 -97
- package/test-14-final.cjs +0 -96
- package/test-actual-handlers.ts +0 -92
- package/test-apilayer-all-14.ts +0 -249
- package/test-apilayer-fixed.ts +0 -248
- package/test-direct-endpoints.ts +0 -174
- package/test-exact-endpoints.ts +0 -144
- package/test-final.ts +0 -83
- package/test-full-routing.ts +0 -100
- package/test-handlers-correct.ts +0 -217
- package/test-numverify-key.ts +0 -41
- package/test-via-handlers.ts +0 -92
- package/test-worldnews.mjs +0 -26
- package/tsconfig.json +0 -20
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
ActionBuilder,
|
|
13
|
-
HttpActionBuilder,
|
|
14
|
-
MutationBuilder,
|
|
15
|
-
QueryBuilder,
|
|
16
|
-
GenericActionCtx,
|
|
17
|
-
GenericMutationCtx,
|
|
18
|
-
GenericQueryCtx,
|
|
19
|
-
GenericDatabaseReader,
|
|
20
|
-
GenericDatabaseWriter,
|
|
21
|
-
} from "convex/server";
|
|
22
|
-
import type { DataModel } from "./dataModel.js";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Define a query in this Convex app's public API.
|
|
26
|
-
*
|
|
27
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
28
|
-
*
|
|
29
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
30
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
31
|
-
*/
|
|
32
|
-
export declare const query: QueryBuilder<DataModel, "public">;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
36
|
-
*
|
|
37
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
38
|
-
*
|
|
39
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
40
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
41
|
-
*/
|
|
42
|
-
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Define a mutation in this Convex app's public API.
|
|
46
|
-
*
|
|
47
|
-
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
48
|
-
*
|
|
49
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
50
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
51
|
-
*/
|
|
52
|
-
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
56
|
-
*
|
|
57
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
58
|
-
*
|
|
59
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
60
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
61
|
-
*/
|
|
62
|
-
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Define an action in this Convex app's public API.
|
|
66
|
-
*
|
|
67
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
68
|
-
* code and code with side-effects, like calling third-party services.
|
|
69
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
70
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
71
|
-
*
|
|
72
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
73
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
74
|
-
*/
|
|
75
|
-
export declare const action: ActionBuilder<DataModel, "public">;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
79
|
-
*
|
|
80
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
81
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
82
|
-
*/
|
|
83
|
-
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Define an HTTP action.
|
|
87
|
-
*
|
|
88
|
-
* The wrapped function will be used to respond to HTTP requests received
|
|
89
|
-
* by a Convex deployment if the requests matches the path and method where
|
|
90
|
-
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
91
|
-
*
|
|
92
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
93
|
-
* and a Fetch API `Request` object as its second.
|
|
94
|
-
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
95
|
-
*/
|
|
96
|
-
export declare const httpAction: HttpActionBuilder;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* A set of services for use within Convex query functions.
|
|
100
|
-
*
|
|
101
|
-
* The query context is passed as the first argument to any Convex query
|
|
102
|
-
* function run on the server.
|
|
103
|
-
*
|
|
104
|
-
* This differs from the {@link MutationCtx} because all of the services are
|
|
105
|
-
* read-only.
|
|
106
|
-
*/
|
|
107
|
-
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A set of services for use within Convex mutation functions.
|
|
111
|
-
*
|
|
112
|
-
* The mutation context is passed as the first argument to any Convex mutation
|
|
113
|
-
* function run on the server.
|
|
114
|
-
*/
|
|
115
|
-
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A set of services for use within Convex action functions.
|
|
119
|
-
*
|
|
120
|
-
* The action context is passed as the first argument to any Convex action
|
|
121
|
-
* function run on the server.
|
|
122
|
-
*/
|
|
123
|
-
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* An interface to read from the database within Convex query functions.
|
|
127
|
-
*
|
|
128
|
-
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
129
|
-
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
130
|
-
* building a query.
|
|
131
|
-
*/
|
|
132
|
-
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* An interface to read from and write to the database within Convex mutation
|
|
136
|
-
* functions.
|
|
137
|
-
*
|
|
138
|
-
* Convex guarantees that all writes within a single mutation are
|
|
139
|
-
* executed atomically, so you never have to worry about partial writes leaving
|
|
140
|
-
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
141
|
-
* for the guarantees Convex provides your functions.
|
|
142
|
-
*/
|
|
143
|
-
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
actionGeneric,
|
|
13
|
-
httpActionGeneric,
|
|
14
|
-
queryGeneric,
|
|
15
|
-
mutationGeneric,
|
|
16
|
-
internalActionGeneric,
|
|
17
|
-
internalMutationGeneric,
|
|
18
|
-
internalQueryGeneric,
|
|
19
|
-
} from "convex/server";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Define a query in this Convex app's public API.
|
|
23
|
-
*
|
|
24
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
25
|
-
*
|
|
26
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
-
*/
|
|
29
|
-
export const query = queryGeneric;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
33
|
-
*
|
|
34
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
35
|
-
*
|
|
36
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
37
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
38
|
-
*/
|
|
39
|
-
export const internalQuery = internalQueryGeneric;
|
|
40
|
-
|
|
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 const mutation = mutationGeneric;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
53
|
-
*
|
|
54
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
55
|
-
*
|
|
56
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
57
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
58
|
-
*/
|
|
59
|
-
export const internalMutation = internalMutationGeneric;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Define an action in this Convex app's public API.
|
|
63
|
-
*
|
|
64
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
65
|
-
* code and code with side-effects, like calling third-party services.
|
|
66
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
67
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
68
|
-
*
|
|
69
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
70
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
71
|
-
*/
|
|
72
|
-
export const action = actionGeneric;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
76
|
-
*
|
|
77
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
78
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
79
|
-
*/
|
|
80
|
-
export const internalAction = internalActionGeneric;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Define an HTTP action.
|
|
84
|
-
*
|
|
85
|
-
* The wrapped function will be used to respond to HTTP requests received
|
|
86
|
-
* by a Convex deployment if the requests matches the path and method where
|
|
87
|
-
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
88
|
-
*
|
|
89
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
90
|
-
* and a Fetch API `Request` object as its second.
|
|
91
|
-
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
92
|
-
*/
|
|
93
|
-
export const httpAction = httpActionGeneric;
|
package/convex/adminActivate.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { mutation } from "./_generated/server";
|
|
2
|
-
import { v } from "convex/values";
|
|
3
|
-
|
|
4
|
-
export const activateWorkspace = mutation({
|
|
5
|
-
args: { workspaceId: v.id("workspaces") },
|
|
6
|
-
handler: async (ctx, { workspaceId }) => {
|
|
7
|
-
const workspace = await ctx.db.get(workspaceId);
|
|
8
|
-
if (!workspace) {
|
|
9
|
-
return { success: false, error: "not_found" };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
await ctx.db.patch(workspaceId, {
|
|
13
|
-
status: "active",
|
|
14
|
-
tier: "pro",
|
|
15
|
-
weeklyUsageLimit: 999999,
|
|
16
|
-
usageLimit: 999999,
|
|
17
|
-
updatedAt: Date.now(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return { success: true };
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function generateToken(): string {
|
|
25
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
26
|
-
let result = '';
|
|
27
|
-
for (let i = 0; i < 32; i++) {
|
|
28
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const createSessionForWorkspace = mutation({
|
|
34
|
-
args: { workspaceId: v.id("workspaces") },
|
|
35
|
-
handler: async (ctx, { workspaceId }) => {
|
|
36
|
-
const workspace = await ctx.db.get(workspaceId);
|
|
37
|
-
if (!workspace || workspace.status !== "active") {
|
|
38
|
-
return { success: false, error: "workspace_not_active" };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const sessionToken = "apiclaw_" + generateToken();
|
|
42
|
-
|
|
43
|
-
await ctx.db.insert("agentSessions", {
|
|
44
|
-
workspaceId,
|
|
45
|
-
sessionToken,
|
|
46
|
-
fingerprint: "hivr-bees",
|
|
47
|
-
lastUsedAt: Date.now(),
|
|
48
|
-
createdAt: Date.now(),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return { success: true, sessionToken };
|
|
52
|
-
},
|
|
53
|
-
});
|
package/convex/adminStats.ts
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { query, mutation } from "./_generated/server";
|
|
2
|
-
import { v } from "convex/values";
|
|
3
|
-
|
|
4
|
-
// Get total user/workspace count
|
|
5
|
-
export const getTotalWorkspaces = query({
|
|
6
|
-
args: {},
|
|
7
|
-
handler: async (ctx) => {
|
|
8
|
-
const workspaces = await ctx.db.query("workspaces").collect();
|
|
9
|
-
const providers = await ctx.db.query("providers").collect();
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
totalWorkspaces: workspaces.length,
|
|
13
|
-
totalProviders: providers.length,
|
|
14
|
-
activeWorkspaces: workspaces.filter(w => w.status === "active").length,
|
|
15
|
-
paid: workspaces.filter(w => ["pro", "scale", "usage_based"].includes(w.tier)).length,
|
|
16
|
-
workspaceBreakdown: {
|
|
17
|
-
free: workspaces.filter(w => w.tier === "free").length,
|
|
18
|
-
pro: workspaces.filter(w => w.tier === "pro").length,
|
|
19
|
-
scale: workspaces.filter(w => w.tier === "scale").length,
|
|
20
|
-
usage_based: workspaces.filter(w => w.tier === "usage_based").length,
|
|
21
|
-
enterprise: workspaces.filter(w => w.tier === "enterprise").length,
|
|
22
|
-
partner: workspaces.filter(w => w.tier === "partner").length,
|
|
23
|
-
},
|
|
24
|
-
providerBreakdown: {
|
|
25
|
-
pending: providers.filter(p => p.status === "pending").length,
|
|
26
|
-
approved: providers.filter(p => p.status === "approved").length,
|
|
27
|
-
rejected: providers.filter(p => p.status === "rejected").length,
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// List all workspace emails (for inspection)
|
|
34
|
-
export const listWorkspaces = query({
|
|
35
|
-
args: {},
|
|
36
|
-
handler: async (ctx) => {
|
|
37
|
-
const workspaces = await ctx.db.query("workspaces").collect();
|
|
38
|
-
return workspaces.map(w => ({
|
|
39
|
-
email: w.email,
|
|
40
|
-
status: w.status,
|
|
41
|
-
tier: w.tier,
|
|
42
|
-
usageCount: w.usageCount,
|
|
43
|
-
createdAt: w.createdAt,
|
|
44
|
-
lastActiveAt: w.lastActiveAt,
|
|
45
|
-
}));
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Delete workspace by email or empty email ghosts
|
|
50
|
-
export const cleanupWorkspaces = mutation({
|
|
51
|
-
args: {
|
|
52
|
-
deleteEmptyEmail: v.optional(v.boolean()),
|
|
53
|
-
deleteEmail: v.optional(v.string()),
|
|
54
|
-
deleteEmailWithTier: v.optional(v.string()),
|
|
55
|
-
activateEmail: v.optional(v.string()),
|
|
56
|
-
},
|
|
57
|
-
handler: async (ctx, { deleteEmptyEmail, deleteEmail, deleteEmailWithTier, activateEmail }) => {
|
|
58
|
-
const workspaces = await ctx.db.query("workspaces").collect();
|
|
59
|
-
let deleted = 0;
|
|
60
|
-
|
|
61
|
-
// Activate a pending workspace
|
|
62
|
-
if (activateEmail) {
|
|
63
|
-
for (const ws of workspaces) {
|
|
64
|
-
if (ws.email === activateEmail && ws.status === "pending") {
|
|
65
|
-
await ctx.db.patch(ws._id, { status: "active" });
|
|
66
|
-
return { activated: activateEmail };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return { error: "not found or not pending" };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
for (const ws of workspaces) {
|
|
73
|
-
let shouldDelete = false;
|
|
74
|
-
|
|
75
|
-
if (deleteEmptyEmail && (!ws.email || ws.email === "")) {
|
|
76
|
-
shouldDelete = true;
|
|
77
|
-
}
|
|
78
|
-
if (deleteEmail && ws.email === deleteEmail) {
|
|
79
|
-
shouldDelete = true;
|
|
80
|
-
}
|
|
81
|
-
// Delete specific email+tier combo (e.g. remove free duplicate but keep pro)
|
|
82
|
-
if (deleteEmailWithTier) {
|
|
83
|
-
const [email, tier] = deleteEmailWithTier.split(":");
|
|
84
|
-
if (ws.email === email && ws.tier === tier) {
|
|
85
|
-
shouldDelete = true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (shouldDelete) {
|
|
90
|
-
// Delete associated sessions
|
|
91
|
-
const sessions = await ctx.db.query("sessions").collect();
|
|
92
|
-
for (const s of sessions) {
|
|
93
|
-
if ((s as any).workspaceId === ws._id) {
|
|
94
|
-
await ctx.db.delete(s._id);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Delete associated agents
|
|
98
|
-
const agents = await ctx.db.query("agents").collect();
|
|
99
|
-
for (const a of agents) {
|
|
100
|
-
if (a.workspaceId === ws._id) {
|
|
101
|
-
await ctx.db.delete(a._id);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
await ctx.db.delete(ws._id);
|
|
105
|
-
deleted++;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return { deleted };
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
export const updateProviderEmail = mutation({
|
|
114
|
-
args: { providerId: v.string(), email: v.string() },
|
|
115
|
-
handler: async (ctx, { providerId, email }) => {
|
|
116
|
-
await ctx.db.patch(providerId as any, { email });
|
|
117
|
-
return { success: true };
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Seed Filestack workspace + 14 days of discovery data
|
|
122
|
-
export const seedFilestackWorkspace = mutation({
|
|
123
|
-
args: {},
|
|
124
|
-
handler: async (ctx) => {
|
|
125
|
-
// 1. Create or update Filestack workspace
|
|
126
|
-
const existing = await ctx.db
|
|
127
|
-
.query("workspaces")
|
|
128
|
-
.withIndex("by_email", (q) => q.eq("email", "marketing@filestack.com"))
|
|
129
|
-
.first();
|
|
130
|
-
|
|
131
|
-
let workspaceId = existing?._id;
|
|
132
|
-
|
|
133
|
-
if (!workspaceId) {
|
|
134
|
-
workspaceId = await ctx.db.insert("workspaces", {
|
|
135
|
-
email: "marketing@filestack.com",
|
|
136
|
-
workspaceName: "Filestack",
|
|
137
|
-
status: "active",
|
|
138
|
-
tier: "partner",
|
|
139
|
-
usageCount: 0,
|
|
140
|
-
usageLimit: 999999,
|
|
141
|
-
weeklyUsageLimit: 999999,
|
|
142
|
-
mainAgentName: "Filestack Partner",
|
|
143
|
-
createdAt: Date.now(),
|
|
144
|
-
updatedAt: Date.now(),
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
await ctx.db.patch(workspaceId, {
|
|
148
|
-
status: "active",
|
|
149
|
-
tier: "partner",
|
|
150
|
-
workspaceName: "Filestack",
|
|
151
|
-
updatedAt: Date.now(),
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 2. Seed 14 days of realistic discovery data
|
|
156
|
-
const logs = [
|
|
157
|
-
{ action: "discovery:virus scan uploaded files", createdAt: 1775238013202, latencyMs: 25 },
|
|
158
|
-
{ action: "discovery:OCR document scan", createdAt: 1775226543202, latencyMs: 36 },
|
|
159
|
-
{ action: "discovery:file upload cdn delivery", createdAt: 1775214346202, latencyMs: 58 },
|
|
160
|
-
{ action: "discovery:upload images users", createdAt: 1775208102202, latencyMs: 13 },
|
|
161
|
-
{ action: "discovery:image transformation api", createdAt: 1775196892202, latencyMs: 18 },
|
|
162
|
-
{ action: "discovery:file upload api", createdAt: 1775194022202, latencyMs: 63 },
|
|
163
|
-
{ action: "discovery:file upload cdn delivery", createdAt: 1775191598202, latencyMs: 63 },
|
|
164
|
-
{ action: "discovery:image transformation api", createdAt: 1775146832202, latencyMs: 20 },
|
|
165
|
-
{ action: "discovery:file upload cdn delivery", createdAt: 1775141820202, latencyMs: 57 },
|
|
166
|
-
{ action: "discovery:virus scan uploaded files", createdAt: 1775112879202, latencyMs: 15 },
|
|
167
|
-
{ action: "discovery:handle user file uploads", createdAt: 1775110663202, latencyMs: 38 },
|
|
168
|
-
{ action: "discovery:file management api", createdAt: 1775029221202, latencyMs: 23 },
|
|
169
|
-
{ action: "discovery:file upload api", createdAt: 1775027445202, latencyMs: 41 },
|
|
170
|
-
{ action: "discovery:upload files from browser", createdAt: 1775019216202, latencyMs: 43 },
|
|
171
|
-
{ action: "discovery:image upload and transform", createdAt: 1774978691202, latencyMs: 65 },
|
|
172
|
-
{ action: "discovery:image upload and transform", createdAt: 1774976661202, latencyMs: 51 },
|
|
173
|
-
{ action: "discovery:file picker widget", createdAt: 1774972305202, latencyMs: 22 },
|
|
174
|
-
{ action: "discovery:image upload and transform", createdAt: 1774963193202, latencyMs: 51 },
|
|
175
|
-
{ action: "discovery:file picker widget", createdAt: 1774941922202, latencyMs: 41 },
|
|
176
|
-
{ action: "discovery:file picker widget", createdAt: 1774935674202, latencyMs: 39 },
|
|
177
|
-
{ action: "discovery:file management api", createdAt: 1774889668202, latencyMs: 21 },
|
|
178
|
-
{ action: "discovery:resize image on upload", createdAt: 1774858239202, latencyMs: 29 },
|
|
179
|
-
{ action: "discovery:upload images users", createdAt: 1774804384202, latencyMs: 21 },
|
|
180
|
-
{ action: "discovery:secure file upload", createdAt: 1774784782202, latencyMs: 18 },
|
|
181
|
-
{ action: "discovery:upload images users", createdAt: 1774720815202, latencyMs: 20 },
|
|
182
|
-
{ action: "discovery:secure file upload", createdAt: 1774699761202, latencyMs: 20 },
|
|
183
|
-
{ action: "discovery:file storage cloud", createdAt: 1774696012202, latencyMs: 16 },
|
|
184
|
-
{ action: "discovery:upload transform deliver files", createdAt: 1774693456202, latencyMs: 39 },
|
|
185
|
-
{ action: "discovery:secure file upload", createdAt: 1774672000202, latencyMs: 49 },
|
|
186
|
-
{ action: "discovery:handle user file uploads", createdAt: 1774631829202, latencyMs: 29 },
|
|
187
|
-
{ action: "discovery:file storage cloud", createdAt: 1774622378202, latencyMs: 52 },
|
|
188
|
-
{ action: "discovery:image transformation api", createdAt: 1774591324202, latencyMs: 30 },
|
|
189
|
-
{ action: "discovery:file picker widget", createdAt: 1774549274202, latencyMs: 49 },
|
|
190
|
-
{ action: "discovery:handle user file uploads", createdAt: 1774533887202, latencyMs: 22 },
|
|
191
|
-
{ action: "discovery:file picker widget", createdAt: 1774531265202, latencyMs: 34 },
|
|
192
|
-
{ action: "discovery:image transformation api", createdAt: 1774522504202, latencyMs: 39 },
|
|
193
|
-
{ action: "discovery:image upload and transform", createdAt: 1774516401202, latencyMs: 37 },
|
|
194
|
-
{ action: "discovery:file storage cloud", createdAt: 1774516031202, latencyMs: 15 },
|
|
195
|
-
{ action: "discovery:upload transform deliver files", createdAt: 1774511980202, latencyMs: 23 },
|
|
196
|
-
{ action: "discovery:file management api", createdAt: 1774425147202, latencyMs: 26 },
|
|
197
|
-
{ action: "discovery:image transformation api", createdAt: 1774416583202, latencyMs: 57 },
|
|
198
|
-
{ action: "discovery:file upload api", createdAt: 1774371763202, latencyMs: 48 },
|
|
199
|
-
{ action: "discovery:resize image on upload", createdAt: 1774357331202, latencyMs: 63 },
|
|
200
|
-
{ action: "discovery:handle user file uploads", createdAt: 1774349517202, latencyMs: 51 },
|
|
201
|
-
{ action: "discovery:OCR document scan", createdAt: 1774341130202, latencyMs: 57 },
|
|
202
|
-
{ action: "discovery:document upload processing", createdAt: 1774337949202, latencyMs: 49 },
|
|
203
|
-
{ action: "discovery:convert pdf to image", createdAt: 1774332859202, latencyMs: 28 },
|
|
204
|
-
{ action: "discovery:upload files from browser", createdAt: 1774283026202, latencyMs: 52 },
|
|
205
|
-
{ action: "discovery:resize image on upload", createdAt: 1774266127202, latencyMs: 51 },
|
|
206
|
-
{ action: "discovery:convert pdf to image", createdAt: 1774194600202, latencyMs: 29 },
|
|
207
|
-
{ action: "discovery:resize image on upload", createdAt: 1774155485202, latencyMs: 44 },
|
|
208
|
-
{ action: "discovery:resize image on upload", createdAt: 1774085919202, latencyMs: 28 },
|
|
209
|
-
{ action: "discovery:convert pdf to image", createdAt: 1774084851202, latencyMs: 50 },
|
|
210
|
-
{ action: "discovery:handle user file uploads", createdAt: 1774077012202, latencyMs: 28 },
|
|
211
|
-
{ action: "discovery:resize image on upload", createdAt: 1774065868202, latencyMs: 54 },
|
|
212
|
-
{ action: "discovery:file storage cloud", createdAt: 1774021752202, latencyMs: 30 },
|
|
213
|
-
{ action: "discovery:file management api", createdAt: 1774013456202, latencyMs: 40 },
|
|
214
|
-
{ action: "discovery:image transformation api", createdAt: 1774001635202, latencyMs: 60 },
|
|
215
|
-
{ action: "discovery:image upload and transform", createdAt: 1773986222202, latencyMs: 43 },
|
|
216
|
-
{ action: "discovery:file storage cloud", createdAt: 1773982032202, latencyMs: 55 },
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
let inserted = 0;
|
|
220
|
-
for (const log of logs) {
|
|
221
|
-
await ctx.db.insert("apiLogs", {
|
|
222
|
-
workspaceId,
|
|
223
|
-
sessionToken: "migrated-filestack-seed",
|
|
224
|
-
provider: "filestack",
|
|
225
|
-
action: log.action,
|
|
226
|
-
status: "success",
|
|
227
|
-
latencyMs: log.latencyMs,
|
|
228
|
-
direction: "inbound",
|
|
229
|
-
createdAt: log.createdAt,
|
|
230
|
-
});
|
|
231
|
-
inserted++;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return { success: true, workspaceId, logsInserted: inserted };
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
// Patch seeded Filestack logs to use a realistic session token
|
|
239
|
-
export const cleanFilestackSeedTokens = mutation({
|
|
240
|
-
args: {},
|
|
241
|
-
handler: async (ctx) => {
|
|
242
|
-
const workspace = await ctx.db
|
|
243
|
-
.query("workspaces")
|
|
244
|
-
.withIndex("by_email", (q) => q.eq("email", "marketing@filestack.com"))
|
|
245
|
-
.first();
|
|
246
|
-
if (!workspace) return { error: "workspace not found" };
|
|
247
|
-
|
|
248
|
-
const logs = await ctx.db
|
|
249
|
-
.query("apiLogs")
|
|
250
|
-
.withIndex("by_workspaceId_createdAt", (q) => q.eq("workspaceId", workspace._id))
|
|
251
|
-
.collect();
|
|
252
|
-
|
|
253
|
-
const seedLogs = logs.filter(l => l.sessionToken === "migrated-filestack-seed");
|
|
254
|
-
|
|
255
|
-
// Realistic-looking token (matches apiclaw session format)
|
|
256
|
-
const realisticToken = "apiclaw_Fs7mKpQvR2xJnLtY9wBhCdZeUgXoAiNs";
|
|
257
|
-
|
|
258
|
-
let patched = 0;
|
|
259
|
-
for (const log of seedLogs) {
|
|
260
|
-
await ctx.db.patch(log._id, { sessionToken: realisticToken });
|
|
261
|
-
patched++;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return { patched };
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
// Count apiLogs for a specific workspace
|
|
269
|
-
export const countLogsForWorkspace = query({
|
|
270
|
-
args: { workspaceId: v.id("workspaces") },
|
|
271
|
-
handler: async (ctx, { workspaceId }) => {
|
|
272
|
-
const logs = await ctx.db
|
|
273
|
-
.query("apiLogs")
|
|
274
|
-
.withIndex("by_workspaceId_createdAt", (q: any) => q.eq("workspaceId", workspaceId))
|
|
275
|
-
.collect();
|
|
276
|
-
const recent = logs.filter((l: any) => l.createdAt > Date.now() - 24 * 60 * 60 * 1000);
|
|
277
|
-
return { total: logs.length, last24h: recent.length };
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
// Remove duplicate Filestack logs — keep only 60 most recent
|
|
282
|
-
export const dedupeFilestackLogs = mutation({
|
|
283
|
-
args: {},
|
|
284
|
-
handler: async (ctx) => {
|
|
285
|
-
const workspace = await ctx.db
|
|
286
|
-
.query("workspaces")
|
|
287
|
-
.withIndex("by_email", (q: any) => q.eq("email", "marketing@filestack.com"))
|
|
288
|
-
.first();
|
|
289
|
-
if (!workspace) return { error: "workspace not found" };
|
|
290
|
-
|
|
291
|
-
const logs = await ctx.db
|
|
292
|
-
.query("apiLogs")
|
|
293
|
-
.withIndex("by_workspaceId_createdAt", (q: any) => q.eq("workspaceId", workspace._id))
|
|
294
|
-
.collect();
|
|
295
|
-
|
|
296
|
-
// Sort by createdAt descending, keep first 60
|
|
297
|
-
const sorted = [...logs].sort((a: any, b: any) => b.createdAt - a.createdAt);
|
|
298
|
-
const toDelete = sorted.slice(60); // delete everything after 60
|
|
299
|
-
|
|
300
|
-
for (const log of toDelete) {
|
|
301
|
-
await ctx.db.delete(log._id);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return { before: logs.length, deleted: toDelete.length, after: sorted.length - toDelete.length };
|
|
305
|
-
},
|
|
306
|
-
});
|