@sales-planner/http-client 1.0.1 → 1.1.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/README.md CHANGED
@@ -106,6 +106,22 @@ const { items: shops } = await client.shops.getAll();
106
106
  const { items: userRoles } = await client.userRoles.getAll();
107
107
  const { items: apiKeys } = await client.apiKeys.getAll();
108
108
 
109
+ // Users - access control
110
+ // System admin only: create user without role
111
+ const user = await client.users.create({ email: 'user@example.com', name: 'User' });
112
+
113
+ // System admin or tenant admin/owner: create user with API key and role
114
+ const { user, apiKey } = await client.users.createWithApiKey({
115
+ email: 'user@example.com',
116
+ name: 'User',
117
+ roleId: 'viewer',
118
+ tenantId: 1,
119
+ shopId: 1, // required for shop-level roles like viewer/editor
120
+ });
121
+
122
+ // Self or system admin: update user profile
123
+ await client.users.update(userId, { name: 'New Name' });
124
+
109
125
  // Roles are predefined and read-only (available to all authenticated users)
110
126
  const { items: roles } = await client.roles.getAll();
111
127
  const role = await client.roles.getById(1);
@@ -1,4 +1,4 @@
1
- import type { User, CreateUserRequest, PaginatedResponse, PaginationQuery } from '@sales-planner/shared';
1
+ import type { User, CreateUserRequest, CreateUserWithApiKeyRequest, PaginatedResponse, PaginationQuery, UpdateUserRequest, UserWithApiKey } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export interface GetUsersQuery extends PaginationQuery {
4
4
  tenantId?: number;
@@ -7,6 +7,8 @@ export declare class UsersClient extends BaseClient {
7
7
  getAll(query?: GetUsersQuery): Promise<PaginatedResponse<User>>;
8
8
  getById(id: number): Promise<User>;
9
9
  create(request: CreateUserRequest): Promise<User>;
10
+ createWithApiKey(request: CreateUserWithApiKeyRequest): Promise<UserWithApiKey>;
11
+ update(id: number, request: UpdateUserRequest): Promise<User>;
10
12
  delete(id: number): Promise<void>;
11
13
  }
12
14
  //# sourceMappingURL=users-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"users-client.d.ts","sourceRoot":"","sources":["../../src/clients/users-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAY,SAAQ,UAAU;IACnC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAM/D,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
1
+ {"version":3,"file":"users-client.d.ts","sourceRoot":"","sources":["../../src/clients/users-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAY,SAAQ,UAAU;IACnC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAM/D,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/E,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -11,6 +11,12 @@ export class UsersClient extends BaseClient {
11
11
  async create(request) {
12
12
  return this.request('POST', '/users', { body: request });
13
13
  }
14
+ async createWithApiKey(request) {
15
+ return this.request('POST', '/users/with-api-key', { body: request });
16
+ }
17
+ async update(id, request) {
18
+ return this.request('PATCH', `/users/${id}`, { body: request });
19
+ }
14
20
  async delete(id) {
15
21
  return this.request('DELETE', `/users/${id}`);
16
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sales-planner/http-client",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "HTTP client for Sales Planner API",
5
5
  "author": "Damir Manapov",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "README.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@sales-planner/shared": "1.0.1"
27
+ "@sales-planner/shared": "1.1.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.7.3"