From e8d70018fabe98555f49c7c3c119fd4588fe1bf4 Mon Sep 17 00:00:00 2001 From: bardonadam Date: Fri, 30 Jan 2026 09:06:39 +0100 Subject: [PATCH] feat: add ActivitySmith client wrapper --- package.json | 17 +++++++++-------- src/ActivitySmith.ts | 24 ++++++++++++++++++++++++ src/index.ts | 4 ++-- tsconfig.base.json | 9 --------- tsconfig.generated.json | 10 +++++++--- tsconfig.json | 7 ++----- tsconfig.src.json | 15 +++++++++++++++ 7 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 src/ActivitySmith.ts delete mode 100644 tsconfig.base.json create mode 100644 tsconfig.src.json diff --git a/package.json b/package.json index 4009365..228cf9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "activitysmith", - "version": "0.1.0", + "version": "0.1.1", "description": "Official ActivitySmith Node.js SDK", "keywords": [ "activitysmith", @@ -9,17 +9,17 @@ "api" ], "homepage": "https://github.com/ActivitySmithHQ/activitysmith-node", - "main": "dist/generated/index.js", - "types": "dist/generated/index.d.ts", + "main": "dist/src/index.js", + "types": "dist/src/index.d.ts", "exports": { ".": { - "types": "./dist/generated/index.d.ts", - "import": "./dist/generated/index.js", - "require": "./dist/generated/index.js", - "default": "./dist/generated/index.js" + "types": "./dist/src/index.d.ts", + "require": "./dist/src/index.js", + "default": "./dist/src/index.js" } }, "files": [ + "dist/src", "dist/generated", "README.md", "LICENSE" @@ -29,7 +29,8 @@ "node": ">=18" }, "scripts": { - "build": "tsc -p tsconfig.generated.json", + "clean": "tsc -b --clean", + "build": "npm run clean && tsc -b", "prepublishOnly": "npm run build", "test": "npm run build && vitest run" }, diff --git a/src/ActivitySmith.ts b/src/ActivitySmith.ts new file mode 100644 index 0000000..54cd32b --- /dev/null +++ b/src/ActivitySmith.ts @@ -0,0 +1,24 @@ +import { Configuration, NotificationsApi, LiveActivitiesApi } from "../generated/index"; + +export interface ActivitySmithOptions { + apiKey: string; +} + +export class ActivitySmith { + public readonly notifications: NotificationsApi; + public readonly liveActivities: LiveActivitiesApi; + + constructor(opts: ActivitySmithOptions) { + if (!opts?.apiKey) { + throw new Error("ActivitySmith: apiKey is required"); + } + + // basePath omitted on purpose — it will use the default from the generated runtime + const config = new Configuration({ + accessToken: opts.apiKey, + }); + + this.notifications = new NotificationsApi(config); + this.liveActivities = new LiveActivitiesApi(config); + } +} diff --git a/src/index.ts b/src/index.ts index 0904800..ad6d6aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,3 @@ // Public exports live here. -// The generator output is in ../generated and can be wrapped/re-exported as needed. -export {}; +import { ActivitySmith } from "./ActivitySmith"; +export = ActivitySmith; diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index 88b1856..0000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "ESNext", - "declaration": true, - "outDir": "dist", - "strict": true - } -} diff --git a/tsconfig.generated.json b/tsconfig.generated.json index 2e03fa5..921f0f5 100644 --- a/tsconfig.generated.json +++ b/tsconfig.generated.json @@ -1,10 +1,14 @@ { - "extends": "./tsconfig.base.json", "compilerOptions": { + "target": "ES2020", "module": "CommonJS", - "rootDir": "generated", + "moduleResolution": "Node", + "declaration": true, + "composite": true, "outDir": "dist/generated", - "strict": false + "rootDir": "generated", + "strict": false, + "skipLibCheck": true }, "include": ["generated"] } diff --git a/tsconfig.json b/tsconfig.json index 2c3251c..3405d93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,4 @@ { - "extends": "./tsconfig.base.json", - "compilerOptions": { - "noEmit": true - }, - "include": ["src"] + "files": [], + "references": [{ "path": "./tsconfig.generated.json" }, { "path": "./tsconfig.src.json" }] } diff --git a/tsconfig.src.json b/tsconfig.src.json new file mode 100644 index 0000000..7880153 --- /dev/null +++ b/tsconfig.src.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "Node", + "declaration": true, + "composite": true, + "outDir": "dist/src", + "rootDir": "src", + "strict": true, + "skipLibCheck": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.generated.json" }] +}