@solvapay/core 1.0.0-preview.17 → 1.0.0-preview.19

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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SolvaPay Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -3,13 +3,15 @@
3
3
  Shared types, schemas, and errors.
4
4
 
5
5
  ## Install
6
+
6
7
  ```bash
7
8
  pnpm add @solvapay/core
8
9
  ```
9
10
 
10
11
  ## Usage
12
+
11
13
  ```ts
12
- import { SolvaPayError, Env } from '@solvapay/core';
14
+ import { SolvaPayError, Env } from '@solvapay/core'
13
15
  ```
14
16
 
15
- More: docs/architecture.md
17
+ More: [docs/guides/architecture.md](../../docs/guides/architecture.md)
package/dist/index.cjs CHANGED
@@ -32,6 +32,11 @@ var Env = import_zod.z.object({
32
32
  SOLVAPAY_API_BASE_URL: import_zod.z.string().url().optional()
33
33
  });
34
34
  var SolvaPayError = class extends Error {
35
+ /**
36
+ * Creates a new SolvaPayError instance.
37
+ *
38
+ * @param message - Error message
39
+ */
35
40
  constructor(message) {
36
41
  super(message);
37
42
  this.name = "SolvaPayError";
@@ -41,7 +46,9 @@ function getSolvaPayConfig() {
41
46
  const solvapaySecretKey = process.env.SOLVAPAY_SECRET_KEY;
42
47
  const solvapayApiBaseUrl = process.env.SOLVAPAY_API_BASE_URL;
43
48
  if (!solvapaySecretKey) {
44
- throw new SolvaPayError("Server configuration error: SolvaPay secret key not configured. Missing SOLVAPAY_SECRET_KEY environment variable.");
49
+ throw new SolvaPayError(
50
+ "Server configuration error: SolvaPay secret key not configured. Missing SOLVAPAY_SECRET_KEY environment variable."
51
+ );
45
52
  }
46
53
  return {
47
54
  apiKey: solvapaySecretKey,
package/dist/index.d.cts CHANGED
@@ -11,7 +11,37 @@ declare const Env: z.ZodObject<{
11
11
  SOLVAPAY_API_BASE_URL?: string | undefined;
12
12
  }>;
13
13
  type Env = z.infer<typeof Env>;
14
+ /**
15
+ * Base error class for SolvaPay SDK errors.
16
+ *
17
+ * All SolvaPay SDK errors extend this class, making it easy to catch
18
+ * and handle SDK-specific errors separately from other errors.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { SolvaPayError } from '@solvapay/core';
23
+ *
24
+ * try {
25
+ * const config = getSolvaPayConfig();
26
+ * } catch (error) {
27
+ * if (error instanceof SolvaPayError) {
28
+ * // Handle SolvaPay-specific error
29
+ * console.error('SolvaPay error:', error.message);
30
+ * } else {
31
+ * // Handle other errors
32
+ * throw error;
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * @since 1.0.0
38
+ */
14
39
  declare class SolvaPayError extends Error {
40
+ /**
41
+ * Creates a new SolvaPayError instance.
42
+ *
43
+ * @param message - Error message
44
+ */
15
45
  constructor(message: string);
16
46
  }
17
47
  interface SolvaPayConfig {
@@ -20,10 +50,28 @@ interface SolvaPayConfig {
20
50
  }
21
51
  /**
22
52
  * Validates and returns SolvaPay configuration from environment variables.
23
- * Throws SolvaPayError if required environment variables are missing.
53
+ *
54
+ * Reads `SOLVAPAY_SECRET_KEY` and optional `SOLVAPAY_API_BASE_URL` from
55
+ * environment variables and returns a validated configuration object.
24
56
  *
25
57
  * @returns SolvaPayConfig object with apiKey and optional apiBaseUrl
26
- * @throws SolvaPayError if SOLVAPAY_SECRET_KEY is missing
58
+ * @throws {SolvaPayError} If SOLVAPAY_SECRET_KEY is missing
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { getSolvaPayConfig } from '@solvapay/core';
63
+ *
64
+ * try {
65
+ * const config = getSolvaPayConfig();
66
+ * console.log('API Key configured:', config.apiKey);
67
+ * } catch (error) {
68
+ * console.error('Configuration error:', error.message);
69
+ * }
70
+ * ```
71
+ *
72
+ * @see {@link SolvaPayConfig} for the return type
73
+ * @see {@link SolvaPayError} for error handling
74
+ * @since 1.0.0
27
75
  */
28
76
  declare function getSolvaPayConfig(): SolvaPayConfig;
29
77
  declare const version = "0.1.0";
package/dist/index.d.ts CHANGED
@@ -11,7 +11,37 @@ declare const Env: z.ZodObject<{
11
11
  SOLVAPAY_API_BASE_URL?: string | undefined;
12
12
  }>;
13
13
  type Env = z.infer<typeof Env>;
14
+ /**
15
+ * Base error class for SolvaPay SDK errors.
16
+ *
17
+ * All SolvaPay SDK errors extend this class, making it easy to catch
18
+ * and handle SDK-specific errors separately from other errors.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { SolvaPayError } from '@solvapay/core';
23
+ *
24
+ * try {
25
+ * const config = getSolvaPayConfig();
26
+ * } catch (error) {
27
+ * if (error instanceof SolvaPayError) {
28
+ * // Handle SolvaPay-specific error
29
+ * console.error('SolvaPay error:', error.message);
30
+ * } else {
31
+ * // Handle other errors
32
+ * throw error;
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * @since 1.0.0
38
+ */
14
39
  declare class SolvaPayError extends Error {
40
+ /**
41
+ * Creates a new SolvaPayError instance.
42
+ *
43
+ * @param message - Error message
44
+ */
15
45
  constructor(message: string);
16
46
  }
17
47
  interface SolvaPayConfig {
@@ -20,10 +50,28 @@ interface SolvaPayConfig {
20
50
  }
21
51
  /**
22
52
  * Validates and returns SolvaPay configuration from environment variables.
23
- * Throws SolvaPayError if required environment variables are missing.
53
+ *
54
+ * Reads `SOLVAPAY_SECRET_KEY` and optional `SOLVAPAY_API_BASE_URL` from
55
+ * environment variables and returns a validated configuration object.
24
56
  *
25
57
  * @returns SolvaPayConfig object with apiKey and optional apiBaseUrl
26
- * @throws SolvaPayError if SOLVAPAY_SECRET_KEY is missing
58
+ * @throws {SolvaPayError} If SOLVAPAY_SECRET_KEY is missing
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { getSolvaPayConfig } from '@solvapay/core';
63
+ *
64
+ * try {
65
+ * const config = getSolvaPayConfig();
66
+ * console.log('API Key configured:', config.apiKey);
67
+ * } catch (error) {
68
+ * console.error('Configuration error:', error.message);
69
+ * }
70
+ * ```
71
+ *
72
+ * @see {@link SolvaPayConfig} for the return type
73
+ * @see {@link SolvaPayError} for error handling
74
+ * @since 1.0.0
27
75
  */
28
76
  declare function getSolvaPayConfig(): SolvaPayConfig;
29
77
  declare const version = "0.1.0";
package/dist/index.js CHANGED
@@ -5,6 +5,11 @@ var Env = z.object({
5
5
  SOLVAPAY_API_BASE_URL: z.string().url().optional()
6
6
  });
7
7
  var SolvaPayError = class extends Error {
8
+ /**
9
+ * Creates a new SolvaPayError instance.
10
+ *
11
+ * @param message - Error message
12
+ */
8
13
  constructor(message) {
9
14
  super(message);
10
15
  this.name = "SolvaPayError";
@@ -14,7 +19,9 @@ function getSolvaPayConfig() {
14
19
  const solvapaySecretKey = process.env.SOLVAPAY_SECRET_KEY;
15
20
  const solvapayApiBaseUrl = process.env.SOLVAPAY_API_BASE_URL;
16
21
  if (!solvapaySecretKey) {
17
- throw new SolvaPayError("Server configuration error: SolvaPay secret key not configured. Missing SOLVAPAY_SECRET_KEY environment variable.");
22
+ throw new SolvaPayError(
23
+ "Server configuration error: SolvaPay secret key not configured. Missing SOLVAPAY_SECRET_KEY environment variable."
24
+ );
18
25
  }
19
26
  return {
20
27
  apiKey: solvapaySecretKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/core",
3
- "version": "1.0.0-preview.17",
3
+ "version": "1.0.0-preview.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -38,6 +38,7 @@
38
38
  "test": "vitest run || exit 0",
39
39
  "test:unit": "vitest run || exit 0",
40
40
  "test:watch": "vitest",
41
- "lint": "echo 'no lint yet'"
41
+ "lint": "eslint src",
42
+ "lint:fix": "eslint src --fix"
42
43
  }
43
44
  }