api2key-base-sdk 0.1.6 → 0.1.7

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.
@@ -50,7 +50,7 @@ export declare class AdminClient {
50
50
  }>;
51
51
  }>;
52
52
  createMembership(input: {
53
- scopeType: 'project' | 'global';
53
+ scopeType: 'project' | 'account';
54
54
  userId?: string;
55
55
  email?: string;
56
56
  projectId?: string;
@@ -63,11 +63,11 @@ export declare class AdminClient {
63
63
  autoRenew?: boolean;
64
64
  }, accessToken?: string): Promise<{
65
65
  membershipId: string;
66
- scopeType: 'project' | 'global';
66
+ scopeType: 'project' | 'account';
67
67
  }>;
68
68
  updateMembership(input: {
69
69
  id: string;
70
- scopeType: 'project' | 'global';
70
+ scopeType: 'project' | 'account';
71
71
  projectId?: string;
72
72
  role?: string;
73
73
  tier?: string;
@@ -79,7 +79,7 @@ export declare class AdminClient {
79
79
  }, accessToken?: string): Promise<{
80
80
  id: string;
81
81
  }>;
82
- deleteMembership(id: string, scopeType: 'project' | 'global', accessToken?: string): Promise<null>;
82
+ deleteMembership(id: string, scopeType: 'project' | 'account', accessToken?: string): Promise<null>;
83
83
  listUsers(filters?: {
84
84
  search?: string;
85
85
  projectId?: string;
@@ -1,8 +1,9 @@
1
1
  import { PlatformHttpClient } from '../core/client';
2
- import type { AuthChangePasswordInput, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthSession, AuthUser, AuthVerifyEmailInput, AuthResetPasswordInput } from '../core/types';
2
+ import type { AuthChangePasswordInput, AuthMeResponse, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthSession, AuthVerifyEmailInput, AuthResetPasswordInput } from '../core/types';
3
3
  export declare class AuthClient {
4
4
  private readonly http;
5
5
  constructor(http: PlatformHttpClient);
6
+ private normalizeAuthOptions;
6
7
  login(input: {
7
8
  email: string;
8
9
  password: string;
@@ -22,10 +23,10 @@ export declare class AuthClient {
22
23
  email: string;
23
24
  }): Promise<AuthPasswordResetDispatchResult | null>;
24
25
  resetPassword(input: AuthResetPasswordInput): Promise<null>;
25
- me(accessToken?: string): Promise<{
26
- user: AuthUser;
27
- membership?: unknown;
28
- }>;
26
+ me(options?: string | {
27
+ accessToken?: string;
28
+ projectId?: string;
29
+ }): Promise<AuthMeResponse>;
29
30
  logout(accessToken?: string): Promise<null>;
30
31
  sendChangePasswordCode(accessToken?: string): Promise<AuthPasswordResetDispatchResult>;
31
32
  changePassword(input: AuthChangePasswordInput, accessToken?: string): Promise<null>;
@@ -2,6 +2,11 @@ export class AuthClient {
2
2
  constructor(http) {
3
3
  this.http = http;
4
4
  }
5
+ normalizeAuthOptions(options) {
6
+ return typeof options === 'string'
7
+ ? { accessToken: options, projectId: undefined }
8
+ : (options ?? {});
9
+ }
5
10
  login(input) {
6
11
  return this.http.request('/api/v1/auth/login', {
7
12
  method: 'POST',
@@ -38,9 +43,14 @@ export class AuthClient {
38
43
  body: input,
39
44
  });
40
45
  }
41
- me(accessToken) {
46
+ me(options) {
47
+ const normalizedOptions = this.normalizeAuthOptions(options);
42
48
  return this.http.request('/api/v1/auth/me', {
43
- accessToken,
49
+ accessToken: normalizedOptions.accessToken,
50
+ projectId: normalizedOptions.projectId,
51
+ query: {
52
+ projectId: normalizedOptions.projectId,
53
+ },
44
54
  });
45
55
  }
46
56
  logout(accessToken) {
@@ -65,6 +65,17 @@ export interface AuthSession {
65
65
  refreshToken?: string;
66
66
  expiresIn?: number;
67
67
  }
68
+ export interface ProjectScope {
69
+ type: 'account' | 'project';
70
+ projectId?: string | null;
71
+ projectName?: string | null;
72
+ projectSlug?: string | null;
73
+ }
74
+ export interface AuthMeResponse {
75
+ user: AuthUser;
76
+ membership?: unknown;
77
+ scope?: ProjectScope;
78
+ }
68
79
  export interface AuthRegistrationPending {
69
80
  requiresEmailVerification: true;
70
81
  email: string;
@@ -131,7 +142,25 @@ export interface MembershipView {
131
142
  is_active?: boolean;
132
143
  days_remaining?: number;
133
144
  }
145
+ export interface CreditsAccountSummary {
146
+ balance: number;
147
+ reserved: number;
148
+ totalEarned: number;
149
+ totalSpent: number;
150
+ }
151
+ export interface CreditsBalanceScope {
152
+ type: ProjectScope['type'];
153
+ projectId?: ProjectScope['projectId'];
154
+ projectName?: ProjectScope['projectName'];
155
+ projectSlug?: ProjectScope['projectSlug'];
156
+ }
134
157
  export interface CreditsBalance {
158
+ balance: number;
159
+ reserved: number;
160
+ total_earned: number;
161
+ total_spent: number;
162
+ account: CreditsAccountSummary;
163
+ scope: CreditsBalanceScope;
135
164
  user: AuthUser;
136
165
  }
137
166
  export interface CreditsLedgerItem {
@@ -423,7 +452,7 @@ export interface AdminProduct {
423
452
  }
424
453
  export interface AdminMembershipRecord {
425
454
  id: string;
426
- scopeType: 'project' | 'global';
455
+ scopeType: 'project' | 'account';
427
456
  role: string;
428
457
  tier: string;
429
458
  status: string;
@@ -448,7 +477,7 @@ export interface AdminMembershipRecord {
448
477
  } | null;
449
478
  }
450
479
  export interface AdminMembershipFilters {
451
- scope?: 'project' | 'global';
480
+ scope?: 'project' | 'account';
452
481
  projectId?: string;
453
482
  status?: string;
454
483
  tier?: string;
@@ -467,7 +496,7 @@ export interface AdminUserRecord {
467
496
  name: string;
468
497
  slug: string;
469
498
  } | null;
470
- globalMembership: {
499
+ accountMembership: {
471
500
  id: string;
472
501
  tier: string | null;
473
502
  status: string | null;
@@ -547,7 +576,26 @@ export interface AdminUserCreditsSummary {
547
576
  total_earned: number;
548
577
  total_spent: number;
549
578
  };
550
- recentLedger: CreditsLedgerItem[];
579
+ projectAccounts?: Array<{
580
+ id: string;
581
+ projectId: string;
582
+ projectName?: string | null;
583
+ projectSlug?: string | null;
584
+ role: string;
585
+ tier: string;
586
+ status: string;
587
+ credits: number;
588
+ startDate?: number | null;
589
+ endDate?: number | null;
590
+ autoRenew: boolean;
591
+ }>;
592
+ recentLedger: Array<CreditsLedgerItem & {
593
+ scopeType?: 'account' | 'project';
594
+ projectId?: string | null;
595
+ projectName?: string | null;
596
+ projectSlug?: string | null;
597
+ refId?: string | null;
598
+ }>;
551
599
  }
552
600
  export interface AdminModelRecord {
553
601
  id: string;
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { SpeechClient } from './speech/client';
11
11
  import { UserApiKeysClient } from './user/api-keys-client';
12
12
  import { UserSettingsClient } from './user/settings-client';
13
13
  export * from './core/errors';
14
- export type { AdminConfigItem, AdminMembershipFilters, AdminMembershipRecord, AdminModelInput, AdminModelRecord, AdminOrderFilters, AdminOrderRecord, AdminProduct, AdminProductBackfillResult, AdminProductListResult, AdminProject, AdminProjectExportFormat, AdminUserCreditsSummary, AdminUserRecord, AiModelSummary, AuthChangePasswordInput, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthRegistrationPending, AuthSession, AuthUser, AuthVerificationDispatchResult, AuthVerifyEmailInput, AuthResetPasswordInput, CreditsBalance, CreditsLedgerItem, MembershipView, OrderDetail, OrderSummary, PaymentCreateResponse, PaymentQueryResponse, PlatformClientOptions, PlatformEnvelope, PlatformRequestOptions, ProductSummary, ProjectSummary, SpeechAccessMembership, SpeechAccessProject, SpeechAccessUser, SpeechAsrProvider, SpeechAsrRequestInput, SpeechAsrSegment, SpeechAsrSrtResult, SpeechAsrTaskResult, SpeechAsrTaskSubmission, SpeechSimpleTranscriptSegment, SpeechSynthesisRequest, SpeechSynthesisResult, SpeechTranscribeResult, SpeechTtsProvider, SpeechVoice, SpeechVoiceListResult, UpdateAdminUserInput, UserApiKeyRecord, UserApiKeySecret, UserSettingDefinition, UserSettingsPayload, } from './core/types';
14
+ export type { AdminConfigItem, AdminMembershipFilters, AdminMembershipRecord, AdminModelInput, AdminModelRecord, AdminOrderFilters, AdminOrderRecord, AdminProduct, AdminProductBackfillResult, AdminProductListResult, AdminProject, AdminProjectExportFormat, AdminUserCreditsSummary, AdminUserRecord, AiModelSummary, AuthChangePasswordInput, AuthMeResponse, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthRegistrationPending, AuthSession, AuthUser, AuthVerificationDispatchResult, AuthVerifyEmailInput, CreditsAccountSummary, AuthResetPasswordInput, CreditsBalance, CreditsBalanceScope, CreditsLedgerItem, MembershipView, OrderDetail, OrderSummary, PaymentCreateResponse, PaymentQueryResponse, PlatformClientOptions, PlatformEnvelope, PlatformRequestOptions, ProjectScope, ProductSummary, ProjectSummary, SpeechAccessMembership, SpeechAccessProject, SpeechAccessUser, SpeechAsrProvider, SpeechAsrRequestInput, SpeechAsrSegment, SpeechAsrSrtResult, SpeechAsrTaskResult, SpeechAsrTaskSubmission, SpeechSimpleTranscriptSegment, SpeechSynthesisRequest, SpeechSynthesisResult, SpeechTranscribeResult, SpeechTtsProvider, SpeechVoice, SpeechVoiceListResult, UpdateAdminUserInput, UserApiKeyRecord, UserApiKeySecret, UserSettingDefinition, UserSettingsPayload, } from './core/types';
15
15
  export declare class BasePlatformClient {
16
16
  readonly http: PlatformHttpClient;
17
17
  readonly auth: AuthClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api2key-base-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "TypeScript SDK for consuming the Api2Key API stable APIs",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -45,4 +45,4 @@
45
45
  "devDependencies": {
46
46
  "typescript": "^5.3.3"
47
47
  }
48
- }
48
+ }