@temboplus/afloat 0.2.0 → 0.2.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,8 @@ export declare const PayoutJSONSchema: z.ZodObject<{
24
24
  updatedAt: z.ZodString;
25
25
  actionedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
26
  approvalStatus: z.ZodOptional<z.ZodNullable<z.ZodNativeEnum<typeof PayoutApprovalStatus>>>;
27
+ createdById: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ actionedById: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
29
  createdBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
28
30
  id: z.ZodString;
29
31
  name: z.ZodString;
@@ -70,6 +72,8 @@ export declare const PayoutJSONSchema: z.ZodObject<{
70
72
  partnerReference?: string | null | undefined;
71
73
  actionedAt?: string | null | undefined;
72
74
  approvalStatus?: PayoutApprovalStatus | null | undefined;
75
+ createdById?: string | null | undefined;
76
+ actionedById?: string | null | undefined;
73
77
  createdBy?: {
74
78
  name: string;
75
79
  id: string;
@@ -99,6 +103,8 @@ export declare const PayoutJSONSchema: z.ZodObject<{
99
103
  partnerReference?: string | null | undefined;
100
104
  actionedAt?: string | null | undefined;
101
105
  approvalStatus?: PayoutApprovalStatus | null | undefined;
106
+ createdById?: string | null | undefined;
107
+ actionedById?: string | null | undefined;
102
108
  createdBy?: {
103
109
  name: string;
104
110
  id: string;
@@ -118,7 +124,27 @@ export type PayoutJSON = z.infer<typeof PayoutJSONSchema>;
118
124
  * Payout class that wraps the Zod schema and provides additional functionality
119
125
  */
120
126
  export declare class Payout {
121
- private readonly data;
127
+ private readonly _id;
128
+ private readonly _profileId;
129
+ private readonly _payeeName;
130
+ private readonly _channel;
131
+ private readonly _msisdn;
132
+ private readonly _amount;
133
+ private readonly _currencyCode;
134
+ private readonly _countryCode;
135
+ private readonly _description;
136
+ private readonly _notes;
137
+ private readonly _status;
138
+ private readonly _statusMessage;
139
+ private readonly _partnerReference;
140
+ private readonly _createdAt;
141
+ private readonly _updatedAt;
142
+ private readonly _actionedAt;
143
+ private readonly _approvalStatus;
144
+ private readonly _createdById;
145
+ private readonly _actionedById;
146
+ private readonly _createdBy;
147
+ private readonly _actionedBy;
122
148
  /**
123
149
  * Private constructor - use static methods to create instances
124
150
  */
@@ -167,6 +193,10 @@ export declare class Payout {
167
193
  get actionedAt(): Date | undefined | null;
168
194
  /** Current approval status of the payout */
169
195
  get approvalStatus(): PayoutApprovalStatus | undefined | null;
196
+ /** Identifier of the user who created the payout */
197
+ get createdById(): string | undefined | null;
198
+ /** Identifier of the user who last actioned the payout */
199
+ get actionedById(): string | undefined | null;
170
200
  /** Information about who created the payout */
171
201
  get createdBy(): PayoutAuthorizer | undefined | null;
172
202
  /** Information about who last actioned the payout */
@@ -199,7 +229,7 @@ export declare class Payout {
199
229
  * This is useful when validating raw data structures before instantiation.
200
230
  *
201
231
  * @param {unknown} obj - The value containing potential payout data
202
- * @returns {obj is Payout} Type predicate indicating if a Payout can be constructed
232
+ * @returns {obj is PayoutDTO} Type predicate indicating if a Payout can be constructed
203
233
  *
204
234
  * @example
205
235
  * ```typescript
@@ -216,7 +246,7 @@ export declare class Payout {
216
246
  * @remarks
217
247
  * This method performs strict validation against the {@link PayoutData} schema
218
248
  */
219
- static canConstruct(obj: unknown): obj is Payout;
249
+ static canConstruct(obj: unknown): obj is PayoutDTO;
220
250
  /**
221
251
  * Validates if an unknown value is a Payout instance.
222
252
  * This is a runtime type guard that ensures proper object structure and data validity.
@@ -238,8 +268,8 @@ export declare class Payout {
238
268
  * @remarks
239
269
  * This method performs a complete structural validation:
240
270
  * 1. Checks if the value is an object
241
- * 2. Verifies presence of internal data property
242
- * 3. Validates the data against PayoutData schema
271
+ * 2. Verifies the instance can serialize to a valid flat PayoutJSON
272
+ * 3. Validates the JSON against PayoutData schema
243
273
  * 4. Ensures the object is a proper Payout instance
244
274
  *
245
275
  * Use this method when:
@@ -250,26 +280,26 @@ export declare class Payout {
250
280
  */
251
281
  static is(obj: unknown): obj is Payout;
252
282
  /**
253
- * Serializes the Payout instance to a JSON-compatible object
254
- *
255
- * Converts all Date objects to ISO strings for proper JSON serialization.
256
- * The resulting object can be safely stringified and stored or transmitted.
257
- *
258
- * @returns {PayoutJSON} A plain object containing all payout data
259
- *
260
- * @example
261
- * ```typescript
262
- * const payout = Payout.create(payoutData);
263
- * const json = payout.toJSON();
264
- * // {
265
- * // id: "payout-123",
266
- * // amount: 50000,
267
- * // currencyCode: "TZS",
268
- * // createdAt: "2024-01-15T10:30:00.000Z",
269
- * // ...
270
- * // }
271
- * ```
272
- */
283
+ * Serializes the Payout instance to a JSON-compatible object
284
+ *
285
+ * Converts all Date objects to ISO strings for proper JSON serialization.
286
+ * The resulting object can be safely stringified and stored or transmitted.
287
+ *
288
+ * @returns {PayoutJSON} A plain object containing all payout data
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * const payout = Payout.create(payoutData);
293
+ * const json = payout.toJSON();
294
+ * // {
295
+ * // id: "payout-123",
296
+ * // amount: 50000,
297
+ * // currencyCode: "TZS",
298
+ * // createdAt: "2024-01-15T10:30:00.000Z",
299
+ * // ...
300
+ * // }
301
+ * ```
302
+ */
273
303
  toJSON(): PayoutJSON;
274
304
  /**
275
305
  * Serializes the Payout instance to a JSON string
@@ -380,4 +410,5 @@ export declare class Payout {
380
410
  * ```
381
411
  */
382
412
  static toJSONArray(payouts: Payout[]): PayoutJSON[];
413
+ private toDTO;
383
414
  }
@@ -1,6 +1,7 @@
1
1
  import { QueryBuilder } from "@/lib/query/index.js";
2
2
  import { PayoutStatus, PayoutApprovalStatus, PayoutFilters } from "./payout.dtos.js";
3
3
  import { Amount } from "@temboplus/frontend-core";
4
+ type PayoutUrlParams = Record<string, string | string[]>;
4
5
  /**
5
6
  * Represents an active filter with its label and value
6
7
  */
@@ -28,7 +29,7 @@ export declare class PayoutQuery extends QueryBuilder {
28
29
  /**
29
30
  * Create from URL search parameters (strings)
30
31
  */
31
- static fromUrlParams(params: Record<string, string>): PayoutQuery;
32
+ static fromUrlParams(params: PayoutUrlParams): PayoutQuery;
32
33
  /**
33
34
  * Create from URLSearchParams object
34
35
  */
@@ -40,14 +41,20 @@ export declare class PayoutQuery extends QueryBuilder {
40
41
  /**
41
42
  * Create from any supported input type
42
43
  */
43
- static from(input: QueryBuilder | PayoutFilters | Record<string, string> | URLSearchParams | null | undefined): PayoutQuery;
44
+ static from(input: QueryBuilder | PayoutFilters | PayoutUrlParams | URLSearchParams | null | undefined): PayoutQuery;
44
45
  /**
45
- * Type guard for string records
46
+ * Type guard for URL param records
46
47
  */
47
- private static isStringRecord;
48
+ private static isUrlParamsRecord;
49
+ private static searchParamsToRecord;
50
+ private static normalizeUrlParams;
51
+ private static toStringList;
48
52
  whereStatus(status: PayoutStatus): this;
53
+ whereStatusIn(statuses: PayoutStatus[]): this;
49
54
  whereApprovalStatus(approvalStatus: PayoutApprovalStatus): this;
55
+ whereApprovalStatusIn(approvalStatuses: PayoutApprovalStatus[]): this;
50
56
  whereChannel(channel: string): this;
57
+ whereChannelIn(channels: string[]): this;
51
58
  wherePending(): this;
52
59
  whereApproved(): this;
53
60
  whereRejected(): this;
@@ -56,7 +63,12 @@ export declare class PayoutQuery extends QueryBuilder {
56
63
  whereAmountBetween(min: Amount, max: Amount): this;
57
64
  wherePayee(payeeName: string): this;
58
65
  whereMsisdn(msisdn: string): this;
66
+ whereMsisdnIn(msisdns: string[]): this;
59
67
  whereProfileId(profileId: string): this;
68
+ whereCreatedById(createdById: string): this;
69
+ whereCreatedByIdIn(createdByIds: string[]): this;
70
+ whereActionedById(actionedById: string): this;
71
+ whereActionedByIdIn(actionedByIds: string[]): this;
60
72
  wherePartnerReference(partnerReference: string): this;
61
73
  whereSearch(searchTerm: string): this;
62
74
  whereCurrencyCode(currencyCode: string): this;
@@ -96,14 +108,46 @@ export declare class PayoutQuery extends QueryBuilder {
96
108
  * Create new instance with status filter
97
109
  */
98
110
  withStatus(status?: PayoutStatus): PayoutQuery;
111
+ /**
112
+ * Create new instance with status in filter
113
+ */
114
+ withStatusIn(statuses?: PayoutStatus[]): PayoutQuery;
99
115
  /**
100
116
  * Create new instance with approval status filter
101
117
  */
102
118
  withApprovalStatus(approvalStatus?: PayoutApprovalStatus): PayoutQuery;
119
+ /**
120
+ * Create new instance with approval status in filter
121
+ */
122
+ withApprovalStatusIn(approvalStatuses?: PayoutApprovalStatus[]): PayoutQuery;
103
123
  /**
104
124
  * Create new instance with channel filter
105
125
  */
106
126
  withChannel(channel?: string): PayoutQuery;
127
+ /**
128
+ * Create new instance with channel in filter
129
+ */
130
+ withChannelIn(channels?: string[]): PayoutQuery;
131
+ /**
132
+ * Create new instance with MSISDN in filter
133
+ */
134
+ withMsisdnIn(msisdns?: string[]): PayoutQuery;
135
+ /**
136
+ * Create new instance with creator ID filter
137
+ */
138
+ withCreatedById(createdById?: string): PayoutQuery;
139
+ /**
140
+ * Create new instance with creator ID in filter
141
+ */
142
+ withCreatedByIdIn(createdByIds?: string[]): PayoutQuery;
143
+ /**
144
+ * Create new instance with actioner ID filter
145
+ */
146
+ withActionedById(actionedById?: string): PayoutQuery;
147
+ /**
148
+ * Create new instance with actioner ID in filter
149
+ */
150
+ withActionedByIdIn(actionedByIds?: string[]): PayoutQuery;
107
151
  /**
108
152
  * Includes default relations for eager loading.
109
153
  * This ensures that related data (createdBy, actionedBy) is fetched automatically.
@@ -174,6 +218,9 @@ export declare class PayoutQuery extends QueryBuilder {
174
218
  * Extract primary sort order
175
219
  */
176
220
  private extractSortOrder;
221
+ private whereInValues;
222
+ private getValidStatuses;
223
+ private getValidApprovalStatuses;
177
224
  /**
178
225
  * Type guard for valid statuses
179
226
  */
@@ -183,3 +230,4 @@ export declare class PayoutQuery extends QueryBuilder {
183
230
  */
184
231
  private isValidApprovalStatus;
185
232
  }
233
+ export {};
@@ -40,7 +40,7 @@ export interface RejectPayoutInput {
40
40
  /**
41
41
  * Flexible query input type - supports the class, filters interface, URL params, etc.
42
42
  */
43
- export type PayoutQueryInput = PayoutQuery | PayoutFilters | Record<string, string> | URLSearchParams | null | undefined;
43
+ export type PayoutQueryInput = PayoutQuery | PayoutFilters | Record<string, string | string[]> | URLSearchParams | null | undefined;
44
44
  /**
45
45
  * Repository class for managing payout operations including creation, approval,
46
46
  * rejection, and retrieval of payouts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-beta.1",
4
4
  "description": "A foundational library for Temboplus-Afloat projects.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -57,6 +57,6 @@
57
57
  "typescript": "^5.9.3"
58
58
  },
59
59
  "dependencies": {
60
- "@temboplus/frontend-core": "^1.0.1"
60
+ "@temboplus/frontend-core": "^1.0.2"
61
61
  }
62
62
  }