@zeriq/api 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,21 @@
1
+ # @zeriq/api
2
+
3
+ TypeScript SDK for the Zeriq Enterprise Workspace API.
4
+
5
+ ```bash
6
+ npm install @zeriq/api
7
+ ```
8
+
9
+ ```ts
10
+ import { ZeriqClient } from "@zeriq/api";
11
+
12
+ const zeriq = new ZeriqClient({
13
+ apiToken: process.env.ZERIQ_API_TOKEN!,
14
+ baseUrl: process.env.ZERIQ_BASE_URL ?? "https://api.zeriq.io/api",
15
+ });
16
+
17
+ const overview = await zeriq.getOverview();
18
+ const docs = await zeriq.getDeveloperDocs();
19
+ ```
20
+
21
+ Use scoped API tokens and configure IP allowlists, mTLS, quotas, and conditional access in the Zeriq developer portal.
@@ -0,0 +1,32 @@
1
+ export type ZeriqClientOptions = {
2
+ apiToken: string;
3
+ baseUrl?: string;
4
+ idempotencyKey?: string;
5
+ userAgent?: string;
6
+ };
7
+ export type ZeriqRequestOptions = {
8
+ method?: "GET" | "POST" | "PATCH" | "DELETE";
9
+ body?: unknown;
10
+ headers?: Record<string, string>;
11
+ idempotencyKey?: string;
12
+ };
13
+ export declare class ZeriqApiError extends Error {
14
+ readonly status: number;
15
+ readonly payload: unknown;
16
+ constructor(message: string, status: number, payload: unknown);
17
+ }
18
+ export declare class ZeriqClient {
19
+ private readonly apiToken;
20
+ private readonly baseUrl;
21
+ private readonly idempotencyKey?;
22
+ private readonly userAgent;
23
+ constructor(options: ZeriqClientOptions);
24
+ request<T = unknown>(path: string, options?: ZeriqRequestOptions): Promise<T>;
25
+ getOverview<T = unknown>(): Promise<T>;
26
+ getDeveloperDocs<T = unknown>(): Promise<T>;
27
+ getDeveloperAnalytics<T = unknown>(days?: number): Promise<T>;
28
+ getEventDeliveries<T = unknown>(subscriptionId: number | string): Promise<T>;
29
+ replayEventDelivery<T = unknown>(subscriptionId: number | string, deliveryId: number | string, currentPassword: string): Promise<T>;
30
+ updateTokenNetworkControls<T = unknown>(tokenId: number | string, controls: Record<string, unknown>): Promise<T>;
31
+ }
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;CAM9D;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,kBAAkB;IAOjC,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,CAAC,CAAC;IAyBvF,WAAW,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC;IAItC,gBAAgB,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC;IAI3C,qBAAqB,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,SAAK,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzD,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI5E,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAOnI,0BAA0B,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAMjH"}
package/dist/index.js ADDED
@@ -0,0 +1,68 @@
1
+ export class ZeriqApiError extends Error {
2
+ status;
3
+ payload;
4
+ constructor(message, status, payload) {
5
+ super(message);
6
+ this.name = "ZeriqApiError";
7
+ this.status = status;
8
+ this.payload = payload;
9
+ }
10
+ }
11
+ export class ZeriqClient {
12
+ apiToken;
13
+ baseUrl;
14
+ idempotencyKey;
15
+ userAgent;
16
+ constructor(options) {
17
+ this.apiToken = options.apiToken;
18
+ this.baseUrl = (options.baseUrl ?? "https://api.zeriq.io/api").replace(/\/+$/, "");
19
+ this.idempotencyKey = options.idempotencyKey;
20
+ this.userAgent = options.userAgent ?? "@zeriq/api/0.1.0";
21
+ }
22
+ async request(path, options = {}) {
23
+ const method = options.method ?? "GET";
24
+ const idempotencyKey = options.idempotencyKey ?? this.idempotencyKey;
25
+ const response = await fetch(`${this.baseUrl}/${path.replace(/^\/+/, "")}`, {
26
+ method,
27
+ headers: {
28
+ Accept: "application/json",
29
+ Authorization: `Bearer ${this.apiToken}`,
30
+ "Content-Type": "application/json",
31
+ "User-Agent": this.userAgent,
32
+ ...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
33
+ ...(options.headers ?? {}),
34
+ },
35
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
36
+ });
37
+ const text = await response.text();
38
+ const payload = text ? JSON.parse(text) : null;
39
+ if (!response.ok) {
40
+ throw new ZeriqApiError(payload?.message ?? "Zeriq API request failed.", response.status, payload);
41
+ }
42
+ return payload;
43
+ }
44
+ getOverview() {
45
+ return this.request("overview");
46
+ }
47
+ getDeveloperDocs() {
48
+ return this.request("settings/api-tokens/developer-docs");
49
+ }
50
+ getDeveloperAnalytics(days = 30) {
51
+ return this.request(`settings/api-tokens/developer-analytics?days=${encodeURIComponent(String(days))}`);
52
+ }
53
+ getEventDeliveries(subscriptionId) {
54
+ return this.request(`settings/api-tokens/event-subscriptions/${subscriptionId}/deliveries`);
55
+ }
56
+ replayEventDelivery(subscriptionId, deliveryId, currentPassword) {
57
+ return this.request(`settings/api-tokens/event-subscriptions/${subscriptionId}/deliveries/${deliveryId}/replay`, {
58
+ method: "POST",
59
+ body: { current_password: currentPassword },
60
+ });
61
+ }
62
+ updateTokenNetworkControls(tokenId, controls) {
63
+ return this.request(`settings/api-tokens/${tokenId}/network-controls`, {
64
+ method: "PATCH",
65
+ body: controls,
66
+ });
67
+ }
68
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@zeriq/api",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Zeriq Enterprise Workspace API.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc -p tsconfig.json",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "zeriq",
18
+ "finpay",
19
+ "api",
20
+ "workspace",
21
+ "enterprise"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Veltrix-Digital-Innovations-LTD/zeriq-typescript-sdk.git"
26
+ },
27
+ "homepage": "https://api.zeriq.io/api/developer/api-tokens/docs",
28
+ "bugs": {
29
+ "url": "https://github.com/Veltrix-Digital-Innovations-LTD/zeriq-typescript-sdk/issues"
30
+ },
31
+ "license": "UNLICENSED",
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "^5.6.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }