@gpt-platform/admin 0.6.1 → 0.6.2

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
@@ -814,7 +814,7 @@ var createClient = (config = {}) => {
814
814
  };
815
815
 
816
816
  // src/version.ts
817
- var SDK_VERSION = "0.6.1";
817
+ var SDK_VERSION = "0.6.2";
818
818
  var DEFAULT_API_VERSION = "2026-03-09";
819
819
 
820
820
  // src/base-client.ts
@@ -2705,6 +2705,15 @@ var getAdminAccounts = (options) => (options.client ?? client).get({
2705
2705
  url: "/admin/accounts",
2706
2706
  ...options
2707
2707
  });
2708
+ var postAdminUsersAuthRegisterViaInvitation = (options) => (options.client ?? client).post({
2709
+ security: [{ scheme: "bearer", type: "http" }],
2710
+ url: "/admin/users/auth/register-via-invitation",
2711
+ ...options,
2712
+ headers: {
2713
+ "Content-Type": "application/vnd.api+json",
2714
+ ...options.headers
2715
+ }
2716
+ });
2708
2717
  var getAdminStorageStats = (options) => (options.client ?? client).get({
2709
2718
  security: [{ scheme: "bearer", type: "http" }],
2710
2719
  url: "/admin/storage/stats",
@@ -6563,6 +6572,36 @@ function createUsersNamespace(rb) {
6563
6572
  options
6564
6573
  );
6565
6574
  },
6575
+ /**
6576
+ * Register a new user via invitation token — skips personal tenant creation,
6577
+ * accepts the invitation, and creates the appropriate AccessGrant.
6578
+ * @param email - Email address (must match the invitation)
6579
+ * @param password - Password (min 8 characters)
6580
+ * @param passwordConfirmation - Must match password
6581
+ * @param invitationToken - Raw invitation token from the invitation email
6582
+ * @param attrs - Optional extra attributes (first_name, last_name)
6583
+ * @returns Created user with JWT token
6584
+ */
6585
+ registerViaInvitation: async (email, password, passwordConfirmation, invitationToken, attrs, options) => {
6586
+ return rb.execute(
6587
+ postAdminUsersAuthRegisterViaInvitation,
6588
+ {
6589
+ body: {
6590
+ data: {
6591
+ type: "user",
6592
+ attributes: {
6593
+ email,
6594
+ password,
6595
+ password_confirmation: passwordConfirmation,
6596
+ invitation_token: invitationToken,
6597
+ ...attrs
6598
+ }
6599
+ }
6600
+ }
6601
+ },
6602
+ options
6603
+ );
6604
+ },
6566
6605
  /**
6567
6606
  * Delete a user and all associated data.
6568
6607
  * @param id - User ID
@@ -11950,6 +11989,147 @@ function createTenantsNamespace(rb) {
11950
11989
  };
11951
11990
  }
11952
11991
 
11992
+ // src/namespaces/access-grants.ts
11993
+ function createAccessGrantsNamespace(rb) {
11994
+ return {
11995
+ /**
11996
+ * List access grants. Filter by subject or object using query params.
11997
+ *
11998
+ * @param params - Optional filter parameters (subject_id, object_id, object_type, relation)
11999
+ * @returns Paginated list of access grants
12000
+ * @example
12001
+ * const grants = await admin.accessGrants.list({ subject_id: userId });
12002
+ */
12003
+ async list(params) {
12004
+ const query = params ? `?${new URLSearchParams(params).toString()}` : "";
12005
+ return rb.rawGet(`/admin/access-grants${query}`);
12006
+ },
12007
+ /**
12008
+ * Get a single access grant by ID.
12009
+ *
12010
+ * @param id - AccessGrant UUID
12011
+ * @returns The access grant record
12012
+ * @example
12013
+ * const grant = await admin.accessGrants.get("grant-uuid");
12014
+ */
12015
+ async get(id) {
12016
+ return rb.rawGet(`/admin/access-grants/${id}`);
12017
+ },
12018
+ /**
12019
+ * Create a new access grant, giving a subject (user or application) a relation to an object (tenant or workspace).
12020
+ *
12021
+ * @param attrs - Grant attributes (subject_type, subject_id, relation, object_type, object_id, expires_at)
12022
+ * @returns The created access grant
12023
+ * @example
12024
+ * const grant = await admin.accessGrants.create({
12025
+ * data: {
12026
+ * type: "access-grant",
12027
+ * attributes: {
12028
+ * subject_type: "user",
12029
+ * subject_id: "user-uuid",
12030
+ * relation: "workspace_editor",
12031
+ * object_type: "workspace",
12032
+ * object_id: "workspace-uuid",
12033
+ * },
12034
+ * },
12035
+ * });
12036
+ */
12037
+ async create(attrs) {
12038
+ return rb.rawPost(`/admin/access-grants`, attrs);
12039
+ },
12040
+ /**
12041
+ * Update an existing access grant (relation, custom_permissions, expires_at).
12042
+ *
12043
+ * @param id - AccessGrant UUID
12044
+ * @param attrs - Attributes to update
12045
+ * @returns The updated access grant
12046
+ * @example
12047
+ * const updated = await admin.accessGrants.update("grant-uuid", {
12048
+ * data: { type: "access-grant", id: "grant-uuid", attributes: { expires_at: "2027-01-01T00:00:00Z" } },
12049
+ * });
12050
+ */
12051
+ async update(id, attrs) {
12052
+ return rb.rawPatch(
12053
+ `/admin/access-grants/${id}`,
12054
+ attrs
12055
+ );
12056
+ },
12057
+ /**
12058
+ * Revoke (delete) an access grant.
12059
+ *
12060
+ * @param id - AccessGrant UUID
12061
+ * @returns void
12062
+ * @example
12063
+ * await admin.accessGrants.revoke("grant-uuid");
12064
+ */
12065
+ async revoke(id) {
12066
+ return rb.rawDelete(`/admin/access-grants/${id}`);
12067
+ }
12068
+ };
12069
+ }
12070
+
12071
+ // src/namespaces/roles.ts
12072
+ function createRolesNamespace(rb) {
12073
+ return {
12074
+ /**
12075
+ * List all roles for the current application.
12076
+ *
12077
+ * @param params - Optional filter parameters
12078
+ * @returns Paginated list of roles
12079
+ * @example
12080
+ * const roles = await admin.roles.list();
12081
+ */
12082
+ async list(params) {
12083
+ const query = params ? `?${new URLSearchParams(params).toString()}` : "";
12084
+ return rb.rawGet(`/admin/roles${query}`);
12085
+ },
12086
+ /**
12087
+ * Create a new role with a set of permissions.
12088
+ *
12089
+ * @param attrs - Role attributes (name, permissions, description)
12090
+ * @returns The created role
12091
+ * @example
12092
+ * const role = await admin.roles.create({
12093
+ * data: {
12094
+ * type: "role",
12095
+ * attributes: {
12096
+ * name: "Document Manager",
12097
+ * permissions: ["extract:document:read:all", "extract:document:ingest:all"],
12098
+ * },
12099
+ * },
12100
+ * });
12101
+ */
12102
+ async create(attrs) {
12103
+ return rb.rawPost(`/admin/roles`, attrs);
12104
+ },
12105
+ /**
12106
+ * Update an existing role's name or permissions.
12107
+ *
12108
+ * @param id - Role UUID
12109
+ * @param attrs - Attributes to update
12110
+ * @returns The updated role
12111
+ * @example
12112
+ * const updated = await admin.roles.update("role-uuid", {
12113
+ * data: { type: "role", id: "role-uuid", attributes: { name: "Senior Document Manager" } },
12114
+ * });
12115
+ */
12116
+ async update(id, attrs) {
12117
+ return rb.rawPatch(`/admin/roles/${id}`, attrs);
12118
+ },
12119
+ /**
12120
+ * Delete a role.
12121
+ *
12122
+ * @param id - Role UUID
12123
+ * @returns void
12124
+ * @example
12125
+ * await admin.roles.destroy("role-uuid");
12126
+ */
12127
+ async destroy(id) {
12128
+ return rb.rawDelete(`/admin/roles/${id}`);
12129
+ }
12130
+ };
12131
+ }
12132
+
11953
12133
  // src/gpt-admin.ts
11954
12134
  var GptAdmin = class extends BaseClient {
11955
12135
  constructor(config) {
@@ -11988,6 +12168,8 @@ var GptAdmin = class extends BaseClient {
11988
12168
  this.compliance = createComplianceNamespace(rb);
11989
12169
  this.pipelines = createPipelinesNamespace(rb);
11990
12170
  this.tenants = createTenantsNamespace(rb);
12171
+ this.accessGrants = createAccessGrantsNamespace(rb);
12172
+ this.roles = createRolesNamespace(rb);
11991
12173
  }
11992
12174
  };
11993
12175