@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.mjs CHANGED
@@ -1001,6 +1001,87 @@ var Channels = class {
1001
1001
  });
1002
1002
  }
1003
1003
  };
1004
+ var Admin = class {
1005
+ /**
1006
+ * List accounts
1007
+ *
1008
+ * 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.
1009
+ * `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.
1010
+ * 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.
1011
+ *
1012
+ */
1013
+ static listUsers(options) {
1014
+ return (options?.client ?? client).get({
1015
+ url: "/v1/admin/users",
1016
+ ...options
1017
+ });
1018
+ }
1019
+ /**
1020
+ * Replace a user's roles
1021
+ *
1022
+ * 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.
1023
+ *
1024
+ */
1025
+ static updateUserRoles(options) {
1026
+ return (options.client ?? client).put({
1027
+ url: "/v1/admin/users/{user_id}/roles",
1028
+ ...options,
1029
+ headers: {
1030
+ "Content-Type": "application/json",
1031
+ ...options.headers
1032
+ }
1033
+ });
1034
+ }
1035
+ /**
1036
+ * Grant a user a plan
1037
+ *
1038
+ * Puts the account on a rung of the infra ladder. Needs the `admin` role.
1039
+ * `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).
1040
+ * 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.
1041
+ *
1042
+ */
1043
+ static grantUserPlan(options) {
1044
+ return (options.client ?? client).put({
1045
+ url: "/v1/admin/users/{user_id}/plan",
1046
+ ...options,
1047
+ headers: {
1048
+ "Content-Type": "application/json",
1049
+ ...options.headers
1050
+ }
1051
+ });
1052
+ }
1053
+ /**
1054
+ * Read a user's credit ledger
1055
+ *
1056
+ * 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.
1057
+ * 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.
1058
+ *
1059
+ */
1060
+ static listUserCredits(options) {
1061
+ return (options.client ?? client).get({
1062
+ url: "/v1/admin/users/{user_id}/credits",
1063
+ ...options
1064
+ });
1065
+ }
1066
+ /**
1067
+ * Grant a user credit
1068
+ *
1069
+ * Writes one `granted` line to the account's credit ledger and answers with the balance it produced. Needs the `admin` role.
1070
+ * 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.
1071
+ * The balance this moves is not yet a ceiling anything enforces; turning it into one is a separate mechanism.
1072
+ *
1073
+ */
1074
+ static grantUserCredit(options) {
1075
+ return (options.client ?? client).post({
1076
+ url: "/v1/admin/users/{user_id}/credits",
1077
+ ...options,
1078
+ headers: {
1079
+ "Content-Type": "application/json",
1080
+ ...options.headers
1081
+ }
1082
+ });
1083
+ }
1084
+ };
1004
1085
  var Agents = class {
1005
1086
  /**
1006
1087
  * List agents
@@ -4096,22 +4177,6 @@ var Users = class {
4096
4177
  }
4097
4178
  });
4098
4179
  }
4099
- /**
4100
- * Replace a user's roles
4101
- *
4102
- * 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.
4103
- *
4104
- */
4105
- static updateUserRoles(options) {
4106
- return (options.client ?? client).put({
4107
- url: "/v1/users/{user_id}/roles",
4108
- ...options,
4109
- headers: {
4110
- "Content-Type": "application/json",
4111
- ...options.headers
4112
- }
4113
- });
4114
- }
4115
4180
  };
4116
4181
  var Webhooks = class {
4117
4182
  /**
@@ -4388,6 +4453,7 @@ const API_BASE_URL = "https://api.naturali.ai";
4388
4453
  */
4389
4454
  var NaturaliClient = class {
4390
4455
  activity;
4456
+ admin;
4391
4457
  actors;
4392
4458
  agents;
4393
4459
  agentVersions;
@@ -4436,6 +4502,7 @@ var NaturaliClient = class {
4436
4502
  }
4437
4503
  }));
4438
4504
  this.activity = bindResource(Activity, this.http);
4505
+ this.admin = bindResource(Admin, this.http);
4439
4506
  this.actors = bindResource(Actors, this.http);
4440
4507
  this.agents = bindResource(Agents, this.http);
4441
4508
  this.agentVersions = bindResource(AgentVersions, this.http);
@@ -4476,4 +4543,4 @@ var NaturaliClient = class {
4476
4543
  }
4477
4544
  };
4478
4545
  //#endregion
4479
- export { Activity, Actors, AgentVersions, Agents, AiProviders, ApiKeys, Approvals, Assistant, AuditLog, Auth, Channels, Conversations, Documents, Embeddings, Evaluations, Exceptions, Files, Formations, Generations, Guardrails, IngestionRules, Knowledge, Memories, MemoryEntries, ModelRoutes, Models, NaturaliClient, Orchestrations, Projects, Quotas, Secrets, Sessions, Tasks, Tools, Traces, Triggers, Users, Webhooks, Workflows, createClient, createConfig };
4546
+ export { Activity, Actors, Admin, AgentVersions, Agents, AiProviders, ApiKeys, Approvals, Assistant, AuditLog, Auth, Channels, Conversations, Documents, Embeddings, Evaluations, Exceptions, Files, Formations, Generations, Guardrails, IngestionRules, Knowledge, Memories, MemoryEntries, ModelRoutes, Models, NaturaliClient, Orchestrations, Projects, Quotas, Secrets, Sessions, Tasks, Tools, Traces, Triggers, Users, Webhooks, Workflows, createClient, createConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/sdk",
3
- "version": "0.86.3",
3
+ "version": "0.88.0",
4
4
  "description": "TypeScript SDK for the naturali.ai API, generated from its OpenAPI specs",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "tsx": "^4.23.1",
38
38
  "typescript": "~6.0.3",
39
39
  "vitest": "^4.1.10",
40
- "@naturali/api": "0.86.3"
40
+ "@naturali/api": "0.88.0"
41
41
  },
42
42
  "scripts": {
43
43
  "generate": "tsx scripts/generate.ts",