@flashbacktech/tsclient 0.4.54 → 0.4.55

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/dist/index.cjs CHANGED
@@ -1215,6 +1215,129 @@ var BudgetsClient = class {
1215
1215
  }
1216
1216
  };
1217
1217
 
1218
+ // src/modules/referrals/ReferralsClient.ts
1219
+ var ReferralsClient = class {
1220
+ constructor(http) {
1221
+ this.http = http;
1222
+ }
1223
+ /** Mint a new referral code for the caller's org. */
1224
+ async mintCode(body = {}) {
1225
+ const res = await this.http.post("/referrals/codes", { body });
1226
+ return unwrapData(res);
1227
+ }
1228
+ /** List the caller org's codes with per-code redeemed/qualified counts. */
1229
+ async listCodes() {
1230
+ const res = await this.http.get("/referrals/codes");
1231
+ return res.data ?? [];
1232
+ }
1233
+ /** Activate or deactivate one of the caller org's codes. */
1234
+ async setCodeActive(codeId, isActive) {
1235
+ const res = await this.http.patch(
1236
+ `/referrals/codes/${codeId}`,
1237
+ { body: { isActive } }
1238
+ );
1239
+ return unwrapData(res);
1240
+ }
1241
+ /** Caller org's referral summary as referrer (redemptions, qualified, credits earned). */
1242
+ async stats() {
1243
+ const res = await this.http.get("/referrals/stats");
1244
+ return unwrapData(res);
1245
+ }
1246
+ /**
1247
+ * Redeem a referral code for the caller's org. Fails (4xx with an
1248
+ * `error_code`) when a guard rejects it: `code_inactive`, `self_referral`,
1249
+ * `already_redeemed`, `already_associated`, or `has_purchases`.
1250
+ */
1251
+ async redeem(body) {
1252
+ const res = await this.http.post(
1253
+ "/referrals/redeem",
1254
+ { body }
1255
+ );
1256
+ return unwrapData(res);
1257
+ }
1258
+ };
1259
+
1260
+ // src/modules/reseller/ResellerClient.ts
1261
+ var ResellerClient = class {
1262
+ constructor(http) {
1263
+ this.http = http;
1264
+ }
1265
+ // --- Reseller self-service (org.isReseller) ---
1266
+ /** Orgs associated to the caller reseller, with gross + commission rollups. */
1267
+ async listAssociatedOrgs() {
1268
+ const res = await this.http.get("/reseller/associated-orgs");
1269
+ return res.data ?? [];
1270
+ }
1271
+ /** The caller reseller's commission ledger. */
1272
+ async listCommissions() {
1273
+ const res = await this.http.get("/reseller/commissions");
1274
+ return res.data ?? [];
1275
+ }
1276
+ /** The caller reseller's payout history. */
1277
+ async listPayouts() {
1278
+ const res = await this.http.get("/reseller/payouts");
1279
+ return res.data ?? [];
1280
+ }
1281
+ // --- Platform-admin only ---
1282
+ /** List all reseller orgs with aggregate performance. */
1283
+ async listResellers() {
1284
+ const res = await this.http.get("/admin/resellers");
1285
+ return res.data ?? [];
1286
+ }
1287
+ /** Designate an org as a reseller (optionally with a per-reseller bps override). */
1288
+ async setReseller(orgId, body = {}) {
1289
+ const res = await this.http.post(
1290
+ `/admin/orgs/${orgId}/reseller`,
1291
+ { body }
1292
+ );
1293
+ return unwrapData(res);
1294
+ }
1295
+ /** Revoke an org's reseller status. */
1296
+ async revokeReseller(orgId) {
1297
+ const res = await this.http.delete(`/admin/orgs/${orgId}/reseller`);
1298
+ return unwrapData(res);
1299
+ }
1300
+ /** End an org's reseller association (stamps resellerDetachedAt). */
1301
+ async detachAssociation(orgId) {
1302
+ const res = await this.http.post(
1303
+ `/admin/orgs/${orgId}/detach-reseller`,
1304
+ { body: {} }
1305
+ );
1306
+ return unwrapData(res);
1307
+ }
1308
+ /** The billing-program-config journal, newest first. */
1309
+ async getProgramConfig() {
1310
+ const res = await this.http.get(
1311
+ "/admin/billing-program-config"
1312
+ );
1313
+ return res.data ?? [];
1314
+ }
1315
+ /** Append a new program-config period (closes the prior open row). */
1316
+ async appendProgramConfig(body) {
1317
+ const res = await this.http.post(
1318
+ "/admin/billing-program-config",
1319
+ { body }
1320
+ );
1321
+ return unwrapData(res);
1322
+ }
1323
+ /** Draft payouts from accrued commissions in the given period. */
1324
+ async generatePayouts(body) {
1325
+ const res = await this.http.post(
1326
+ "/admin/reseller-payouts/generate",
1327
+ { body }
1328
+ );
1329
+ return res.data ?? [];
1330
+ }
1331
+ /** Approve or mark-paid a payout (and optionally record an external ref). */
1332
+ async updatePayout(payoutId, body) {
1333
+ const res = await this.http.patch(
1334
+ `/admin/reseller-payouts/${payoutId}`,
1335
+ { body }
1336
+ );
1337
+ return unwrapData(res);
1338
+ }
1339
+ };
1340
+
1218
1341
  // src/client.ts
1219
1342
  var AgentEngineFacade = class {
1220
1343
  constructor(templates, scheduledTasks) {
@@ -1248,6 +1371,8 @@ var CloudAgentClient = class {
1248
1371
  this.billing = new BillingFacade(new SubscriptionsClient(this.http), new CreditsClient(this.http));
1249
1372
  this.usage = new UsageClient(this.http);
1250
1373
  this.budgets = new BudgetsClient(this.http);
1374
+ this.referrals = new ReferralsClient(this.http);
1375
+ this.reseller = new ResellerClient(this.http);
1251
1376
  }
1252
1377
  };
1253
1378
 
@@ -2098,6 +2223,8 @@ exports.NotImplementedError = NotImplementedError;
2098
2223
  exports.OrgRoles = OrgRoles;
2099
2224
  exports.PROVIDER_CATALOG = PROVIDER_CATALOG;
2100
2225
  exports.ProviderType = ProviderType;
2226
+ exports.ReferralsClient = ReferralsClient;
2227
+ exports.ResellerClient = ResellerClient;
2101
2228
  exports.ResourcesClient = ResourcesClient;
2102
2229
  exports.computeDisplayHint = computeDisplayHint;
2103
2230
  exports.getProvider = getProvider;