@naturali/sdk 0.86.3 → 0.88.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/dist/index.cjs CHANGED
@@ -1002,6 +1002,87 @@ var Channels = class {
1002
1002
  });
1003
1003
  }
1004
1004
  };
1005
+ var Admin = class {
1006
+ /**
1007
+ * List accounts
1008
+ *
1009
+ * A cursor page of every account, newest first, each with the plan it is on and the balance of its credit ledger. Needs the `admin` role.
1010
+ * `email` narrows the page to one account. It matches the whole address case-insensitively and takes no wildcards: an operator looking for `Ana@Acme.com` finds a row stored as `ana@acme.com`, and there is no substring search across customers' addresses.
1011
+ * An account with no subscription reads as `free` with a balance of `0`: the absence of a row is the free plan, and the least-privileged rung is also what any unresolvable lookup should answer.
1012
+ *
1013
+ */
1014
+ static listUsers(options) {
1015
+ return (options?.client ?? client).get({
1016
+ url: "/v1/admin/users",
1017
+ ...options
1018
+ });
1019
+ }
1020
+ /**
1021
+ * Replace a user's roles
1022
+ *
1023
+ * Replaces the platform roles of any user. Needs the `admin` role, and each role that changes needs the caller to hold the role that grants it (today `admin` grants `admin`). Values outside the catalog are rejected with a 400, and a caller cannot remove their own `admin` role.
1024
+ *
1025
+ */
1026
+ static updateUserRoles(options) {
1027
+ return (options.client ?? client).put({
1028
+ url: "/v1/admin/users/{user_id}/roles",
1029
+ ...options,
1030
+ headers: {
1031
+ "Content-Type": "application/json",
1032
+ ...options.headers
1033
+ }
1034
+ });
1035
+ }
1036
+ /**
1037
+ * Grant a user a plan
1038
+ *
1039
+ * Puts the account on a rung of the infra ladder. Needs the `admin` role.
1040
+ * `PUT` because a user has exactly one plan: setting it twice leaves one subscription, never two (two rows for one payer is a state where "which plan is this?" has no answer).
1041
+ * The rung is recorded and read back, and **nothing enforces it yet** — no route refuses a feature for the plan an account is on. Downgrading is the same call with a lower rung, and what becomes of resources a lower plan would not hold is a separate mechanism that is not built.
1042
+ *
1043
+ */
1044
+ static grantUserPlan(options) {
1045
+ return (options.client ?? client).put({
1046
+ url: "/v1/admin/users/{user_id}/plan",
1047
+ ...options,
1048
+ headers: {
1049
+ "Content-Type": "application/json",
1050
+ ...options.headers
1051
+ }
1052
+ });
1053
+ }
1054
+ /**
1055
+ * Read a user's credit ledger
1056
+ *
1057
+ * A cursor page of the account's credit lines, newest first, with the balance they sum to. Needs the `admin` role — including for the account's own owner, since the customer-facing view of a balance belongs with a billing surface this API does not serve yet.
1058
+ * What an operator reads it for is writing a correction: the line that was wrong stays on the record, so it has to be legible before it can be compensated for.
1059
+ *
1060
+ */
1061
+ static listUserCredits(options) {
1062
+ return (options.client ?? client).get({
1063
+ url: "/v1/admin/users/{user_id}/credits",
1064
+ ...options
1065
+ });
1066
+ }
1067
+ /**
1068
+ * Grant a user credit
1069
+ *
1070
+ * Writes one `granted` line to the account's credit ledger and answers with the balance it produced. Needs the `admin` role.
1071
+ * The ledger is append-only and the balance is its sum — there is no balance to set and no line to edit or delete. A mistake is corrected by granting a **negative** `amount_usd`, which leaves the wrong line on the record beside the one that compensates for it. Granted credit is customer-acquisition cost rather than revenue, which is why each line records its kind and the operator who authorized it.
1072
+ * The balance this moves is not yet a ceiling anything enforces; turning it into one is a separate mechanism.
1073
+ *
1074
+ */
1075
+ static grantUserCredit(options) {
1076
+ return (options.client ?? client).post({
1077
+ url: "/v1/admin/users/{user_id}/credits",
1078
+ ...options,
1079
+ headers: {
1080
+ "Content-Type": "application/json",
1081
+ ...options.headers
1082
+ }
1083
+ });
1084
+ }
1085
+ };
1005
1086
  var Agents = class {
1006
1087
  /**
1007
1088
  * List agents
@@ -4097,22 +4178,6 @@ var Users = class {
4097
4178
  }
4098
4179
  });
4099
4180
  }
4100
- /**
4101
- * Replace a user's roles
4102
- *
4103
- * Replaces the platform roles of any user. Needs the `admin` role, and each role that changes needs the caller to hold the role that grants it (today `admin` grants `admin`). Values outside the catalog are rejected with a 400, and a caller cannot remove their own `admin` role.
4104
- *
4105
- */
4106
- static updateUserRoles(options) {
4107
- return (options.client ?? client).put({
4108
- url: "/v1/users/{user_id}/roles",
4109
- ...options,
4110
- headers: {
4111
- "Content-Type": "application/json",
4112
- ...options.headers
4113
- }
4114
- });
4115
- }
4116
4181
  };
4117
4182
  var Webhooks = class {
4118
4183
  /**
@@ -4389,6 +4454,7 @@ const API_BASE_URL = "https://api.naturali.ai";
4389
4454
  */
4390
4455
  var NaturaliClient = class {
4391
4456
  activity;
4457
+ admin;
4392
4458
  actors;
4393
4459
  agents;
4394
4460
  agentVersions;
@@ -4437,6 +4503,7 @@ var NaturaliClient = class {
4437
4503
  }
4438
4504
  }));
4439
4505
  this.activity = bindResource(Activity, this.http);
4506
+ this.admin = bindResource(Admin, this.http);
4440
4507
  this.actors = bindResource(Actors, this.http);
4441
4508
  this.agents = bindResource(Agents, this.http);
4442
4509
  this.agentVersions = bindResource(AgentVersions, this.http);
@@ -4479,6 +4546,7 @@ var NaturaliClient = class {
4479
4546
  //#endregion
4480
4547
  exports.Activity = Activity;
4481
4548
  exports.Actors = Actors;
4549
+ exports.Admin = Admin;
4482
4550
  exports.AgentVersions = AgentVersions;
4483
4551
  exports.Agents = Agents;
4484
4552
  exports.AiProviders = AiProviders;