@temboplus/afloat 0.1.13 → 0.1.30

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 (119) hide show
  1. package/esm/src/features/auth/access/contract.d.ts +14 -0
  2. package/esm/src/features/auth/access/contract.d.ts.map +1 -0
  3. package/esm/src/features/auth/access/contract.js +14 -0
  4. package/esm/src/features/auth/contract.d.ts +20 -20
  5. package/esm/src/features/auth/contract.js +2 -2
  6. package/esm/src/features/auth/identity/contract.d.ts +0 -7
  7. package/esm/src/features/auth/identity/contract.d.ts.map +1 -1
  8. package/esm/src/features/auth/identity/contract.js +0 -1
  9. package/esm/src/features/auth/identity/repository.d.ts +2 -2
  10. package/esm/src/features/auth/identity/repository.d.ts.map +1 -1
  11. package/esm/src/features/auth/identity/repository.js +5 -5
  12. package/esm/src/features/auth/manager.js +1 -1
  13. package/esm/src/features/auth/profile/contract.d.ts +17 -25
  14. package/esm/src/features/auth/profile/contract.d.ts.map +1 -1
  15. package/esm/src/features/auth/profile/contract.js +2 -4
  16. package/esm/src/features/auth/repository.d.ts +0 -1
  17. package/esm/src/features/auth/repository.d.ts.map +1 -1
  18. package/esm/src/features/auth/repository.js +3 -11
  19. package/esm/src/features/auth/storage/server_token_handler.d.ts +7 -6
  20. package/esm/src/features/auth/storage/server_token_handler.d.ts.map +1 -1
  21. package/esm/src/features/auth/storage/server_token_handler.js +73 -26
  22. package/esm/src/features/contact/contract.d.ts +10 -10
  23. package/esm/src/features/payout/contract.d.ts +12 -12
  24. package/esm/src/features/wallet/repository.d.ts +1 -28
  25. package/esm/src/features/wallet/repository.d.ts.map +1 -1
  26. package/esm/src/features/wallet/repository.js +0 -51
  27. package/esm/src/models/contact/derivatives/contact.js +2 -2
  28. package/esm/src/models/contact/derivatives/contact_info.d.ts +8 -8
  29. package/esm/src/models/contact/derivatives/contact_info.d.ts.map +1 -1
  30. package/esm/src/models/contact/derivatives/contact_info.js +12 -12
  31. package/esm/src/models/payout/channel.d.ts +4 -4
  32. package/esm/src/models/payout/channel.d.ts.map +1 -1
  33. package/esm/src/models/payout/channel.js +2 -2
  34. package/esm/src/models/payout/derivatives/payout.d.ts.map +1 -1
  35. package/esm/src/models/payout/derivatives/payout.js +2 -2
  36. package/esm/src/models/user/profile.d.ts +135 -12
  37. package/esm/src/models/user/profile.d.ts.map +1 -1
  38. package/esm/src/models/user/profile.js +318 -12
  39. package/esm/src/models/user/user.d.ts +14 -17
  40. package/esm/src/models/user/user.d.ts.map +1 -1
  41. package/esm/src/models/user/user.js +109 -26
  42. package/esm/src/models/wallet/index.d.ts +0 -1
  43. package/esm/src/models/wallet/index.d.ts.map +1 -1
  44. package/esm/src/models/wallet/index.js +0 -1
  45. package/esm/src/shared/token_required_repository.d.ts +78 -0
  46. package/esm/src/shared/token_required_repository.d.ts.map +1 -0
  47. package/esm/src/shared/token_required_repository.js +128 -0
  48. package/package.json +7 -7
  49. package/script/src/features/auth/access/contract.d.ts +14 -0
  50. package/script/src/features/auth/access/contract.d.ts.map +1 -0
  51. package/script/src/features/auth/access/contract.js +17 -0
  52. package/script/src/features/auth/contract.d.ts +20 -20
  53. package/script/src/features/auth/contract.js +1 -1
  54. package/script/src/features/auth/identity/contract.d.ts +0 -7
  55. package/script/src/features/auth/identity/contract.d.ts.map +1 -1
  56. package/script/src/features/auth/identity/contract.js +0 -1
  57. package/script/src/features/auth/identity/repository.d.ts +2 -2
  58. package/script/src/features/auth/identity/repository.d.ts.map +1 -1
  59. package/script/src/features/auth/identity/repository.js +5 -5
  60. package/script/src/features/auth/manager.js +1 -1
  61. package/script/src/features/auth/profile/contract.d.ts +17 -25
  62. package/script/src/features/auth/profile/contract.d.ts.map +1 -1
  63. package/script/src/features/auth/profile/contract.js +1 -3
  64. package/script/src/features/auth/repository.d.ts +0 -1
  65. package/script/src/features/auth/repository.d.ts.map +1 -1
  66. package/script/src/features/auth/repository.js +3 -11
  67. package/script/src/features/auth/storage/server_token_handler.d.ts +7 -6
  68. package/script/src/features/auth/storage/server_token_handler.d.ts.map +1 -1
  69. package/script/src/features/auth/storage/server_token_handler.js +72 -25
  70. package/script/src/features/contact/contract.d.ts +10 -10
  71. package/script/src/features/payout/contract.d.ts +12 -12
  72. package/script/src/features/wallet/repository.d.ts +1 -28
  73. package/script/src/features/wallet/repository.d.ts.map +1 -1
  74. package/script/src/features/wallet/repository.js +0 -51
  75. package/script/src/models/contact/derivatives/contact.js +1 -1
  76. package/script/src/models/contact/derivatives/contact_info.d.ts +8 -8
  77. package/script/src/models/contact/derivatives/contact_info.d.ts.map +1 -1
  78. package/script/src/models/contact/derivatives/contact_info.js +11 -11
  79. package/script/src/models/payout/channel.d.ts +4 -4
  80. package/script/src/models/payout/channel.d.ts.map +1 -1
  81. package/script/src/models/payout/channel.js +2 -2
  82. package/script/src/models/payout/derivatives/payout.d.ts.map +1 -1
  83. package/script/src/models/payout/derivatives/payout.js +1 -1
  84. package/script/src/models/user/profile.d.ts +135 -12
  85. package/script/src/models/user/profile.d.ts.map +1 -1
  86. package/script/src/models/user/profile.js +320 -13
  87. package/script/src/models/user/user.d.ts +14 -17
  88. package/script/src/models/user/user.d.ts.map +1 -1
  89. package/script/src/models/user/user.js +109 -26
  90. package/script/src/models/wallet/index.d.ts +0 -1
  91. package/script/src/models/wallet/index.d.ts.map +1 -1
  92. package/script/src/models/wallet/index.js +0 -1
  93. package/script/src/shared/token_required_repository.d.ts +78 -0
  94. package/script/src/shared/token_required_repository.d.ts.map +1 -0
  95. package/script/src/shared/token_required_repository.js +132 -0
  96. package/esm/src/features/auth/profile/repository.d.ts +0 -11
  97. package/esm/src/features/auth/profile/repository.d.ts.map +0 -1
  98. package/esm/src/features/auth/profile/repository.js +0 -21
  99. package/esm/src/features/files-gen/contract.d.ts +0 -67
  100. package/esm/src/features/files-gen/contract.d.ts.map +0 -1
  101. package/esm/src/features/files-gen/contract.js +0 -40
  102. package/esm/src/features/files-gen/repository.d.ts +0 -50
  103. package/esm/src/features/files-gen/repository.d.ts.map +0 -1
  104. package/esm/src/features/files-gen/repository.js +0 -56
  105. package/esm/src/models/wallet/statement.d.ts +0 -27
  106. package/esm/src/models/wallet/statement.d.ts.map +0 -1
  107. package/esm/src/models/wallet/statement.js +0 -13
  108. package/script/src/features/auth/profile/repository.d.ts +0 -11
  109. package/script/src/features/auth/profile/repository.d.ts.map +0 -1
  110. package/script/src/features/auth/profile/repository.js +0 -25
  111. package/script/src/features/files-gen/contract.d.ts +0 -67
  112. package/script/src/features/files-gen/contract.d.ts.map +0 -1
  113. package/script/src/features/files-gen/contract.js +0 -43
  114. package/script/src/features/files-gen/repository.d.ts +0 -50
  115. package/script/src/features/files-gen/repository.d.ts.map +0 -1
  116. package/script/src/features/files-gen/repository.js +0 -60
  117. package/script/src/models/wallet/statement.d.ts +0 -27
  118. package/script/src/models/wallet/statement.d.ts.map +0 -1
  119. package/script/src/models/wallet/statement.js +0 -16
@@ -1,56 +0,0 @@
1
- import { contract } from "./contract.js";
2
- import { BaseRepository } from "../../shared/index.js";
3
- import { APIError } from "../../errors/api_error.js";
4
- /**
5
- * Repository class for managing file generation operations including
6
- * statement PDFs and account details documents.
7
- * @extends {BaseRepository<typeof contract>}
8
- */
9
- export class AfloatFilesRepo extends BaseRepository {
10
- /**
11
- * Creates an instance of AfloatFilesRepo initialized with the files generation contract.
12
- * Configures the repository with the PDF maker service endpoint.
13
- */
14
- constructor(props) {
15
- super("wallet", contract, {
16
- root: "https://api.afloat.money/pdf-maker/afloat",
17
- // root: "http://localhost:3000/afloat",
18
- auth: props?.auth,
19
- });
20
- }
21
- /**
22
- * Generates and downloads a statement PDF based on the provided parameters.
23
- * @param {GenStatementInput} body - The statement generation parameters
24
- * @param {Date} body.start_date - Start date for the statement period
25
- * @param {Date} body.end_date - End date for the statement period
26
- * @param {string} body.return_file_type - Desired file format for the statement
27
- * @param {string} [body.account_no] - Optional account number to generate statement for
28
- * @throws {APIError} If the statement generation operation fails
29
- * @returns {Promise<StatementFile>} The generated statement file
30
- */
31
- async downloadStatement(body) {
32
- const result = await this.client.genStatementPDF({ body });
33
- if (result.status === 201) {
34
- return result.body;
35
- }
36
- if (result.status === 202) {
37
- throw new APIError({
38
- message: result.body.message,
39
- statusCode: 202,
40
- });
41
- }
42
- throw APIError.unknown("An error occurred while generating statement PDF");
43
- }
44
- /**
45
- * Generates a PDF containing detailed account information.
46
- * @throws {APIError} If the PDF generation operation fails
47
- * @returns {Promise<GenAccountDetailsResponse>} The generated account details PDF
48
- */
49
- async genAccountDetailsPDF() {
50
- const result = await this.client.genAccountDetailsPDF();
51
- if (result.status === 201) {
52
- return result.body;
53
- }
54
- throw APIError.unknown("An error occurred while generating account details PDF");
55
- }
56
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Enum representing the supported output formats for statement generation.
3
- * Used to specify the desired file format when requesting statement downloads.
4
- *
5
- * @enum {string}
6
- */
7
- export declare enum STATEMENT_OUTPUT_TYPE {
8
- /** Generate statement as a PDF document */
9
- PDF = "PDF",
10
- /** Generate statement as an Excel spreadsheet */
11
- EXCEL = "EXCEL"
12
- }
13
- /**
14
- * Interface defining the structure of a generated statement file.
15
- * Contains metadata about the file and its content type.
16
- *
17
- * @interface StatementFile
18
- * @property {string} file - Base64 encoded string of the file content or file path
19
- * @property {string} file_extension - File extension (e.g., "pdf", "xlsx") without the dot
20
- * @property {string} mime_type - MIME type of the file (e.g., "application/pdf", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
21
- */
22
- export interface StatementFile {
23
- file: string;
24
- file_extension: string;
25
- mime_type: string;
26
- }
27
- //# sourceMappingURL=statement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/statement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,GAAG,QAAQ;IACX,iDAAiD;IACjD,KAAK,UAAU;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Enum representing the supported output formats for statement generation.
3
- * Used to specify the desired file format when requesting statement downloads.
4
- *
5
- * @enum {string}
6
- */
7
- export var STATEMENT_OUTPUT_TYPE;
8
- (function (STATEMENT_OUTPUT_TYPE) {
9
- /** Generate statement as a PDF document */
10
- STATEMENT_OUTPUT_TYPE["PDF"] = "PDF";
11
- /** Generate statement as an Excel spreadsheet */
12
- STATEMENT_OUTPUT_TYPE["EXCEL"] = "EXCEL";
13
- })(STATEMENT_OUTPUT_TYPE || (STATEMENT_OUTPUT_TYPE = {}));
@@ -1,11 +0,0 @@
1
- import type { Profile } from "../../../models/index.js";
2
- import { BaseRepository } from "../../../shared/base_repository.js";
3
- import { profileContract } from "./contract.js";
4
- export declare class ProfileRepository extends BaseRepository<typeof profileContract> {
5
- /**
6
- * Initializes an instance of ProfileRepository.
7
- */
8
- constructor();
9
- getCurrentProfile(token: string): Promise<Profile>;
10
- }
11
- //# sourceMappingURL=repository.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../../src/src/features/auth/profile/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,eAAe,CAAC;IAC3E;;OAEG;;IAKG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAUzD"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProfileRepository = void 0;
4
- const base_repository_js_1 = require("../../../shared/base_repository.js");
5
- const api_error_js_1 = require("../../../errors/api_error.js");
6
- const contract_js_1 = require("./contract.js");
7
- class ProfileRepository extends base_repository_js_1.BaseRepository {
8
- /**
9
- * Initializes an instance of ProfileRepository.
10
- */
11
- constructor() {
12
- super("profile", contract_js_1.profileContract);
13
- }
14
- async getCurrentProfile(token) {
15
- const headers = { token };
16
- const result = await this.client.getCurrentProfile({ headers });
17
- if (result.status === 200)
18
- return result.body;
19
- throw new api_error_js_1.APIError({
20
- message: "An error occurred while trying to get the current profile",
21
- statusCode: 502,
22
- });
23
- }
24
- }
25
- exports.ProfileRepository = ProfileRepository;
@@ -1,67 +0,0 @@
1
- import { z } from "zod";
2
- import { STATEMENT_OUTPUT_TYPE } from "../../models/wallet/index.js";
3
- export declare const contract: {
4
- genStatementPDF: {
5
- method: "POST";
6
- body: z.ZodObject<{
7
- end_date: z.ZodDate;
8
- start_date: z.ZodDate;
9
- account_no: z.ZodOptional<z.ZodString>;
10
- return_file_type: z.ZodEnum<[STATEMENT_OUTPUT_TYPE.EXCEL, STATEMENT_OUTPUT_TYPE.PDF]>;
11
- }, "strip", z.ZodTypeAny, {
12
- end_date: Date;
13
- start_date: Date;
14
- return_file_type: STATEMENT_OUTPUT_TYPE;
15
- account_no?: string | undefined;
16
- }, {
17
- end_date: Date;
18
- start_date: Date;
19
- return_file_type: STATEMENT_OUTPUT_TYPE;
20
- account_no?: string | undefined;
21
- }>;
22
- path: "/statement";
23
- responses: {
24
- 201: z.ZodObject<{
25
- file: z.ZodString;
26
- file_extension: z.ZodString;
27
- mime_type: z.ZodString;
28
- }, "strip", z.ZodTypeAny, {
29
- file: string;
30
- file_extension: string;
31
- mime_type: string;
32
- }, {
33
- file: string;
34
- file_extension: string;
35
- mime_type: string;
36
- }>;
37
- 202: z.ZodObject<{
38
- message: z.ZodString;
39
- }, "strip", z.ZodTypeAny, {
40
- message: string;
41
- }, {
42
- message: string;
43
- }>;
44
- };
45
- };
46
- genAccountDetailsPDF: {
47
- method: "POST";
48
- body: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
49
- path: "/account_details";
50
- responses: {
51
- 201: z.ZodObject<{
52
- file: z.ZodString;
53
- file_extension: z.ZodString;
54
- mime_type: z.ZodString;
55
- }, "strip", z.ZodTypeAny, {
56
- file: string;
57
- file_extension: string;
58
- mime_type: string;
59
- }, {
60
- file: string;
61
- file_extension: string;
62
- mime_type: string;
63
- }>;
64
- };
65
- };
66
- };
67
- //# sourceMappingURL=contract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/files-gen/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCnB,CAAC"}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contract = void 0;
4
- const zod_1 = require("zod");
5
- const core_1 = require("@ts-rest/core");
6
- const index_js_1 = require("../../models/wallet/index.js");
7
- exports.contract = (0, core_1.initContract)().router({
8
- genStatementPDF: {
9
- method: "POST",
10
- path: "/statement",
11
- body: zod_1.z.object({
12
- end_date: zod_1.z.date(),
13
- start_date: zod_1.z.date(),
14
- account_no: zod_1.z.string().optional(),
15
- return_file_type: zod_1.z.enum([
16
- index_js_1.STATEMENT_OUTPUT_TYPE.EXCEL,
17
- index_js_1.STATEMENT_OUTPUT_TYPE.PDF,
18
- ]),
19
- }),
20
- responses: {
21
- 201: zod_1.z.object({
22
- file: zod_1.z.string(),
23
- file_extension: zod_1.z.string(),
24
- mime_type: zod_1.z.string(),
25
- }),
26
- 202: zod_1.z.object({
27
- message: zod_1.z.string(),
28
- }),
29
- },
30
- },
31
- genAccountDetailsPDF: {
32
- method: "POST",
33
- path: "/account_details",
34
- body: zod_1.z.object({}),
35
- responses: {
36
- 201: zod_1.z.object({
37
- file: zod_1.z.string(),
38
- file_extension: zod_1.z.string(),
39
- mime_type: zod_1.z.string(),
40
- }),
41
- },
42
- },
43
- });
@@ -1,50 +0,0 @@
1
- import { contract } from "./contract.js";
2
- import { BaseRepository } from "../../shared/index.js";
3
- import type { ClientInferRequest, ClientInferResponseBody } from "@ts-rest/core";
4
- import type { StatementFile } from "../../models/wallet/index.js";
5
- import type { AfloatAuth } from "../auth/index.js";
6
- /**
7
- * Type definition for statement generation input parameters.
8
- * Inferred from the contract's genStatementPDF endpoint request body.
9
- * @typedef {ClientInferRequest<typeof contract.genStatementPDF>["body"]} GenStatementInput
10
- */
11
- type GenStatementInput = ClientInferRequest<typeof contract.genStatementPDF>["body"];
12
- /**
13
- * Type definition for account details response.
14
- * Inferred from the contract's genAccountDetailsPDF endpoint response body.
15
- * @typedef {ClientInferResponseBody<typeof contract.genAccountDetailsPDF>} GenAccountDetailsResponse
16
- */
17
- type GenAccountDetailsResponse = ClientInferResponseBody<typeof contract.genAccountDetailsPDF>;
18
- /**
19
- * Repository class for managing file generation operations including
20
- * statement PDFs and account details documents.
21
- * @extends {BaseRepository<typeof contract>}
22
- */
23
- export declare class AfloatFilesRepo extends BaseRepository<typeof contract> {
24
- /**
25
- * Creates an instance of AfloatFilesRepo initialized with the files generation contract.
26
- * Configures the repository with the PDF maker service endpoint.
27
- */
28
- constructor(props?: {
29
- auth?: AfloatAuth;
30
- });
31
- /**
32
- * Generates and downloads a statement PDF based on the provided parameters.
33
- * @param {GenStatementInput} body - The statement generation parameters
34
- * @param {Date} body.start_date - Start date for the statement period
35
- * @param {Date} body.end_date - End date for the statement period
36
- * @param {string} body.return_file_type - Desired file format for the statement
37
- * @param {string} [body.account_no] - Optional account number to generate statement for
38
- * @throws {APIError} If the statement generation operation fails
39
- * @returns {Promise<StatementFile>} The generated statement file
40
- */
41
- downloadStatement(body: GenStatementInput): Promise<StatementFile>;
42
- /**
43
- * Generates a PDF containing detailed account information.
44
- * @throws {APIError} If the PDF generation operation fails
45
- * @returns {Promise<GenAccountDetailsResponse>} The generated account details PDF
46
- */
47
- genAccountDetailsPDF(): Promise<GenAccountDetailsResponse>;
48
- }
49
- export {};
50
- //# sourceMappingURL=repository.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/files-gen/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,KAAK,iBAAiB,GAAG,kBAAkB,CACzC,OAAO,QAAQ,CAAC,eAAe,CAChC,CAAC,MAAM,CAAC,CAAC;AAEV;;;;GAIG;AACH,KAAK,yBAAyB,GAAG,uBAAuB,CACtD,OAAO,QAAQ,CAAC,oBAAoB,CACrC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IAClE;;;OAGG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAQzC;;;;;;;;;OASG;IACG,iBAAiB,CACrB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,aAAa,CAAC;IAiBzB;;;;OAIG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;CAWjE"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AfloatFilesRepo = void 0;
4
- const contract_js_1 = require("./contract.js");
5
- const index_js_1 = require("../../shared/index.js");
6
- const api_error_js_1 = require("../../errors/api_error.js");
7
- /**
8
- * Repository class for managing file generation operations including
9
- * statement PDFs and account details documents.
10
- * @extends {BaseRepository<typeof contract>}
11
- */
12
- class AfloatFilesRepo extends index_js_1.BaseRepository {
13
- /**
14
- * Creates an instance of AfloatFilesRepo initialized with the files generation contract.
15
- * Configures the repository with the PDF maker service endpoint.
16
- */
17
- constructor(props) {
18
- super("wallet", contract_js_1.contract, {
19
- root: "https://api.afloat.money/pdf-maker/afloat",
20
- // root: "http://localhost:3000/afloat",
21
- auth: props?.auth,
22
- });
23
- }
24
- /**
25
- * Generates and downloads a statement PDF based on the provided parameters.
26
- * @param {GenStatementInput} body - The statement generation parameters
27
- * @param {Date} body.start_date - Start date for the statement period
28
- * @param {Date} body.end_date - End date for the statement period
29
- * @param {string} body.return_file_type - Desired file format for the statement
30
- * @param {string} [body.account_no] - Optional account number to generate statement for
31
- * @throws {APIError} If the statement generation operation fails
32
- * @returns {Promise<StatementFile>} The generated statement file
33
- */
34
- async downloadStatement(body) {
35
- const result = await this.client.genStatementPDF({ body });
36
- if (result.status === 201) {
37
- return result.body;
38
- }
39
- if (result.status === 202) {
40
- throw new api_error_js_1.APIError({
41
- message: result.body.message,
42
- statusCode: 202,
43
- });
44
- }
45
- throw api_error_js_1.APIError.unknown("An error occurred while generating statement PDF");
46
- }
47
- /**
48
- * Generates a PDF containing detailed account information.
49
- * @throws {APIError} If the PDF generation operation fails
50
- * @returns {Promise<GenAccountDetailsResponse>} The generated account details PDF
51
- */
52
- async genAccountDetailsPDF() {
53
- const result = await this.client.genAccountDetailsPDF();
54
- if (result.status === 201) {
55
- return result.body;
56
- }
57
- throw api_error_js_1.APIError.unknown("An error occurred while generating account details PDF");
58
- }
59
- }
60
- exports.AfloatFilesRepo = AfloatFilesRepo;
@@ -1,27 +0,0 @@
1
- /**
2
- * Enum representing the supported output formats for statement generation.
3
- * Used to specify the desired file format when requesting statement downloads.
4
- *
5
- * @enum {string}
6
- */
7
- export declare enum STATEMENT_OUTPUT_TYPE {
8
- /** Generate statement as a PDF document */
9
- PDF = "PDF",
10
- /** Generate statement as an Excel spreadsheet */
11
- EXCEL = "EXCEL"
12
- }
13
- /**
14
- * Interface defining the structure of a generated statement file.
15
- * Contains metadata about the file and its content type.
16
- *
17
- * @interface StatementFile
18
- * @property {string} file - Base64 encoded string of the file content or file path
19
- * @property {string} file_extension - File extension (e.g., "pdf", "xlsx") without the dot
20
- * @property {string} mime_type - MIME type of the file (e.g., "application/pdf", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
21
- */
22
- export interface StatementFile {
23
- file: string;
24
- file_extension: string;
25
- mime_type: string;
26
- }
27
- //# sourceMappingURL=statement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/statement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,GAAG,QAAQ;IACX,iDAAiD;IACjD,KAAK,UAAU;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATEMENT_OUTPUT_TYPE = void 0;
4
- /**
5
- * Enum representing the supported output formats for statement generation.
6
- * Used to specify the desired file format when requesting statement downloads.
7
- *
8
- * @enum {string}
9
- */
10
- var STATEMENT_OUTPUT_TYPE;
11
- (function (STATEMENT_OUTPUT_TYPE) {
12
- /** Generate statement as a PDF document */
13
- STATEMENT_OUTPUT_TYPE["PDF"] = "PDF";
14
- /** Generate statement as an Excel spreadsheet */
15
- STATEMENT_OUTPUT_TYPE["EXCEL"] = "EXCEL";
16
- })(STATEMENT_OUTPUT_TYPE || (exports.STATEMENT_OUTPUT_TYPE = STATEMENT_OUTPUT_TYPE = {}));