@peac/adapter-core 0.9.31
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/LICENSE +190 -0
- package/README.md +92 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/result.d.ts +99 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +105 -0
- package/dist/result.js.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.d.ts +95 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +192 -0
- package/dist/validators.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 PEAC Protocol Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @peac/adapter-core
|
|
2
|
+
|
|
3
|
+
Shared utilities for PEAC payment rail adapters.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @peac/adapter-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Result Type
|
|
14
|
+
|
|
15
|
+
All adapter functions use the Result type for explicit error handling:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { ok, err, isOk, type Result } from '@peac/adapter-core';
|
|
19
|
+
|
|
20
|
+
function parseEvent(input: unknown): Result<Event, AdapterError> {
|
|
21
|
+
if (!input) {
|
|
22
|
+
return adapterErr('input is required', 'missing_required_field');
|
|
23
|
+
}
|
|
24
|
+
return ok({ ...parsed });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Handle result
|
|
28
|
+
const result = parseEvent(data);
|
|
29
|
+
if (isOk(result)) {
|
|
30
|
+
console.log(result.value);
|
|
31
|
+
} else {
|
|
32
|
+
console.error(result.error.message);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Validators
|
|
37
|
+
|
|
38
|
+
Common validation functions for adapter inputs:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { requireString, requireAmount, requireCurrency, requireObject } from '@peac/adapter-core';
|
|
42
|
+
|
|
43
|
+
function parseWebhook(event: unknown) {
|
|
44
|
+
const objResult = requireObject(event);
|
|
45
|
+
if (!objResult.ok) return objResult;
|
|
46
|
+
|
|
47
|
+
const amountResult = requireAmount(objResult.value.amount);
|
|
48
|
+
if (!amountResult.ok) return amountResult;
|
|
49
|
+
|
|
50
|
+
const currencyResult = requireCurrency(objResult.value.currency);
|
|
51
|
+
if (!currencyResult.ok) return currencyResult;
|
|
52
|
+
|
|
53
|
+
return ok({ amount: amountResult.value, currency: currencyResult.value });
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Available Validators
|
|
58
|
+
|
|
59
|
+
| Validator | Description |
|
|
60
|
+
| ------------------------------------- | --------------------------- |
|
|
61
|
+
| `requireString(value, field)` | Non-empty string required |
|
|
62
|
+
| `optionalString(value, field)` | String or undefined |
|
|
63
|
+
| `requireNumber(value, field)` | Finite number required |
|
|
64
|
+
| `requireAmount(value)` | Non-negative safe integer |
|
|
65
|
+
| `requireCurrency(value)` | ISO 4217 currency code |
|
|
66
|
+
| `optionalNetwork(value)` | Network identifier (CAIP-2) |
|
|
67
|
+
| `requireObject(value, field)` | Non-null object |
|
|
68
|
+
| `optionalTimestamp(value)` | ISO 8601 or Unix seconds |
|
|
69
|
+
| `optionalBoolean(value, field)` | Boolean or undefined |
|
|
70
|
+
| `requireEnum(value, allowed, field)` | Value from allowed list |
|
|
71
|
+
| `optionalEnum(value, allowed, field)` | Enum or undefined |
|
|
72
|
+
|
|
73
|
+
### JSON Types
|
|
74
|
+
|
|
75
|
+
Re-exported from `@peac/kernel` for convenience:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import type { JsonObject, JsonValue } from '@peac/adapter-core';
|
|
79
|
+
|
|
80
|
+
interface PaymentEvidence {
|
|
81
|
+
rail: string;
|
|
82
|
+
evidence: JsonObject; // JSON-safe, no unknown
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
Apache-2.0
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
Part of the [PEAC Protocol](https://peacprotocol.org).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Adapter Core
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for PEAC payment rail adapters.
|
|
5
|
+
* Provides Result types and validators for consistent adapter implementation.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { JsonPrimitive, JsonValue, JsonArray, JsonObject } from '@peac/kernel';
|
|
10
|
+
export { type Result, ok, err, adapterErr, isOk, isErr, map, mapErr, chain, unwrap, unwrapOr, } from './result.js';
|
|
11
|
+
export type { AdapterError, AdapterErrorCode } from './types.js';
|
|
12
|
+
export { requireString, optionalString, requireNumber, requireAmount, requireCurrency, optionalNetwork, requireObject, optionalTimestamp, optionalBoolean, requireEnum, optionalEnum, } from './validators.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGpF,OAAO,EACL,KAAK,MAAM,EACX,EAAE,EACF,GAAG,EACH,UAAU,EACV,IAAI,EACJ,KAAK,EACL,GAAG,EACH,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGjE,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Adapter Core
|
|
4
|
+
*
|
|
5
|
+
* Shared utilities for PEAC payment rail adapters.
|
|
6
|
+
* Provides Result types and validators for consistent adapter implementation.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.optionalEnum = exports.requireEnum = exports.optionalBoolean = exports.optionalTimestamp = exports.requireObject = exports.optionalNetwork = exports.requireCurrency = exports.requireAmount = exports.requireNumber = exports.optionalString = exports.requireString = exports.unwrapOr = exports.unwrap = exports.chain = exports.mapErr = exports.map = exports.isErr = exports.isOk = exports.adapterErr = exports.err = exports.ok = void 0;
|
|
12
|
+
// Result utilities
|
|
13
|
+
var result_js_1 = require("./result.js");
|
|
14
|
+
Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return result_js_1.ok; } });
|
|
15
|
+
Object.defineProperty(exports, "err", { enumerable: true, get: function () { return result_js_1.err; } });
|
|
16
|
+
Object.defineProperty(exports, "adapterErr", { enumerable: true, get: function () { return result_js_1.adapterErr; } });
|
|
17
|
+
Object.defineProperty(exports, "isOk", { enumerable: true, get: function () { return result_js_1.isOk; } });
|
|
18
|
+
Object.defineProperty(exports, "isErr", { enumerable: true, get: function () { return result_js_1.isErr; } });
|
|
19
|
+
Object.defineProperty(exports, "map", { enumerable: true, get: function () { return result_js_1.map; } });
|
|
20
|
+
Object.defineProperty(exports, "mapErr", { enumerable: true, get: function () { return result_js_1.mapErr; } });
|
|
21
|
+
Object.defineProperty(exports, "chain", { enumerable: true, get: function () { return result_js_1.chain; } });
|
|
22
|
+
Object.defineProperty(exports, "unwrap", { enumerable: true, get: function () { return result_js_1.unwrap; } });
|
|
23
|
+
Object.defineProperty(exports, "unwrapOr", { enumerable: true, get: function () { return result_js_1.unwrapOr; } });
|
|
24
|
+
// Validators
|
|
25
|
+
var validators_js_1 = require("./validators.js");
|
|
26
|
+
Object.defineProperty(exports, "requireString", { enumerable: true, get: function () { return validators_js_1.requireString; } });
|
|
27
|
+
Object.defineProperty(exports, "optionalString", { enumerable: true, get: function () { return validators_js_1.optionalString; } });
|
|
28
|
+
Object.defineProperty(exports, "requireNumber", { enumerable: true, get: function () { return validators_js_1.requireNumber; } });
|
|
29
|
+
Object.defineProperty(exports, "requireAmount", { enumerable: true, get: function () { return validators_js_1.requireAmount; } });
|
|
30
|
+
Object.defineProperty(exports, "requireCurrency", { enumerable: true, get: function () { return validators_js_1.requireCurrency; } });
|
|
31
|
+
Object.defineProperty(exports, "optionalNetwork", { enumerable: true, get: function () { return validators_js_1.optionalNetwork; } });
|
|
32
|
+
Object.defineProperty(exports, "requireObject", { enumerable: true, get: function () { return validators_js_1.requireObject; } });
|
|
33
|
+
Object.defineProperty(exports, "optionalTimestamp", { enumerable: true, get: function () { return validators_js_1.optionalTimestamp; } });
|
|
34
|
+
Object.defineProperty(exports, "optionalBoolean", { enumerable: true, get: function () { return validators_js_1.optionalBoolean; } });
|
|
35
|
+
Object.defineProperty(exports, "requireEnum", { enumerable: true, get: function () { return validators_js_1.requireEnum; } });
|
|
36
|
+
Object.defineProperty(exports, "optionalEnum", { enumerable: true, get: function () { return validators_js_1.optionalEnum; } });
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAKH,mBAAmB;AACnB,yCAYqB;AAVnB,+FAAA,EAAE,OAAA;AACF,gGAAA,GAAG,OAAA;AACH,uGAAA,UAAU,OAAA;AACV,iGAAA,IAAI,OAAA;AACJ,kGAAA,KAAK,OAAA;AACL,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,mGAAA,MAAM,OAAA;AACN,qGAAA,QAAQ,OAAA;AAMV,aAAa;AACb,iDAYyB;AAXvB,8GAAA,aAAa,OAAA;AACb,+GAAA,cAAc,OAAA;AACd,8GAAA,aAAa,OAAA;AACb,8GAAA,aAAa,OAAA;AACb,gHAAA,eAAe,OAAA;AACf,gHAAA,eAAe,OAAA;AACf,8GAAA,aAAa,OAAA;AACb,kHAAA,iBAAiB,OAAA;AACjB,gHAAA,eAAe,OAAA;AACf,4GAAA,WAAW,OAAA;AACX,6GAAA,YAAY,OAAA"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result type utilities for adapter operations
|
|
3
|
+
*
|
|
4
|
+
* Enforces "never throws" invariant - all adapter functions return Result<T>.
|
|
5
|
+
*/
|
|
6
|
+
import type { AdapterError, AdapterErrorCode } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Result type for adapter operations
|
|
9
|
+
*
|
|
10
|
+
* All adapter parsing/validation functions should return this type
|
|
11
|
+
* instead of throwing exceptions. This makes error handling explicit
|
|
12
|
+
* and predictable.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* function parseEvent(input: unknown): Result<Event, AdapterError> {
|
|
16
|
+
* if (!input) {
|
|
17
|
+
* return adapterErr('input is required', 'missing_required_field');
|
|
18
|
+
* }
|
|
19
|
+
* return ok({ ... });
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
export type Result<T, E = AdapterError> = {
|
|
23
|
+
ok: true;
|
|
24
|
+
value: T;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
error: E;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Create a success result
|
|
31
|
+
*/
|
|
32
|
+
export declare function ok<T>(value: T): Result<T, never>;
|
|
33
|
+
/**
|
|
34
|
+
* Create a generic error result
|
|
35
|
+
*/
|
|
36
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
37
|
+
/**
|
|
38
|
+
* Create an adapter error result (convenience helper)
|
|
39
|
+
*
|
|
40
|
+
* @param message - Human-readable error message
|
|
41
|
+
* @param code - Machine-readable error code
|
|
42
|
+
* @param field - Optional field name that caused the error
|
|
43
|
+
*/
|
|
44
|
+
export declare function adapterErr(message: string, code: AdapterErrorCode, field?: string): Result<never, AdapterError>;
|
|
45
|
+
/**
|
|
46
|
+
* Check if result is ok (type guard)
|
|
47
|
+
*/
|
|
48
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
49
|
+
ok: true;
|
|
50
|
+
value: T;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Check if result is error (type guard)
|
|
54
|
+
*/
|
|
55
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
56
|
+
ok: false;
|
|
57
|
+
error: E;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Map over a successful result
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const result = ok(5);
|
|
64
|
+
* const doubled = map(result, x => x * 2); // ok(10)
|
|
65
|
+
*/
|
|
66
|
+
export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
|
|
67
|
+
/**
|
|
68
|
+
* Map over an error result
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const result = err({ message: 'oops' });
|
|
72
|
+
* const mapped = mapErr(result, e => ({ ...e, prefix: 'Error: ' }));
|
|
73
|
+
*/
|
|
74
|
+
export declare function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
|
|
75
|
+
/**
|
|
76
|
+
* Chain results (flatMap/bind)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const parseNumber = (s: string): Result<number, string> => {
|
|
80
|
+
* const n = parseInt(s);
|
|
81
|
+
* return isNaN(n) ? err('not a number') : ok(n);
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* const result = chain(ok('42'), parseNumber); // ok(42)
|
|
85
|
+
*/
|
|
86
|
+
export declare function chain<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
|
|
87
|
+
/**
|
|
88
|
+
* Unwrap a result, throwing if it's an error
|
|
89
|
+
*
|
|
90
|
+
* Use sparingly - prefer explicit error handling.
|
|
91
|
+
*
|
|
92
|
+
* @throws The error value if result is an error
|
|
93
|
+
*/
|
|
94
|
+
export declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
95
|
+
/**
|
|
96
|
+
* Unwrap a result with a default value for errors
|
|
97
|
+
*/
|
|
98
|
+
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
|
|
99
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,YAAY,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3F;;GAEG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAEhD;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,C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C,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAEjG;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAKpD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAEvE"}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Result type utilities for adapter operations
|
|
4
|
+
*
|
|
5
|
+
* Enforces "never throws" invariant - all adapter functions return Result<T>.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ok = ok;
|
|
9
|
+
exports.err = err;
|
|
10
|
+
exports.adapterErr = adapterErr;
|
|
11
|
+
exports.isOk = isOk;
|
|
12
|
+
exports.isErr = isErr;
|
|
13
|
+
exports.map = map;
|
|
14
|
+
exports.mapErr = mapErr;
|
|
15
|
+
exports.chain = chain;
|
|
16
|
+
exports.unwrap = unwrap;
|
|
17
|
+
exports.unwrapOr = unwrapOr;
|
|
18
|
+
/**
|
|
19
|
+
* Create a success result
|
|
20
|
+
*/
|
|
21
|
+
function ok(value) {
|
|
22
|
+
return { ok: true, value };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a generic error result
|
|
26
|
+
*/
|
|
27
|
+
function err(error) {
|
|
28
|
+
return { ok: false, error };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an adapter error result (convenience helper)
|
|
32
|
+
*
|
|
33
|
+
* @param message - Human-readable error message
|
|
34
|
+
* @param code - Machine-readable error code
|
|
35
|
+
* @param field - Optional field name that caused the error
|
|
36
|
+
*/
|
|
37
|
+
function adapterErr(message, code, field) {
|
|
38
|
+
return err({ code, message, field });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if result is ok (type guard)
|
|
42
|
+
*/
|
|
43
|
+
function isOk(result) {
|
|
44
|
+
return result.ok;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if result is error (type guard)
|
|
48
|
+
*/
|
|
49
|
+
function isErr(result) {
|
|
50
|
+
return !result.ok;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Map over a successful result
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const result = ok(5);
|
|
57
|
+
* const doubled = map(result, x => x * 2); // ok(10)
|
|
58
|
+
*/
|
|
59
|
+
function map(result, fn) {
|
|
60
|
+
return result.ok ? ok(fn(result.value)) : result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Map over an error result
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const result = err({ message: 'oops' });
|
|
67
|
+
* const mapped = mapErr(result, e => ({ ...e, prefix: 'Error: ' }));
|
|
68
|
+
*/
|
|
69
|
+
function mapErr(result, fn) {
|
|
70
|
+
return result.ok ? result : err(fn(result.error));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Chain results (flatMap/bind)
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const parseNumber = (s: string): Result<number, string> => {
|
|
77
|
+
* const n = parseInt(s);
|
|
78
|
+
* return isNaN(n) ? err('not a number') : ok(n);
|
|
79
|
+
* };
|
|
80
|
+
*
|
|
81
|
+
* const result = chain(ok('42'), parseNumber); // ok(42)
|
|
82
|
+
*/
|
|
83
|
+
function chain(result, fn) {
|
|
84
|
+
return result.ok ? fn(result.value) : result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Unwrap a result, throwing if it's an error
|
|
88
|
+
*
|
|
89
|
+
* Use sparingly - prefer explicit error handling.
|
|
90
|
+
*
|
|
91
|
+
* @throws The error value if result is an error
|
|
92
|
+
*/
|
|
93
|
+
function unwrap(result) {
|
|
94
|
+
if (result.ok) {
|
|
95
|
+
return result.value;
|
|
96
|
+
}
|
|
97
|
+
throw result.error;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Unwrap a result with a default value for errors
|
|
101
|
+
*/
|
|
102
|
+
function unwrapOr(result, defaultValue) {
|
|
103
|
+
return result.ok ? result.value : defaultValue;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwBH,gBAEC;AAKD,kBAEC;AASD,gCAMC;AAKD,oBAEC;AAKD,sBAEC;AASD,kBAEC;AASD,wBAEC;AAaD,sBAEC;AASD,wBAKC;AAKD,4BAEC;AAnGD;;GAEG;AACH,SAAgB,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,SAAgB,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,OAAe,EACf,IAAsB,EACtB,KAAc;IAEd,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAgB,IAAI,CAAO,MAAoB;IAC7C,OAAO,MAAM,CAAC,EAAE,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,KAAK,CAAO,MAAoB;IAC9C,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,GAAG,CAAU,MAAoB,EAAE,EAAmB;IACpE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAU,MAAoB,EAAE,EAAmB;IACvE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,KAAK,CAAU,MAAoB,EAAE,EAA8B;IACjF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAO,MAAoB;IAC/C,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACd,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,MAAM,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAO,MAAoB,EAAE,YAAe;IAClE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AACjD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for PEAC payment rail adapters
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Adapter error codes (extensible)
|
|
6
|
+
*
|
|
7
|
+
* Core codes that all adapters should use for consistency.
|
|
8
|
+
* Adapters may extend with additional codes as needed.
|
|
9
|
+
*/
|
|
10
|
+
export type AdapterErrorCode = 'missing_required_field' | 'invalid_amount' | 'invalid_currency' | 'invalid_network' | 'parse_error' | 'validation_error' | string;
|
|
11
|
+
/**
|
|
12
|
+
* Adapter error with code and message
|
|
13
|
+
*
|
|
14
|
+
* Provides structured error information for adapter operations.
|
|
15
|
+
*/
|
|
16
|
+
export interface AdapterError {
|
|
17
|
+
/** Machine-readable error code */
|
|
18
|
+
code: AdapterErrorCode;
|
|
19
|
+
/** Human-readable error message */
|
|
20
|
+
message: string;
|
|
21
|
+
/** Optional field name that caused the error */
|
|
22
|
+
field?: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB,wBAAwB,GACxB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,MAAM,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,IAAI,EAAE,gBAAgB,CAAC;IACvB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared validators for PEAC payment rail adapters
|
|
3
|
+
*
|
|
4
|
+
* These validators enforce consistent validation logic across all adapters.
|
|
5
|
+
* They follow the "never throws" pattern using Result types.
|
|
6
|
+
*/
|
|
7
|
+
import { type Result } from './result.js';
|
|
8
|
+
import type { AdapterError } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validate required string field
|
|
11
|
+
*
|
|
12
|
+
* @param value - Value to validate
|
|
13
|
+
* @param fieldName - Field name for error messages
|
|
14
|
+
* @returns Result with string value or error
|
|
15
|
+
*/
|
|
16
|
+
export declare function requireString(value: unknown, fieldName: string): Result<string, AdapterError>;
|
|
17
|
+
/**
|
|
18
|
+
* Validate optional string field
|
|
19
|
+
*
|
|
20
|
+
* @param value - Value to validate
|
|
21
|
+
* @param fieldName - Field name for error messages
|
|
22
|
+
* @returns Result with string value, undefined, or error
|
|
23
|
+
*/
|
|
24
|
+
export declare function optionalString(value: unknown, fieldName: string): Result<string | undefined, AdapterError>;
|
|
25
|
+
/**
|
|
26
|
+
* Validate required number field
|
|
27
|
+
*
|
|
28
|
+
* @param value - Value to validate
|
|
29
|
+
* @param fieldName - Field name for error messages
|
|
30
|
+
* @returns Result with number value or error
|
|
31
|
+
*/
|
|
32
|
+
export declare function requireNumber(value: unknown, fieldName: string): Result<number, AdapterError>;
|
|
33
|
+
/**
|
|
34
|
+
* Validate amount (must be safe non-negative integer in minor units)
|
|
35
|
+
*
|
|
36
|
+
* @param value - Value to validate
|
|
37
|
+
* @returns Result with amount or error
|
|
38
|
+
*/
|
|
39
|
+
export declare function requireAmount(value: unknown): Result<number, AdapterError>;
|
|
40
|
+
/**
|
|
41
|
+
* Validate currency code (ISO 4217, uppercase)
|
|
42
|
+
*
|
|
43
|
+
* @param value - Value to validate
|
|
44
|
+
* @returns Result with normalized currency code or error
|
|
45
|
+
*/
|
|
46
|
+
export declare function requireCurrency(value: unknown): Result<string, AdapterError>;
|
|
47
|
+
/**
|
|
48
|
+
* Validate optional network identifier (CAIP-2 format preferred)
|
|
49
|
+
*
|
|
50
|
+
* @param value - Value to validate
|
|
51
|
+
* @returns Result with network string, undefined, or error
|
|
52
|
+
*/
|
|
53
|
+
export declare function optionalNetwork(value: unknown): Result<string | undefined, AdapterError>;
|
|
54
|
+
/**
|
|
55
|
+
* Parse object safely (for webhook payloads)
|
|
56
|
+
*
|
|
57
|
+
* @param value - Value to validate
|
|
58
|
+
* @param fieldName - Field name for error messages
|
|
59
|
+
* @returns Result with object or error
|
|
60
|
+
*/
|
|
61
|
+
export declare function requireObject(value: unknown, fieldName?: string): Result<Record<string, unknown>, AdapterError>;
|
|
62
|
+
/**
|
|
63
|
+
* Validate optional timestamp (ISO 8601 string or Unix seconds)
|
|
64
|
+
*
|
|
65
|
+
* @param value - Value to validate
|
|
66
|
+
* @returns Result with ISO 8601 string, undefined, or error
|
|
67
|
+
*/
|
|
68
|
+
export declare function optionalTimestamp(value: unknown): Result<string | undefined, AdapterError>;
|
|
69
|
+
/**
|
|
70
|
+
* Validate optional boolean field
|
|
71
|
+
*
|
|
72
|
+
* @param value - Value to validate
|
|
73
|
+
* @param fieldName - Field name for error messages
|
|
74
|
+
* @returns Result with boolean value, undefined, or error
|
|
75
|
+
*/
|
|
76
|
+
export declare function optionalBoolean(value: unknown, fieldName: string): Result<boolean | undefined, AdapterError>;
|
|
77
|
+
/**
|
|
78
|
+
* Validate enum value
|
|
79
|
+
*
|
|
80
|
+
* @param value - Value to validate
|
|
81
|
+
* @param allowed - Array of allowed values
|
|
82
|
+
* @param fieldName - Field name for error messages
|
|
83
|
+
* @returns Result with validated value or error
|
|
84
|
+
*/
|
|
85
|
+
export declare function requireEnum<T extends string>(value: unknown, allowed: readonly T[], fieldName: string): Result<T, AdapterError>;
|
|
86
|
+
/**
|
|
87
|
+
* Validate optional enum value
|
|
88
|
+
*
|
|
89
|
+
* @param value - Value to validate
|
|
90
|
+
* @param allowed - Array of allowed values
|
|
91
|
+
* @param fieldName - Field name for error messages
|
|
92
|
+
* @returns Result with validated value, undefined, or error
|
|
93
|
+
*/
|
|
94
|
+
export declare function optionalEnum<T extends string>(value: unknown, allowed: readonly T[], fieldName: string): Result<T | undefined, AdapterError>;
|
|
95
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../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AC7B,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,OAAO,GAAG,SAAS,EAAE,YAAY,CAAC,CAQ3C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC1C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAYzB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,YAAY,CAAC,CAKrC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared validators for PEAC payment rail adapters
|
|
4
|
+
*
|
|
5
|
+
* These validators enforce consistent validation logic across all adapters.
|
|
6
|
+
* They follow the "never throws" pattern using Result types.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.requireString = requireString;
|
|
10
|
+
exports.optionalString = optionalString;
|
|
11
|
+
exports.requireNumber = requireNumber;
|
|
12
|
+
exports.requireAmount = requireAmount;
|
|
13
|
+
exports.requireCurrency = requireCurrency;
|
|
14
|
+
exports.optionalNetwork = optionalNetwork;
|
|
15
|
+
exports.requireObject = requireObject;
|
|
16
|
+
exports.optionalTimestamp = optionalTimestamp;
|
|
17
|
+
exports.optionalBoolean = optionalBoolean;
|
|
18
|
+
exports.requireEnum = requireEnum;
|
|
19
|
+
exports.optionalEnum = optionalEnum;
|
|
20
|
+
const result_js_1 = require("./result.js");
|
|
21
|
+
/**
|
|
22
|
+
* Validate required string field
|
|
23
|
+
*
|
|
24
|
+
* @param value - Value to validate
|
|
25
|
+
* @param fieldName - Field name for error messages
|
|
26
|
+
* @returns Result with string value or error
|
|
27
|
+
*/
|
|
28
|
+
function requireString(value, fieldName) {
|
|
29
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
30
|
+
return (0, result_js_1.adapterErr)(`${fieldName} is required and must be a non-empty string`, 'missing_required_field', fieldName);
|
|
31
|
+
}
|
|
32
|
+
return (0, result_js_1.ok)(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate optional string field
|
|
36
|
+
*
|
|
37
|
+
* @param value - Value to validate
|
|
38
|
+
* @param fieldName - Field name for error messages
|
|
39
|
+
* @returns Result with string value, undefined, or error
|
|
40
|
+
*/
|
|
41
|
+
function optionalString(value, fieldName) {
|
|
42
|
+
if (value === undefined || value === null) {
|
|
43
|
+
return (0, result_js_1.ok)(undefined);
|
|
44
|
+
}
|
|
45
|
+
if (typeof value !== 'string') {
|
|
46
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be a string if provided`, 'validation_error', fieldName);
|
|
47
|
+
}
|
|
48
|
+
return (0, result_js_1.ok)(value);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validate required number field
|
|
52
|
+
*
|
|
53
|
+
* @param value - Value to validate
|
|
54
|
+
* @param fieldName - Field name for error messages
|
|
55
|
+
* @returns Result with number value or error
|
|
56
|
+
*/
|
|
57
|
+
function requireNumber(value, fieldName) {
|
|
58
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
59
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be a finite number`, 'validation_error', fieldName);
|
|
60
|
+
}
|
|
61
|
+
return (0, result_js_1.ok)(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Validate amount (must be safe non-negative integer in minor units)
|
|
65
|
+
*
|
|
66
|
+
* @param value - Value to validate
|
|
67
|
+
* @returns Result with amount or error
|
|
68
|
+
*/
|
|
69
|
+
function requireAmount(value) {
|
|
70
|
+
if (typeof value !== 'number') {
|
|
71
|
+
return (0, result_js_1.adapterErr)('amount must be a number', 'invalid_amount', 'amount');
|
|
72
|
+
}
|
|
73
|
+
if (!Number.isSafeInteger(value)) {
|
|
74
|
+
return (0, result_js_1.adapterErr)('amount must be a safe integer', 'invalid_amount', 'amount');
|
|
75
|
+
}
|
|
76
|
+
if (value < 0) {
|
|
77
|
+
return (0, result_js_1.adapterErr)('amount must be non-negative', 'invalid_amount', 'amount');
|
|
78
|
+
}
|
|
79
|
+
return (0, result_js_1.ok)(value);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Validate currency code (ISO 4217, uppercase)
|
|
83
|
+
*
|
|
84
|
+
* @param value - Value to validate
|
|
85
|
+
* @returns Result with normalized currency code or error
|
|
86
|
+
*/
|
|
87
|
+
function requireCurrency(value) {
|
|
88
|
+
if (typeof value !== 'string') {
|
|
89
|
+
return (0, result_js_1.adapterErr)('currency must be a string', 'invalid_currency', 'currency');
|
|
90
|
+
}
|
|
91
|
+
const normalized = value.toUpperCase();
|
|
92
|
+
if (!/^[A-Z]{3}$/.test(normalized)) {
|
|
93
|
+
return (0, result_js_1.adapterErr)('currency must be a valid ISO 4217 code (3 uppercase letters)', 'invalid_currency', 'currency');
|
|
94
|
+
}
|
|
95
|
+
return (0, result_js_1.ok)(normalized);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Validate optional network identifier (CAIP-2 format preferred)
|
|
99
|
+
*
|
|
100
|
+
* @param value - Value to validate
|
|
101
|
+
* @returns Result with network string, undefined, or error
|
|
102
|
+
*/
|
|
103
|
+
function optionalNetwork(value) {
|
|
104
|
+
if (value === undefined || value === null) {
|
|
105
|
+
return (0, result_js_1.ok)(undefined);
|
|
106
|
+
}
|
|
107
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
108
|
+
return (0, result_js_1.adapterErr)('network must be a non-empty string if provided', 'invalid_network', 'network');
|
|
109
|
+
}
|
|
110
|
+
return (0, result_js_1.ok)(value);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Parse object safely (for webhook payloads)
|
|
114
|
+
*
|
|
115
|
+
* @param value - Value to validate
|
|
116
|
+
* @param fieldName - Field name for error messages
|
|
117
|
+
* @returns Result with object or error
|
|
118
|
+
*/
|
|
119
|
+
function requireObject(value, fieldName = 'input') {
|
|
120
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
121
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be a non-null object`, 'parse_error', fieldName);
|
|
122
|
+
}
|
|
123
|
+
return (0, result_js_1.ok)(value);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Validate optional timestamp (ISO 8601 string or Unix seconds)
|
|
127
|
+
*
|
|
128
|
+
* @param value - Value to validate
|
|
129
|
+
* @returns Result with ISO 8601 string, undefined, or error
|
|
130
|
+
*/
|
|
131
|
+
function optionalTimestamp(value) {
|
|
132
|
+
if (value === undefined || value === null) {
|
|
133
|
+
return (0, result_js_1.ok)(undefined);
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === 'string') {
|
|
136
|
+
// Accept ISO 8601 strings as-is
|
|
137
|
+
return (0, result_js_1.ok)(value);
|
|
138
|
+
}
|
|
139
|
+
if (typeof value === 'number' && Number.isSafeInteger(value) && value > 0) {
|
|
140
|
+
// Convert Unix seconds to ISO string
|
|
141
|
+
return (0, result_js_1.ok)(new Date(value * 1000).toISOString());
|
|
142
|
+
}
|
|
143
|
+
return (0, result_js_1.adapterErr)('timestamp must be an ISO 8601 string or Unix seconds', 'validation_error', 'timestamp');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Validate optional boolean field
|
|
147
|
+
*
|
|
148
|
+
* @param value - Value to validate
|
|
149
|
+
* @param fieldName - Field name for error messages
|
|
150
|
+
* @returns Result with boolean value, undefined, or error
|
|
151
|
+
*/
|
|
152
|
+
function optionalBoolean(value, fieldName) {
|
|
153
|
+
if (value === undefined || value === null) {
|
|
154
|
+
return (0, result_js_1.ok)(undefined);
|
|
155
|
+
}
|
|
156
|
+
if (typeof value !== 'boolean') {
|
|
157
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be a boolean if provided`, 'validation_error', fieldName);
|
|
158
|
+
}
|
|
159
|
+
return (0, result_js_1.ok)(value);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Validate enum value
|
|
163
|
+
*
|
|
164
|
+
* @param value - Value to validate
|
|
165
|
+
* @param allowed - Array of allowed values
|
|
166
|
+
* @param fieldName - Field name for error messages
|
|
167
|
+
* @returns Result with validated value or error
|
|
168
|
+
*/
|
|
169
|
+
function requireEnum(value, allowed, fieldName) {
|
|
170
|
+
if (typeof value !== 'string') {
|
|
171
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be a string`, 'validation_error', fieldName);
|
|
172
|
+
}
|
|
173
|
+
if (!allowed.includes(value)) {
|
|
174
|
+
return (0, result_js_1.adapterErr)(`${fieldName} must be one of: ${allowed.join(', ')}`, 'validation_error', fieldName);
|
|
175
|
+
}
|
|
176
|
+
return (0, result_js_1.ok)(value);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Validate optional enum value
|
|
180
|
+
*
|
|
181
|
+
* @param value - Value to validate
|
|
182
|
+
* @param allowed - Array of allowed values
|
|
183
|
+
* @param fieldName - Field name for error messages
|
|
184
|
+
* @returns Result with validated value, undefined, or error
|
|
185
|
+
*/
|
|
186
|
+
function optionalEnum(value, allowed, fieldName) {
|
|
187
|
+
if (value === undefined || value === null) {
|
|
188
|
+
return (0, result_js_1.ok)(undefined);
|
|
189
|
+
}
|
|
190
|
+
return requireEnum(value, allowed, fieldName);
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAYH,sCASC;AASD,wCAWC;AASD,sCAKC;AAQD,sCAWC;A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vB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,IAAA,sBAAU,EAAC,GAAG,SAAS,gCAAgC,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,IAAA,cAAE,EAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CACzB,KAAc,EACd,OAAqB,EACrB,SAAiB;IAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAA,sBAAU,EAAC,GAAG,SAAS,mBAAmB,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAU,CAAC,EAAE,CAAC;QAClC,OAAO,IAAA,sBAAU,EACf,GAAG,SAAS,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACpD,kBAAkB,EAClB,SAAS,CACV,CAAC;IACJ,CAAC;IACD,OAAO,IAAA,cAAE,EAAC,KAAU,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,KAAc,EACd,OAAqB,EACrB,SAAiB;IAEjB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,IAAA,cAAE,EAAC,SAAS,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peac/adapter-core",
|
|
3
|
+
"version": "0.9.31",
|
|
4
|
+
"description": "Shared utilities for PEAC payment rail adapters",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/peacprotocol/peac.git",
|
|
18
|
+
"directory": "packages/adapters/core"
|
|
19
|
+
},
|
|
20
|
+
"author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@peac/kernel": "0.9.31"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.10.0",
|
|
34
|
+
"typescript": "^5.3.3",
|
|
35
|
+
"vitest": "^1.6.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"clean": "rm -rf dist"
|
|
42
|
+
}
|
|
43
|
+
}
|