@deconscrew/forgefx-sdk-ts 1.0.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 ADDED
@@ -0,0 +1,24 @@
1
+ # ForgeFX TypeScript SDK
2
+
3
+ Official TypeScript SDK for the ForgeFX / Outlaw Code Studio API.
4
+
5
+ ## Installation
6
+
7
+ npm install forgefx-sdk-ts
8
+
9
+ ## Usage
10
+
11
+ import { ForgeFXClient } from 'forgefx-sdk-ts';
12
+
13
+ const fx = new ForgeFXClient({ apiKey: process.env.FORGEFX_API_KEY! });
14
+
15
+ await fx.health();
16
+ await fx.validate('forgefx-vampire-framework');
17
+
18
+ ## Node Requirement
19
+
20
+ Node.js 18 or newer (native fetch required).
21
+
22
+ ## Version
23
+
24
+ 1.0.0
@@ -0,0 +1,12 @@
1
+ export declare class ForgeFXClient {
2
+ private apiKey;
3
+ private baseUrl;
4
+ constructor(opts: {
5
+ apiKey: string;
6
+ baseUrl?: string;
7
+ });
8
+ health(): Promise<{
9
+ status: string;
10
+ }>;
11
+ validate(product: string): Promise<any>;
12
+ }
package/dist/client.js ADDED
@@ -0,0 +1,34 @@
1
+ import { apiRequest } from './request.js';
2
+ import { LicenseInvalidError } from './errors.js';
3
+ export class ForgeFXClient {
4
+ apiKey;
5
+ baseUrl;
6
+ constructor(opts) {
7
+ if (!opts.apiKey) {
8
+ throw new Error('ForgeFXClient requires an apiKey');
9
+ }
10
+ this.apiKey = opts.apiKey;
11
+ this.baseUrl = (opts.baseUrl || 'https://api.outlawcodestudio.com')
12
+ .replace(/\/$/, '');
13
+ }
14
+ async health() {
15
+ return apiRequest({
16
+ baseUrl: this.baseUrl,
17
+ apiKey: this.apiKey,
18
+ path: '/health'
19
+ });
20
+ }
21
+ async validate(product) {
22
+ const result = await apiRequest({
23
+ baseUrl: this.baseUrl,
24
+ apiKey: this.apiKey,
25
+ path: '/v1/validate',
26
+ method: 'POST',
27
+ body: { product }
28
+ });
29
+ if (!result.valid) {
30
+ throw new LicenseInvalidError(result.reason);
31
+ }
32
+ return result;
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ export declare class ForgeFXError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class LicenseInvalidError extends ForgeFXError {
5
+ constructor(reason?: string);
6
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,12 @@
1
+ export class ForgeFXError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'ForgeFXError';
5
+ }
6
+ }
7
+ export class LicenseInvalidError extends ForgeFXError {
8
+ constructor(reason) {
9
+ super(reason || 'License invalid');
10
+ this.name = 'LicenseInvalidError';
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ export { ForgeFXClient } from './client.js';
2
+ export * from './errors.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { ForgeFXClient } from './client.js';
2
+ export * from './errors.js';
@@ -0,0 +1,8 @@
1
+ export interface ApiRequestOptions {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ path: string;
5
+ method?: string;
6
+ body?: unknown;
7
+ }
8
+ export declare function apiRequest<T>(opts: ApiRequestOptions): Promise<T>;
@@ -0,0 +1,17 @@
1
+ export async function apiRequest(opts) {
2
+ const url = `${opts.baseUrl}${opts.path}`;
3
+ const res = await fetch(url, {
4
+ method: opts.method || 'GET',
5
+ headers: {
6
+ 'Content-Type': 'application/json',
7
+ 'X-API-Key': opts.apiKey
8
+ },
9
+ body: opts.body ? JSON.stringify(opts.body) : undefined
10
+ });
11
+ const text = await res.text();
12
+ const data = text ? JSON.parse(text) : null;
13
+ if (!res.ok) {
14
+ throw new Error(`ForgeFX request failed (${res.status})`);
15
+ }
16
+ return data;
17
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@deconscrew/forgefx-sdk-ts",
3
+ "version": "1.0.0",
4
+ "description": "Official TypeScript SDK for the ForgeFX / Outlaw Code Studio Licensing API",
5
+ "author": "Outlaw Code Studio",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/deconscrew/forgefx-sdk-ts"
25
+ },
26
+ "keywords": [
27
+ "forgefx",
28
+ "outlaw-code-studio",
29
+ "licensing",
30
+ "sdk",
31
+ "typescript",
32
+ "api"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }