@nemphi/sdk 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,89 @@
1
+ # @nemphi/sdk
2
+
3
+ TypeScript SDK for interacting with Nemphi API products from Node.js, edge runtimes, and browsers.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @nemphi/sdk
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { NemphiSdk } from "@nemphi/sdk";
15
+
16
+ const sdk = new NemphiSdk({
17
+ baseUrl: "https://api.your-domain.com",
18
+ token: process.env.NEMPHI_TOKEN,
19
+ organizationId: "org_123",
20
+ });
21
+
22
+ const usage = await sdk.usage.getCurrent();
23
+ console.log(usage);
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ - `baseUrl` (required): Base URL for your platform API deployment.
29
+ - `token` (optional): Bearer token sent as `Authorization: Bearer <token>`.
30
+ - `apiKey` (optional): API key sent as `x-api-key`.
31
+ - `organizationId` (optional): Default organization header (`x-organization-id`).
32
+ - `defaultHeaders` (optional): Additional headers merged into every request.
33
+ - `fetch` (optional): Custom fetch implementation.
34
+
35
+ ## Included product resources
36
+
37
+ - `sdk.usage`
38
+ - `listPlans()`
39
+ - `getCurrent()`
40
+ - `getHistory({ start, end })`
41
+ - `listEvents(query)`
42
+ - `trackEvent({ eventType, count, metadata })`
43
+ - `getMonthlyReport(month)`
44
+ - `sdk.organization`
45
+ - `create({ name })`
46
+ - `getMembers()`
47
+ - `listMemberships()`
48
+ - `listInvitations()`
49
+ - `inviteMember(input)`
50
+ - `removeMember(memberId)`
51
+ - `updateMemberRole(memberId, role)`
52
+ - `getStats()`
53
+ - `getActivity(query)`
54
+ - `sdk.crm`
55
+ - `listContacts(query)` / `getContact(contactId)`
56
+ - `createContact(body)` / `updateContact(contactId, body)`
57
+ - `listDeals(query)` / `createDeal(body)` / `updateDeal(dealId, body)`
58
+ - `listTasks(query)` / `createTask(body)`
59
+ - `createNote(body)`
60
+
61
+ ## Error handling
62
+
63
+ ```ts
64
+ import { NemphiApiError } from "@nemphi/sdk";
65
+
66
+ try {
67
+ await sdk.usage.trackEvent({ eventType: "message_sent" });
68
+ } catch (error) {
69
+ if (error instanceof NemphiApiError) {
70
+ console.error(error.status, error.message, error.data);
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## Release and deployment (Trusted Publishing)
76
+
77
+ The SDK is published to npm via GitHub Actions using npm Trusted Publishing (OIDC) in `.github/workflows/publish-sdk.yml`.
78
+
79
+ 1. In npm, open the package settings for `@nemphi/sdk` and add a **Trusted Publisher** for this GitHub repository/workflow.
80
+ 2. Ensure `packages/sdk/package.json` version is bumped.
81
+ 3. Push a matching tag in the format `sdk-v<version>` (example: `sdk-v0.1.0`).
82
+ 4. The workflow will typecheck, build `dist/`, verify the tag-version match, and run `npm publish --access public`.
83
+
84
+ Notes:
85
+
86
+ - No `NPM_TOKEN` secret is required for publishing when Trusted Publishing is configured.
87
+ - Keep `id-token: write` permission in the workflow so GitHub can mint the OIDC token for npm.
88
+ - `package.json` should include a `repository.url` that exactly matches the GitHub repo URL configured in npm Trusted Publisher settings.
89
+ - npm can automatically generate provenance for public packages published from public GitHub repositories via Trusted Publishing.
@@ -0,0 +1,12 @@
1
+ import type { RequestOptions, SdkOptions } from "./types";
2
+ export declare class NemphiClient {
3
+ readonly baseUrl: string;
4
+ readonly organizationId?: string;
5
+ private readonly apiKey?;
6
+ private readonly token?;
7
+ private readonly defaultHeaders;
8
+ private readonly fetchImpl;
9
+ constructor(options: SdkOptions);
10
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
11
+ }
12
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgC,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA0BxF,qBAAa,YAAY;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;gBAExC,OAAO,EAAE,UAAU;IAazB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;CAgDzE"}
package/dist/client.js ADDED
@@ -0,0 +1,69 @@
1
+ import { NemphiApiError } from "./errors";
2
+ function appendQuery(url, query) {
3
+ if (!query) {
4
+ return;
5
+ }
6
+ for (const [key, value] of Object.entries(query)) {
7
+ if (value === null || value === undefined) {
8
+ continue;
9
+ }
10
+ if (Array.isArray(value)) {
11
+ for (const item of value) {
12
+ if (item === null || item === undefined) {
13
+ continue;
14
+ }
15
+ url.searchParams.append(key, String(item));
16
+ }
17
+ continue;
18
+ }
19
+ url.searchParams.set(key, String(value));
20
+ }
21
+ }
22
+ export class NemphiClient {
23
+ constructor(options) {
24
+ this.baseUrl = options.baseUrl.replace(/\/+$/, "");
25
+ this.apiKey = options.apiKey;
26
+ this.token = options.token;
27
+ this.organizationId = options.organizationId;
28
+ this.defaultHeaders = options.defaultHeaders || {};
29
+ this.fetchImpl = options.fetch || globalThis.fetch;
30
+ if (!this.fetchImpl) {
31
+ throw new Error("No fetch implementation available. Pass options.fetch in non-browser environments.");
32
+ }
33
+ }
34
+ async request(path, options = {}) {
35
+ const url = new URL(`${this.baseUrl}${path}`);
36
+ appendQuery(url, options.query);
37
+ const headers = new Headers({
38
+ Accept: "application/json",
39
+ ...this.defaultHeaders,
40
+ ...options.headers,
41
+ });
42
+ if (options.body !== undefined && !headers.has("content-type")) {
43
+ headers.set("content-type", "application/json");
44
+ }
45
+ if (this.apiKey && !headers.has("x-api-key")) {
46
+ headers.set("x-api-key", this.apiKey);
47
+ }
48
+ if (this.token && !headers.has("authorization")) {
49
+ headers.set("authorization", `Bearer ${this.token}`);
50
+ }
51
+ if (this.organizationId && !headers.has("x-organization-id")) {
52
+ headers.set("x-organization-id", this.organizationId);
53
+ }
54
+ const response = await this.fetchImpl(url.toString(), {
55
+ method: options.method || "GET",
56
+ headers,
57
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
58
+ signal: options.signal,
59
+ });
60
+ const contentType = response.headers.get("content-type") || "";
61
+ const isJson = contentType.includes("application/json");
62
+ const payload = isJson ? (await response.json()) : await response.text();
63
+ if (!response.ok) {
64
+ const apiError = payload;
65
+ throw new NemphiApiError(apiError?.message || response.statusText || "Request failed", response.status, payload);
66
+ }
67
+ return payload;
68
+ }
69
+ }
@@ -0,0 +1,6 @@
1
+ export declare class NemphiApiError extends Error {
2
+ readonly status: number;
3
+ readonly data: unknown;
4
+ constructor(message: string, status: number, data: unknown);
5
+ }
6
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D"}
package/dist/errors.js ADDED
@@ -0,0 +1,8 @@
1
+ export class NemphiApiError extends Error {
2
+ constructor(message, status, data) {
3
+ super(message);
4
+ this.name = "NemphiApiError";
5
+ this.status = status;
6
+ this.data = data;
7
+ }
8
+ }
@@ -0,0 +1,21 @@
1
+ import { NemphiClient } from "./client";
2
+ import { CrmResource } from "./resources/crm";
3
+ import { OrganizationResource } from "./resources/organization";
4
+ import { UsageResource } from "./resources/usage";
5
+ import type { SdkOptions } from "./types";
6
+ export declare class NemphiSdk {
7
+ readonly client: NemphiClient;
8
+ readonly usage: UsageResource;
9
+ readonly organization: OrganizationResource;
10
+ readonly crm: CrmResource;
11
+ constructor(options: SdkOptions);
12
+ }
13
+ export { NemphiClient } from "./client";
14
+ export { NemphiApiError } from "./errors";
15
+ export { CrmResource } from "./resources/crm";
16
+ export { OrganizationResource } from "./resources/organization";
17
+ export { UsageResource } from "./resources/usage";
18
+ export type { ApiErrorPayload, HttpMethod, QueryParams, QueryValue, RequestOptions, SdkOptions, } from "./types";
19
+ export type { InviteMemberInput } from "./resources/organization";
20
+ export type { TrackUsageEventInput, UsageEventType } from "./resources/usage";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,qBAAa,SAAS;IACpB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;gBAEd,OAAO,EAAE,UAAU;CAMhC;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import { NemphiClient } from "./client";
2
+ import { CrmResource } from "./resources/crm";
3
+ import { OrganizationResource } from "./resources/organization";
4
+ import { UsageResource } from "./resources/usage";
5
+ export class NemphiSdk {
6
+ constructor(options) {
7
+ this.client = new NemphiClient(options);
8
+ this.usage = new UsageResource(this.client);
9
+ this.organization = new OrganizationResource(this.client);
10
+ this.crm = new CrmResource(this.client);
11
+ }
12
+ }
13
+ export { NemphiClient } from "./client";
14
+ export { NemphiApiError } from "./errors";
15
+ export { CrmResource } from "./resources/crm";
16
+ export { OrganizationResource } from "./resources/organization";
17
+ export { UsageResource } from "./resources/usage";
@@ -0,0 +1,17 @@
1
+ import type { NemphiClient } from "../client";
2
+ import type { QueryParams } from "../types";
3
+ export declare class CrmResource {
4
+ private readonly client;
5
+ constructor(client: NemphiClient);
6
+ listContacts(query?: QueryParams): Promise<Record<string, unknown>>;
7
+ getContact(contactId: string): Promise<Record<string, unknown>>;
8
+ createContact(body: Record<string, unknown>): Promise<Record<string, unknown>>;
9
+ updateContact(contactId: string, body: Record<string, unknown>): Promise<Record<string, unknown>>;
10
+ listDeals(query?: QueryParams): Promise<Record<string, unknown>>;
11
+ createDeal(body: Record<string, unknown>): Promise<Record<string, unknown>>;
12
+ updateDeal(dealId: string, body: Record<string, unknown>): Promise<Record<string, unknown>>;
13
+ listTasks(query?: QueryParams): Promise<Record<string, unknown>>;
14
+ createTask(body: Record<string, unknown>): Promise<Record<string, unknown>>;
15
+ createNote(body: Record<string, unknown>): Promise<Record<string, unknown>>;
16
+ }
17
+ //# sourceMappingURL=crm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crm.d.ts","sourceRoot":"","sources":["../../src/resources/crm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAIhC,YAAY,CAAC,KAAK,GAAE,WAAgB;IAMpC,UAAU,CAAC,SAAS,EAAE,MAAM;IAI5B,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO3C,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO9D,SAAS,CAAC,KAAK,GAAE,WAAgB;IAMjC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOxC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOxD,SAAS,CAAC,KAAK,GAAE,WAAgB;IAMjC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOxC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMzC"}
@@ -0,0 +1,59 @@
1
+ export class CrmResource {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ listContacts(query = {}) {
6
+ return this.client.request("/crm/contacts", {
7
+ query,
8
+ });
9
+ }
10
+ getContact(contactId) {
11
+ return this.client.request(`/crm/contacts/${contactId}`);
12
+ }
13
+ createContact(body) {
14
+ return this.client.request("/crm/contacts", {
15
+ method: "POST",
16
+ body,
17
+ });
18
+ }
19
+ updateContact(contactId, body) {
20
+ return this.client.request(`/crm/contacts/${contactId}`, {
21
+ method: "PATCH",
22
+ body,
23
+ });
24
+ }
25
+ listDeals(query = {}) {
26
+ return this.client.request("/crm/deals", {
27
+ query,
28
+ });
29
+ }
30
+ createDeal(body) {
31
+ return this.client.request("/crm/deals", {
32
+ method: "POST",
33
+ body,
34
+ });
35
+ }
36
+ updateDeal(dealId, body) {
37
+ return this.client.request(`/crm/deals/${dealId}`, {
38
+ method: "PATCH",
39
+ body,
40
+ });
41
+ }
42
+ listTasks(query = {}) {
43
+ return this.client.request("/crm/tasks", {
44
+ query,
45
+ });
46
+ }
47
+ createTask(body) {
48
+ return this.client.request("/crm/tasks", {
49
+ method: "POST",
50
+ body,
51
+ });
52
+ }
53
+ createNote(body) {
54
+ return this.client.request("/crm/notes", {
55
+ method: "POST",
56
+ body,
57
+ });
58
+ }
59
+ }
@@ -0,0 +1,23 @@
1
+ import type { NemphiClient } from "../client";
2
+ import type { QueryParams } from "../types";
3
+ export type InviteMemberInput = {
4
+ email: string;
5
+ role?: "admin" | "member";
6
+ expiresInDays?: number;
7
+ };
8
+ export declare class OrganizationResource {
9
+ private readonly client;
10
+ constructor(client: NemphiClient);
11
+ create(input: {
12
+ name: string;
13
+ }): Promise<Record<string, unknown>>;
14
+ getMembers(): Promise<Record<string, unknown>>;
15
+ listMemberships(): Promise<Record<string, unknown>>;
16
+ listInvitations(): Promise<Record<string, unknown>>;
17
+ inviteMember(input: InviteMemberInput): Promise<Record<string, unknown>>;
18
+ removeMember(memberId: string): Promise<Record<string, unknown>>;
19
+ updateMemberRole(memberId: string, role: "owner" | "admin" | "member"): Promise<Record<string, unknown>>;
20
+ getStats(): Promise<Record<string, unknown>>;
21
+ getActivity(query?: QueryParams): Promise<Record<string, unknown>>;
22
+ }
23
+ //# sourceMappingURL=organization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/resources/organization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAIhC,MAAM,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAO9B,UAAU;IAIV,eAAe;IAIf,eAAe;IAIf,YAAY,CAAC,KAAK,EAAE,iBAAiB;IAOrC,YAAY,CAAC,QAAQ,EAAE,MAAM;IAM7B,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ;IAOrE,QAAQ;IAIR,WAAW,CAAC,KAAK,GAAE,WAAgB;CAKpC"}
@@ -0,0 +1,45 @@
1
+ export class OrganizationResource {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ create(input) {
6
+ return this.client.request("/organization", {
7
+ method: "POST",
8
+ body: input,
9
+ });
10
+ }
11
+ getMembers() {
12
+ return this.client.request("/organization/members");
13
+ }
14
+ listMemberships() {
15
+ return this.client.request("/organization/memberships");
16
+ }
17
+ listInvitations() {
18
+ return this.client.request("/organization/invitations");
19
+ }
20
+ inviteMember(input) {
21
+ return this.client.request("/organization/members", {
22
+ method: "POST",
23
+ body: input,
24
+ });
25
+ }
26
+ removeMember(memberId) {
27
+ return this.client.request(`/organization/members/${memberId}`, {
28
+ method: "DELETE",
29
+ });
30
+ }
31
+ updateMemberRole(memberId, role) {
32
+ return this.client.request(`/organization/members/${memberId}/role`, {
33
+ method: "PATCH",
34
+ body: { role },
35
+ });
36
+ }
37
+ getStats() {
38
+ return this.client.request("/organization/stats");
39
+ }
40
+ getActivity(query = {}) {
41
+ return this.client.request("/organization/activity", {
42
+ query,
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,27 @@
1
+ import type { NemphiClient } from "../client";
2
+ import type { QueryParams } from "../types";
3
+ export type UsageEventType = "message_sent" | "email_sent";
4
+ export type TrackUsageEventInput = {
5
+ eventType: UsageEventType;
6
+ count?: number;
7
+ metadata?: Record<string, unknown>;
8
+ };
9
+ export declare class UsageResource {
10
+ private readonly client;
11
+ constructor(client: NemphiClient);
12
+ listPlans(): Promise<{
13
+ plans: Array<Record<string, unknown>>;
14
+ }>;
15
+ getCurrent(): Promise<Record<string, unknown>>;
16
+ getHistory(input: {
17
+ start: string;
18
+ end: string;
19
+ }): Promise<Record<string, unknown>>;
20
+ listEvents(query?: QueryParams): Promise<Record<string, unknown>>;
21
+ trackEvent(input: TrackUsageEventInput): Promise<{
22
+ accepted: boolean;
23
+ queued: boolean;
24
+ }>;
25
+ getMonthlyReport(month: string): Promise<Record<string, unknown>>;
26
+ }
27
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,YAAY,CAAC;AAEjB,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAIhC,SAAS;eAC6B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;IAGpE,UAAU;IAIV,UAAU,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAShD,UAAU,CAAC,KAAK,GAAE,WAAgB;IAMlC,UAAU,CAAC,KAAK,EAAE,oBAAoB;kBACG,OAAO;gBAAU,OAAO;;IAMjE,gBAAgB,CAAC,KAAK,EAAE,MAAM;CAK/B"}
@@ -0,0 +1,35 @@
1
+ export class UsageResource {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ listPlans() {
6
+ return this.client.request("/usage/plans");
7
+ }
8
+ getCurrent() {
9
+ return this.client.request("/usage/current");
10
+ }
11
+ getHistory(input) {
12
+ return this.client.request("/usage/history", {
13
+ query: {
14
+ start: input.start,
15
+ end: input.end,
16
+ },
17
+ });
18
+ }
19
+ listEvents(query = {}) {
20
+ return this.client.request("/usage/events", {
21
+ query,
22
+ });
23
+ }
24
+ trackEvent(input) {
25
+ return this.client.request("/usage/events", {
26
+ method: "POST",
27
+ body: input,
28
+ });
29
+ }
30
+ getMonthlyReport(month) {
31
+ return this.client.request("/usage/reports/monthly", {
32
+ query: { month },
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,27 @@
1
+ export type HttpMethod = "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
2
+ export type QueryValue = string | number | boolean | null | undefined;
3
+ export type QueryParams = Record<string, QueryValue | QueryValue[]>;
4
+ export type RequestOptions = {
5
+ method?: HttpMethod;
6
+ query?: QueryParams;
7
+ body?: unknown;
8
+ headers?: Record<string, string>;
9
+ signal?: AbortSignal;
10
+ };
11
+ export type SdkOptions = {
12
+ baseUrl: string;
13
+ apiKey?: string;
14
+ token?: string;
15
+ organizationId?: string;
16
+ defaultHeaders?: Record<string, string>;
17
+ fetch?: typeof globalThis.fetch;
18
+ };
19
+ export type ApiErrorPayload = {
20
+ message?: string;
21
+ [key: string]: unknown;
22
+ };
23
+ export type PaginatedResponse<T> = {
24
+ nextCursor: string | null;
25
+ total?: number;
26
+ } & T;
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,CAAC,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@nemphi/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for interacting with the Nemphi platform API products",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "check-types": "tsc -p tsconfig.json --noEmit",
22
+ "prepack": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "sdk",
26
+ "api",
27
+ "typescript",
28
+ "crm",
29
+ "usage"
30
+ ],
31
+ "license": "MIT",
32
+ "peerDependencies": {
33
+ "typescript": "^5.0.0"
34
+ }
35
+ }