@amos.com/node 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -0
- package/openapi/schema.ts +4406 -0
- package/package.json +58 -0
- package/src/index.ts +54 -0
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amos.com/node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Node.js client for the Amos Pay API.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"openapi/schema.ts",
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"biome": "biome check --write",
|
|
22
|
+
"prebuild": "npm run generate",
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"generate": "git -C ../openapi pull && rm -rf openapi/schema.ts && openapi-typescript ../openapi/amos/openapi.public.yaml --output openapi/schema.ts",
|
|
25
|
+
"changeset": "changeset",
|
|
26
|
+
"version": "changeset version",
|
|
27
|
+
"release": "npm run build && changeset publish"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"amos",
|
|
31
|
+
"payment processing",
|
|
32
|
+
"credit cards",
|
|
33
|
+
"api"
|
|
34
|
+
],
|
|
35
|
+
"author": "Amos",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/amos/amos-node.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/amos/amos-node/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/amos/amos-node#readme",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"openapi-fetch": "0.17.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@biomejs/biome": "2.4.14",
|
|
50
|
+
"@changesets/cli": "2.31.0",
|
|
51
|
+
"@types/node": "25.6.2",
|
|
52
|
+
"openapi-typescript": "7.13.0",
|
|
53
|
+
"typescript": "5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=24.11.0"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import createClient, {
|
|
2
|
+
type ClientOptions,
|
|
3
|
+
type Middleware,
|
|
4
|
+
} from "openapi-fetch";
|
|
5
|
+
import type { paths } from "../openapi/schema";
|
|
6
|
+
|
|
7
|
+
export * from "../openapi/schema";
|
|
8
|
+
|
|
9
|
+
export const PAY_API_BASE_URL_PRODUCTION = "https://pay.subfi.com";
|
|
10
|
+
export const PAY_API_BASE_URL_SANDBOX = "https://pay-sandbox.subfi.com";
|
|
11
|
+
export const PAY_API_VERSION = "1";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a typed `openapi-fetch` client for the SubFi Pay API.
|
|
15
|
+
*
|
|
16
|
+
* The returned client exposes `GET`, `POST`, `PUT`, `DELETE`, etc., each
|
|
17
|
+
* fully typed against the OpenAPI spec — paths, path/query/header params,
|
|
18
|
+
* request bodies, and response bodies are all checked at compile time.
|
|
19
|
+
*
|
|
20
|
+
* Provide credentials and the required `X-Api-Version` header either as
|
|
21
|
+
* default `headers` here or via `params.header` on each call. Use
|
|
22
|
+
* `client.use(middleware)` to add per-request behavior such as fresh
|
|
23
|
+
* idempotency keys.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import {
|
|
28
|
+
* createPayApiClient,
|
|
29
|
+
* PAY_API_BASE_URL_SANDBOX,
|
|
30
|
+
* PAY_API_VERSION,
|
|
31
|
+
* } from "@subfico/pay-js-sdk/api";
|
|
32
|
+
*
|
|
33
|
+
* const pay = createPayApiClient({
|
|
34
|
+
* baseUrl: PAY_API_BASE_URL_SANDBOX,
|
|
35
|
+
* headers: {
|
|
36
|
+
* "X-Api-Key": process.env.SUBFI_API_KEY!,
|
|
37
|
+
* "X-Api-Version": PAY_API_VERSION,
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* const { data, error } = await pay.POST("/customers", {
|
|
42
|
+
* params: { header: { "X-Api-Version": PAY_API_VERSION } },
|
|
43
|
+
* body: { customer: { email: "alex@example.com" } },
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function createPayApiClient(options: ClientOptions) {
|
|
48
|
+
return createClient<paths>(options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A configured SubFi Pay API client returned by {@link createPayApiClient}. */
|
|
52
|
+
export type PayApiClient = ReturnType<typeof createPayApiClient>;
|
|
53
|
+
|
|
54
|
+
export type { ClientOptions, Middleware };
|