@halo-ads/types 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 ADDED
@@ -0,0 +1,37 @@
1
+ # @halo-ads/types
2
+
3
+ > Shared TypeScript types for the Halo Ads SDK — zero runtime, import-only.
4
+
5
+ This package is a pure type library. It exports no JavaScript at runtime; all exports are `interface`, `type`, and `enum` declarations.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @halo-ads/types
11
+ ```
12
+
13
+ ## Key types
14
+
15
+ | Type | Description |
16
+ |---|---|
17
+ | `HaloConfig` | SDK initialisation options |
18
+ | `Ad` | A resolved ad creative |
19
+ | `AdFormat` | `banner \| card \| native \| carousel \| interstitial` |
20
+ | `AdTheme` | CSS-variable-style theme tokens |
21
+ | `AdRequest` / `AdResponse` | Fetch request/response shapes |
22
+ | `TrackEventName` / `TrackEventPayload` | Analytics event envelope |
23
+ | `UserProfile` | Client-side user profile (interests, device, geo) |
24
+ | `IAdProvider` | Interface for swapping mock ↔ real API |
25
+ | `HaloAdsInstance` | Full SDK surface interface |
26
+
27
+ ## Usage
28
+
29
+ ```ts
30
+ import type { Ad, AdFormat, HaloConfig } from '@halo-ads/types';
31
+
32
+ const config: HaloConfig = {
33
+ publisherId: 'pub_xxx',
34
+ apiKey: 'pk_live_...',
35
+ environment: 'production',
36
+ };
37
+ ```
@@ -0,0 +1,124 @@
1
+ interface HaloConfig {
2
+ /** Your publisher ID from the Halo Ads dashboard */
3
+ publisherId: string;
4
+ /** API key (pk_live_... or pk_test_...) */
5
+ apiKey?: string;
6
+ /** Enable debug logging */
7
+ debug?: boolean;
8
+ /** Override the API base URL (for self-hosted / staging) */
9
+ apiBaseUrl?: string;
10
+ /** Ad environment */
11
+ environment?: 'production' | 'staging' | 'development';
12
+ }
13
+ type AdFormat = 'banner' | 'card' | 'native' | 'carousel' | 'interstitial';
14
+ type AdCategory = 'sports' | 'finance' | 'travel' | 'food' | 'gaming' | 'technology' | 'fashion' | 'health' | 'entertainment' | 'other';
15
+ interface Ad {
16
+ id: string;
17
+ title: string;
18
+ description: string;
19
+ /** URL to the ad creative image */
20
+ image: string;
21
+ /** Destination URL when clicked */
22
+ url: string;
23
+ category: AdCategory;
24
+ /** Call-to-action button label */
25
+ ctaText: string;
26
+ /** Advertiser name */
27
+ advertiser?: string;
28
+ /** Sponsored label override */
29
+ sponsoredLabel?: string;
30
+ /** Format hint for renderers */
31
+ format?: AdFormat;
32
+ /** Custom theme tokens */
33
+ theme?: AdTheme;
34
+ }
35
+ interface AdTheme {
36
+ primaryColor?: string;
37
+ backgroundColor?: string;
38
+ textColor?: string;
39
+ ctaBackground?: string;
40
+ ctaTextColor?: string;
41
+ borderRadius?: string;
42
+ }
43
+ interface AdRequest {
44
+ slot: string;
45
+ format?: AdFormat;
46
+ publisherId?: string;
47
+ /** Optional targeting hints */
48
+ targeting?: Record<string, string | string[]>;
49
+ }
50
+ interface AdResponse {
51
+ ad: Ad | null;
52
+ slot: string;
53
+ requestId: string;
54
+ fill: boolean;
55
+ timestamp: number;
56
+ }
57
+ interface RenderOptions {
58
+ /** CSS selector or HTMLElement */
59
+ container: string | HTMLElement;
60
+ slot: string;
61
+ format?: AdFormat;
62
+ theme?: AdTheme;
63
+ onImpression?: (ad: Ad) => void;
64
+ onClick?: (ad: Ad) => void;
65
+ }
66
+ type TrackEventName = 'page_view' | 'impression' | 'click' | 'view' | 'purchase' | 'conversion' | 'close' | string;
67
+ interface TrackEventPayload {
68
+ adId?: string;
69
+ slot?: string;
70
+ value?: number;
71
+ currency?: string;
72
+ label?: string;
73
+ [key: string]: unknown;
74
+ }
75
+ interface AnalyticsEvent {
76
+ name: TrackEventName;
77
+ payload?: TrackEventPayload;
78
+ publisherId: string;
79
+ sessionId: string;
80
+ timestamp: number;
81
+ url: string;
82
+ userAgent: string;
83
+ }
84
+ interface UserProfile {
85
+ /** Inferred interests from ad interactions */
86
+ interests: string[];
87
+ /** Browser language */
88
+ language: string;
89
+ /** Inferred country (ISO 3166-1 alpha-2) */
90
+ country: string;
91
+ /** Device type */
92
+ device: 'mobile' | 'tablet' | 'desktop' | 'unknown';
93
+ /** Unique session ID */
94
+ sessionId: string;
95
+ /** Timestamp of first seen */
96
+ firstSeen: number;
97
+ /** Timestamp of last seen */
98
+ lastSeen: number;
99
+ /** Ad IDs already shown this session */
100
+ seenAdIds: string[];
101
+ }
102
+ interface IAdProvider {
103
+ fetchAd(request: AdRequest): Promise<AdResponse>;
104
+ fetchAds(requests: AdRequest[]): Promise<AdResponse[]>;
105
+ }
106
+ interface IAnalyticsProvider {
107
+ send(event: AnalyticsEvent): Promise<void>;
108
+ }
109
+ interface IProfileStore {
110
+ get(): UserProfile;
111
+ update(partial: Partial<UserProfile>): void;
112
+ clear(): void;
113
+ }
114
+ interface HaloAdsInstance {
115
+ init(config: HaloConfig): void;
116
+ track(name: TrackEventName, payload?: TrackEventPayload): void;
117
+ getAd(request: AdRequest): Promise<Ad | null>;
118
+ render(options: RenderOptions): Promise<void>;
119
+ getProfile(): UserProfile;
120
+ isInitialized(): boolean;
121
+ destroy(): void;
122
+ }
123
+
124
+ export type { Ad, AdCategory, AdFormat, AdRequest, AdResponse, AdTheme, AnalyticsEvent, HaloAdsInstance, HaloConfig, IAdProvider, IAnalyticsProvider, IProfileStore, RenderOptions, TrackEventName, TrackEventPayload, UserProfile };
@@ -0,0 +1,124 @@
1
+ interface HaloConfig {
2
+ /** Your publisher ID from the Halo Ads dashboard */
3
+ publisherId: string;
4
+ /** API key (pk_live_... or pk_test_...) */
5
+ apiKey?: string;
6
+ /** Enable debug logging */
7
+ debug?: boolean;
8
+ /** Override the API base URL (for self-hosted / staging) */
9
+ apiBaseUrl?: string;
10
+ /** Ad environment */
11
+ environment?: 'production' | 'staging' | 'development';
12
+ }
13
+ type AdFormat = 'banner' | 'card' | 'native' | 'carousel' | 'interstitial';
14
+ type AdCategory = 'sports' | 'finance' | 'travel' | 'food' | 'gaming' | 'technology' | 'fashion' | 'health' | 'entertainment' | 'other';
15
+ interface Ad {
16
+ id: string;
17
+ title: string;
18
+ description: string;
19
+ /** URL to the ad creative image */
20
+ image: string;
21
+ /** Destination URL when clicked */
22
+ url: string;
23
+ category: AdCategory;
24
+ /** Call-to-action button label */
25
+ ctaText: string;
26
+ /** Advertiser name */
27
+ advertiser?: string;
28
+ /** Sponsored label override */
29
+ sponsoredLabel?: string;
30
+ /** Format hint for renderers */
31
+ format?: AdFormat;
32
+ /** Custom theme tokens */
33
+ theme?: AdTheme;
34
+ }
35
+ interface AdTheme {
36
+ primaryColor?: string;
37
+ backgroundColor?: string;
38
+ textColor?: string;
39
+ ctaBackground?: string;
40
+ ctaTextColor?: string;
41
+ borderRadius?: string;
42
+ }
43
+ interface AdRequest {
44
+ slot: string;
45
+ format?: AdFormat;
46
+ publisherId?: string;
47
+ /** Optional targeting hints */
48
+ targeting?: Record<string, string | string[]>;
49
+ }
50
+ interface AdResponse {
51
+ ad: Ad | null;
52
+ slot: string;
53
+ requestId: string;
54
+ fill: boolean;
55
+ timestamp: number;
56
+ }
57
+ interface RenderOptions {
58
+ /** CSS selector or HTMLElement */
59
+ container: string | HTMLElement;
60
+ slot: string;
61
+ format?: AdFormat;
62
+ theme?: AdTheme;
63
+ onImpression?: (ad: Ad) => void;
64
+ onClick?: (ad: Ad) => void;
65
+ }
66
+ type TrackEventName = 'page_view' | 'impression' | 'click' | 'view' | 'purchase' | 'conversion' | 'close' | string;
67
+ interface TrackEventPayload {
68
+ adId?: string;
69
+ slot?: string;
70
+ value?: number;
71
+ currency?: string;
72
+ label?: string;
73
+ [key: string]: unknown;
74
+ }
75
+ interface AnalyticsEvent {
76
+ name: TrackEventName;
77
+ payload?: TrackEventPayload;
78
+ publisherId: string;
79
+ sessionId: string;
80
+ timestamp: number;
81
+ url: string;
82
+ userAgent: string;
83
+ }
84
+ interface UserProfile {
85
+ /** Inferred interests from ad interactions */
86
+ interests: string[];
87
+ /** Browser language */
88
+ language: string;
89
+ /** Inferred country (ISO 3166-1 alpha-2) */
90
+ country: string;
91
+ /** Device type */
92
+ device: 'mobile' | 'tablet' | 'desktop' | 'unknown';
93
+ /** Unique session ID */
94
+ sessionId: string;
95
+ /** Timestamp of first seen */
96
+ firstSeen: number;
97
+ /** Timestamp of last seen */
98
+ lastSeen: number;
99
+ /** Ad IDs already shown this session */
100
+ seenAdIds: string[];
101
+ }
102
+ interface IAdProvider {
103
+ fetchAd(request: AdRequest): Promise<AdResponse>;
104
+ fetchAds(requests: AdRequest[]): Promise<AdResponse[]>;
105
+ }
106
+ interface IAnalyticsProvider {
107
+ send(event: AnalyticsEvent): Promise<void>;
108
+ }
109
+ interface IProfileStore {
110
+ get(): UserProfile;
111
+ update(partial: Partial<UserProfile>): void;
112
+ clear(): void;
113
+ }
114
+ interface HaloAdsInstance {
115
+ init(config: HaloConfig): void;
116
+ track(name: TrackEventName, payload?: TrackEventPayload): void;
117
+ getAd(request: AdRequest): Promise<Ad | null>;
118
+ render(options: RenderOptions): Promise<void>;
119
+ getProfile(): UserProfile;
120
+ isInitialized(): boolean;
121
+ destroy(): void;
122
+ }
123
+
124
+ export type { Ad, AdCategory, AdFormat, AdRequest, AdResponse, AdTheme, AnalyticsEvent, HaloAdsInstance, HaloConfig, IAdProvider, IAnalyticsProvider, IProfileStore, RenderOptions, TrackEventName, TrackEventPayload, UserProfile };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
package/dist/index.mjs ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@halo-ads/types",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "description": "Shared TypeScript types for Halo Ads SDK — zero runtime, import-only",
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.ts",
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "devDependencies": {
24
+ "tsup": "^8.0.2",
25
+ "typescript": "^5.4.5"
26
+ },
27
+ "scripts": {
28
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
29
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
30
+ "typecheck": "tsc --noEmit",
31
+ "clean": "rm -rf dist *.tsbuildinfo"
32
+ }
33
+ }