@murabei-data-science/pumpwood-services 1.0.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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +504 -0
  3. package/dist/example-usage.d.ts +8 -0
  4. package/dist/example-usage.d.ts.map +1 -0
  5. package/dist/example-usage.js +156 -0
  6. package/dist/example-usage.js.map +1 -0
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +43 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/jest.setup.d.ts +2 -0
  12. package/dist/jest.setup.d.ts.map +1 -0
  13. package/dist/jest.setup.js +8 -0
  14. package/dist/jest.setup.js.map +1 -0
  15. package/dist/src/core/api-service.d.ts +58 -0
  16. package/dist/src/core/api-service.d.ts.map +1 -0
  17. package/dist/src/core/api-service.js +192 -0
  18. package/dist/src/core/api-service.js.map +1 -0
  19. package/dist/src/core/pumpwood-client.d.ts +46 -0
  20. package/dist/src/core/pumpwood-client.d.ts.map +1 -0
  21. package/dist/src/core/pumpwood-client.js +110 -0
  22. package/dist/src/core/pumpwood-client.js.map +1 -0
  23. package/dist/src/core/safe-await.d.ts +20 -0
  24. package/dist/src/core/safe-await.d.ts.map +1 -0
  25. package/dist/src/core/safe-await.js +31 -0
  26. package/dist/src/core/safe-await.js.map +1 -0
  27. package/dist/src/services/delete.d.ts +17 -0
  28. package/dist/src/services/delete.d.ts.map +1 -0
  29. package/dist/src/services/delete.js +28 -0
  30. package/dist/src/services/delete.js.map +1 -0
  31. package/dist/src/services/execute-action-file.d.ts +43 -0
  32. package/dist/src/services/execute-action-file.d.ts.map +1 -0
  33. package/dist/src/services/execute-action-file.js +50 -0
  34. package/dist/src/services/execute-action-file.js.map +1 -0
  35. package/dist/src/services/execute-action.d.ts +47 -0
  36. package/dist/src/services/execute-action.d.ts.map +1 -0
  37. package/dist/src/services/execute-action.js +54 -0
  38. package/dist/src/services/execute-action.js.map +1 -0
  39. package/dist/src/services/execute-static-action-file.d.ts +46 -0
  40. package/dist/src/services/execute-static-action-file.d.ts.map +1 -0
  41. package/dist/src/services/execute-static-action-file.js +55 -0
  42. package/dist/src/services/execute-static-action-file.js.map +1 -0
  43. package/dist/src/services/execute-static-action.d.ts +33 -0
  44. package/dist/src/services/execute-static-action.d.ts.map +1 -0
  45. package/dist/src/services/execute-static-action.js +44 -0
  46. package/dist/src/services/execute-static-action.js.map +1 -0
  47. package/dist/src/services/get-sso-token.d.ts +19 -0
  48. package/dist/src/services/get-sso-token.d.ts.map +1 -0
  49. package/dist/src/services/get-sso-token.js +58 -0
  50. package/dist/src/services/get-sso-token.js.map +1 -0
  51. package/dist/src/services/list-without-pag.d.ts +23 -0
  52. package/dist/src/services/list-without-pag.d.ts.map +1 -0
  53. package/dist/src/services/list-without-pag.js +37 -0
  54. package/dist/src/services/list-without-pag.js.map +1 -0
  55. package/dist/src/services/list.d.ts +18 -0
  56. package/dist/src/services/list.d.ts.map +1 -0
  57. package/dist/src/services/list.js +32 -0
  58. package/dist/src/services/list.js.map +1 -0
  59. package/dist/src/services/login-sso.d.ts +16 -0
  60. package/dist/src/services/login-sso.d.ts.map +1 -0
  61. package/dist/src/services/login-sso.js +50 -0
  62. package/dist/src/services/login-sso.js.map +1 -0
  63. package/dist/src/services/login.d.ts +21 -0
  64. package/dist/src/services/login.d.ts.map +1 -0
  65. package/dist/src/services/login.js +54 -0
  66. package/dist/src/services/login.js.map +1 -0
  67. package/dist/src/services/retrieve-file.d.ts +25 -0
  68. package/dist/src/services/retrieve-file.d.ts.map +1 -0
  69. package/dist/src/services/retrieve-file.js +36 -0
  70. package/dist/src/services/retrieve-file.js.map +1 -0
  71. package/dist/src/services/retrieve-options.d.ts +18 -0
  72. package/dist/src/services/retrieve-options.d.ts.map +1 -0
  73. package/dist/src/services/retrieve-options.js +29 -0
  74. package/dist/src/services/retrieve-options.js.map +1 -0
  75. package/dist/src/services/retrieve.d.ts +13 -0
  76. package/dist/src/services/retrieve.d.ts.map +1 -0
  77. package/dist/src/services/retrieve.js +26 -0
  78. package/dist/src/services/retrieve.js.map +1 -0
  79. package/dist/src/services/save.d.ts +18 -0
  80. package/dist/src/services/save.d.ts.map +1 -0
  81. package/dist/src/services/save.js +31 -0
  82. package/dist/src/services/save.js.map +1 -0
  83. package/dist/src/services/upload.d.ts +25 -0
  84. package/dist/src/services/upload.d.ts.map +1 -0
  85. package/dist/src/services/upload.js +41 -0
  86. package/dist/src/services/upload.js.map +1 -0
  87. package/dist/src/types/error.d.ts +13 -0
  88. package/dist/src/types/error.d.ts.map +1 -0
  89. package/dist/src/types/error.js +53 -0
  90. package/dist/src/types/error.js.map +1 -0
  91. package/dist/src/types/http.d.ts +42 -0
  92. package/dist/src/types/http.d.ts.map +1 -0
  93. package/dist/src/types/http.js +3 -0
  94. package/dist/src/types/http.js.map +1 -0
  95. package/package.json +34 -0
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteService = void 0;
4
+ const safe_await_js_1 = require("../core/safe-await.js");
5
+ /**
6
+ * Deletes an item for a given model from the API.
7
+ * @template T - The expected type of the delete response data (defaults to void).
8
+ * @param {ApiService} api - An instance of the ApiService.
9
+ * @param {string} modelClass - The name of the model class to delete from.
10
+ * @param {number} pk - The primary key of the item to delete.
11
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error, consistent with safeAwait.
12
+ *
13
+ * @example
14
+ * const [result, error] = await DeleteService(api, "users", 123);
15
+ * if (error) console.error("Failed to delete user:", error);
16
+ * else console.log("User deleted successfully");
17
+ */
18
+ const DeleteService = async (api, modelClass, pk) => {
19
+ const normalizedModelClass = modelClass.toLowerCase();
20
+ const [response, error] = await (0, safe_await_js_1.safeAwait)(api.request("DELETE", `/${normalizedModelClass}/delete/${String(pk)}/`));
21
+ if (error) {
22
+ console.error("==> DeleteService ERROR:", error);
23
+ return [null, error];
24
+ }
25
+ return [response, null];
26
+ };
27
+ exports.DeleteService = DeleteService;
28
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/services/delete.ts"],"names":[],"mappings":";;;AAEA,yDAAkD;AAElD;;;;;;;;;;;;GAYG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,GAAe,EACf,UAAkB,EAClB,EAAU,EAC8B,EAAE;IAC1C,MAAM,oBAAoB,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAEtD,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,yBAAS,EACvC,GAAG,CAAC,OAAO,CAAI,QAAQ,EAAE,IAAI,oBAAoB,WAAW,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAC3E,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB"}
@@ -0,0 +1,43 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { IFileData } from "../types/http.js";
3
+ import type { ApiService } from "../core/api-service.js";
4
+ /**
5
+ * Executes an action on a model instance and returns the result as a binary file (Blob).
6
+ * Used for actions that generate file downloads such as Excel exports, PDF reports, etc.
7
+ *
8
+ * ⚠️ Blob URL lifecycle: always call URL.revokeObjectURL() after the download is triggered
9
+ * to avoid memory leaks. See example below.
10
+ *
11
+ * @param {ApiService} params.api - An instance of the ApiService.
12
+ * @param {string} params.modelClass - The name of the model class.
13
+ * @param {string} params.actionName - The name of the action to execute.
14
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
15
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters.
16
+ * @returns {Promise<[IFileData | null, IErrorDict | null]>} A tuple containing the file data or an error.
17
+ *
18
+ * @example
19
+ * const [fileData, error] = await ExecuteActionFileService({
20
+ * api,
21
+ * modelClass: "Report",
22
+ * actionName: "export_excel",
23
+ * });
24
+ * if (error) throw new Error(error.message);
25
+ *
26
+ * const url = URL.createObjectURL(fileData!.blob);
27
+ * try {
28
+ * const a = document.createElement("a");
29
+ * a.href = url;
30
+ * a.download = "report.xlsx";
31
+ * a.click();
32
+ * } finally {
33
+ * URL.revokeObjectURL(url); // always revoke to prevent memory leaks
34
+ * }
35
+ */
36
+ export declare const ExecuteActionFileService: ({ api, modelClass, actionName, parameters, queryParams, }: {
37
+ api: ApiService;
38
+ modelClass: string;
39
+ actionName: string;
40
+ parameters?: Record<string, any>;
41
+ queryParams?: Record<string, string>;
42
+ }) => Promise<[IFileData | null, IErrorDict | null]>;
43
+ //# sourceMappingURL=execute-action-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-action-file.d.ts","sourceRoot":"","sources":["../../../src/services/execute-action-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,wBAAwB,GAAU,2DAM5C;IACD,GAAG,EAAE,UAAU,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,KAAG,OAAO,CAAC,CAAC,SAAS,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAuBhD,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecuteActionFileService = void 0;
4
+ const safe_await_js_1 = require("../core/safe-await.js");
5
+ /**
6
+ * Executes an action on a model instance and returns the result as a binary file (Blob).
7
+ * Used for actions that generate file downloads such as Excel exports, PDF reports, etc.
8
+ *
9
+ * ⚠️ Blob URL lifecycle: always call URL.revokeObjectURL() after the download is triggered
10
+ * to avoid memory leaks. See example below.
11
+ *
12
+ * @param {ApiService} params.api - An instance of the ApiService.
13
+ * @param {string} params.modelClass - The name of the model class.
14
+ * @param {string} params.actionName - The name of the action to execute.
15
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
16
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters.
17
+ * @returns {Promise<[IFileData | null, IErrorDict | null]>} A tuple containing the file data or an error.
18
+ *
19
+ * @example
20
+ * const [fileData, error] = await ExecuteActionFileService({
21
+ * api,
22
+ * modelClass: "Report",
23
+ * actionName: "export_excel",
24
+ * });
25
+ * if (error) throw new Error(error.message);
26
+ *
27
+ * const url = URL.createObjectURL(fileData!.blob);
28
+ * try {
29
+ * const a = document.createElement("a");
30
+ * a.href = url;
31
+ * a.download = "report.xlsx";
32
+ * a.click();
33
+ * } finally {
34
+ * URL.revokeObjectURL(url); // always revoke to prevent memory leaks
35
+ * }
36
+ */
37
+ const ExecuteActionFileService = async ({ api, modelClass, actionName, parameters, queryParams, }) => {
38
+ const normalizedModelClass = modelClass.toLowerCase();
39
+ const requestBody = parameters ?? {};
40
+ const [response, error] = await (0, safe_await_js_1.safeAwait)(queryParams
41
+ ? api.postFileRequest(`/${normalizedModelClass}/actions/${actionName}/`, requestBody, queryParams)
42
+ : api.postFileRequest(`/${normalizedModelClass}/actions/${actionName}/`, requestBody));
43
+ if (error) {
44
+ console.error("==> ExecuteActionFileService ERROR:", error);
45
+ return [null, error];
46
+ }
47
+ return [response, null];
48
+ };
49
+ exports.ExecuteActionFileService = ExecuteActionFileService;
50
+ //# sourceMappingURL=execute-action-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-action-file.js","sourceRoot":"","sources":["../../../src/services/execute-action-file.ts"],"names":[],"mappings":";;;AAGA,yDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,GAAG,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAOZ,EAAkD,EAAE;IACnD,MAAM,oBAAoB,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACtD,MAAM,WAAW,GAAG,UAAU,IAAI,EAAE,CAAC;IAErC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,yBAAS,EACvC,WAAW;QACT,CAAC,CAAC,GAAG,CAAC,eAAe,CACjB,IAAI,oBAAoB,YAAY,UAAU,GAAG,EACjD,WAAW,EACX,WAAW,CACZ;QACH,CAAC,CAAC,GAAG,CAAC,eAAe,CACjB,IAAI,oBAAoB,YAAY,UAAU,GAAG,EACjD,WAAW,CACZ,CACN,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAnCW,QAAA,wBAAwB,4BAmCnC"}
@@ -0,0 +1,47 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { ApiService } from "../core/api-service.js";
3
+ /**
4
+ * Executes an action on a model instance.
5
+ *
6
+ * Actions are custom methods defined on Pumpwood models that perform specific operations.
7
+ * This service calls the action endpoint with the provided parameters.
8
+ *
9
+ * @template T - The expected type of the action response data.
10
+ * @param {object} params - The parameters object.
11
+ * @param {ApiService} params.api - An instance of the ApiService.
12
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
13
+ * @param {number} params.pk - The primary key of the item to execute the action on.
14
+ * @param {string} params.actionName - The name of the action to execute.
15
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
16
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
17
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
18
+ *
19
+ * @example
20
+ * const [result, error] = await ExecuteActionService({
21
+ * api: api,
22
+ * modelClass: "MaterialApprovalActivity",
23
+ * pk: 123,
24
+ * actionName: "review",
25
+ * parameters: { new_status: "approved" }
26
+ * });
27
+ * if (error) console.error("Failed to execute action:", error);
28
+ * else console.log("Action executed successfully:", result);
29
+ *
30
+ * @example
31
+ * const [result, error] = await ExecuteActionService({
32
+ * api: api,
33
+ * modelClass: "MaterialApprovalActivity",
34
+ * pk: 0,
35
+ * actionName: "get_statistics",
36
+ * parameters: { year: 2024 }
37
+ * });
38
+ */
39
+ export declare const ExecuteActionService: <T = any>({ api, modelClass, pk, actionName, parameters, queryParams, }: {
40
+ api: ApiService;
41
+ modelClass: string;
42
+ pk: number;
43
+ actionName: string;
44
+ parameters?: Record<string, any>;
45
+ queryParams?: Record<string, string>;
46
+ }) => Promise<[T | null, IErrorDict | null]>;
47
+ //# sourceMappingURL=execute-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-action.d.ts","sourceRoot":"","sources":["../../../src/services/execute-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,oBAAoB,GAAU,CAAC,GAAG,GAAG,EAAE,+DAOjD;IACD,GAAG,EAAE,UAAU,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,KAAG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAyBxC,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecuteActionService = void 0;
4
+ const safe_await_js_1 = require("../core/safe-await.js");
5
+ /**
6
+ * Executes an action on a model instance.
7
+ *
8
+ * Actions are custom methods defined on Pumpwood models that perform specific operations.
9
+ * This service calls the action endpoint with the provided parameters.
10
+ *
11
+ * @template T - The expected type of the action response data.
12
+ * @param {object} params - The parameters object.
13
+ * @param {ApiService} params.api - An instance of the ApiService.
14
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
15
+ * @param {number} params.pk - The primary key of the item to execute the action on.
16
+ * @param {string} params.actionName - The name of the action to execute.
17
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
18
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
19
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
20
+ *
21
+ * @example
22
+ * const [result, error] = await ExecuteActionService({
23
+ * api: api,
24
+ * modelClass: "MaterialApprovalActivity",
25
+ * pk: 123,
26
+ * actionName: "review",
27
+ * parameters: { new_status: "approved" }
28
+ * });
29
+ * if (error) console.error("Failed to execute action:", error);
30
+ * else console.log("Action executed successfully:", result);
31
+ *
32
+ * @example
33
+ * const [result, error] = await ExecuteActionService({
34
+ * api: api,
35
+ * modelClass: "MaterialApprovalActivity",
36
+ * pk: 0,
37
+ * actionName: "get_statistics",
38
+ * parameters: { year: 2024 }
39
+ * });
40
+ */
41
+ const ExecuteActionService = async ({ api, modelClass, pk, actionName, parameters, queryParams, }) => {
42
+ const normalizedModelClass = modelClass.toLowerCase();
43
+ const requestBody = parameters || {};
44
+ const [response, error] = await (0, safe_await_js_1.safeAwait)(queryParams
45
+ ? api.request("POST", `/${normalizedModelClass}/actions/${actionName}/${String(pk)}/`, requestBody, queryParams)
46
+ : api.request("POST", `/${normalizedModelClass}/actions/${actionName}/${String(pk)}/`, requestBody));
47
+ if (error) {
48
+ console.error("==> ExecuteActionService ERROR:", error);
49
+ return [null, error];
50
+ }
51
+ return [response, null];
52
+ };
53
+ exports.ExecuteActionService = ExecuteActionService;
54
+ //# sourceMappingURL=execute-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-action.js","sourceRoot":"","sources":["../../../src/services/execute-action.ts"],"names":[],"mappings":";;;AAEA,yDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,MAAM,oBAAoB,GAAG,KAAK,EAAW,EAClD,GAAG,EACH,UAAU,EACV,EAAE,EACF,UAAU,EACV,UAAU,EACV,WAAW,GAQZ,EAA0C,EAAE;IAC3C,MAAM,oBAAoB,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACtD,MAAM,WAAW,GAAG,UAAU,IAAI,EAAE,CAAC;IAErC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,yBAAS,EACvC,WAAW;QACT,CAAC,CAAC,GAAG,CAAC,OAAO,CACT,MAAM,EACN,IAAI,oBAAoB,YAAY,UAAU,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,EAC/D,WAAW,EACX,WAAW,CACZ;QACH,CAAC,CAAC,GAAG,CAAC,OAAO,CACT,MAAM,EACN,IAAI,oBAAoB,YAAY,UAAU,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,EAC/D,WAAW,CACZ,CACN,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAvCW,QAAA,oBAAoB,wBAuC/B"}
@@ -0,0 +1,46 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { IFileData } from "../types/http.js";
3
+ import type { ApiService } from "../core/api-service.js";
4
+ /**
5
+ * Executes a static action on a model class (no instance required) and returns the result as a binary file (Blob).
6
+ *
7
+ * Static actions are class-level methods that don't require a specific instance.
8
+ *
9
+ * ⚠️ Blob URL lifecycle: always call URL.revokeObjectURL() after the download is triggered
10
+ * to avoid memory leaks.
11
+ *
12
+ * @param {object} params - The parameters object.
13
+ * @param {ApiService} params.api - An instance of the ApiService.
14
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
15
+ * @param {string} params.actionName - The name of the static action to execute.
16
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
17
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
18
+ * @returns {Promise<[IFileData | null, IErrorDict | null]>} A tuple containing the file data or an error.
19
+ *
20
+ * @example
21
+ * const [fileData, error] = await ExecuteStaticActionFileService({
22
+ * api,
23
+ * modelClass: "Report",
24
+ * actionName: "export_global_stats",
25
+ * parameters: { year: 2024 }
26
+ * });
27
+ * if (error) throw new Error(error.message);
28
+ *
29
+ * const url = URL.createObjectURL(fileData!.blob);
30
+ * try {
31
+ * const a = document.createElement("a");
32
+ * a.href = url;
33
+ * a.download = "stats.xlsx";
34
+ * a.click();
35
+ * } finally {
36
+ * URL.revokeObjectURL(url);
37
+ * }
38
+ */
39
+ export declare const ExecuteStaticActionFileService: ({ api, modelClass, actionName, parameters, queryParams, }: {
40
+ api: ApiService;
41
+ modelClass: string;
42
+ actionName: string;
43
+ parameters?: Record<string, any>;
44
+ queryParams?: Record<string, string>;
45
+ }) => Promise<[IFileData | null, IErrorDict | null]>;
46
+ //# sourceMappingURL=execute-static-action-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-static-action-file.d.ts","sourceRoot":"","sources":["../../../src/services/execute-static-action-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,8BAA8B,GAAU,2DAMlD;IACD,GAAG,EAAE,UAAU,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,KAAG,OAAO,CAAC,CAAC,SAAS,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAsBhD,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecuteStaticActionFileService = void 0;
4
+ const execute_action_file_js_1 = require("./execute-action-file.js");
5
+ /**
6
+ * Executes a static action on a model class (no instance required) and returns the result as a binary file (Blob).
7
+ *
8
+ * Static actions are class-level methods that don't require a specific instance.
9
+ *
10
+ * ⚠️ Blob URL lifecycle: always call URL.revokeObjectURL() after the download is triggered
11
+ * to avoid memory leaks.
12
+ *
13
+ * @param {object} params - The parameters object.
14
+ * @param {ApiService} params.api - An instance of the ApiService.
15
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
16
+ * @param {string} params.actionName - The name of the static action to execute.
17
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
18
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
19
+ * @returns {Promise<[IFileData | null, IErrorDict | null]>} A tuple containing the file data or an error.
20
+ *
21
+ * @example
22
+ * const [fileData, error] = await ExecuteStaticActionFileService({
23
+ * api,
24
+ * modelClass: "Report",
25
+ * actionName: "export_global_stats",
26
+ * parameters: { year: 2024 }
27
+ * });
28
+ * if (error) throw new Error(error.message);
29
+ *
30
+ * const url = URL.createObjectURL(fileData!.blob);
31
+ * try {
32
+ * const a = document.createElement("a");
33
+ * a.href = url;
34
+ * a.download = "stats.xlsx";
35
+ * a.click();
36
+ * } finally {
37
+ * URL.revokeObjectURL(url);
38
+ * }
39
+ */
40
+ const ExecuteStaticActionFileService = async ({ api, modelClass, actionName, parameters, queryParams, }) => {
41
+ const params = {
42
+ api,
43
+ modelClass,
44
+ actionName,
45
+ };
46
+ if (parameters !== undefined) {
47
+ params.parameters = parameters;
48
+ }
49
+ if (queryParams !== undefined) {
50
+ params.queryParams = queryParams;
51
+ }
52
+ return (0, execute_action_file_js_1.ExecuteActionFileService)(params);
53
+ };
54
+ exports.ExecuteStaticActionFileService = ExecuteStaticActionFileService;
55
+ //# sourceMappingURL=execute-static-action-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-static-action-file.js","sourceRoot":"","sources":["../../../src/services/execute-static-action-file.ts"],"names":[],"mappings":";;;AAGA,qEAAoE;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACI,MAAM,8BAA8B,GAAG,KAAK,EAAE,EACnD,GAAG,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAOZ,EAAkD,EAAE;IACnD,MAAM,MAAM,GAMR;QACF,GAAG;QACH,UAAU;QACV,UAAU;KACX,CAAC;IAEF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,OAAO,IAAA,iDAAwB,EAAC,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC;AAlCW,QAAA,8BAA8B,kCAkCzC"}
@@ -0,0 +1,33 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { ApiService } from "../core/api-service.js";
3
+ /**
4
+ * Executes a static action on a model class (no instance required).
5
+ *
6
+ * Static actions are class-level methods that don't require a specific instance.
7
+ * This is a convenience wrapper around ExecuteActionService with pk=0.
8
+ *
9
+ * @template T - The expected type of the action response data.
10
+ * @param {object} params - The parameters object.
11
+ * @param {ApiService} params.api - An instance of the ApiService.
12
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
13
+ * @param {string} params.actionName - The name of the static action to execute.
14
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
15
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
16
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
17
+ *
18
+ * @example
19
+ * const [stats, error] = await ExecuteStaticActionService({
20
+ * api: api,
21
+ * modelClass: "MaterialApprovalActivity",
22
+ * actionName: "get_statistics",
23
+ * parameters: { year: 2024 }
24
+ * });
25
+ */
26
+ export declare const ExecuteStaticActionService: <T = any>({ api, modelClass, actionName, parameters, queryParams, }: {
27
+ api: ApiService;
28
+ modelClass: string;
29
+ actionName: string;
30
+ parameters?: Record<string, any>;
31
+ queryParams?: Record<string, string>;
32
+ }) => Promise<[T | null, IErrorDict | null]>;
33
+ //# sourceMappingURL=execute-static-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-static-action.d.ts","sourceRoot":"","sources":["../../../src/services/execute-static-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,0BAA0B,GAAU,CAAC,GAAG,GAAG,EAAE,2DAMvD;IACD,GAAG,EAAE,UAAU,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,KAAG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAwBxC,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecuteStaticActionService = void 0;
4
+ const execute_action_js_1 = require("./execute-action.js");
5
+ /**
6
+ * Executes a static action on a model class (no instance required).
7
+ *
8
+ * Static actions are class-level methods that don't require a specific instance.
9
+ * This is a convenience wrapper around ExecuteActionService with pk=0.
10
+ *
11
+ * @template T - The expected type of the action response data.
12
+ * @param {object} params - The parameters object.
13
+ * @param {ApiService} params.api - An instance of the ApiService.
14
+ * @param {string} params.modelClass - The name of the model class to execute the action on.
15
+ * @param {string} params.actionName - The name of the static action to execute.
16
+ * @param {Record<string, any>} [params.parameters] - Optional parameters to pass to the action.
17
+ * @param {Record<string, string>} [params.queryParams] - Optional query parameters to append to the URL.
18
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
19
+ *
20
+ * @example
21
+ * const [stats, error] = await ExecuteStaticActionService({
22
+ * api: api,
23
+ * modelClass: "MaterialApprovalActivity",
24
+ * actionName: "get_statistics",
25
+ * parameters: { year: 2024 }
26
+ * });
27
+ */
28
+ const ExecuteStaticActionService = async ({ api, modelClass, actionName, parameters, queryParams, }) => {
29
+ const params = {
30
+ api,
31
+ modelClass,
32
+ pk: 0,
33
+ actionName,
34
+ };
35
+ if (parameters !== undefined) {
36
+ params.parameters = parameters;
37
+ }
38
+ if (queryParams !== undefined) {
39
+ params.queryParams = queryParams;
40
+ }
41
+ return (0, execute_action_js_1.ExecuteActionService)(params);
42
+ };
43
+ exports.ExecuteStaticActionService = ExecuteStaticActionService;
44
+ //# sourceMappingURL=execute-static-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-static-action.js","sourceRoot":"","sources":["../../../src/services/execute-static-action.ts"],"names":[],"mappings":";;;AAEA,2DAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,0BAA0B,GAAG,KAAK,EAAW,EACxD,GAAG,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAOZ,EAA0C,EAAE;IAC3C,MAAM,MAAM,GAOR;QACF,GAAG;QACH,UAAU;QACV,EAAE,EAAE,CAAC;QACL,UAAU;KACX,CAAC;IAEF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,OAAO,IAAA,wCAAoB,EAAI,MAAM,CAAC,CAAC;AACzC,CAAC,CAAC;AApCW,QAAA,0BAA0B,8BAoCrC"}
@@ -0,0 +1,19 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { IGetSSOTokenResult } from "../types/http.js";
3
+ /**
4
+ * Exchanges an SSO callback URL for a Pumpwood token and user info.
5
+ * Called after the OAuth2 provider redirects back to the application.
6
+ *
7
+ * @param {string} url - The full SSO callback URL (including query params from the provider).
8
+ * @returns {Promise<[IGetSSOTokenResult | null, IErrorDict | null]>} A tuple with the token + user or an error.
9
+ *
10
+ * @example
11
+ * const [result, error] = await GetSSOTokenService(callbackUrl);
12
+ * if (error) console.error("SSO token exchange failed:", error.message);
13
+ * else {
14
+ * setCookie("PumpwoodAuthorization", result.token);
15
+ * setCookie("user", JSON.stringify(result.user));
16
+ * }
17
+ */
18
+ export declare const GetSSOTokenService: (url: string) => Promise<[IGetSSOTokenResult | null, IErrorDict | null]>;
19
+ //# sourceMappingURL=get-sso-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sso-token.d.ts","sourceRoot":"","sources":["../../../src/services/get-sso-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,KACV,OAAO,CAAC,CAAC,kBAAkB,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CA4CxD,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSSOTokenService = void 0;
4
+ const safe_await_js_1 = require("../core/safe-await.js");
5
+ const error_js_1 = require("../types/error.js");
6
+ /**
7
+ * Exchanges an SSO callback URL for a Pumpwood token and user info.
8
+ * Called after the OAuth2 provider redirects back to the application.
9
+ *
10
+ * @param {string} url - The full SSO callback URL (including query params from the provider).
11
+ * @returns {Promise<[IGetSSOTokenResult | null, IErrorDict | null]>} A tuple with the token + user or an error.
12
+ *
13
+ * @example
14
+ * const [result, error] = await GetSSOTokenService(callbackUrl);
15
+ * if (error) console.error("SSO token exchange failed:", error.message);
16
+ * else {
17
+ * setCookie("PumpwoodAuthorization", result.token);
18
+ * setCookie("user", JSON.stringify(result.user));
19
+ * }
20
+ */
21
+ const GetSSOTokenService = async (url) => {
22
+ if (!url) {
23
+ return [null, (0, error_js_1.normalizeToErrorDict)(new Error("GetSSOTokenService: url is required"))];
24
+ }
25
+ const [response, fetchError] = await (0, safe_await_js_1.safeAwait)(fetch(url));
26
+ if (fetchError) {
27
+ return [null, fetchError];
28
+ }
29
+ if (!response.ok) {
30
+ const errorText = await response.text();
31
+ return [null, (0, error_js_1.normalizeToErrorDict)((0, error_js_1.createHttpError)(response.status, `HTTP ${response.status}: ${errorText}`))];
32
+ }
33
+ const [jsonData, jsonError] = await (0, safe_await_js_1.safeAwait)(response.json());
34
+ if (jsonError) {
35
+ return [null, jsonError];
36
+ }
37
+ if (!jsonData.token) {
38
+ return [null, (0, error_js_1.normalizeToErrorDict)(new Error("GetSSOTokenService: response did not contain a token"))];
39
+ }
40
+ if (!jsonData.user?.email) {
41
+ return [null, (0, error_js_1.normalizeToErrorDict)(new Error("GetSSOTokenService: response did not contain user.email"))];
42
+ }
43
+ if (!jsonData.user?.username) {
44
+ return [null, (0, error_js_1.normalizeToErrorDict)(new Error("GetSSOTokenService: response did not contain user.username"))];
45
+ }
46
+ return [
47
+ {
48
+ token: jsonData.token,
49
+ user: {
50
+ email: jsonData.user.email,
51
+ username: jsonData.user.username,
52
+ },
53
+ },
54
+ null,
55
+ ];
56
+ };
57
+ exports.GetSSOTokenService = GetSSOTokenService;
58
+ //# sourceMappingURL=get-sso-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sso-token.js","sourceRoot":"","sources":["../../../src/services/get-sso-token.ts"],"names":[],"mappings":";;;AAEA,yDAAkD;AAClD,gDAA0E;AAE1E;;;;;;;;;;;;;;GAcG;AACI,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAC8C,EAAE;IAC3D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,IAAI,EAAE,IAAA,+BAAoB,EAAC,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,MAAM,IAAA,yBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3D,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,EAAE,IAAA,+BAAoB,EAAC,IAAA,0BAAe,EAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjH,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,MAAM,IAAA,yBAAS,EAAmE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjI,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,EAAE,IAAA,+BAAoB,EAAC,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC,CAAC;IACzG,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,EAAE,IAAA,+BAAoB,EAAC,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC,CAAC,CAAC;IAC5G,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,EAAE,IAAA,+BAAoB,EAAC,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC,CAAC,CAAC;IAC/G,CAAC;IAED,OAAO;QACL;YACE,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE;gBACJ,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK;gBAC1B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;aACjC;SACF;QACD,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AA9CW,QAAA,kBAAkB,sBA8C7B"}
@@ -0,0 +1,23 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { ApiService } from "../core/api-service.js";
3
+ /**
4
+ * Fetches all items for a given model without pagination.
5
+ * Use for small datasets (comments, versions, lookups) where pagination is not needed.
6
+ * @template T - The expected type of the response data.
7
+ * @param {ApiService} api - An instance of the ApiService.
8
+ * @param {string} modelClass - The name of the model class to list.
9
+ * @param {any} [body] - Optional request body (filter_dict, fields, order_by, etc.).
10
+ * @param {Record<string, string>} [queryParams] - Optional query parameters to append to the URL.
11
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
12
+ *
13
+ * @example
14
+ * const [items, error] = await ListWithoutPagService(api, "descriptiongeoarea", {
15
+ * filter_dict: { is_active: true },
16
+ * fields: ["pk", "name"],
17
+ * order_by: ["name"],
18
+ * });
19
+ * if (error) console.error("Failed to fetch items:", error);
20
+ * else console.log("Items:", items);
21
+ */
22
+ export declare const ListWithoutPagService: <T>(api: ApiService, modelClass: string, body?: any, queryParams?: Record<string, string>) => Promise<[T | null, IErrorDict | null]>;
23
+ //# sourceMappingURL=list-without-pag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-without-pag.d.ts","sourceRoot":"","sources":["../../../src/services/list-without-pag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qBAAqB,GAAU,CAAC,EAC3C,KAAK,UAAU,EACf,YAAY,MAAM,EAClB,OAAO,GAAG,EACV,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAgBvC,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListWithoutPagService = void 0;
4
+ const safe_await_js_1 = require("../core/safe-await.js");
5
+ /**
6
+ * Fetches all items for a given model without pagination.
7
+ * Use for small datasets (comments, versions, lookups) where pagination is not needed.
8
+ * @template T - The expected type of the response data.
9
+ * @param {ApiService} api - An instance of the ApiService.
10
+ * @param {string} modelClass - The name of the model class to list.
11
+ * @param {any} [body] - Optional request body (filter_dict, fields, order_by, etc.).
12
+ * @param {Record<string, string>} [queryParams] - Optional query parameters to append to the URL.
13
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error.
14
+ *
15
+ * @example
16
+ * const [items, error] = await ListWithoutPagService(api, "descriptiongeoarea", {
17
+ * filter_dict: { is_active: true },
18
+ * fields: ["pk", "name"],
19
+ * order_by: ["name"],
20
+ * });
21
+ * if (error) console.error("Failed to fetch items:", error);
22
+ * else console.log("Items:", items);
23
+ */
24
+ const ListWithoutPagService = async (api, modelClass, body, queryParams) => {
25
+ const requestBody = body ?? {};
26
+ const normalizedModelClass = modelClass.toLowerCase();
27
+ const [response, error] = await (0, safe_await_js_1.safeAwait)(queryParams
28
+ ? api.request("POST", `/${normalizedModelClass}/list-without-pag/`, requestBody, queryParams)
29
+ : api.request("POST", `/${normalizedModelClass}/list-without-pag/`, requestBody));
30
+ if (error) {
31
+ console.error("==> ListWithoutPagService ERROR:", error);
32
+ return [null, error];
33
+ }
34
+ return [response, null];
35
+ };
36
+ exports.ListWithoutPagService = ListWithoutPagService;
37
+ //# sourceMappingURL=list-without-pag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-without-pag.js","sourceRoot":"","sources":["../../../src/services/list-without-pag.ts"],"names":[],"mappings":";;;AAEA,yDAAkD;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACxC,GAAe,EACf,UAAkB,EAClB,IAAU,EACV,WAAoC,EACI,EAAE;IAC1C,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,oBAAoB,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAEtD,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,yBAAS,EACvC,WAAW;QACT,CAAC,CAAC,GAAG,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,oBAAoB,oBAAoB,EAAE,WAAW,EAAE,WAAW,CAAC;QAChG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,oBAAoB,oBAAoB,EAAE,WAAW,CAAC,CACtF,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AArBW,QAAA,qBAAqB,yBAqBhC"}
@@ -0,0 +1,18 @@
1
+ import type { IErrorDict } from "../types/error.js";
2
+ import type { ApiService } from "../core/api-service.js";
3
+ /**
4
+ * Fetches a list of items for a given model from the API.
5
+ * @template T - The expected type of the list response data.
6
+ * @param {ApiService} api - An instance of the ApiService.
7
+ * @param {string} modelClass - The name of the model class to list.
8
+ * @param {any} [body] - Optional request body for the list operation.
9
+ * @param {Record<string, string>} [queryParams] - Optional query parameters to append to the URL.
10
+ * @returns {Promise<[T | null, IErrorDict | null]>} A tuple containing the response data or an error, consistent with safeAwait.
11
+ *
12
+ * @example
13
+ * const [users, error] = await ListService<User[]>(api, "users", { limit: 10 });
14
+ * if (error) console.error("Failed to fetch users:", error);
15
+ * else console.log("Users:", users);
16
+ */
17
+ export declare const ListService: <T>(api: ApiService, modelClass: string, body?: any, queryParams?: Record<string, string>) => Promise<[T | null, IErrorDict | null]>;
18
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/services/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EACjC,KAAK,UAAU,EACf,YAAY,MAAM,EAClB,OAAO,GAAG,EACV,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAgBvC,CAAC"}