@onlyworlds/sdk 4.51.0 → 4.52.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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.52.0] - 2026-10-22
9
+
10
+ ### Changed
11
+
12
+ - **Every options object refuses an unknown key** the way `list()` did in 4.51.0: `draught`, `get`, `create`, `bulk`, `changes`, `changesAll`, `removeImage`, `redeemJoin`, `signInWithPassword`, `mintWorldKey`, `signInWithOnlyWorlds`, `completeSignIn`, `ask` and `sort` throw a TypeError naming the key and the known keys before anything is sent. A dropped key was never harmless: `atomc: true` ran a batch non-atomically, `idempotency_key` let a retry create twice, `afetr` read the whole feed, `mode` misspelt widened a draught to the caller's view. TypeScript callers were already refused at compile time; this is for plain JavaScript.
13
+
8
14
  ## [4.51.0] - 2026-10-22
9
15
 
10
16
  ### Changed
package/dist/index.d.ts CHANGED
@@ -2726,6 +2726,11 @@ interface OwFileDownload {
2726
2726
  kind: OwFileKind;
2727
2727
  size: number;
2728
2728
  }
2729
+ /**
2730
+ * The parameters of `list()` and `listAll()`. A wire filter goes under `filter`; any key not named
2731
+ * here is a TypeError before anything is sent (since 4.51.0; before, an unknown key was dropped and the
2732
+ * list came back whole).
2733
+ */
2729
2734
  interface ListParams {
2730
2735
  limit?: number;
2731
2736
  cursor?: string;
package/dist/index.js CHANGED
@@ -575,13 +575,7 @@ var OwV2Client = class {
575
575
  // -- Element CRUD --------------------------------------------------------
576
576
  /** GET /{type}/ -- one cursor page. */
577
577
  async list(type, params = {}) {
578
- for (const k of Object.keys(params)) {
579
- if (!LIST_PARAM_KEYS.has(k)) {
580
- throw new TypeError(
581
- `list: unknown parameter '${k}'. A wire filter (name, name__icontains, supertype, subtype, characters) goes under filter: { ${k}: ... }; the other keys are ${[...LIST_PARAM_KEYS].join(", ")}. Nothing was sent: an unknown key was once dropped, and the list came back whole.`
582
- );
583
- }
584
- }
578
+ only("list", params, LIST_PARAM_KEYS, "A wire filter (name, name__icontains, supertype, subtype, characters) goes under filter: { ... }.");
585
579
  const query = buildQuery({
586
580
  limit: params.limit ?? this.pageSize,
587
581
  cursor: params.cursor,
@@ -606,6 +600,7 @@ var OwV2Client = class {
606
600
  * empty means the serving is partial. Served `Cache-Control: private, no-store`.
607
601
  */
608
602
  async draught(characterId, policy = {}) {
603
+ only("draught", policy, ["components", "mode", "asOf", "undated", "since", "budget", "depth"]);
609
604
  const query = buildQuery({
610
605
  components: policy.components?.join(","),
611
606
  mode: policy.mode,
@@ -631,6 +626,7 @@ var OwV2Client = class {
631
626
  * #421: the owner reads as another reader; see ListParams.viewAs).
632
627
  */
633
628
  async get(type, id, opts = {}) {
629
+ only("get", opts, ["expand", "fields", "viewAs"]);
634
630
  const query = buildQuery({ expand: opts.expand?.join(","), fields: opts.fields?.join(","), as: opts.viewAs });
635
631
  return this.request("GET", `/${type}/${id}/`, { query });
636
632
  }
@@ -645,6 +641,7 @@ var OwV2Client = class {
645
641
  * `null` are accepted and stored as `''` (nameless Markers exist).
646
642
  */
647
643
  async create(type, element, opts = {}) {
644
+ only("create", opts, ["idempotencyKey"]);
648
645
  refuseKnownOf(element, "create");
649
646
  const body = sanitizePayload(element);
650
647
  if (body.id === void 0 || body.id === null || body.id === "") {
@@ -731,6 +728,7 @@ var OwV2Client = class {
731
728
  * fresh UUIDv7. Ids you supply are kept.
732
729
  */
733
730
  async bulk(items, opts = {}) {
731
+ only("bulk", opts, ["atomic", "idempotencyKey"]);
734
732
  items.forEach((it, index) => refuseKnownOf(it.element, `bulk: items[${index}]`));
735
733
  const body = {
736
734
  items: items.map((it, index) => {
@@ -772,6 +770,7 @@ var OwV2Client = class {
772
770
  * that is not a date and time is a 422 naming `after`.
773
771
  */
774
772
  async changes(opts = {}) {
773
+ only("changes", opts, ["since", "limit", "after"]);
775
774
  const query = buildQuery({ since: opts.since, limit: opts.limit ?? this.changesPageSize, after: opts.after });
776
775
  const page = await this.request("GET", "/changes/", { query });
777
776
  return { ...page, cursor: String(page.cursor) };
@@ -802,6 +801,7 @@ var OwV2Client = class {
802
801
  * `head` and `epoch`: the view epoch the walk ran under, for a guest or a contributor).
803
802
  */
804
803
  async *changesAll(since, opts = {}) {
804
+ only("changesAll", opts, ["after"]);
805
805
  let cursor = since;
806
806
  let page;
807
807
  do {
@@ -891,6 +891,7 @@ var OwV2Client = class {
891
891
  * ticket is still unspent).
892
892
  */
893
893
  async removeImage(keyOrUrl, opts = {}) {
894
+ only("removeImage", opts, ["ticket"]);
894
895
  const ticket = opts.ticket ?? await this.createRemovalTicket(keyOrUrl);
895
896
  let res;
896
897
  try {
@@ -1076,6 +1077,7 @@ var OwV2Client = class {
1076
1077
  * for one ignores `character`.
1077
1078
  */
1078
1079
  async redeemJoin(code, opts = {}) {
1080
+ only("redeemJoin", opts, ["name", "agentName", "character"]);
1079
1081
  const body = { code };
1080
1082
  if (opts.name !== void 0) body.name = opts.name;
1081
1083
  if (opts.agentName !== void 0) body.agent_name = opts.agentName;
@@ -1104,6 +1106,7 @@ var OwV2Client = class {
1104
1106
  * `failed` (anything else, with keel's message). The password is never in an error.
1105
1107
  */
1106
1108
  async signInWithPassword(opts) {
1109
+ only("signInWithPassword", opts, ["email", "username", "password", "tokenName"]);
1107
1110
  const { email, username, password, tokenName } = opts ?? {};
1108
1111
  const login = typeof email === "string" ? email.trim() : "";
1109
1112
  const user = typeof username === "string" ? username.trim() : "";
@@ -1384,6 +1387,7 @@ var OwV2Client = class {
1384
1387
  * token only; no Idempotency-Key.
1385
1388
  */
1386
1389
  async mintWorldKey(worldId, opts = {}) {
1390
+ only("mintWorldKey", opts, ["scope", "name"]);
1387
1391
  if (this.keyKind !== "account") {
1388
1392
  throw new TypeError("mintWorldKey needs an account token (ow_a_)");
1389
1393
  }
@@ -1403,6 +1407,7 @@ var OwV2Client = class {
1403
1407
  * is sent; any client, keyless included. The handoff sheet: Orrery `keel/signin-handoff.md` §3.
1404
1408
  */
1405
1409
  async signInWithOnlyWorlds(opts) {
1410
+ only("signInWithOnlyWorlds", opts, ["clientId", "redirectUri", "resume", "storage", "navigate"]);
1406
1411
  return beginSignIn(this.baseUrl, opts);
1407
1412
  }
1408
1413
  /**
@@ -1415,6 +1420,7 @@ var OwV2Client = class {
1415
1420
  * 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`.
1416
1421
  */
1417
1422
  async completeSignIn(opts) {
1423
+ only("completeSignIn", opts, ["clientId", "storage", "url"]);
1418
1424
  return completeSignIn(this.baseUrl, this.fetchImpl, opts);
1419
1425
  }
1420
1426
  // -- Ask your world (keel #159) -------------------------------------------
@@ -1429,6 +1435,7 @@ var OwV2Client = class {
1429
1435
  * them counts. 422 for a question over 500 characters or context past its limits.
1430
1436
  */
1431
1437
  async ask(req) {
1438
+ only("ask", req, ["worldId", "question", "context"]);
1432
1439
  if (this.keyKind !== "account") {
1433
1440
  throw new TypeError("ask needs an account token (ow_a_): the proxy meters per account");
1434
1441
  }
@@ -1448,6 +1455,7 @@ var OwV2Client = class {
1448
1455
  * to 200 characters, anchors up to 120.
1449
1456
  */
1450
1457
  async sort(req) {
1458
+ only("sort", req, ["worldId", "notes", "slice"]);
1451
1459
  if (this.keyKind !== "account") {
1452
1460
  throw new TypeError("sort needs an account token (ow_a_): the proxy meters per account");
1453
1461
  }
@@ -1645,7 +1653,15 @@ function objectKey(keyOrUrl) {
1645
1653
  if (!/^https?:\/\//i.test(keyOrUrl)) return keyOrUrl;
1646
1654
  return decodeURIComponent(new URL(keyOrUrl).pathname.replace(/^\/+/, ""));
1647
1655
  }
1648
- var LIST_PARAM_KEYS = /* @__PURE__ */ new Set(["limit", "cursor", "ids", "createdBy", "expand", "fields", "filter", "viewAs"]);
1656
+ var LIST_PARAM_KEYS = ["limit", "cursor", "ids", "createdBy", "expand", "fields", "filter", "viewAs"];
1657
+ function only(method, obj, keys, hint = "") {
1658
+ if (!obj || typeof obj !== "object") return;
1659
+ for (const k of Object.keys(obj)) {
1660
+ if (!keys.includes(k)) {
1661
+ throw new TypeError(`${method}: unknown parameter '${k}'. ${hint ? hint + " " : ""}The keys are ${keys.join(", ")}. Nothing was sent.`);
1662
+ }
1663
+ }
1664
+ }
1649
1665
  function buildQuery(params) {
1650
1666
  const q = new URLSearchParams();
1651
1667
  for (const [k, v] of Object.entries(params)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.51.0",
3
+ "version": "4.52.0",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {