@ikatec/digisac-api-sdk 4.10.0 → 4.11.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 (57) hide show
  1. package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs +28 -0
  2. package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs.map +1 -1
  3. package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts +24 -0
  4. package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts.map +1 -1
  5. package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs +28 -0
  6. package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs.map +1 -1
  7. package/dist/apis/contactBlockLists/types.d.ts +6 -1
  8. package/dist/apis/contactBlockLists/types.d.ts.map +1 -1
  9. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs +31 -1
  10. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs.map +1 -1
  11. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts +28 -2
  12. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts.map +1 -1
  13. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs +31 -1
  14. package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs.map +1 -1
  15. package/dist/apis/contactBlockListsControls/types.d.ts +7 -0
  16. package/dist/apis/contactBlockListsControls/types.d.ts.map +1 -1
  17. package/dist/apis/distribution/DistributionApi.cjs +25 -0
  18. package/dist/apis/distribution/DistributionApi.cjs.map +1 -1
  19. package/dist/apis/distribution/DistributionApi.d.ts +20 -1
  20. package/dist/apis/distribution/DistributionApi.d.ts.map +1 -1
  21. package/dist/apis/distribution/DistributionApi.mjs +25 -0
  22. package/dist/apis/distribution/DistributionApi.mjs.map +1 -1
  23. package/dist/apis/distribution/types.d.ts +18 -1
  24. package/dist/apis/distribution/types.d.ts.map +1 -1
  25. package/dist/apis/integrations/IntegrationsApi.cjs +17 -0
  26. package/dist/apis/integrations/IntegrationsApi.cjs.map +1 -1
  27. package/dist/apis/integrations/IntegrationsApi.d.ts +15 -2
  28. package/dist/apis/integrations/IntegrationsApi.d.ts.map +1 -1
  29. package/dist/apis/integrations/IntegrationsApi.mjs +17 -0
  30. package/dist/apis/integrations/IntegrationsApi.mjs.map +1 -1
  31. package/dist/apis/integrations/types.d.ts +15 -6
  32. package/dist/apis/integrations/types.d.ts.map +1 -1
  33. package/dist/core/BaseCrudApi.cjs +3 -1
  34. package/dist/core/BaseCrudApi.cjs.map +1 -1
  35. package/dist/core/BaseCrudApi.d.ts +6 -4
  36. package/dist/core/BaseCrudApi.d.ts.map +1 -1
  37. package/dist/core/BaseCrudApi.mjs +3 -1
  38. package/dist/core/BaseCrudApi.mjs.map +1 -1
  39. package/dist/core/types.d.ts +1 -1
  40. package/dist/core/types.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/apis/contactBlockLists/ContactBlockListsApi.test.ts +57 -0
  43. package/src/apis/contactBlockLists/ContactBlockListsApi.ts +44 -0
  44. package/src/apis/contactBlockLists/types.ts +6 -1
  45. package/src/apis/contactBlockListsControls/ContactBlockListsControlsApi.test.ts +48 -0
  46. package/src/apis/contactBlockListsControls/ContactBlockListsControlsApi.ts +49 -2
  47. package/src/apis/contactBlockListsControls/types.ts +7 -0
  48. package/src/apis/distribution/DistributionApi.test.ts +65 -0
  49. package/src/apis/distribution/DistributionApi.ts +39 -1
  50. package/src/apis/distribution/types.ts +17 -1
  51. package/src/apis/integrations/IntegrationsApi.test.ts +42 -0
  52. package/src/apis/integrations/IntegrationsApi.ts +35 -2
  53. package/src/apis/integrations/types.ts +25 -6
  54. package/src/apis/payloads.test-d.ts +58 -0
  55. package/src/core/BaseCrudApi.test-d.ts +11 -1
  56. package/src/core/BaseCrudApi.ts +15 -6
  57. package/src/core/types.ts +4 -2
@@ -1,9 +1,22 @@
1
1
  import type { ApiClient } from '../../core/ApiClient';
2
2
  import type { ListQuery } from '../../core/types';
3
3
  import { BaseCrudApi } from '../../core/BaseCrudApi';
4
- import type { Integration, CreateIntegrationPayload, UpdateIntegrationPayload } from './types';
5
- export declare class IntegrationsApi extends BaseCrudApi<Integration, CreateIntegrationPayload, UpdateIntegrationPayload, ListQuery<Integration>, 'OK'> {
4
+ import type { Integration, CreateIntegrationPayload, UpdateIntegrationPayload, IntegrationWriteResponse } from './types';
5
+ /** Integrations of the account (buttons and events of the UI). `getById` answers `null` for an unknown id. */
6
+ export declare class IntegrationsApi extends BaseCrudApi<Integration, CreateIntegrationPayload, UpdateIntegrationPayload, ListQuery<Integration>, 'OK', IntegrationWriteResponse, IntegrationWriteResponse> {
6
7
  constructor(client: ApiClient);
8
+ /**
9
+ * Creates an integration. Resolves `{}` — also when the type is unique (`event_ticket_transfer`,
10
+ * `event_ticket_closed`), already exists in the account and nothing is created. Find the integration with
11
+ * `getMany` (e.g. by `text`).
12
+ * @permissions integrations.create
13
+ */
14
+ create(body: CreateIntegrationPayload, headers?: Record<string, string>): Promise<IntegrationWriteResponse>;
15
+ /**
16
+ * Updates an integration. Resolves `{}`; read it again with `getById`. An unknown id answers 500.
17
+ * @permissions integrations.view OR integrations.update
18
+ */
19
+ updateById(id: string, body: UpdateIntegrationPayload, headers?: Record<string, string>): Promise<IntegrationWriteResponse>;
7
20
  /**
8
21
  * Deletes an integration. Resolves the text `'OK'`; an unknown id answers 500.
9
22
  * @permissions integrations.view OR integrations.destroy
@@ -1 +1 @@
1
- {"version":3,"file":"IntegrationsApi.d.ts","sourceRoot":"","sources":["../../../src/apis/integrations/IntegrationsApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,wBAAw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MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjF"}
@@ -1,11 +1,28 @@
1
1
  import { BaseCrudApi } from "../../core/BaseCrudApi.mjs";
2
2
 
3
3
  //#region src/apis/integrations/IntegrationsApi.ts
4
+ /** Integrations of the account (buttons and events of the UI). `getById` answers `null` for an unknown id. */
4
5
  var IntegrationsApi = class extends BaseCrudApi {
5
6
  constructor(client) {
6
7
  super(client, "/integrations");
7
8
  }
8
9
  /**
10
+ * Creates an integration. Resolves `{}` — also when the type is unique (`event_ticket_transfer`,
11
+ * `event_ticket_closed`), already exists in the account and nothing is created. Find the integration with
12
+ * `getMany` (e.g. by `text`).
13
+ * @permissions integrations.create
14
+ */
15
+ create(body, headers) {
16
+ return super.create(body, headers);
17
+ }
18
+ /**
19
+ * Updates an integration. Resolves `{}`; read it again with `getById`. An unknown id answers 500.
20
+ * @permissions integrations.view OR integrations.update
21
+ */
22
+ updateById(id, body, headers) {
23
+ return super.updateById(id, body, headers);
24
+ }
25
+ /**
9
26
  * Deletes an integration. Resolves the text `'OK'`; an unknown id answers 500.
10
27
  * @permissions integrations.view OR integrations.destroy
11
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"IntegrationsApi.mjs","names":[],"sources":["../../../src/apis/integrations/IntegrationsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport type { ListQuery } from '../../core/types'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { Integration, CreateIntegrationPayload, UpdateIntegrationPayload } from './types'\n\nexport class IntegrationsApi extends BaseCrudApi<\n Integration,\n CreateIntegrationPayload,\n UpdateIntegrationPayload,\n ListQuery<Integration>,\n 'OK'\n> {\n constructor(client: ApiClient) {\n super(client, '/integrations')\n }\n\n /**\n * Deletes an integration. Resolves the text `'OK'`; an unknown id answers 500.\n * @permissions integrations.view OR integrations.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;AAKA,IAAa,kBAAb,cAAqC,YAMnC;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,gBAAgB;;;;;;CAOhC,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ"}
1
+ {"version":3,"file":"IntegrationsApi.mjs","names":[],"sources":["../../../src/apis/integrations/IntegrationsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport type { ListQuery } from '../../core/types'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type {\n Integration,\n CreateIntegrationPayload,\n UpdateIntegrationPayload,\n IntegrationWriteResponse,\n} from './types'\n\n/** Integrations of the account (buttons and events of the UI). `getById` answers `null` for an unknown id. */\nexport class IntegrationsApi extends BaseCrudApi<\n Integration,\n CreateIntegrationPayload,\n UpdateIntegrationPayload,\n ListQuery<Integration>,\n 'OK',\n IntegrationWriteResponse,\n IntegrationWriteResponse\n> {\n constructor(client: ApiClient) {\n super(client, '/integrations')\n }\n\n /**\n * Creates an integration. Resolves `{}` — also when the type is unique (`event_ticket_transfer`,\n * `event_ticket_closed`), already exists in the account and nothing is created. Find the integration with\n * `getMany` (e.g. by `text`).\n * @permissions integrations.create\n */\n override create(\n body: CreateIntegrationPayload,\n headers?: Record<string, string>,\n ): Promise<IntegrationWriteResponse> {\n return super.create(body, headers)\n }\n\n /**\n * Updates an integration. Resolves `{}`; read it again with `getById`. An unknown id answers 500.\n * @permissions integrations.view OR integrations.update\n */\n override updateById(\n id: string,\n body: UpdateIntegrationPayload,\n headers?: Record<string, string>,\n ): Promise<IntegrationWriteResponse> {\n return super.updateById(id, body, headers)\n }\n\n /**\n * Deletes an integration. Resolves the text `'OK'`; an unknown id answers 500.\n * @permissions integrations.view OR integrations.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;AAWA,IAAa,kBAAb,cAAqC,YAQnC;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,gBAAgB;;;;;;;;CAShC,AAAS,OACP,MACA,SACmC;AACnC,SAAO,MAAM,OAAO,MAAM,QAAQ;;;;;;CAOpC,AAAS,WACP,IACA,MACA,SACmC;AACnC,SAAO,MAAM,WAAW,IAAI,MAAM,QAAQ;;;;;;CAO5C,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ"}
@@ -1,26 +1,35 @@
1
+ /**
2
+ * The types the UI shows: buttons (`menu_button` in the header, `context_menu_button_*` in the contact and
3
+ * message menus) and events that open the integration when a ticket is transferred or closed (unique per
4
+ * account). The backend accepts any string.
5
+ */
6
+ export type IntegrationType = 'menu_button' | 'context_menu_button_contact_modal' | 'context_menu_button_contact_side_list' | 'context_menu_button_message' | 'event_ticket_transfer' | 'event_ticket_closed' | (string & {});
7
+ export type IntegrationSize = 'sm' | 'md' | 'lg' | (string & {});
1
8
  export type Integration = {
2
9
  id: string;
3
- type: string;
10
+ type: IntegrationType;
4
11
  url: string | null;
5
12
  icon: string | null;
6
13
  text: string | null;
7
- size: string | null;
14
+ size: IntegrationSize | null;
8
15
  accountId: string;
9
16
  createdAt: string;
10
17
  updatedAt: string;
11
18
  };
19
+ /** What `create` and `updateById` resolve to: an empty object. */
20
+ export type IntegrationWriteResponse = Record<string, never>;
12
21
  export type CreateIntegrationPayload = {
13
- type: string;
22
+ type: IntegrationType;
14
23
  url?: string;
15
24
  icon?: string;
16
25
  text?: string;
17
- size?: string;
26
+ size?: IntegrationSize;
18
27
  };
19
28
  export type UpdateIntegrationPayload = {
20
- type?: string;
29
+ type?: IntegrationType;
21
30
  url?: string | null;
22
31
  icon?: string | null;
23
32
  text?: string | null;
24
- size?: string | null;
33
+ size?: IntegrationSize | null;
25
34
  };
26
35
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/integrations/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/integrations/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,mCAAmC,GACnC,uCAAuC,GACvC,6BAA6B,GAC7B,uBAAuB,GACvB,qBAAqB,GACrB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,eAAe,CAAA;IACrB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,kEAAkE;AAClE,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAE5D,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,eAAe,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,eAAe,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;CAC9B,CAAA"}
@@ -4,7 +4,9 @@ const require_core_BaseReadApi = require('./BaseReadApi.cjs');
4
4
  //#region src/core/BaseCrudApi.ts
5
5
  /**
6
6
  * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.
7
- * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`).
7
+ * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`);
8
+ * `TCreateResponse` and `TUpdateResponse` are what `create` and `updateById` resolve to, for the routes
9
+ * that do not answer the resource (an empty body, `{}`, another model).
8
10
  */
9
11
  var BaseCrudApi = class extends require_core_BaseReadApi.BaseReadApi {
10
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCrudApi.cjs","names":["BaseReadApi"],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/**\n * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.\n * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`).\n */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n TDeleteResponse = TResponse,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.post<TResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.put<TResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TDeleteResponse> {\n return this.client.delete<TDeleteResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;;;;;AAoBA,IAAa,cAAb,cAOUA,qCAEV;;;;;CAKE,OAAO,MAAe,SAAsD;AAC1E,SAAO,KAAK,OAAO,KAAyB,KAAK,UAAU,MAAM,QAAQ;;;;;;CAO3E,WAAW,IAAY,MAAe,SAAsD;AAC1F,SAAO,KAAK,OAAO,IAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAOrF,WAAW,IAAY,SAA4D;AACjF,SAAO,KAAK,OAAO,OAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
1
+ {"version":3,"file":"BaseCrudApi.cjs","names":["BaseReadApi"],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/**\n * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.\n * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`);\n * `TCreateResponse` and `TUpdateResponse` are what `create` and `updateById` resolve to, for the routes\n * that do not answer the resource (an empty body, `{}`, another model).\n */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n TDeleteResponse = TResponse,\n TCreateResponse = TResponse,\n TUpdateResponse = TResponse,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements\n CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse, TCreateResponse, TUpdateResponse>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TCreateResponse> {\n return this.client.post<TCreateResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(\n id: string,\n body: TUpdate,\n headers?: Record<string, string>,\n ): Promise<TUpdateResponse> {\n return this.client.put<TUpdateResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TDeleteResponse> {\n return this.client.delete<TDeleteResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,IAAa,cAAb,cASUA,qCAGV;;;;;CAKE,OAAO,MAAe,SAA4D;AAChF,SAAO,KAAK,OAAO,KAA+B,KAAK,UAAU,MAAM,QAAQ;;;;;;CAOjF,WACE,IACA,MACA,SAC0B;AAC1B,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAO3F,WAAW,IAAY,SAA4D;AACjF,SAAO,KAAK,OAAO,OAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
@@ -3,19 +3,21 @@ import type { CrudApi, ListQuery } from './types';
3
3
  export type { WhereClause, IncludeItem, ListQuery, GetByIdQuery, Paginated, HasGetMany, HasGetById, HasCreate, HasUpdateById, HasDeleteById, CrudApi, } from './types';
4
4
  /**
5
5
  * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.
6
- * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`).
6
+ * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`);
7
+ * `TCreateResponse` and `TUpdateResponse` are what `create` and `updateById` resolve to, for the routes
8
+ * that do not answer the resource (an empty body, `{}`, another model).
7
9
  */
8
- export declare class BaseCrudApi<TResponse, TCreate, TUpdate = TCreate, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>, TDeleteResponse = TResponse> extends BaseReadApi<TResponse, TQuery> implements CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse> {
10
+ export declare class BaseCrudApi<TResponse, TCreate, TUpdate = TCreate, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>, TDeleteResponse = TResponse, TCreateResponse = TResponse, TUpdateResponse = TResponse> extends BaseReadApi<TResponse, TQuery> implements CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse, TCreateResponse, TUpdateResponse> {
9
11
  /**
10
12
  * Creates a new resource.
11
13
  * @permissions $resourceName.create
12
14
  */
13
- create(body: TCreate, headers?: Record<string, string>): Promise<TResponse>;
15
+ create(body: TCreate, headers?: Record<string, string>): Promise<TCreateResponse>;
14
16
  /**
15
17
  * Updates an existing resource by ID.
16
18
  * @permissions $resourceName.update
17
19
  */
18
- updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TResponse>;
20
+ updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TUpdateResponse>;
19
21
  /**
20
22
  * Deletes a resource by ID.
21
23
  * @permissions $resourceName.destroy
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCrudApi.d.ts","sourceRoot":"","sources":["../../src/core/BaseCrudApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACjD,YAAY,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,qBAAa,WAAW,CACtB,SAAS,EACT,OAAO,EACP,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,EAC1D,eAAe,GAAG,SAAS,CAE3B,SAAQ,WAAW,CAAC,SAAS,EAAE,MAAM,CACrC,YAAW,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC;IAExE;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,M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C,eAAe,CAAC;IAIjF;;;OAGG;IACH,UAAU,CACR,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,eAAe,CAAC;IAI3B;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;CAGnF"}
@@ -3,7 +3,9 @@ import { BaseReadApi } from "./BaseReadApi.mjs";
3
3
  //#region src/core/BaseCrudApi.ts
4
4
  /**
5
5
  * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.
6
- * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`).
6
+ * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`);
7
+ * `TCreateResponse` and `TUpdateResponse` are what `create` and `updateById` resolve to, for the routes
8
+ * that do not answer the resource (an empty body, `{}`, another model).
7
9
  */
8
10
  var BaseCrudApi = class extends BaseReadApi {
9
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCrudApi.mjs","names":[],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/**\n * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.\n * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`).\n */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n TDeleteResponse = TResponse,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.post<TResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.put<TResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TDeleteResponse> {\n return this.client.delete<TDeleteResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,cAAb,cAOU,YAEV;;;;;CAKE,OAAO,MAAe,SAAsD;AAC1E,SAAO,KAAK,OAAO,KAAyB,KAAK,UAAU,MAAM,QAAQ;;;;;;CAO3E,WAAW,IAAY,MAAe,SAAsD;AAC1F,SAAO,KAAK,OAAO,IAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAOrF,WAAW,IAAY,SAA4D;AACjF,SAAO,KAAK,OAAO,OAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
1
+ {"version":3,"file":"BaseCrudApi.mjs","names":[],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/**\n * Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`.\n * `TDeleteResponse` is what `deleteById` resolves to (most routes answer the text `'OK'`);\n * `TCreateResponse` and `TUpdateResponse` are what `create` and `updateById` resolve to, for the routes\n * that do not answer the resource (an empty body, `{}`, another model).\n */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n TDeleteResponse = TResponse,\n TCreateResponse = TResponse,\n TUpdateResponse = TResponse,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements\n CrudApi<TResponse, TCreate, TUpdate, TQuery, TDeleteResponse, TCreateResponse, TUpdateResponse>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TCreateResponse> {\n return this.client.post<TCreateResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(\n id: string,\n body: TUpdate,\n headers?: Record<string, string>,\n ): Promise<TUpdateResponse> {\n return this.client.put<TUpdateResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TDeleteResponse> {\n return this.client.delete<TDeleteResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAa,cAAb,cASU,YAGV;;;;;CAKE,OAAO,MAAe,SAA4D;AAChF,SAAO,KAAK,OAAO,KAA+B,KAAK,UAAU,MAAM,QAAQ;;;;;;CAOjF,WACE,IACA,MACA,SAC0B;AAC1B,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAO3F,WAAW,IAAY,SAA4D;AACjF,SAAO,KAAK,OAAO,OAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
@@ -107,6 +107,6 @@ export interface HasUpdateById<TResponse, TUpdate> {
107
107
  export interface HasDeleteById<TResponse> {
108
108
  deleteById(id: string, headers?: Record<string, string>): Promise<TResponse>;
109
109
  }
110
- export type CrudApi<TResponse, TCreate, TUpdate = TCreate, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>, TDeleteResponse = TResponse> = HasGetMany<TResponse, TQuery> & HasGetById<TResponse> & HasCreate<TResponse, TCreate> & HasUpdateById<TResponse, TUpdate> & HasDeleteById<TDeleteResponse>;
110
+ export type CrudApi<TResponse, TCreate, TUpdate = TCreate, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>, TDeleteResponse = TResponse, TCreateResponse = TResponse, TUpdateResponse = TResponse> = HasGetMany<TResponse, TQuery> & HasGetById<TResponse> & HasCreate<TCreateResponse, TCreate> & HasUpdateById<TUpdateResponse, TUpdate> & HasDeleteById<TDeleteResponse>;
111
111
  export {};
112
112
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAIxD,KAAK,mBAAmB,CAAC,CAAC,GAAG,SAAS,IAAI;IACxC,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,GAAG,CAAC,EAAE,IAAI,GAAG,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,CAAC,CAAA;CACT,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAA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,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5F;AAED,MAAM,WAAW,aAAa,CAAC,SAAS;IACtC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CAC7E;AAED,MAAM,MAAM,OAAO,CACjB,SAAS,EACT,OAAO,EACP,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,EAC1D,eAAe,GAAG,SAAS,EAC3B,eAAe,GAAG,SAAS,EAC3B,eAAe,GAAG,SAAS,IACzB,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,GAC/B,UAAU,CAAC,SAAS,CAAC,GACrB,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC,GACnC,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,GACvC,aAAa,CAAC,eAAe,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikatec/digisac-api-sdk",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -0,0 +1,57 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { ContactBlockListsApi } from './ContactBlockListsApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ get: vi.fn(),
12
+ post: vi.fn(),
13
+ put: vi.fn(),
14
+ patch: vi.fn(),
15
+ delete: vi.fn(),
16
+ }
17
+ }
18
+
19
+ // ── Tests ────────────────────────────────────────────────────────────
20
+
21
+ describe('ContactBlockListsApi', () => {
22
+ let client: ReturnType<typeof createMockClient>
23
+ let api: ContactBlockListsApi
24
+
25
+ beforeEach(() => {
26
+ client = createMockClient()
27
+ api = new ContactBlockListsApi(client)
28
+ })
29
+
30
+ describe('count', () => {
31
+ it('calls client.get with /contact-block-lists/count when no query is provided', async () => {
32
+ vi.mocked(client.get).mockResolvedValue({ count: 3 })
33
+ await expect(api.count()).resolves.toEqual({ count: 3 })
34
+ expect(client.get).toHaveBeenCalledWith('/contact-block-lists/count', undefined)
35
+ })
36
+
37
+ it('serializes the query and forwards custom headers', async () => {
38
+ const headers = { 'X-Custom': 'value' }
39
+ vi.mocked(client.get).mockResolvedValue({ count: 1 })
40
+ await api.count({ where: { name: 'QA' } }, headers)
41
+ const [url, sent] = vi.mocked(client.get).mock.calls[0] ?? []
42
+ expect(url).toContain('/contact-block-lists/count?')
43
+ expect(url).toContain('where')
44
+ expect(sent).toBe(headers)
45
+ })
46
+ })
47
+
48
+ it('create posts the name and the file of the CSV', async () => {
49
+ vi.mocked(client.post).mockResolvedValue({ id: 'list-1', status: 'ready' })
50
+ await api.create({ name: 'QA', fileId: 'file-1', defaultDDI: '55' })
51
+ expect(client.post).toHaveBeenCalledWith(
52
+ '/contact-block-lists',
53
+ { name: 'QA', fileId: 'file-1', defaultDDI: '55' },
54
+ undefined,
55
+ )
56
+ })
57
+ })
@@ -7,6 +7,10 @@ import type {
7
7
  UpdateContactBlockListPayload,
8
8
  } from './types'
9
9
 
10
+ /**
11
+ * Lists of numbers to block. A list is processed in the background after it is created (`status`
12
+ * `ready` → `done` or `error`). `getById` answers `null` for an unknown id.
13
+ */
10
14
  export class ContactBlockListsApi extends BaseCrudApi<
11
15
  ContactBlockList,
12
16
  CreateContactBlockListPayload,
@@ -18,6 +22,46 @@ export class ContactBlockListsApi extends BaseCrudApi<
18
22
  super(client, '/contact-block-lists')
19
23
  }
20
24
 
25
+ /**
26
+ * Counts the block lists matching the query.
27
+ * @permissions contacts.view OR contacts.block
28
+ */
29
+ count(
30
+ query?: ListQuery<ContactBlockList>,
31
+ headers?: Record<string, string>,
32
+ ): Promise<{ count: number }> {
33
+ return this.client.get<{ count: number }>(
34
+ `${this.basePath}/count${this.toQueryString(query)}`,
35
+ headers,
36
+ )
37
+ }
38
+
39
+ /**
40
+ * Creates a block list from a CSV uploaded with `FilesApi.createToUpload` (`attachedType:
41
+ * 'contact_block_list.file'` — with any other type the list is never processed). The CSV is
42
+ * comma-separated with the columns `ddi,number` (an empty DDI takes `defaultDDI`); invalid numbers are
43
+ * skipped. Resolves the list with `status: 'ready'`.
44
+ * @permissions contacts.view OR contacts.block
45
+ */
46
+ override create(
47
+ body: CreateContactBlockListPayload,
48
+ headers?: Record<string, string>,
49
+ ): Promise<ContactBlockList> {
50
+ return super.create(body, headers)
51
+ }
52
+
53
+ /**
54
+ * Updates a block list. `name` is required by the backend (400 without it). An unknown id answers 500.
55
+ * @permissions contacts.view OR contacts.update OR contacts.block
56
+ */
57
+ override updateById(
58
+ id: string,
59
+ body: UpdateContactBlockListPayload,
60
+ headers?: Record<string, string>,
61
+ ): Promise<ContactBlockList> {
62
+ return super.updateById(id, body, headers)
63
+ }
64
+
21
65
  /**
22
66
  * Deletes a block list and its numbers. Resolves the text `'OK'`; a list being processed (or with
23
67
  * a block/unblock in progress) answers 500.
@@ -1,3 +1,4 @@
1
+ import type { File } from '../files/types'
1
2
  import type { User } from '../users/types'
2
3
 
3
4
  export type ContactBlockListStatus = 'ready' | 'processing' | 'done' | 'error'
@@ -17,9 +18,11 @@ export type ContactBlockList = {
17
18
  deletedAt: string | null
18
19
  // relationships
19
20
  user?: User
21
+ /** The uploaded CSV (`include: ['importFile']`). */
22
+ importFile?: File
20
23
  }
21
24
 
22
- export type ContactBlockListRelationships = 'user'
25
+ export type ContactBlockListRelationships = 'user' | 'importFile'
23
26
 
24
27
  export type CreateContactBlockListPayload = {
25
28
  name: string
@@ -29,7 +32,9 @@ export type CreateContactBlockListPayload = {
29
32
  }
30
33
 
31
34
  export type UpdateContactBlockListPayload = {
35
+ /** Required by the backend (400 without it), even to change only `defaultDDI`. */
32
36
  name?: string
37
+ /** @deprecated Ignored by the backend: the numbers come only from the CSV of the create. */
33
38
  contacts?: string[]
34
39
  defaultDDI?: string | null
35
40
  }
@@ -0,0 +1,48 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { ContactBlockListsControlsApi } from './ContactBlockListsControlsApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ get: vi.fn(),
12
+ post: vi.fn(),
13
+ put: vi.fn(),
14
+ patch: vi.fn(),
15
+ delete: vi.fn(),
16
+ }
17
+ }
18
+
19
+ // ── Tests ────────────────────────────────────────────────────────────
20
+
21
+ describe('ContactBlockListsControlsApi', () => {
22
+ let client: ReturnType<typeof createMockClient>
23
+ let api: ContactBlockListsControlsApi
24
+
25
+ beforeEach(() => {
26
+ client = createMockClient()
27
+ api = new ContactBlockListsControlsApi(client)
28
+ })
29
+
30
+ it('count calls client.get with /contact-block-lists-controls/count', async () => {
31
+ vi.mocked(client.get).mockResolvedValue({ count: 2 })
32
+ await expect(api.count()).resolves.toEqual({ count: 2 })
33
+ expect(client.get).toHaveBeenCalledWith('/contact-block-lists-controls/count', undefined)
34
+ })
35
+
36
+ it('create posts the runs and resolves with no body', async () => {
37
+ vi.mocked(client.post).mockResolvedValue(undefined)
38
+ const body = {
39
+ reason: 'QA',
40
+ servicesIds: ['svc-1'],
41
+ contactBlockListsIds: ['list-1'],
42
+ action: 'block' as const,
43
+ revertExceptions: false,
44
+ }
45
+ await expect(api.create(body)).resolves.toBeUndefined()
46
+ expect(client.post).toHaveBeenCalledWith('/contact-block-lists-controls', body, undefined)
47
+ })
48
+ })
@@ -7,19 +7,66 @@ import type {
7
7
  UpdateContactBlockListsControlPayload,
8
8
  } from './types'
9
9
 
10
+ /**
11
+ * Block/unblock runs of block lists over connections. A run blocks (or unblocks) the contacts of the
12
+ * connection whose numbers are in the list, in the background, and blocking closes their open tickets.
13
+ * `getById` answers `null` for an unknown id.
14
+ */
10
15
  export class ContactBlockListsControlsApi extends BaseCrudApi<
11
16
  ContactBlockListsControl,
12
17
  CreateContactBlockListsControlPayload,
13
18
  UpdateContactBlockListsControlPayload,
14
19
  ListQuery<ContactBlockListsControl>,
15
- 'OK'
20
+ 'OK',
21
+ void
16
22
  > {
17
23
  constructor(client: ApiClient) {
18
24
  super(client, '/contact-block-lists-controls')
19
25
  }
20
26
 
21
27
  /**
22
- * Deletes a block/unblock run. Resolves the text `'OK'`.
28
+ * Counts the runs matching the query.
29
+ * @permissions contacts.view OR contacts.block
30
+ */
31
+ count(
32
+ query?: ListQuery<ContactBlockListsControl>,
33
+ headers?: Record<string, string>,
34
+ ): Promise<{ count: number }> {
35
+ return this.client.get<{ count: number }>(
36
+ `${this.basePath}/count${this.toQueryString(query)}`,
37
+ headers,
38
+ )
39
+ }
40
+
41
+ /**
42
+ * Starts the runs: one per connection × list of the body, all with the same `reason`. Resolves with no
43
+ * body — find the runs with `getMany` by `reason`.
44
+ * @permissions contacts.view OR contacts.block
45
+ */
46
+ override create(
47
+ body: CreateContactBlockListsControlPayload,
48
+ headers?: Record<string, string>,
49
+ ): Promise<void> {
50
+ return super.create(body, headers)
51
+ }
52
+
53
+ /**
54
+ * Updates a run. The backend requires `reason`, `servicesIds`, `contactBlockListsIds` and `action` (400
55
+ * without them), but ignores the ids, and a new `action` does not run anything again. An unknown id
56
+ * answers 500.
57
+ * @permissions contacts.view OR contacts.update OR contacts.block
58
+ */
59
+ override updateById(
60
+ id: string,
61
+ body: UpdateContactBlockListsControlPayload,
62
+ headers?: Record<string, string>,
63
+ ): Promise<ContactBlockListsControl> {
64
+ return super.updateById(id, body, headers)
65
+ }
66
+
67
+ /**
68
+ * Deletes a block/unblock run. Resolves the text `'OK'`; it does not undo the contacts already
69
+ * blocked or unblocked.
23
70
  * @permissions contacts.view OR contacts.destroy OR contacts.block
24
71
  */
25
72
  override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
@@ -31,12 +31,19 @@ export type ContactBlockListsControl = {
31
31
  export type ContactBlockListsControlRelationships = 'contactBlockList' | 'user' | 'service'
32
32
 
33
33
  export type CreateContactBlockListsControlPayload = {
34
+ /** Unique in the account (409 when another run already has it). */
34
35
  reason: string
35
36
  servicesIds: string[]
36
37
  contactBlockListsIds: string[]
37
38
  action: ContactBlockListsControlAction
39
+ /**
40
+ * Applies the opposite action to the contacts of the connection that are NOT in the list: with `block`, it
41
+ * unblocks them; with `unblock`, it blocks all of them.
42
+ */
43
+ revertExceptions?: boolean
38
44
  }
39
45
 
46
+ /** The backend requires the four fields (400 without them); the ids are ignored. */
40
47
  export type UpdateContactBlockListsControlPayload = {
41
48
  reason?: string
42
49
  servicesIds?: string[]
@@ -0,0 +1,65 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { DistributionApi } from './DistributionApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ get: vi.fn(),
12
+ post: vi.fn(),
13
+ put: vi.fn(),
14
+ patch: vi.fn(),
15
+ delete: vi.fn(),
16
+ }
17
+ }
18
+
19
+ // ── Tests ────────────────────────────────────────────────────────────
20
+
21
+ describe('DistributionApi', () => {
22
+ let client: ReturnType<typeof createMockClient>
23
+ let api: DistributionApi
24
+
25
+ beforeEach(() => {
26
+ client = createMockClient()
27
+ api = new DistributionApi(client)
28
+ })
29
+
30
+ describe('create', () => {
31
+ it('posts the body, links included, to /distribution', async () => {
32
+ vi.mocked(client.post).mockResolvedValue(undefined)
33
+ const body = { name: 'QA', maxNum: 1, redistributeAll: false, departments: [{ id: 'dep-1' }] }
34
+ const result = await api.create(body)
35
+ expect(client.post).toHaveBeenCalledWith('/distribution', body, undefined)
36
+ expect(result).toBeUndefined()
37
+ })
38
+ })
39
+
40
+ describe('updateById', () => {
41
+ it('sends the id in the body too, which is where the backend reads it', async () => {
42
+ vi.mocked(client.put).mockResolvedValue([])
43
+ await api.updateById('dist-1', { name: 'QA', roles: [{ id: 'role-1' }] })
44
+ expect(client.put).toHaveBeenCalledWith(
45
+ '/distribution/dist-1',
46
+ { name: 'QA', roles: [{ id: 'role-1' }], id: 'dist-1' },
47
+ undefined,
48
+ )
49
+ })
50
+
51
+ it('keeps the id of the URL over an id of the body and forwards custom headers', async () => {
52
+ const headers = { 'X-Custom': 'value' }
53
+ await api.updateById('dist-1', { id: 'other' } as never, headers)
54
+ expect(client.put).toHaveBeenCalledWith('/distribution/dist-1', { id: 'dist-1' }, headers)
55
+ })
56
+ })
57
+
58
+ describe('deleteById', () => {
59
+ it('calls client.delete with /distribution/:id', async () => {
60
+ vi.mocked(client.delete).mockResolvedValue(undefined)
61
+ await api.deleteById('dist-1')
62
+ expect(client.delete).toHaveBeenCalledWith('/distribution/dist-1', undefined)
63
+ })
64
+ })
65
+ })