@merkaly/api 0.32.2 → 0.33.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.
package/README.md CHANGED
@@ -17,6 +17,10 @@ and used by the frontends (admin, store, dashboard). The source of truth is
17
17
  - **A leaf that is an array becomes an entry point with a barrel**: `"@/order": { "sale": [...] }`
18
18
  is importable as `@merkaly/api/order/sale`. Intermediate maps do not generate one, so
19
19
  `@merkaly/api/order` alone does not resolve: add a leaf (`type`, `home`...) instead.
20
+ - Validators of one app live in the api's `src/application/<app>/validators` and are listed with
21
+ their full `application/...` path under a group named after the surface: `"@/www": {
22
+ "onboarding": ["application/www/validators/onboarding.request.validator"] }` is
23
+ `@merkaly/api/www/onboarding`, `"@/auth": { "identity": [...] }` is `@merkaly/api/auth/identity`.
20
24
  - New domains need their group here (e.g. `"@/dashboard": { "home": [...] }`) or their types
21
25
  never reach the package.
22
26
 
@@ -23,6 +23,14 @@ export interface AccountAuthProfile {
23
23
  phone?: string;
24
24
  picture?: string;
25
25
  }
26
+ export interface AccountIdentityProfile {
27
+ birthDate: string;
28
+ cpf: string;
29
+ name: string;
30
+ }
31
+ export interface OnboardingResult {
32
+ organization: string;
33
+ }
26
34
  export interface AccountAuthPasswordTicket {
27
35
  ticket: string;
28
36
  }
@@ -0,0 +1,6 @@
1
+ import { AbstractRequestValidator } from '../../abstract.validator.js';
2
+ export declare class SaveAccountIdentityRequestValidator extends AbstractRequestValidator {
3
+ name: string;
4
+ cpf: string;
5
+ birthDate: string;
6
+ }
@@ -0,0 +1,36 @@
1
+ import 'reflect-metadata';
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ import * as class_transformer_1 from "class-transformer";
12
+ import * as class_validator_1 from "class-validator";
13
+ import * as delivery_request_validator_1 from '../../order/sale/index.js';
14
+ import * as abstract_validator_1 from '../../abstract.validator.js';
15
+ export class SaveAccountIdentityRequestValidator extends abstract_validator_1.AbstractRequestValidator {
16
+ name;
17
+ cpf;
18
+ birthDate;
19
+ }
20
+ __decorate([
21
+ (0, class_validator_1.IsString)(),
22
+ (0, class_validator_1.Length)(5, 120),
23
+ (0, class_validator_1.Matches)(/^\S+(\s+\S+)+$/, { message: '$property must be the full name' }),
24
+ (0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
25
+ __metadata("design:type", String)
26
+ ], SaveAccountIdentityRequestValidator.prototype, "name", void 0);
27
+ __decorate([
28
+ (0, delivery_request_validator_1.IsCpf)(),
29
+ (0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
30
+ __metadata("design:type", String)
31
+ ], SaveAccountIdentityRequestValidator.prototype, "cpf", void 0);
32
+ __decorate([
33
+ (0, delivery_request_validator_1.IsBirthday)(),
34
+ (0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
35
+ __metadata("design:type", String)
36
+ ], SaveAccountIdentityRequestValidator.prototype, "birthDate", void 0);
@@ -0,0 +1 @@
1
+ export * from './identity.request.validator';
@@ -0,0 +1 @@
1
+ export * from './identity.request.validator.js';
@@ -4,18 +4,15 @@ import { AbstractEntity } from '../../abstract.entity.js';
4
4
  import { FinanceWithdrawalStatusEnum } from './withdrawal.enum.js';
5
5
  export declare class FinanceWithdrawalEntity extends AbstractEntity {
6
6
  amount: number;
7
- fee?: number | null;
8
- netAmount?: number | null;
9
- pixKeyType?: PaymentPixKeyTypeEnum | null;
10
- pixKeyMasked?: string | null;
7
+ fee: number;
8
+ readonly netAmount: number;
9
+ keyType?: PaymentPixKeyTypeEnum | null;
10
+ keyMasked?: string | null;
11
11
  status: FinanceWithdrawalStatusEnum;
12
12
  rawStatus: string;
13
13
  failReason?: string | null;
14
- authorized?: boolean | null;
15
14
  requestedBy?: AccountUserEntity | string | null;
16
- requestedAt: Date;
17
15
  completedAt?: Date | null;
18
- provider: string;
19
- reference: string;
16
+ transferId: string;
20
17
  receiptUrl?: string | null;
21
18
  }
package/dist/index.d.ts CHANGED
@@ -36,4 +36,6 @@ export * from './order/item';
36
36
  export * from './content/page';
37
37
  export * from './settings/organization';
38
38
  export * from './settings/authentication';
39
+ export * from './auth/identity';
40
+ export * from './www/onboarding';
39
41
  export type { SaveEntityArgs } from './repository.types';
package/dist/index.js CHANGED
@@ -27,3 +27,5 @@ export * from './order/item/index.js';
27
27
  export * from './content/page/index.js';
28
28
  export * from './settings/organization/index.js';
29
29
  export * from './settings/authentication/index.js';
30
+ export * from './auth/identity/index.js';
31
+ export * from './www/onboarding/index.js';
@@ -59,11 +59,18 @@ export interface PaymentAccountBalance {
59
59
  export interface PaymentAccountTransfer {
60
60
  id: string;
61
61
  amount: number;
62
- fee: number | null;
62
+ fee: number;
63
+ netAmount: number;
63
64
  status: string;
64
65
  failReason: string | null;
65
66
  createdAt: Date | null;
66
67
  }
68
+ export type PaymentWithdrawalAuthorization = {
69
+ status: 'APPROVED';
70
+ } | {
71
+ status: 'REFUSED';
72
+ refuseReason: string;
73
+ };
67
74
  export interface PaymentAccountCommercialInfo {
68
75
  personType: PaymentAccountPersonTypeEnum;
69
76
  cpfCnpj: string;
@@ -18,8 +18,8 @@ declare abstract class PaymentAccountContactRequestValidator extends AbstractReq
18
18
  }
19
19
  export declare class CreatePaymentAccountRequestValidator extends PaymentAccountContactRequestValidator {
20
20
  personType: PaymentAccountPersonTypeEnum;
21
- name: string;
22
- cpfCnpj: string;
21
+ name?: string;
22
+ cpfCnpj?: string;
23
23
  birthDate?: string;
24
24
  companyType?: PaymentAccountCompanyTypeEnum;
25
25
  constructor();
@@ -65,16 +65,6 @@ const pixKey = ({ value, obj }) => {
65
65
  }
66
66
  return type === account_enum_1.PaymentPixKeyTypeEnum.EMAIL ? value.trim().toLowerCase() : value.trim();
67
67
  };
68
- function IsAccountDocument() {
69
- return (0, class_validator_1.ValidateBy)({
70
- name: 'isAccountDocument',
71
- validator: {
72
- defaultMessage: () => '$property must be a valid CPF (individual) or CNPJ (company)',
73
- validate: (value, args) => (isCompany(args.object) ? isCnpj(value) : (0, delivery_request_validator_1.isCpf)(value)),
74
- },
75
- });
76
- }
77
- const isIndividual = (body) => body.personType === account_enum_1.PaymentAccountPersonTypeEnum.INDIVIDUAL;
78
68
  const isCompany = (body) => body.personType === account_enum_1.PaymentAccountPersonTypeEnum.COMPANY;
79
69
  export class PaymentAccountAddressRequestValidator extends abstract_validator_1.AbstractRequestValidator {
80
70
  postalCode;
@@ -158,18 +148,20 @@ __decorate([
158
148
  __metadata("design:type", String)
159
149
  ], CreatePaymentAccountRequestValidator.prototype, "personType", void 0);
160
150
  __decorate([
151
+ (0, class_validator_1.ValidateIf)(isCompany),
161
152
  (0, class_validator_1.IsString)(),
162
153
  (0, class_validator_1.Length)(2, 120),
163
154
  (0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
164
155
  __metadata("design:type", String)
165
156
  ], CreatePaymentAccountRequestValidator.prototype, "name", void 0);
166
157
  __decorate([
167
- IsAccountDocument(),
158
+ (0, class_validator_1.ValidateIf)(isCompany),
159
+ IsCnpj(),
168
160
  (0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
169
161
  __metadata("design:type", String)
170
162
  ], CreatePaymentAccountRequestValidator.prototype, "cpfCnpj", void 0);
171
163
  __decorate([
172
- (0, class_validator_1.ValidateIf)(isIndividual),
164
+ (0, class_validator_1.IsOptional)(),
173
165
  (0, delivery_request_validator_1.IsBirthday)(),
174
166
  (0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
175
167
  __metadata("design:type", String)
@@ -1,4 +1,4 @@
1
- const sale_enum_1 = require('./sale.enum');
1
+ import * as sale_enum_1 from './sale.enum.js';
2
2
  export var OrderBuyerStageEnum;
3
3
  (function (OrderBuyerStageEnum) {
4
4
  OrderBuyerStageEnum["AWAITING_PAYMENT"] = "AWAITING_PAYMENT";
@@ -0,0 +1 @@
1
+ export * from './onboarding.request.validator';
@@ -0,0 +1 @@
1
+ export * from './onboarding.request.validator.js';
@@ -0,0 +1,10 @@
1
+ import { SaveAccountIdentityRequestValidator } from '../../auth/identity';
2
+ import { AbstractRequestValidator } from '../../abstract.validator.js';
3
+ export declare class OnboardingCompanyRequestValidator extends AbstractRequestValidator {
4
+ name: string;
5
+ email?: string;
6
+ }
7
+ export declare class CreateOnboardingRequestValidator extends AbstractRequestValidator {
8
+ company: OnboardingCompanyRequestValidator;
9
+ identity?: SaveAccountIdentityRequestValidator;
10
+ }
@@ -0,0 +1,50 @@
1
+ import 'reflect-metadata';
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ import * as class_transformer_1 from "class-transformer";
12
+ import * as class_validator_1 from "class-validator";
13
+ import * as identity_request_validator_1 from '../../auth/identity/index.js';
14
+ import * as abstract_validator_1 from '../../abstract.validator.js';
15
+ const trim = ({ value }) => (typeof value === 'string' ? value.trim() : value);
16
+ const lower = ({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value;
17
+ export class OnboardingCompanyRequestValidator extends abstract_validator_1.AbstractRequestValidator {
18
+ name;
19
+ email;
20
+ }
21
+ __decorate([
22
+ (0, class_validator_1.IsString)(),
23
+ (0, class_validator_1.Length)(2, 100),
24
+ (0, class_validator_1.Matches)(/[\p{L}\p{N}]/u, { message: '$property must have a letter or digit' }),
25
+ (0, class_transformer_1.Transform)(trim),
26
+ __metadata("design:type", String)
27
+ ], OnboardingCompanyRequestValidator.prototype, "name", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsEmail)(),
30
+ (0, class_validator_1.Length)(3, 254),
31
+ (0, class_validator_1.IsOptional)(),
32
+ (0, class_transformer_1.Transform)(lower),
33
+ __metadata("design:type", String)
34
+ ], OnboardingCompanyRequestValidator.prototype, "email", void 0);
35
+ export class CreateOnboardingRequestValidator extends abstract_validator_1.AbstractRequestValidator {
36
+ company;
37
+ identity;
38
+ }
39
+ __decorate([
40
+ (0, class_validator_1.IsDefined)(),
41
+ (0, class_validator_1.ValidateNested)(),
42
+ (0, class_transformer_1.Type)(() => OnboardingCompanyRequestValidator),
43
+ __metadata("design:type", OnboardingCompanyRequestValidator)
44
+ ], CreateOnboardingRequestValidator.prototype, "company", void 0);
45
+ __decorate([
46
+ (0, class_validator_1.IsOptional)(),
47
+ (0, class_validator_1.ValidateNested)(),
48
+ (0, class_transformer_1.Type)(() => identity_request_validator_1.SaveAccountIdentityRequestValidator),
49
+ __metadata("design:type", identity_request_validator_1.SaveAccountIdentityRequestValidator)
50
+ ], CreateOnboardingRequestValidator.prototype, "identity", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.32.2",
3
+ "version": "0.33.1",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript interfaces and enums for Merkaly API",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.6.1",
33
33
  "changelogen": "^0.6.2",
34
- "oxlint": "^1.91.0",
34
+ "oxlint": "^1.92.0",
35
35
  "tsx": "^4.23.0",
36
36
  "typescript": "^7.0.2"
37
37
  },