@agentforge-io/nest 0.2.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 +486 -0
- package/dist/agent-forge.module.d.ts +21 -0
- package/dist/agent-forge.module.js +144 -0
- package/dist/agent-forge.module.js.map +1 -0
- package/dist/auth/current-user.decorator.d.ts +8 -0
- package/dist/auth/current-user.decorator.js +9 -0
- package/dist/auth/current-user.decorator.js.map +1 -0
- package/dist/auth/public.decorator.d.ts +2 -0
- package/dist/auth/public.decorator.js +8 -0
- package/dist/auth/public.decorator.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/agent-runner.service.d.ts +1 -0
- package/dist/core/agent-runner.service.js +6 -0
- package/dist/core/agent-runner.service.js.map +1 -0
- package/dist/core/orchestrator.service.d.ts +2 -0
- package/dist/core/orchestrator.service.js +7 -0
- package/dist/core/orchestrator.service.js.map +1 -0
- package/dist/core/tool-registry.service.d.ts +1 -0
- package/dist/core/tool-registry.service.js +6 -0
- package/dist/core/tool-registry.service.js.map +1 -0
- package/dist/database/entities/auth-identity.entity.d.ts +1 -0
- package/dist/database/entities/auth-identity.entity.js +6 -0
- package/dist/database/entities/auth-identity.entity.js.map +1 -0
- package/dist/database/entities/conversation.entity.d.ts +1 -0
- package/dist/database/entities/conversation.entity.js +6 -0
- package/dist/database/entities/conversation.entity.js.map +1 -0
- package/dist/database/entities/email-token.entity.d.ts +1 -0
- package/dist/database/entities/email-token.entity.js +6 -0
- package/dist/database/entities/email-token.entity.js.map +1 -0
- package/dist/database/entities/index.d.ts +7 -0
- package/dist/database/entities/index.js +16 -0
- package/dist/database/entities/index.js.map +1 -0
- package/dist/database/entities/message.entity.d.ts +1 -0
- package/dist/database/entities/message.entity.js +6 -0
- package/dist/database/entities/message.entity.js.map +1 -0
- package/dist/database/entities/refresh-token.entity.d.ts +1 -0
- package/dist/database/entities/refresh-token.entity.js +6 -0
- package/dist/database/entities/refresh-token.entity.js.map +1 -0
- package/dist/database/entities/subscription.entity.d.ts +1 -0
- package/dist/database/entities/subscription.entity.js +6 -0
- package/dist/database/entities/subscription.entity.js.map +1 -0
- package/dist/database/entities/usage-record.entity.d.ts +1 -0
- package/dist/database/entities/usage-record.entity.js +6 -0
- package/dist/database/entities/usage-record.entity.js.map +1 -0
- package/dist/database/entities/user.entity.d.ts +1 -0
- package/dist/database/entities/user.entity.js +6 -0
- package/dist/database/entities/user.entity.js.map +1 -0
- package/dist/decorators/agent-tool.decorator.d.ts +21 -0
- package/dist/decorators/agent-tool.decorator.js +12 -0
- package/dist/decorators/agent-tool.decorator.js.map +1 -0
- package/dist/decorators/rate-limit.decorator.d.ts +9 -0
- package/dist/decorators/rate-limit.decorator.js +11 -0
- package/dist/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/decorators/require-plan.decorator.d.ts +2 -0
- package/dist/decorators/require-plan.decorator.js +8 -0
- package/dist/decorators/require-plan.decorator.js.map +1 -0
- package/dist/filters/agentforge-exception.filter.d.ts +5 -0
- package/dist/filters/agentforge-exception.filter.js +40 -0
- package/dist/filters/agentforge-exception.filter.js.map +1 -0
- package/dist/guards/rate-limit.guard.d.ts +10 -0
- package/dist/guards/rate-limit.guard.js +73 -0
- package/dist/guards/rate-limit.guard.js.map +1 -0
- package/dist/guards/usage-limit.guard.d.ts +11 -0
- package/dist/guards/usage-limit.guard.js +57 -0
- package/dist/guards/usage-limit.guard.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/usage-tracking.interceptor.d.ts +6 -0
- package/dist/interceptors/usage-tracking.interceptor.js +30 -0
- package/dist/interceptors/usage-tracking.interceptor.js.map +1 -0
- package/dist/modules/admin/admin-plans.controller.d.ts +11 -0
- package/dist/modules/admin/admin-plans.controller.js +97 -0
- package/dist/modules/admin/admin-plans.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenant-agents.controller.d.ts +61 -0
- package/dist/modules/admin/admin-tenant-agents.controller.js +424 -0
- package/dist/modules/admin/admin-tenant-agents.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenant-billing.controller.d.ts +51 -0
- package/dist/modules/admin/admin-tenant-billing.controller.js +119 -0
- package/dist/modules/admin/admin-tenant-billing.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenants.controller.d.ts +43 -0
- package/dist/modules/admin/admin-tenants.controller.js +178 -0
- package/dist/modules/admin/admin-tenants.controller.js.map +1 -0
- package/dist/modules/admin/admin-users.controller.d.ts +41 -0
- package/dist/modules/admin/admin-users.controller.js +121 -0
- package/dist/modules/admin/admin-users.controller.js.map +1 -0
- package/dist/modules/admin/admin.module.d.ts +2 -0
- package/dist/modules/admin/admin.module.js +26 -0
- package/dist/modules/admin/admin.module.js.map +1 -0
- package/dist/modules/admin/platform-admin.guard.d.ts +7 -0
- package/dist/modules/admin/platform-admin.guard.js +52 -0
- package/dist/modules/admin/platform-admin.guard.js.map +1 -0
- package/dist/modules/agent/agent.controller.d.ts +34 -0
- package/dist/modules/agent/agent.controller.js +178 -0
- package/dist/modules/agent/agent.controller.js.map +1 -0
- package/dist/modules/agent/agent.module.d.ts +2 -0
- package/dist/modules/agent/agent.module.js +23 -0
- package/dist/modules/agent/agent.module.js.map +1 -0
- package/dist/modules/agent/agent.service.d.ts +2 -0
- package/dist/modules/agent/agent.service.js +7 -0
- package/dist/modules/agent/agent.service.js.map +1 -0
- package/dist/modules/agent/dto/create-conversation.dto.d.ts +8 -0
- package/dist/modules/agent/dto/create-conversation.dto.js +48 -0
- package/dist/modules/agent/dto/create-conversation.dto.js.map +1 -0
- package/dist/modules/agent/dto/send-message.dto.d.ts +12 -0
- package/dist/modules/agent/dto/send-message.dto.js +42 -0
- package/dist/modules/agent/dto/send-message.dto.js.map +1 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.d.ts +1 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.js +6 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.js.map +1 -0
- package/dist/modules/agent/prepared-stream.service.d.ts +1 -0
- package/dist/modules/agent/prepared-stream.service.js +7 -0
- package/dist/modules/agent/prepared-stream.service.js.map +1 -0
- package/dist/modules/agent/prepared-stream.types.d.ts +1 -0
- package/dist/modules/agent/prepared-stream.types.js +6 -0
- package/dist/modules/agent/prepared-stream.types.js.map +1 -0
- package/dist/modules/agent/redis-prepared-stream.store.d.ts +9 -0
- package/dist/modules/agent/redis-prepared-stream.store.js +48 -0
- package/dist/modules/agent/redis-prepared-stream.store.js.map +1 -0
- package/dist/modules/auth/auth.controller.d.ts +63 -0
- package/dist/modules/auth/auth.controller.js +255 -0
- package/dist/modules/auth/auth.controller.js.map +1 -0
- package/dist/modules/auth/auth.module.d.ts +4 -0
- package/dist/modules/auth/auth.module.js +71 -0
- package/dist/modules/auth/auth.module.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +2 -0
- package/dist/modules/auth/auth.service.js +7 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/auth/decorators/current-user.decorator.d.ts +8 -0
- package/dist/modules/auth/decorators/current-user.decorator.js +12 -0
- package/dist/modules/auth/decorators/current-user.decorator.js.map +1 -0
- package/dist/modules/auth/decorators/public.decorator.d.ts +2 -0
- package/dist/modules/auth/decorators/public.decorator.js +8 -0
- package/dist/modules/auth/decorators/public.decorator.js.map +1 -0
- package/dist/modules/auth/dto/login.dto.d.ts +4 -0
- package/dist/modules/auth/dto/login.dto.js +29 -0
- package/dist/modules/auth/dto/login.dto.js.map +1 -0
- package/dist/modules/auth/dto/register.dto.d.ts +5 -0
- package/dist/modules/auth/dto/register.dto.js +36 -0
- package/dist/modules/auth/dto/register.dto.js.map +1 -0
- package/dist/modules/auth/guards/jwt-auth.guard.d.ts +9 -0
- package/dist/modules/auth/guards/jwt-auth.guard.js +37 -0
- package/dist/modules/auth/guards/jwt-auth.guard.js.map +1 -0
- package/dist/modules/auth/guards/local-auth.guard.d.ts +4 -0
- package/dist/modules/auth/guards/local-auth.guard.js +18 -0
- package/dist/modules/auth/guards/local-auth.guard.js.map +1 -0
- package/dist/modules/auth/guards/oauth-configured.guard.d.ts +11 -0
- package/dist/modules/auth/guards/oauth-configured.guard.js +51 -0
- package/dist/modules/auth/guards/oauth-configured.guard.js.map +1 -0
- package/dist/modules/auth/oauth.controller.d.ts +20 -0
- package/dist/modules/auth/oauth.controller.js +208 -0
- package/dist/modules/auth/oauth.controller.js.map +1 -0
- package/dist/modules/auth/refresh-token.service.d.ts +2 -0
- package/dist/modules/auth/refresh-token.service.js +7 -0
- package/dist/modules/auth/refresh-token.service.js.map +1 -0
- package/dist/modules/auth/strategies/github.strategy.d.ts +12 -0
- package/dist/modules/auth/strategies/github.strategy.js +57 -0
- package/dist/modules/auth/strategies/github.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/google.strategy.d.ts +19 -0
- package/dist/modules/auth/strategies/google.strategy.js +56 -0
- package/dist/modules/auth/strategies/google.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/jwt.strategy.d.ts +18 -0
- package/dist/modules/auth/strategies/jwt.strategy.js +49 -0
- package/dist/modules/auth/strategies/jwt.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/local.strategy.d.ts +11 -0
- package/dist/modules/auth/strategies/local.strategy.js +31 -0
- package/dist/modules/auth/strategies/local.strategy.js.map +1 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.d.ts +1 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.js +6 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.js.map +1 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.d.ts +19 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js +118 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js.map +1 -0
- package/dist/modules/billing/billing.controller.d.ts +54 -0
- package/dist/modules/billing/billing.controller.js +180 -0
- package/dist/modules/billing/billing.controller.js.map +1 -0
- package/dist/modules/billing/billing.module.d.ts +2 -0
- package/dist/modules/billing/billing.module.js +57 -0
- package/dist/modules/billing/billing.module.js.map +1 -0
- package/dist/modules/billing/billing.service.d.ts +2 -0
- package/dist/modules/billing/billing.service.js +7 -0
- package/dist/modules/billing/billing.service.js.map +1 -0
- package/dist/modules/billing/usage.service.d.ts +2 -0
- package/dist/modules/billing/usage.service.js +6 -0
- package/dist/modules/billing/usage.service.js.map +1 -0
- package/dist/modules/connectors/connectors.controller.d.ts +16 -0
- package/dist/modules/connectors/connectors.controller.js +142 -0
- package/dist/modules/connectors/connectors.controller.js.map +1 -0
- package/dist/modules/connectors/connectors.module.d.ts +2 -0
- package/dist/modules/connectors/connectors.module.js +20 -0
- package/dist/modules/connectors/connectors.module.js.map +1 -0
- package/dist/modules/conversation/conversation.module.d.ts +2 -0
- package/dist/modules/conversation/conversation.module.js +17 -0
- package/dist/modules/conversation/conversation.module.js.map +1 -0
- package/dist/modules/conversation/conversation.service.d.ts +1 -0
- package/dist/modules/conversation/conversation.service.js +7 -0
- package/dist/modules/conversation/conversation.service.js.map +1 -0
- package/dist/modules/email/adapters/email-adapter.interface.d.ts +1 -0
- package/dist/modules/email/adapters/email-adapter.interface.js +6 -0
- package/dist/modules/email/adapters/email-adapter.interface.js.map +1 -0
- package/dist/modules/email/adapters/noop.adapter.d.ts +1 -0
- package/dist/modules/email/adapters/noop.adapter.js +6 -0
- package/dist/modules/email/adapters/noop.adapter.js.map +1 -0
- package/dist/modules/email/adapters/resend.adapter.d.ts +1 -0
- package/dist/modules/email/adapters/resend.adapter.js +6 -0
- package/dist/modules/email/adapters/resend.adapter.js.map +1 -0
- package/dist/modules/email/email.module.d.ts +2 -0
- package/dist/modules/email/email.module.js +17 -0
- package/dist/modules/email/email.module.js.map +1 -0
- package/dist/modules/email/email.service.d.ts +1 -0
- package/dist/modules/email/email.service.js +6 -0
- package/dist/modules/email/email.service.js.map +1 -0
- package/dist/modules/email/templates/transactional.template.d.ts +18 -0
- package/dist/modules/email/templates/transactional.template.js +43 -0
- package/dist/modules/email/templates/transactional.template.js.map +1 -0
- package/dist/modules/mcp/mcp-admin.controller.d.ts +35 -0
- package/dist/modules/mcp/mcp-admin.controller.js +111 -0
- package/dist/modules/mcp/mcp-admin.controller.js.map +1 -0
- package/dist/modules/mcp/mcp.module.d.ts +8 -0
- package/dist/modules/mcp/mcp.module.js +38 -0
- package/dist/modules/mcp/mcp.module.js.map +1 -0
- package/dist/modules/public-chat/public-chat.controller.d.ts +54 -0
- package/dist/modules/public-chat/public-chat.controller.js +279 -0
- package/dist/modules/public-chat/public-chat.controller.js.map +1 -0
- package/dist/modules/public-chat/public-chat.module.d.ts +2 -0
- package/dist/modules/public-chat/public-chat.module.js +20 -0
- package/dist/modules/public-chat/public-chat.module.js.map +1 -0
- package/dist/modules/queue/jobs.controller.d.ts +23 -0
- package/dist/modules/queue/jobs.controller.js +98 -0
- package/dist/modules/queue/jobs.controller.js.map +1 -0
- package/dist/modules/queue/processors/agent.processor.d.ts +12 -0
- package/dist/modules/queue/processors/agent.processor.js +65 -0
- package/dist/modules/queue/processors/agent.processor.js.map +1 -0
- package/dist/modules/queue/queue.module.d.ts +5 -0
- package/dist/modules/queue/queue.module.js +55 -0
- package/dist/modules/queue/queue.module.js.map +1 -0
- package/dist/modules/queue/queue.service.d.ts +15 -0
- package/dist/modules/queue/queue.service.js +86 -0
- package/dist/modules/queue/queue.service.js.map +1 -0
- package/dist/providers/repositories.providers.d.ts +3 -0
- package/dist/providers/repositories.providers.js +35 -0
- package/dist/providers/repositories.providers.js.map +1 -0
- package/dist/providers/services.providers.d.ts +4 -0
- package/dist/providers/services.providers.js +142 -0
- package/dist/providers/services.providers.js.map +1 -0
- package/dist/redis/redis.provider.d.ts +3 -0
- package/dist/redis/redis.provider.js +48 -0
- package/dist/redis/redis.provider.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var StripeAdapter_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.StripeAdapter = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const stripe_1 = require("stripe");
|
|
16
|
+
let StripeAdapter = StripeAdapter_1 = class StripeAdapter {
|
|
17
|
+
constructor(config, plans = []) {
|
|
18
|
+
this.logger = new common_1.Logger(StripeAdapter_1.name);
|
|
19
|
+
this.stripe = new stripe_1.default(config.secretKey, {
|
|
20
|
+
apiVersion: '2023-10-16',
|
|
21
|
+
});
|
|
22
|
+
this.plans = plans;
|
|
23
|
+
}
|
|
24
|
+
async createCustomer(params) {
|
|
25
|
+
const customer = await this.stripe.customers.create({
|
|
26
|
+
email: params.email,
|
|
27
|
+
name: params.name,
|
|
28
|
+
metadata: params.metadata ?? {},
|
|
29
|
+
});
|
|
30
|
+
this.logger.debug(`Created Stripe customer: ${customer.id}`);
|
|
31
|
+
return customer.id;
|
|
32
|
+
}
|
|
33
|
+
async createCheckoutSession(params) {
|
|
34
|
+
const plan = this.plans.find((p) => p.id === params.planId);
|
|
35
|
+
if (!plan?.stripePriceId) {
|
|
36
|
+
throw new Error(`Plan "${params.planId}" has no Stripe price ID configured`);
|
|
37
|
+
}
|
|
38
|
+
const session = await this.stripe.checkout.sessions.create({
|
|
39
|
+
mode: plan.interval ? 'subscription' : 'payment',
|
|
40
|
+
payment_method_types: ['card'],
|
|
41
|
+
line_items: [{ price: plan.stripePriceId, quantity: 1 }],
|
|
42
|
+
success_url: params.successUrl,
|
|
43
|
+
cancel_url: params.cancelUrl,
|
|
44
|
+
metadata: {
|
|
45
|
+
userId: params.userId,
|
|
46
|
+
planId: params.planId,
|
|
47
|
+
...params.metadata,
|
|
48
|
+
},
|
|
49
|
+
subscription_data: plan.interval
|
|
50
|
+
? { metadata: { userId: params.userId, planId: params.planId } }
|
|
51
|
+
: undefined,
|
|
52
|
+
});
|
|
53
|
+
return { sessionId: session.id, url: session.url };
|
|
54
|
+
}
|
|
55
|
+
async createSubscription(params) {
|
|
56
|
+
const subscription = await this.stripe.subscriptions.create({
|
|
57
|
+
customer: params.customerId,
|
|
58
|
+
items: [{ price: params.priceId }],
|
|
59
|
+
trial_period_days: params.trialDays,
|
|
60
|
+
payment_behavior: 'default_incomplete',
|
|
61
|
+
expand: ['latest_invoice.payment_intent'],
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
subscriptionId: subscription.id,
|
|
65
|
+
status: subscription.status,
|
|
66
|
+
currentPeriodEnd: new Date(subscription.current_period_end * 1000),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async cancelSubscription(subscriptionId, atPeriodEnd = true) {
|
|
70
|
+
if (atPeriodEnd) {
|
|
71
|
+
await this.stripe.subscriptions.update(subscriptionId, {
|
|
72
|
+
cancel_at_period_end: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
await this.stripe.subscriptions.cancel(subscriptionId);
|
|
77
|
+
}
|
|
78
|
+
this.logger.log(`Subscription ${subscriptionId} cancelled (atPeriodEnd=${atPeriodEnd})`);
|
|
79
|
+
}
|
|
80
|
+
async getSubscription(subscriptionId) {
|
|
81
|
+
const sub = await this.stripe.subscriptions.retrieve(subscriptionId);
|
|
82
|
+
return {
|
|
83
|
+
subscriptionId: sub.id,
|
|
84
|
+
status: sub.status,
|
|
85
|
+
currentPeriodEnd: new Date(sub.current_period_end * 1000),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async getPortalUrl(customerId, returnUrl) {
|
|
89
|
+
const session = await this.stripe.billingPortal.sessions.create({
|
|
90
|
+
customer: customerId,
|
|
91
|
+
return_url: returnUrl,
|
|
92
|
+
});
|
|
93
|
+
return session.url;
|
|
94
|
+
}
|
|
95
|
+
async handleWebhook(payload, signature) {
|
|
96
|
+
let event;
|
|
97
|
+
try {
|
|
98
|
+
event = this.stripe.webhooks.constructEvent(payload, signature, process.env.STRIPE_WEBHOOK_SECRET ?? '');
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
throw new Error(`Stripe webhook verification failed: ${err}`);
|
|
102
|
+
}
|
|
103
|
+
this.logger.debug(`Stripe webhook received: ${event.type}`);
|
|
104
|
+
return {
|
|
105
|
+
type: event.type,
|
|
106
|
+
data: event.data.object,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
getStripeInstance() {
|
|
110
|
+
return this.stripe;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
exports.StripeAdapter = StripeAdapter;
|
|
114
|
+
exports.StripeAdapter = StripeAdapter = StripeAdapter_1 = __decorate([
|
|
115
|
+
(0, common_1.Injectable)(),
|
|
116
|
+
__metadata("design:paramtypes", [Object, Array])
|
|
117
|
+
], StripeAdapter);
|
|
118
|
+
//# sourceMappingURL=stripe.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.adapter.js","sourceRoot":"","sources":["../../../../../src/modules/billing/adapters/stripe/stripe.adapter.ts"],"names":[],"mappings":";;;;;;;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,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAG5D,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAiC;SACnD,CAAC;IACJ,CAAC;IAID,iBAAiB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AAnIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;;GACA,aAAa,CAmIzB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PlanService, UsageService } from '@agentforge/core';
|
|
2
|
+
import { BillingService } from './billing.service';
|
|
3
|
+
export declare class BillingController {
|
|
4
|
+
private readonly billing;
|
|
5
|
+
private readonly usage;
|
|
6
|
+
private readonly plans;
|
|
7
|
+
constructor(billing: BillingService, usage: UsageService, plans: PlanService);
|
|
8
|
+
getPlans(): Promise<import("@agentforge/core").Plan[]>;
|
|
9
|
+
checkoutSuccess(sessionId?: string): {
|
|
10
|
+
status: string;
|
|
11
|
+
message: string;
|
|
12
|
+
sessionId: string | null;
|
|
13
|
+
};
|
|
14
|
+
checkoutCancel(): {
|
|
15
|
+
status: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
createCheckout(body: {
|
|
19
|
+
planId: string;
|
|
20
|
+
}, userId: string): Promise<import("@agentforge/core").CheckoutResult>;
|
|
21
|
+
getPortal(body: {
|
|
22
|
+
returnUrl?: string;
|
|
23
|
+
}, userId: string): Promise<import("@agentforge/core").PortalResult>;
|
|
24
|
+
getOverview(userId: string): Promise<import("@agentforge/core").BillingOverviewResult>;
|
|
25
|
+
cancelSubscription(userId: string, body: {
|
|
26
|
+
immediately?: boolean;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
getMyBilling(userId: string): Promise<{
|
|
31
|
+
plan: {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
features: string[];
|
|
35
|
+
limits: {
|
|
36
|
+
requestsPerMonth: number;
|
|
37
|
+
tokensPerMonth: number;
|
|
38
|
+
};
|
|
39
|
+
priceInCents: number | undefined;
|
|
40
|
+
interval: "month" | "year" | undefined;
|
|
41
|
+
};
|
|
42
|
+
usage: {
|
|
43
|
+
period: string;
|
|
44
|
+
requestCount: number;
|
|
45
|
+
totalTokens: number;
|
|
46
|
+
requestLimit: number;
|
|
47
|
+
tokenLimit: number;
|
|
48
|
+
};
|
|
49
|
+
availablePlans: import("@agentforge/core").Plan[];
|
|
50
|
+
}>;
|
|
51
|
+
handleWebhook(payload: Buffer, signature: string): Promise<{
|
|
52
|
+
received: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BillingController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const core_1 = require("@agentforge/core");
|
|
19
|
+
const billing_service_1 = require("./billing.service");
|
|
20
|
+
const public_decorator_1 = require("../auth/decorators/public.decorator");
|
|
21
|
+
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
|
22
|
+
let BillingController = class BillingController {
|
|
23
|
+
constructor(billing, usage, plans) {
|
|
24
|
+
this.billing = billing;
|
|
25
|
+
this.usage = usage;
|
|
26
|
+
this.plans = plans;
|
|
27
|
+
}
|
|
28
|
+
getPlans() {
|
|
29
|
+
return this.billing.getPlans();
|
|
30
|
+
}
|
|
31
|
+
checkoutSuccess(sessionId) {
|
|
32
|
+
return {
|
|
33
|
+
status: 'success',
|
|
34
|
+
message: 'Checkout completed. The subscription will activate once the webhook is processed.',
|
|
35
|
+
sessionId: sessionId ?? null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
checkoutCancel() {
|
|
39
|
+
return {
|
|
40
|
+
status: 'canceled',
|
|
41
|
+
message: 'Checkout was canceled. No charge was made.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async createCheckout(body, userId) {
|
|
45
|
+
return this.billing.createCheckout({ userId, planId: body.planId });
|
|
46
|
+
}
|
|
47
|
+
async getPortal(body, userId) {
|
|
48
|
+
return this.billing.getPortalUrl(userId, body.returnUrl);
|
|
49
|
+
}
|
|
50
|
+
async getOverview(userId) {
|
|
51
|
+
return this.billing.getOverview(userId);
|
|
52
|
+
}
|
|
53
|
+
async cancelSubscription(userId, body) {
|
|
54
|
+
await this.billing.cancelSubscription(userId, body.immediately);
|
|
55
|
+
return { success: true };
|
|
56
|
+
}
|
|
57
|
+
async getMyBilling(userId) {
|
|
58
|
+
const summary = await this.usage.getSummary(userId);
|
|
59
|
+
const allPlans = await this.plans.list();
|
|
60
|
+
const plan = allPlans.find((p) => p.id === summary.planId);
|
|
61
|
+
return {
|
|
62
|
+
plan: {
|
|
63
|
+
id: summary.planId,
|
|
64
|
+
name: plan?.name ?? summary.planId,
|
|
65
|
+
features: plan?.features ?? [],
|
|
66
|
+
limits: {
|
|
67
|
+
requestsPerMonth: summary.requestsLimit,
|
|
68
|
+
tokensPerMonth: summary.tokensLimit,
|
|
69
|
+
},
|
|
70
|
+
priceInCents: plan?.priceInCents,
|
|
71
|
+
interval: plan?.interval,
|
|
72
|
+
},
|
|
73
|
+
usage: {
|
|
74
|
+
period: summary.periodStart.toISOString().slice(0, 7),
|
|
75
|
+
requestCount: summary.requestsUsed,
|
|
76
|
+
totalTokens: summary.tokensUsed,
|
|
77
|
+
requestLimit: summary.requestsLimit,
|
|
78
|
+
tokenLimit: summary.tokensLimit,
|
|
79
|
+
},
|
|
80
|
+
availablePlans: allPlans,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async handleWebhook(payload, signature) {
|
|
84
|
+
await this.billing.handleWebhook(payload, signature);
|
|
85
|
+
return { received: true };
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.BillingController = BillingController;
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, public_decorator_1.Public)(),
|
|
91
|
+
(0, common_1.Get)('plans'),
|
|
92
|
+
(0, swagger_1.ApiOperation)({ summary: 'List available plans' }),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", []),
|
|
95
|
+
__metadata("design:returntype", void 0)
|
|
96
|
+
], BillingController.prototype, "getPlans", null);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, public_decorator_1.Public)(),
|
|
99
|
+
(0, common_1.Get)('success'),
|
|
100
|
+
(0, swagger_1.ApiOperation)({
|
|
101
|
+
summary: 'Default landing for Stripe success redirect (used when no frontend is configured)',
|
|
102
|
+
}),
|
|
103
|
+
__param(0, (0, common_1.Query)('session_id')),
|
|
104
|
+
__metadata("design:type", Function),
|
|
105
|
+
__metadata("design:paramtypes", [String]),
|
|
106
|
+
__metadata("design:returntype", void 0)
|
|
107
|
+
], BillingController.prototype, "checkoutSuccess", null);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, public_decorator_1.Public)(),
|
|
110
|
+
(0, common_1.Get)('cancel'),
|
|
111
|
+
(0, swagger_1.ApiOperation)({
|
|
112
|
+
summary: 'Default landing for Stripe cancel redirect (used when no frontend is configured)',
|
|
113
|
+
}),
|
|
114
|
+
__metadata("design:type", Function),
|
|
115
|
+
__metadata("design:paramtypes", []),
|
|
116
|
+
__metadata("design:returntype", void 0)
|
|
117
|
+
], BillingController.prototype, "checkoutCancel", null);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, common_1.Post)('checkout'),
|
|
120
|
+
(0, swagger_1.ApiOperation)({ summary: 'Create a checkout session for the authenticated user' }),
|
|
121
|
+
__param(0, (0, common_1.Body)()),
|
|
122
|
+
__param(1, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
123
|
+
__metadata("design:type", Function),
|
|
124
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
125
|
+
__metadata("design:returntype", Promise)
|
|
126
|
+
], BillingController.prototype, "createCheckout", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, common_1.Post)('portal'),
|
|
129
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get customer portal URL for the authenticated user' }),
|
|
130
|
+
__param(0, (0, common_1.Body)()),
|
|
131
|
+
__param(1, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
132
|
+
__metadata("design:type", Function),
|
|
133
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
134
|
+
__metadata("design:returntype", Promise)
|
|
135
|
+
], BillingController.prototype, "getPortal", null);
|
|
136
|
+
__decorate([
|
|
137
|
+
(0, common_1.Get)('overview'),
|
|
138
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get billing overview for the authenticated user' }),
|
|
139
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
140
|
+
__metadata("design:type", Function),
|
|
141
|
+
__metadata("design:paramtypes", [String]),
|
|
142
|
+
__metadata("design:returntype", Promise)
|
|
143
|
+
], BillingController.prototype, "getOverview", null);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, common_1.Delete)('subscription'),
|
|
146
|
+
(0, swagger_1.ApiOperation)({ summary: 'Cancel the authenticated user’s subscription' }),
|
|
147
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
148
|
+
__param(1, (0, common_1.Body)()),
|
|
149
|
+
__metadata("design:type", Function),
|
|
150
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
151
|
+
__metadata("design:returntype", Promise)
|
|
152
|
+
], BillingController.prototype, "cancelSubscription", null);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, common_1.Get)('me'),
|
|
155
|
+
(0, swagger_1.ApiOperation)({
|
|
156
|
+
summary: 'Personal billing overview for the authenticated user — plan, usage, available plans',
|
|
157
|
+
}),
|
|
158
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
159
|
+
__metadata("design:type", Function),
|
|
160
|
+
__metadata("design:paramtypes", [String]),
|
|
161
|
+
__metadata("design:returntype", Promise)
|
|
162
|
+
], BillingController.prototype, "getMyBilling", null);
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, public_decorator_1.Public)(),
|
|
165
|
+
(0, common_1.Post)('webhook'),
|
|
166
|
+
(0, swagger_1.ApiOperation)({ summary: 'Handle payment provider webhook (signature-verified)' }),
|
|
167
|
+
__param(0, (0, common_1.RawBody)()),
|
|
168
|
+
__param(1, (0, common_1.Headers)('stripe-signature')),
|
|
169
|
+
__metadata("design:type", Function),
|
|
170
|
+
__metadata("design:paramtypes", [Buffer, String]),
|
|
171
|
+
__metadata("design:returntype", Promise)
|
|
172
|
+
], BillingController.prototype, "handleWebhook", null);
|
|
173
|
+
exports.BillingController = BillingController = __decorate([
|
|
174
|
+
(0, swagger_1.ApiTags)('Billing'),
|
|
175
|
+
(0, common_1.Controller)('billing'),
|
|
176
|
+
__metadata("design:paramtypes", [billing_service_1.BillingService,
|
|
177
|
+
core_1.UsageService,
|
|
178
|
+
core_1.PlanService])
|
|
179
|
+
], BillingController);
|
|
180
|
+
//# sourceMappingURL=billing.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.controller.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,6CAAwD;AACxD,2CAA6D;AAC7D,uDAAmD;AACnD,0EAA6D;AAC7D,sFAAwE;AAIjE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YACmB,OAAuB,EACvB,KAAmB,EACnB,KAAkB;QAFlB,YAAO,GAAP,OAAO,CAAgB;QACvB,UAAK,GAAL,KAAK,CAAc;QACnB,UAAK,GAAL,KAAK,CAAa;IAClC,CAAC;IAKJ,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAOD,eAAe,CAAsB,SAAkB;QACrD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,mFAAmF;YAC5F,SAAS,EAAE,SAAS,IAAI,IAAI;SAC7B,CAAC;IACJ,CAAC;IAOD,cAAc;QACZ,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,4CAA4C;SACtD,CAAC;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CACV,IAAwB,EACT,MAAc;QAErC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACtE,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS,CACL,IAA4B,EACb,MAAc;QAErC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,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AW,EAAC,QAAQ,CAAC,CAAA;;;;kDAGvB;AAIK;IAFL,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC;IAC1D,WAAA,IAAA,oCAAW,EAAC,QAAQ,CAAC,CAAA;;;;oDAEvC;AAIK;IAFL,IAAA,eAAM,EAAC,cAAc,CAAC;IACtB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;IAEvE,WAAA,IAAA,oCAAW,EAAC,QAAQ,CAAC,CAAA;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;;;;2DAIR;AAOK;IALL,IAAA,YAAG,EAAC,IAAI,CAAC;IACT,IAAA,sBAAY,EAAC;QACZ,OAAO,EACL,qFAAqF;KACxF,CAAC;IACkB,WAAA,IAAA,oCAAW,EAAC,QAAQ,CAAC,CAAA;;;;qDAyBxC;AAKK;IAHL,IAAA,yBAAM,GAAE;IACR,IAAA,aAAI,EAAC,SAAS,CAAC;IACf,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,sDAAsD,EAAE,CAAC;IAE/E,WAAA,IAAA,gBAAO,GAAE,CAAA;IACT,WAAA,IAAA,gBAAO,EAAC,kBAAkB,CAAC,CAAA;;qCADR,MAAM;;sDAK3B;4BAlHU,iBAAiB;IAF7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAGQ,gCAAc;QAChB,mBAAY;QACZ,kBAAW;GAJ1B,iBAAiB,CAmH7B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BillingModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@agentforge/core");
|
|
12
|
+
const billing_controller_1 = require("./billing.controller");
|
|
13
|
+
const billing_adapter_interface_1 = require("./adapters/billing-adapter.interface");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
let BillingModule = class BillingModule {
|
|
16
|
+
};
|
|
17
|
+
exports.BillingModule = BillingModule;
|
|
18
|
+
exports.BillingModule = BillingModule = __decorate([
|
|
19
|
+
(0, common_1.Module)({
|
|
20
|
+
providers: [
|
|
21
|
+
{
|
|
22
|
+
provide: billing_adapter_interface_1.BILLING_ADAPTER,
|
|
23
|
+
inject: [constants_1.AGENT_FORGE_CONFIG],
|
|
24
|
+
useFactory: (config) => {
|
|
25
|
+
if (!config.billing) {
|
|
26
|
+
return new NoopBillingAdapter();
|
|
27
|
+
}
|
|
28
|
+
if (config.billing.provider === 'stripe') {
|
|
29
|
+
if (!config.billing.stripe) {
|
|
30
|
+
throw new Error('Stripe config is required when provider is "stripe"');
|
|
31
|
+
}
|
|
32
|
+
return new core_1.StripeAdapter(config.billing.stripe, config.billing.plans ?? []);
|
|
33
|
+
}
|
|
34
|
+
if (config.billing.provider === 'custom' && config.billing.customAdapter) {
|
|
35
|
+
return new config.billing.customAdapter();
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Unknown billing provider: ${config.billing.provider}`);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
controllers: [billing_controller_1.BillingController],
|
|
42
|
+
exports: [billing_adapter_interface_1.BILLING_ADAPTER],
|
|
43
|
+
})
|
|
44
|
+
], BillingModule);
|
|
45
|
+
class NoopBillingAdapter {
|
|
46
|
+
error() {
|
|
47
|
+
throw new Error('Billing is not configured. Add a billing config to AgentForgeModule.forRoot()');
|
|
48
|
+
}
|
|
49
|
+
createCheckoutSession() { return this.error(); }
|
|
50
|
+
createSubscription() { return this.error(); }
|
|
51
|
+
cancelSubscription() { return this.error(); }
|
|
52
|
+
handleWebhook() { return this.error(); }
|
|
53
|
+
getPortalUrl() { return this.error(); }
|
|
54
|
+
createCustomer() { return this.error(); }
|
|
55
|
+
getSubscription() { return this.error(); }
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=billing.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.module.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAAiD;AAEjD,6DAAyD;AACzD,oFAAuE;AACvE,+CAAqD;AA2C9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IA5BzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,2CAAe;gBACxB,MAAM,EAAE,CAAC,8BAAkB,CAAC;gBAC5B,UAAU,EAAE,CAAC,MAAwB,EAAmB,EAAE;oBACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACpB,OAAO,IAAI,kBAAkB,EAAE,CAAC;oBAClC,CAAC;oBAED,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;wBACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;4BAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;wBACzE,CAAC;wBACD,OAAO,IAAI,oBAAa,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBAC9E,CAAC;oBAED,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;wBACzE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;oBAC5C,CAAC;oBAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC1E,CAAC;aACF;SACF;QACD,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAe,CAAC;KAC3B,CAAC;GACW,aAAa,CAAG;AAE7B,MAAM,kBAAkB;IACd,KAAK;QACX,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACnG,CAAC;IACD,qBAAqB,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,kBAAkB,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7C,kBAAkB,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7C,aAAa,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACxC,YAAY,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACvC,cAAc,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzC,eAAe,KAAK,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingError = exports.BillingService = void 0;
|
|
4
|
+
var core_1 = require("@agentforge/core");
|
|
5
|
+
Object.defineProperty(exports, "BillingService", { enumerable: true, get: function () { return core_1.BillingService; } });
|
|
6
|
+
Object.defineProperty(exports, "BillingError", { enumerable: true, get: function () { return core_1.BillingError; } });
|
|
7
|
+
//# sourceMappingURL=billing.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.service.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.service.ts"],"names":[],"mappings":";;;AAAA,yCAAgE;AAAvD,sGAAA,cAAc,OAAA;AAAE,oGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageService = void 0;
|
|
4
|
+
var core_1 = require("@agentforge/core");
|
|
5
|
+
Object.defineProperty(exports, "UsageService", { enumerable: true, get: function () { return core_1.UsageService; } });
|
|
6
|
+
//# sourceMappingURL=usage.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.service.js","sourceRoot":"","sources":["../../../src/modules/billing/usage.service.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAAvC,oGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import { ConnectorRegistryService } from '@agentforge-io/core';
|
|
3
|
+
import { type AuthUser } from '../../auth/current-user.decorator';
|
|
4
|
+
export declare class ConnectorsController {
|
|
5
|
+
private readonly registry;
|
|
6
|
+
constructor(registry: ConnectorRegistryService);
|
|
7
|
+
list(user: AuthUser): Promise<{
|
|
8
|
+
items: import("@agentforge-io/core").ConnectorStatus[];
|
|
9
|
+
}>;
|
|
10
|
+
authorize(id: string, postAuthRedirect: string | undefined, user: AuthUser, req: Request): Promise<{
|
|
11
|
+
url: string;
|
|
12
|
+
}>;
|
|
13
|
+
callback(code: string, state: string, postAuthRedirect: string | undefined, req: Request, res: Response): Promise<void>;
|
|
14
|
+
private buildCallbackUrl;
|
|
15
|
+
disconnect(id: string, user: AuthUser): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ConnectorsController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const core_1 = require("@agentforge-io/core");
|
|
19
|
+
const current_user_decorator_1 = require("../../auth/current-user.decorator");
|
|
20
|
+
const public_decorator_1 = require("../../auth/public.decorator");
|
|
21
|
+
let ConnectorsController = class ConnectorsController {
|
|
22
|
+
constructor(registry) {
|
|
23
|
+
this.registry = registry;
|
|
24
|
+
}
|
|
25
|
+
async list(user) {
|
|
26
|
+
if (!user?.userId)
|
|
27
|
+
throw new common_1.BadRequestException('No active user');
|
|
28
|
+
return { items: await this.registry.listForUser(user.userId) };
|
|
29
|
+
}
|
|
30
|
+
async authorize(id, postAuthRedirect, user, req) {
|
|
31
|
+
if (!user?.userId)
|
|
32
|
+
throw new common_1.BadRequestException('No active user');
|
|
33
|
+
const redirectUri = this.buildCallbackUrl(req, postAuthRedirect);
|
|
34
|
+
try {
|
|
35
|
+
return await this.registry.startAuthorize(id, user.userId, redirectUri);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (e instanceof core_1.ConnectorError && e.code === 'unknown_connector') {
|
|
39
|
+
throw new common_1.NotFoundException(e.message);
|
|
40
|
+
}
|
|
41
|
+
if (e instanceof core_1.ConnectorError && e.code === 'not_configured') {
|
|
42
|
+
throw new common_1.ConflictException(e.message);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async callback(code, state, postAuthRedirect, req, res) {
|
|
48
|
+
if (!code || !state) {
|
|
49
|
+
throw new common_1.BadRequestException('Missing code or state');
|
|
50
|
+
}
|
|
51
|
+
const redirectUri = this.buildCallbackUrl(req, postAuthRedirect);
|
|
52
|
+
try {
|
|
53
|
+
const { connectorId } = await this.registry.completeAuthorize(state, code, redirectUri);
|
|
54
|
+
const target = postAuthRedirect
|
|
55
|
+
? `${postAuthRedirect}?connector=${encodeURIComponent(connectorId)}&status=ok`
|
|
56
|
+
: `/connectors?connector=${encodeURIComponent(connectorId)}&status=ok`;
|
|
57
|
+
res.redirect(302, target);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
const msg = e instanceof Error ? e.message : 'OAuth callback failed';
|
|
61
|
+
const target = postAuthRedirect
|
|
62
|
+
? `${postAuthRedirect}?status=error&error=${encodeURIComponent(msg)}`
|
|
63
|
+
: `/connectors?status=error&error=${encodeURIComponent(msg)}`;
|
|
64
|
+
res.redirect(302, target);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
buildCallbackUrl(req, postAuthRedirect) {
|
|
68
|
+
const proto = req.protocol;
|
|
69
|
+
const host = req.get('host');
|
|
70
|
+
const base = `${proto}://${host}/connectors/callback`;
|
|
71
|
+
if (!postAuthRedirect)
|
|
72
|
+
return base;
|
|
73
|
+
return `${base}?postAuthRedirect=${encodeURIComponent(postAuthRedirect)}`;
|
|
74
|
+
}
|
|
75
|
+
async disconnect(id, user) {
|
|
76
|
+
if (!user?.userId)
|
|
77
|
+
throw new common_1.BadRequestException('No active user');
|
|
78
|
+
try {
|
|
79
|
+
await this.registry.disconnect(user.userId, id);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (e instanceof core_1.ConnectorError && e.code === 'not_connected') {
|
|
83
|
+
throw new common_1.NotFoundException(e.message);
|
|
84
|
+
}
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
exports.ConnectorsController = ConnectorsController;
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, common_1.Get)(),
|
|
92
|
+
(0, swagger_1.ApiOperation)({ summary: 'List connectors with per-user connection status' }),
|
|
93
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", [Object]),
|
|
96
|
+
__metadata("design:returntype", Promise)
|
|
97
|
+
], ConnectorsController.prototype, "list", null);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, common_1.Post)(':id/authorize'),
|
|
100
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
101
|
+
(0, swagger_1.ApiOperation)({
|
|
102
|
+
summary: 'Begin OAuth authorize flow for a connector',
|
|
103
|
+
}),
|
|
104
|
+
__param(0, (0, common_1.Param)('id')),
|
|
105
|
+
__param(1, (0, common_1.Query)('postAuthRedirect')),
|
|
106
|
+
__param(2, (0, current_user_decorator_1.CurrentUser)()),
|
|
107
|
+
__param(3, (0, common_1.Req)()),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], ConnectorsController.prototype, "authorize", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, common_1.Get)('callback'),
|
|
114
|
+
(0, public_decorator_1.Public)(),
|
|
115
|
+
(0, swagger_1.ApiOperation)({
|
|
116
|
+
summary: 'OAuth callback. Verifies state, exchanges code, persists tokens.',
|
|
117
|
+
}),
|
|
118
|
+
__param(0, (0, common_1.Query)('code')),
|
|
119
|
+
__param(1, (0, common_1.Query)('state')),
|
|
120
|
+
__param(2, (0, common_1.Query)('postAuthRedirect')),
|
|
121
|
+
__param(3, (0, common_1.Req)()),
|
|
122
|
+
__param(4, (0, common_1.Res)()),
|
|
123
|
+
__metadata("design:type", Function),
|
|
124
|
+
__metadata("design:paramtypes", [String, String, Object, Object, Object]),
|
|
125
|
+
__metadata("design:returntype", Promise)
|
|
126
|
+
], ConnectorsController.prototype, "callback", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, common_1.Delete)(':id'),
|
|
129
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
130
|
+
(0, swagger_1.ApiOperation)({ summary: 'Disconnect a connector for the current user' }),
|
|
131
|
+
__param(0, (0, common_1.Param)('id')),
|
|
132
|
+
__param(1, (0, current_user_decorator_1.CurrentUser)()),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], ConnectorsController.prototype, "disconnect", null);
|
|
137
|
+
exports.ConnectorsController = ConnectorsController = __decorate([
|
|
138
|
+
(0, swagger_1.ApiTags)('Connectors'),
|
|
139
|
+
(0, common_1.Controller)('connectors'),
|
|
140
|
+
__metadata("design:paramtypes", [core_1.ConnectorRegistryService])
|
|
141
|
+
], ConnectorsController);
|
|
142
|
+
//# sourceMappingURL=connectors.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.controller.js","sourceRoot":"","sources":["../../../src/modules/connectors/connectors.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;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