@distyra/sdk 0.3.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.
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by openapi-typescript.
4
+ * Do not make direct changes to the file.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @distyra/sdk — TypeScript client for the Distyra Transaction Enrichment &
3
+ * SME Underwriting API.
4
+ *
5
+ * Two layers:
6
+ *
7
+ * - `paths` — generated types from the OpenAPI snapshot in
8
+ * apps/saas-api/openapi.json. Re-exported so callers can write their own
9
+ * openapi-fetch client if they need non-default behavior.
10
+ * - `createDistyraClient()` — opinionated factory that wires up bearer auth
11
+ * and a default base URL, returning a typed openapi-fetch client.
12
+ *
13
+ * Consumers: the banking backend internally (shadow-mode and cutover paths,
14
+ * v2 plan §16.4 weeks 6–9) plus external API customers via the published
15
+ * `@distyra/sdk` npm package.
16
+ *
17
+ * Regenerate after any saas-api schema change:
18
+ *
19
+ * 1. `npm run snapshot -w @brightfield/saas-api` — refresh openapi.json
20
+ * 2. `npm run build -w @distyra/sdk` — regen + compile
21
+ *
22
+ * The committed openapi.json snapshot makes SDK regen reproducible from git
23
+ * without a running server.
24
+ */
25
+ import { type Client, type ClientOptions } from 'openapi-fetch';
26
+ import type { paths } from './generated';
27
+ export type { paths } from './generated';
28
+ export type { components, operations } from './generated';
29
+ /**
30
+ * Production base URL. Mirrors the OpenAPI `servers[0]` entry; kept in sync by
31
+ * hand because the SDK shouldn't have to parse the spec at runtime. The API and
32
+ * CDN stay on `.com`; only the Distyra website and customer portal use `.eu`.
33
+ */
34
+ export declare const PRODUCTION_BASE_URL = "https://api.distyra.com";
35
+ export interface DistyraClientOptions extends Omit<ClientOptions, 'baseUrl' | 'headers'> {
36
+ /** API key (`sk_…`). Required. */
37
+ apiKey: string;
38
+ /** Override the default production base URL — local dev, staging, etc. */
39
+ baseUrl?: string;
40
+ /** Extra headers merged on every request (rarely needed; useful for tracing). */
41
+ headers?: Record<string, string>;
42
+ }
43
+ /**
44
+ * Create a typed openapi-fetch client pre-bound to the Distyra API.
45
+ *
46
+ * Example:
47
+ *
48
+ * const sdk = createDistyraClient({ apiKey: process.env.DISTYRA_KEY! });
49
+ * const { data, error, response } = await sdk.POST('/v1/enrich', {
50
+ * body: { descriptor: 'ALBERT HEIJN 1234 NL', amount: -23.45, currency: 'EUR' },
51
+ * });
52
+ *
53
+ * `data` is fully typed against the EnrichResponse schema. `error` carries
54
+ * the standard `{ error, detail? }` envelope on 4xx/5xx.
55
+ */
56
+ export declare function createDistyraClient(opts: DistyraClientOptions): Client<paths>;
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * @distyra/sdk — TypeScript client for the Distyra Transaction Enrichment &
4
+ * SME Underwriting API.
5
+ *
6
+ * Two layers:
7
+ *
8
+ * - `paths` — generated types from the OpenAPI snapshot in
9
+ * apps/saas-api/openapi.json. Re-exported so callers can write their own
10
+ * openapi-fetch client if they need non-default behavior.
11
+ * - `createDistyraClient()` — opinionated factory that wires up bearer auth
12
+ * and a default base URL, returning a typed openapi-fetch client.
13
+ *
14
+ * Consumers: the banking backend internally (shadow-mode and cutover paths,
15
+ * v2 plan §16.4 weeks 6–9) plus external API customers via the published
16
+ * `@distyra/sdk` npm package.
17
+ *
18
+ * Regenerate after any saas-api schema change:
19
+ *
20
+ * 1. `npm run snapshot -w @brightfield/saas-api` — refresh openapi.json
21
+ * 2. `npm run build -w @distyra/sdk` — regen + compile
22
+ *
23
+ * The committed openapi.json snapshot makes SDK regen reproducible from git
24
+ * without a running server.
25
+ */
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.PRODUCTION_BASE_URL = void 0;
31
+ exports.createDistyraClient = createDistyraClient;
32
+ const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
33
+ /**
34
+ * Production base URL. Mirrors the OpenAPI `servers[0]` entry; kept in sync by
35
+ * hand because the SDK shouldn't have to parse the spec at runtime. The API and
36
+ * CDN stay on `.com`; only the Distyra website and customer portal use `.eu`.
37
+ */
38
+ exports.PRODUCTION_BASE_URL = 'https://api.distyra.com';
39
+ /**
40
+ * Create a typed openapi-fetch client pre-bound to the Distyra API.
41
+ *
42
+ * Example:
43
+ *
44
+ * const sdk = createDistyraClient({ apiKey: process.env.DISTYRA_KEY! });
45
+ * const { data, error, response } = await sdk.POST('/v1/enrich', {
46
+ * body: { descriptor: 'ALBERT HEIJN 1234 NL', amount: -23.45, currency: 'EUR' },
47
+ * });
48
+ *
49
+ * `data` is fully typed against the EnrichResponse schema. `error` carries
50
+ * the standard `{ error, detail? }` envelope on 4xx/5xx.
51
+ */
52
+ function createDistyraClient(opts) {
53
+ const { apiKey, baseUrl = exports.PRODUCTION_BASE_URL, headers, ...rest } = opts;
54
+ if (!apiKey) {
55
+ throw new Error('createDistyraClient: apiKey is required');
56
+ }
57
+ return (0, openapi_fetch_1.default)({
58
+ baseUrl,
59
+ headers: {
60
+ Authorization: `Bearer ${apiKey}`,
61
+ 'Content-Type': 'application/json',
62
+ ...(headers ?? {}),
63
+ },
64
+ ...rest,
65
+ });
66
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@distyra/sdk",
3
+ "version": "0.3.0",
4
+ "description": "TypeScript SDK for the Distyra Transaction Enrichment & SME Underwriting API. Generated from the committed OpenAPI spec; thin, typed wrapper around openapi-fetch.",
5
+ "license": "MIT",
6
+ "author": "Brightfield Software",
7
+ "homepage": "https://distyra.com",
8
+ "keywords": [
9
+ "distyra",
10
+ "transaction enrichment",
11
+ "underwriting",
12
+ "open banking",
13
+ "psd2",
14
+ "openapi",
15
+ "typescript"
16
+ ],
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "generate": "openapi-typescript ../../apps/saas-api/openapi.json -o src/generated.ts",
28
+ "build": "npm run generate && tsc",
29
+ "typecheck": "tsc --noEmit",
30
+ "prepublishOnly": "npm run build"
31
+ },
32
+ "dependencies": {
33
+ "openapi-fetch": "^0.13.0"
34
+ },
35
+ "devDependencies": {
36
+ "openapi-typescript": "^7.5.0"
37
+ }
38
+ }