@sales-planner/http-client 0.14.0 → 0.15.1

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 (54) hide show
  1. package/README.md +44 -363
  2. package/dist/clients/api-keys-client.d.ts +3 -3
  3. package/dist/clients/api-keys-client.d.ts.map +1 -1
  4. package/dist/clients/api-keys-client.js +3 -3
  5. package/dist/clients/brands-client.d.ts +18 -16
  6. package/dist/clients/brands-client.d.ts.map +1 -1
  7. package/dist/clients/brands-client.js +4 -37
  8. package/dist/clients/categories-client.d.ts +18 -16
  9. package/dist/clients/categories-client.d.ts.map +1 -1
  10. package/dist/clients/categories-client.js +4 -38
  11. package/dist/clients/coded-entity-client.d.ts +30 -0
  12. package/dist/clients/coded-entity-client.d.ts.map +1 -0
  13. package/dist/clients/coded-entity-client.js +60 -0
  14. package/dist/clients/crud-client.d.ts +14 -0
  15. package/dist/clients/crud-client.d.ts.map +1 -0
  16. package/dist/clients/crud-client.js +26 -0
  17. package/dist/clients/groups-client.d.ts +18 -16
  18. package/dist/clients/groups-client.d.ts.map +1 -1
  19. package/dist/clients/groups-client.js +4 -38
  20. package/dist/clients/marketplaces-client.d.ts +18 -16
  21. package/dist/clients/marketplaces-client.d.ts.map +1 -1
  22. package/dist/clients/marketplaces-client.js +4 -37
  23. package/dist/clients/roles-client.d.ts +6 -6
  24. package/dist/clients/sales-history-client.d.ts +29 -13
  25. package/dist/clients/sales-history-client.d.ts.map +1 -1
  26. package/dist/clients/sales-history-client.js +5 -5
  27. package/dist/clients/sales-planner-client.d.ts +12 -16
  28. package/dist/clients/sales-planner-client.d.ts.map +1 -1
  29. package/dist/clients/sales-planner-client.js +12 -17
  30. package/dist/clients/shop-scoped-client.d.ts +30 -0
  31. package/dist/clients/shop-scoped-client.d.ts.map +1 -0
  32. package/dist/clients/shop-scoped-client.js +58 -0
  33. package/dist/clients/shops-client.d.ts +6 -6
  34. package/dist/clients/shops-client.d.ts.map +1 -1
  35. package/dist/clients/shops-client.js +6 -6
  36. package/dist/clients/skus-client.d.ts +6 -6
  37. package/dist/clients/skus-client.d.ts.map +1 -1
  38. package/dist/clients/skus-client.js +6 -6
  39. package/dist/clients/statuses-client.d.ts +18 -16
  40. package/dist/clients/statuses-client.d.ts.map +1 -1
  41. package/dist/clients/statuses-client.js +4 -38
  42. package/dist/clients/suppliers-client.d.ts +18 -16
  43. package/dist/clients/suppliers-client.d.ts.map +1 -1
  44. package/dist/clients/suppliers-client.js +4 -37
  45. package/dist/clients/tenants-client.d.ts +6 -6
  46. package/dist/clients/tenants-client.d.ts.map +1 -1
  47. package/dist/clients/tenants-client.js +6 -6
  48. package/dist/clients/user-roles-client.d.ts +4 -4
  49. package/dist/clients/user-roles-client.d.ts.map +1 -1
  50. package/dist/clients/user-roles-client.js +4 -4
  51. package/dist/clients/users-client.d.ts +4 -4
  52. package/dist/clients/users-client.d.ts.map +1 -1
  53. package/dist/clients/users-client.js +4 -4
  54. package/package.json +2 -2
@@ -0,0 +1,58 @@
1
+ import { ImportExportBaseClient } from './import-export-base-client.js';
2
+ /**
3
+ * Generic client for shop-scoped resources with import/export capabilities.
4
+ *
5
+ * @typeParam TEntity - The entity type
6
+ * @typeParam TCreateRequest - The create request type
7
+ * @typeParam TUpdateRequest - The update request type
8
+ * @typeParam TImportItem - The import item type
9
+ * @typeParam TExportItem - The export item type
10
+ * @typeParam TImportResult - The import result type
11
+ * @typeParam TQuery - The query type for getAll/export (defaults to empty object)
12
+ */
13
+ export class ShopScopedClient extends ImportExportBaseClient {
14
+ resourcePath;
15
+ constructor(config, resourcePath) {
16
+ super(config);
17
+ this.resourcePath = resourcePath;
18
+ }
19
+ async getAll(ctx, query) {
20
+ return this.request('GET', `/${this.resourcePath}`, {
21
+ params: { ...ctx, ...query },
22
+ });
23
+ }
24
+ async getById(ctx, id) {
25
+ return this.request('GET', `/${this.resourcePath}/${id}`, { params: ctx });
26
+ }
27
+ async create(ctx, request) {
28
+ return this.request('POST', `/${this.resourcePath}`, { body: request, params: ctx });
29
+ }
30
+ async update(ctx, id, request) {
31
+ return this.request('PUT', `/${this.resourcePath}/${id}`, { body: request, params: ctx });
32
+ }
33
+ async delete(ctx, id) {
34
+ return this.request('DELETE', `/${this.resourcePath}/${id}`, { params: ctx });
35
+ }
36
+ async importJson(ctx, items) {
37
+ return this.request('POST', `/${this.resourcePath}/import/json`, { body: items, params: ctx });
38
+ }
39
+ async importCsv(ctx, csvContent) {
40
+ return this.uploadCsv(`/${this.resourcePath}/import/csv`, csvContent, ctx);
41
+ }
42
+ async exportJson(ctx, query) {
43
+ return this.request('GET', `/${this.resourcePath}/export/json`, {
44
+ params: { ...ctx, ...query },
45
+ });
46
+ }
47
+ async exportCsv(ctx, query) {
48
+ return this.requestText('GET', `/${this.resourcePath}/export/csv`, {
49
+ params: { ...ctx, ...query },
50
+ });
51
+ }
52
+ async getExampleJson() {
53
+ return this.requestPublic('GET', `/${this.resourcePath}/examples/json`);
54
+ }
55
+ async getExampleCsv() {
56
+ return this.requestTextPublic('GET', `/${this.resourcePath}/examples/csv`);
57
+ }
58
+ }
@@ -1,11 +1,11 @@
1
1
  import type { Shop, CreateShopRequest, UpdateShopRequest, DeleteDataResult } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export declare class ShopsClient extends BaseClient {
4
- getShops(tenantId?: number): Promise<Shop[]>;
5
- getShop(id: number): Promise<Shop>;
6
- createShop(request: CreateShopRequest): Promise<Shop>;
7
- updateShop(id: number, request: UpdateShopRequest): Promise<Shop>;
8
- deleteShop(id: number): Promise<void>;
9
- deleteShopData(id: number): Promise<DeleteDataResult>;
4
+ getAll(tenantId?: number): Promise<Shop[]>;
5
+ getById(id: number): Promise<Shop>;
6
+ create(request: CreateShopRequest): Promise<Shop>;
7
+ update(id: number, request: UpdateShopRequest): Promise<Shop>;
8
+ delete(id: number): Promise<void>;
9
+ deleteData(id: number): Promise<DeleteDataResult>;
10
10
  }
11
11
  //# sourceMappingURL=shops-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shops-client.d.ts","sourceRoot":"","sources":["../../src/clients/shops-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,UAAU;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAI5C,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG5D"}
1
+ {"version":3,"file":"shops-client.d.ts","sourceRoot":"","sources":["../../src/clients/shops-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,UAAU;IACnC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAI1C,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,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAGxD"}
@@ -1,21 +1,21 @@
1
1
  import { BaseClient } from './base-client.js';
2
2
  export class ShopsClient extends BaseClient {
3
- async getShops(tenantId) {
3
+ async getAll(tenantId) {
4
4
  return this.request('GET', '/shops', { params: { tenantId } });
5
5
  }
6
- async getShop(id) {
6
+ async getById(id) {
7
7
  return this.request('GET', `/shops/${id}`);
8
8
  }
9
- async createShop(request) {
9
+ async create(request) {
10
10
  return this.request('POST', '/shops', { body: request });
11
11
  }
12
- async updateShop(id, request) {
12
+ async update(id, request) {
13
13
  return this.request('PUT', `/shops/${id}`, { body: request });
14
14
  }
15
- async deleteShop(id) {
15
+ async delete(id) {
16
16
  return this.request('DELETE', `/shops/${id}`);
17
17
  }
18
- async deleteShopData(id) {
18
+ async deleteData(id) {
19
19
  return this.request('DELETE', `/shops/${id}/data`);
20
20
  }
21
21
  }
@@ -1,12 +1,12 @@
1
1
  import type { Sku, CreateSkuRequest, UpdateSkuRequest, ImportSkuItem, SkuExportItem, SkuImportResult, ShopContextParams, PaginationQuery, PaginatedResponse } from '@sales-planner/shared';
2
2
  import { ImportExportBaseClient } from './import-export-base-client.js';
3
3
  export declare class SkusClient extends ImportExportBaseClient {
4
- getSkus(ctx: ShopContextParams, query?: PaginationQuery): Promise<PaginatedResponse<Sku>>;
5
- getSku(ctx: ShopContextParams, id: number): Promise<Sku>;
6
- getSkuByCode(ctx: ShopContextParams, code: string): Promise<Sku>;
7
- createSku(ctx: ShopContextParams, request: CreateSkuRequest): Promise<Sku>;
8
- updateSku(ctx: ShopContextParams, id: number, request: UpdateSkuRequest): Promise<Sku>;
9
- deleteSku(ctx: ShopContextParams, id: number): Promise<void>;
4
+ getAll(ctx: ShopContextParams, query?: PaginationQuery): Promise<PaginatedResponse<Sku>>;
5
+ getById(ctx: ShopContextParams, id: number): Promise<Sku>;
6
+ getByCode(ctx: ShopContextParams, code: string): Promise<Sku>;
7
+ create(ctx: ShopContextParams, request: CreateSkuRequest): Promise<Sku>;
8
+ update(ctx: ShopContextParams, id: number, request: UpdateSkuRequest): Promise<Sku>;
9
+ delete(ctx: ShopContextParams, id: number): Promise<void>;
10
10
  importJson(ctx: ShopContextParams, items: ImportSkuItem[]): Promise<SkuImportResult>;
11
11
  importCsv(ctx: ShopContextParams, csvContent: string): Promise<SkuImportResult>;
12
12
  exportJson(ctx: ShopContextParams): Promise<SkuExportItem[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"skus-client.d.ts","sourceRoot":"","sources":["../../src/clients/skus-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,qBAAa,UAAW,SAAQ,sBAAsB;IAC9C,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAIzF,MAAM,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD,YAAY,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIhE,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1E,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE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,CAAC;IAI7D,MAAM,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAIvE,MAAM,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAInF,MAAM,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpF,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI/E,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI5D,SAAS,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD,cAAc,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAI1C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
@@ -1,21 +1,21 @@
1
1
  import { ImportExportBaseClient } from './import-export-base-client.js';
2
2
  export class SkusClient extends ImportExportBaseClient {
3
- async getSkus(ctx, query) {
3
+ async getAll(ctx, query) {
4
4
  return this.request('GET', '/skus', { params: { ...ctx, ...query } });
5
5
  }
6
- async getSku(ctx, id) {
6
+ async getById(ctx, id) {
7
7
  return this.request('GET', `/skus/${id}`, { params: ctx });
8
8
  }
9
- async getSkuByCode(ctx, code) {
9
+ async getByCode(ctx, code) {
10
10
  return this.request('GET', `/skus/code/${encodeURIComponent(code)}`, { params: ctx });
11
11
  }
12
- async createSku(ctx, request) {
12
+ async create(ctx, request) {
13
13
  return this.request('POST', '/skus', { body: request, params: ctx });
14
14
  }
15
- async updateSku(ctx, id, request) {
15
+ async update(ctx, id, request) {
16
16
  return this.request('PUT', `/skus/${id}`, { body: request, params: ctx });
17
17
  }
18
- async deleteSku(ctx, id) {
18
+ async delete(ctx, id) {
19
19
  return this.request('DELETE', `/skus/${id}`, { params: ctx });
20
20
  }
21
21
  async importJson(ctx, items) {
@@ -1,17 +1,19 @@
1
- import type { Status, CreateStatusRequest, UpdateStatusRequest, ImportStatusItem, StatusExportItem, ImportResult, ShopContextParams } from '@sales-planner/shared';
2
- import { ImportExportBaseClient } from './import-export-base-client.js';
3
- export declare class StatusesClient extends ImportExportBaseClient {
4
- getStatuses(ctx: ShopContextParams): Promise<Status[]>;
5
- getStatus(ctx: ShopContextParams, id: number): Promise<Status>;
6
- getStatusByCode(ctx: ShopContextParams, code: string): Promise<Status>;
7
- createStatus(ctx: ShopContextParams, request: CreateStatusRequest): Promise<Status>;
8
- updateStatus(ctx: ShopContextParams, id: number, request: UpdateStatusRequest): Promise<Status>;
9
- deleteStatus(ctx: ShopContextParams, id: number): Promise<void>;
10
- importJson(ctx: ShopContextParams, items: ImportStatusItem[]): Promise<ImportResult>;
11
- importCsv(ctx: ShopContextParams, csvContent: string): Promise<ImportResult>;
12
- exportJson(ctx: ShopContextParams): Promise<StatusExportItem[]>;
13
- exportCsv(ctx: ShopContextParams): Promise<string>;
14
- getExampleJson(): Promise<StatusExportItem[]>;
15
- getExampleCsv(): Promise<string>;
1
+ import type {
2
+ Status,
3
+ CreateStatusRequest,
4
+ UpdateStatusRequest,
5
+ ImportStatusItem,
6
+ StatusExportItem,
7
+ } from '@sales-planner/shared';
8
+ import type { ClientConfig } from './base-client.js';
9
+ import { CodedEntityClient } from './coded-entity-client.js';
10
+ export declare class StatusesClient extends CodedEntityClient<
11
+ Status,
12
+ CreateStatusRequest,
13
+ UpdateStatusRequest,
14
+ ImportStatusItem,
15
+ StatusExportItem
16
+ > {
17
+ constructor(config: ClientConfig);
16
18
  }
17
- //# sourceMappingURL=statuses-client.d.ts.map
19
+ //# sourceMappingURL=stat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AC,MAAM,CAAC;IAIlD,cAAc,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI7C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
1
+ {"version":3,"file":"statuses-client.d.ts","sourceRoot":"","sources":["../../src/clients/statuses-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,qBAAa,cAAe,SAAQ,iBAAiB,CACnD,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,CACjB;gBACa,MAAM,EAAE,YAAY;CAGjC"}
@@ -1,40 +1,6 @@
1
- import { ImportExportBaseClient } from './import-export-base-client.js';
2
- export class StatusesClient extends ImportExportBaseClient {
3
- async getStatuses(ctx) {
4
- return this.request('GET', '/statuses', { params: ctx });
5
- }
6
- async getStatus(ctx, id) {
7
- return this.request('GET', `/statuses/${id}`, { params: ctx });
8
- }
9
- async getStatusByCode(ctx, code) {
10
- return this.request('GET', `/statuses/code/${encodeURIComponent(code)}`, { params: ctx });
11
- }
12
- async createStatus(ctx, request) {
13
- return this.request('POST', '/statuses', { body: request, params: ctx });
14
- }
15
- async updateStatus(ctx, id, request) {
16
- return this.request('PUT', `/statuses/${id}`, { body: request, params: ctx });
17
- }
18
- async deleteStatus(ctx, id) {
19
- return this.request('DELETE', `/statuses/${id}`, { params: ctx });
20
- }
21
- // Import/Export methods
22
- async importJson(ctx, items) {
23
- return this.request('POST', '/statuses/import/json', { body: items, params: ctx });
24
- }
25
- async importCsv(ctx, csvContent) {
26
- return this.uploadCsv('/statuses/import/csv', csvContent, ctx);
27
- }
28
- async exportJson(ctx) {
29
- return this.request('GET', '/statuses/export/json', { params: ctx });
30
- }
31
- async exportCsv(ctx) {
32
- return this.requestText('GET', '/statuses/export/csv', { params: ctx });
33
- }
34
- async getExampleJson() {
35
- return this.requestPublic('GET', '/statuses/examples/json');
36
- }
37
- async getExampleCsv() {
38
- return this.requestTextPublic('GET', '/statuses/examples/csv');
1
+ import { CodedEntityClient } from './coded-entity-client.js';
2
+ export class StatusesClient extends CodedEntityClient {
3
+ constructor(config) {
4
+ super(config, 'statuses');
39
5
  }
40
6
  }
@@ -1,17 +1,19 @@
1
- import type { Supplier, CreateSupplierRequest, UpdateSupplierRequest, ImportSupplierItem, SupplierExportItem, ImportResult, ShopContextParams } from '@sales-planner/shared';
2
- import { ImportExportBaseClient } from './import-export-base-client.js';
3
- export declare class SuppliersClient extends ImportExportBaseClient {
4
- getSuppliers(ctx: ShopContextParams): Promise<Supplier[]>;
5
- getSupplier(ctx: ShopContextParams, id: number): Promise<Supplier>;
6
- getSupplierByCode(ctx: ShopContextParams, code: string): Promise<Supplier>;
7
- createSupplier(ctx: ShopContextParams, request: CreateSupplierRequest): Promise<Supplier>;
8
- updateSupplier(ctx: ShopContextParams, id: number, request: UpdateSupplierRequest): Promise<Supplier>;
9
- deleteSupplier(ctx: ShopContextParams, id: number): Promise<void>;
10
- importJson(ctx: ShopContextParams, items: ImportSupplierItem[]): Promise<ImportResult>;
11
- importCsv(ctx: ShopContextParams, csvContent: string): Promise<ImportResult>;
12
- exportJson(ctx: ShopContextParams): Promise<SupplierExportItem[]>;
13
- exportCsv(ctx: ShopContextParams): Promise<string>;
14
- getExampleJson(): Promise<SupplierExportItem[]>;
15
- getExampleCsv(): Promise<string>;
1
+ import type {
2
+ Supplier,
3
+ CreateSupplierRequest,
4
+ UpdateSupplierRequest,
5
+ ImportSupplierItem,
6
+ SupplierExportItem,
7
+ } from '@sales-planner/shared';
8
+ import type { ClientConfig } from './base-client.js';
9
+ import { CodedEntityClient } from './coded-entity-client.js';
10
+ export declare class SuppliersClient extends CodedEntityClient<
11
+ Supplier,
12
+ CreateSupplierRequest,
13
+ UpdateSupplierRequest,
14
+ ImportSupplierItem,
15
+ SupplierExportItem
16
+ > {
17
+ constructor(config: ClientConfig);
16
18
  }
17
- //# sourceMappingURL=suppliers-client.d.ts.map
19
+ //# sourceMappingURL=suppliers-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"suppliers-client.d.ts","sourceRoot":"","sources":["../../src/clients/suppliers-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,qBAAa,eAAgB,SAAQ,sBAAsB;IACnD,YAAY,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIzD,WAAW,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlE,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI1E,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIzF,cAAc,CAClB,GAAG,EAAE,iBAAiB,EACtB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,QAAQ,CAAC;IAId,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAItF,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI5E,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAIjE,SAAS,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD,cAAc,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAI/C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
1
+ {"version":3,"file":"suppliers-client.d.ts","sourceRoot":"","sources":["../../src/clients/suppliers-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,qBAAa,eAAgB,SAAQ,iBAAiB,CACpD,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,MAAM,EAAE,YAAY;CAGjC"}
@@ -1,39 +1,6 @@
1
- import { ImportExportBaseClient } from './import-export-base-client.js';
2
- export class SuppliersClient extends ImportExportBaseClient {
3
- async getSuppliers(ctx) {
4
- return this.request('GET', '/suppliers', { params: ctx });
5
- }
6
- async getSupplier(ctx, id) {
7
- return this.request('GET', `/suppliers/${id}`, { params: ctx });
8
- }
9
- async getSupplierByCode(ctx, code) {
10
- return this.request('GET', `/suppliers/code/${encodeURIComponent(code)}`, { params: ctx });
11
- }
12
- async createSupplier(ctx, request) {
13
- return this.request('POST', '/suppliers', { params: ctx, body: request });
14
- }
15
- async updateSupplier(ctx, id, request) {
16
- return this.request('PUT', `/suppliers/${id}`, { params: ctx, body: request });
17
- }
18
- async deleteSupplier(ctx, id) {
19
- return this.request('DELETE', `/suppliers/${id}`, { params: ctx });
20
- }
21
- async importJson(ctx, items) {
22
- return this.request('POST', '/suppliers/import/json', { params: ctx, body: items });
23
- }
24
- async importCsv(ctx, csvContent) {
25
- return this.uploadCsv('/suppliers/import/csv', csvContent, ctx);
26
- }
27
- async exportJson(ctx) {
28
- return this.request('GET', '/suppliers/export/json', { params: ctx });
29
- }
30
- async exportCsv(ctx) {
31
- return this.requestText('GET', '/suppliers/export/csv', { params: ctx });
32
- }
33
- async getExampleJson() {
34
- return this.requestPublic('GET', '/suppliers/examples/json');
35
- }
36
- async getExampleCsv() {
37
- return this.requestTextPublic('GET', '/suppliers/examples/csv');
1
+ import { CodedEntityClient } from './coded-entity-client.js';
2
+ export class SuppliersClient extends CodedEntityClient {
3
+ constructor(config) {
4
+ super(config, 'suppliers');
38
5
  }
39
6
  }
@@ -1,11 +1,11 @@
1
1
  import type { Tenant, CreateTenantRequest, UpdateTenantRequest, CreateTenantWithShopRequest, TenantWithShopAndApiKey } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export declare class TenantsClient extends BaseClient {
4
- getTenants(): Promise<Tenant[]>;
5
- getTenant(id: number): Promise<Tenant>;
6
- createTenant(request: CreateTenantRequest): Promise<Tenant>;
7
- createTenantWithShopAndUser(request: CreateTenantWithShopRequest): Promise<TenantWithShopAndApiKey>;
8
- updateTenant(id: number, request: UpdateTenantRequest): Promise<Tenant>;
9
- deleteTenant(id: number): Promise<void>;
4
+ getAll(): Promise<Tenant[]>;
5
+ getById(id: number): Promise<Tenant>;
6
+ create(request: CreateTenantRequest): Promise<Tenant>;
7
+ createWithShopAndUser(request: CreateTenantWithShopRequest): Promise<TenantWithShopAndApiKey>;
8
+ update(id: number, request: UpdateTenantRequest): Promise<Tenant>;
9
+ delete(id: number): Promise<void>;
10
10
  }
11
11
  //# sourceMappingURL=tenants-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,aAAc,SAAQ,UAAU;IACrC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAItC,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3D,2BAA2B,CAC/B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC;IAI7B,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvE,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
1
+ {"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI3B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,qBAAqB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -1,21 +1,21 @@
1
1
  import { BaseClient } from './base-client.js';
2
2
  export class TenantsClient extends BaseClient {
3
- async getTenants() {
3
+ async getAll() {
4
4
  return this.request('GET', '/tenants');
5
5
  }
6
- async getTenant(id) {
6
+ async getById(id) {
7
7
  return this.request('GET', `/tenants/${id}`);
8
8
  }
9
- async createTenant(request) {
9
+ async create(request) {
10
10
  return this.request('POST', '/tenants', { body: request });
11
11
  }
12
- async createTenantWithShopAndUser(request) {
12
+ async createWithShopAndUser(request) {
13
13
  return this.request('POST', '/tenants/with-shop-and-user', { body: request });
14
14
  }
15
- async updateTenant(id, request) {
15
+ async update(id, request) {
16
16
  return this.request('PUT', `/tenants/${id}`, { body: request });
17
17
  }
18
- async deleteTenant(id) {
18
+ async delete(id) {
19
19
  return this.request('DELETE', `/tenants/${id}`);
20
20
  }
21
21
  }
@@ -1,9 +1,9 @@
1
1
  import type { CreateUserRoleRequest, GetUserRolesQuery, UserRoleResponse } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export declare class UserRolesClient extends BaseClient {
4
- getUserRoles(query?: GetUserRolesQuery): Promise<UserRoleResponse[]>;
5
- getUserRole(id: number): Promise<UserRoleResponse>;
6
- createUserRole(request: CreateUserRoleRequest): Promise<UserRoleResponse>;
7
- deleteUserRole(id: number): Promise<void>;
4
+ getAll(query?: GetUserRolesQuery): Promise<UserRoleResponse[]>;
5
+ getById(id: number): Promise<UserRoleResponse>;
6
+ create(request: CreateUserRoleRequest): Promise<UserRoleResponse>;
7
+ delete(id: number): Promise<void>;
8
8
  }
9
9
  //# sourceMappingURL=user-roles-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-roles-client.d.ts","sourceRoot":"","sources":["../../src/clients/user-roles-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,eAAgB,SAAQ,UAAU;IACvC,YAAY,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IASpE,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlD,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIzE,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhD"}
1
+ {"version":3,"file":"user-roles-client.d.ts","sourceRoot":"","sources":["../../src/clients/user-roles-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,eAAgB,SAAQ,UAAU;IACvC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAS9D,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI9C,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -1,6 +1,6 @@
1
1
  import { BaseClient } from './base-client.js';
2
2
  export class UserRolesClient extends BaseClient {
3
- async getUserRoles(query) {
3
+ async getAll(query) {
4
4
  const params = new URLSearchParams();
5
5
  if (query?.userId)
6
6
  params.append('userId', String(query.userId));
@@ -11,13 +11,13 @@ export class UserRolesClient extends BaseClient {
11
11
  const queryString = params.toString();
12
12
  return this.request('GET', `/user-roles${queryString ? `?${queryString}` : ''}`);
13
13
  }
14
- async getUserRole(id) {
14
+ async getById(id) {
15
15
  return this.request('GET', `/user-roles/${id}`);
16
16
  }
17
- async createUserRole(request) {
17
+ async create(request) {
18
18
  return this.request('POST', '/user-roles', { body: request });
19
19
  }
20
- async deleteUserRole(id) {
20
+ async delete(id) {
21
21
  return this.request('DELETE', `/user-roles/${id}`);
22
22
  }
23
23
  }
@@ -1,9 +1,9 @@
1
1
  import type { User, CreateUserRequest } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export declare class UsersClient extends BaseClient {
4
- getUsers(): Promise<User[]>;
5
- getUser(id: number): Promise<User>;
6
- createUser(request: CreateUserRequest): Promise<User>;
7
- deleteUser(id: number): Promise<void>;
4
+ getAll(): Promise<User[]>;
5
+ getById(id: number): Promise<User>;
6
+ create(request: CreateUserRequest): Promise<User>;
7
+ delete(id: number): Promise<void>;
8
8
  }
9
9
  //# 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,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,UAAU;IACnC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAI3B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5C"}
1
+ {"version":3,"file":"users-client.d.ts","sourceRoot":"","sources":["../../src/clients/users-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,UAAU;IACnC,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIzB,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,15 +1,15 @@
1
1
  import { BaseClient } from './base-client.js';
2
2
  export class UsersClient extends BaseClient {
3
- async getUsers() {
3
+ async getAll() {
4
4
  return this.request('GET', '/users');
5
5
  }
6
- async getUser(id) {
6
+ async getById(id) {
7
7
  return this.request('GET', `/users/${id}`);
8
8
  }
9
- async createUser(request) {
9
+ async create(request) {
10
10
  return this.request('POST', '/users', { body: request });
11
11
  }
12
- async deleteUser(id) {
12
+ async delete(id) {
13
13
  return this.request('DELETE', `/users/${id}`);
14
14
  }
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sales-planner/http-client",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
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": "0.12.0"
27
+ "@sales-planner/shared": "0.13.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.7.3"