@bunbase-ae/js 3.3.1-next.421.7803b2a → 3.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/admin.ts +27 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunbase-ae/js",
3
- "version": "3.3.1-next.421.7803b2a",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript/JavaScript SDK for BunBase",
6
6
  "license": "UNLICENSED",
package/src/admin.ts CHANGED
@@ -899,6 +899,33 @@ class AdminCollectionsClient {
899
899
  );
900
900
  }
901
901
 
902
+ /**
903
+ * Transfer ownership of a record to another user (#701).
904
+ *
905
+ * `_owner_id` is normally immutable; this admin-only call reassigns it so a
906
+ * record created on behalf of a not-yet-provisioned user can later be owned
907
+ * by that user (and read via the `owner` access rule). For tenant-scoped
908
+ * collections the new owner must be a member of the record's tenant.
909
+ *
910
+ * ```ts
911
+ * const rec = await bbClient.admin.collections.transferOwner<Resident>(
912
+ * "residents", residentId, newUserId,
913
+ * );
914
+ * // rec._owner_id === newUserId
915
+ * ```
916
+ */
917
+ async transferOwner<T extends Record<string, unknown> = Record<string, unknown>>(
918
+ collection: string,
919
+ id: string,
920
+ owner: string,
921
+ ): Promise<T & AdminRecord> {
922
+ return this.http.request<T & AdminRecord>(
923
+ "POST",
924
+ `/api/v1/admin/collections/${collection}/records/${id}/transfer-owner`,
925
+ { body: { owner } },
926
+ );
927
+ }
928
+
902
929
  // ── Indexes ──────────────────────────────────────────────────────────────────
903
930
 
904
931
  async listIndexes(collection: string): Promise<IndexInfo[]> {