@nangohq/types 0.68.0 → 0.69.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.
@@ -2,7 +2,7 @@ import type { Result } from '../result.js';
2
2
  import type { DBTeam } from '../team/db.js';
3
3
  import type { DBUser } from '../user/db.js';
4
4
  export interface BillingClient {
5
- ingest: (events: BillingIngestEvent[]) => Promise<void>;
5
+ ingest: (events: BillingEvent[]) => Promise<Result<void>>;
6
6
  upsertCustomer: (team: DBTeam, user: DBUser) => Promise<Result<BillingCustomer>>;
7
7
  updateCustomer: (customerId: string, name: string) => Promise<Result<void>>;
8
8
  linkStripeToCustomer(teamId: number, customerId: string): Promise<Result<void>>;
@@ -52,19 +52,71 @@ export interface BillingPlan {
52
52
  id: string;
53
53
  external_plan_id: string;
54
54
  }
55
- export interface BillingIngestEvent {
56
- type: 'monthly_active_records' | 'billable_connections' | 'billable_actions' | 'billable_active_connections' | 'function_executions';
57
- idempotencyKey: string;
58
- accountId: number;
59
- timestamp: Date;
60
- properties: Record<string, string | number | Date>;
61
- }
62
- export interface BillingMetric {
63
- type: BillingIngestEvent['type'];
64
- value: number;
55
+ type BillingPropertyValue = string | number | boolean | Date | undefined;
56
+ type BillingProperties = Record<string, BillingPropertyValue | Record<string, BillingPropertyValue>>;
57
+ interface BillingEventBase<TType extends string, TProperties extends BillingProperties = BillingProperties> {
58
+ type: TType;
65
59
  properties: {
66
- accountId: number;
67
- timestamp?: Date | undefined;
60
+ timestamp: Date;
68
61
  idempotencyKey?: string | undefined;
69
- } & BillingIngestEvent['properties'];
62
+ accountId: number;
63
+ count: number;
64
+ } & TProperties;
70
65
  }
66
+ export type MarBillingEvent = BillingEventBase<'monthly_active_records', {
67
+ connectionId: number;
68
+ environmentId: number;
69
+ providerConfigKey: string;
70
+ syncId: string;
71
+ model: string;
72
+ }>;
73
+ export type RecordsBillingEvent = BillingEventBase<'records', {
74
+ frequencyMs: number;
75
+ telemetry: {
76
+ sizeBytes: number;
77
+ };
78
+ }>;
79
+ export type ActionsBillingEvent = BillingEventBase<'billable_actions', {
80
+ connectionId: number;
81
+ environmentId: number;
82
+ providerConfigKey: string;
83
+ actionName: string;
84
+ }>;
85
+ export type FunctionExecutionsBillingEvent = BillingEventBase<'function_executions', {
86
+ type: string;
87
+ connectionId: number;
88
+ telemetry: {
89
+ successes: number;
90
+ failures: number;
91
+ durationMs: number;
92
+ compute: number;
93
+ customLogs: number;
94
+ proxyCalls: number;
95
+ };
96
+ frequencyMs?: number | undefined;
97
+ }>;
98
+ export type ProxyBillingEvent = BillingEventBase<'proxy', {
99
+ connectionId: number;
100
+ environmentId: number;
101
+ providerConfigKey: string;
102
+ provider: string;
103
+ telemetry: {
104
+ successes: number;
105
+ failures: number;
106
+ };
107
+ }>;
108
+ export type WebhookForwardBillingEvent = BillingEventBase<'webhook_forwards', {
109
+ environmentId: number;
110
+ providerConfigKey: string;
111
+ provider: string;
112
+ telemetry: {
113
+ successes: number;
114
+ failures: number;
115
+ };
116
+ }>;
117
+ export type ConnectionsBillingEvent = BillingEventBase<'billable_connections'>;
118
+ export type ConnectionsBillingEventV2 = BillingEventBase<'billable_connections_v2', {
119
+ frequencyMs: number;
120
+ }>;
121
+ export type BillingEvent = MarBillingEvent | RecordsBillingEvent | ActionsBillingEvent | ProxyBillingEvent | WebhookForwardBillingEvent | FunctionExecutionsBillingEvent | ConnectionsBillingEvent | ConnectionsBillingEventV2;
122
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface DBConfig {
2
+ encryption_key_hash: string | null;
3
+ encryption_complete: boolean;
4
+ }
package/dist/index.d.ts CHANGED
@@ -49,7 +49,7 @@ export type * from './integration/api.js';
49
49
  export type * from './integration/db.js';
50
50
  export type * from './providers/provider.js';
51
51
  export type * from './auth/api.js';
52
- export type * from './auth/db.js';
52
+ export type * from './oauthSessions/db.js';
53
53
  export type * from './auth/http.api.js';
54
54
  export type * from './deploy/api.js';
55
55
  export type * from './deploy/index.js';
@@ -64,6 +64,7 @@ export type * from './plans/db.js';
64
64
  export type * from './plans/http.api.js';
65
65
  export type * from './stripe/http.api.js';
66
66
  export type * from './proxy/http.api.js';
67
+ export type * from './dbConfig/db.js';
67
68
  export type * from './nangoYaml/index.js';
68
69
  export type * from './environment/db.js';
69
70
  export type * from './environment/api/index.js';
@@ -0,0 +1,34 @@
1
+ import type { AuthModeType } from '../auth/api.js';
2
+ import type { Timestamps } from '../db.js';
3
+ export interface DBOAuthSession extends Timestamps {
4
+ id: string;
5
+ provider_config_key: string;
6
+ provider: string;
7
+ connection_id: string;
8
+ callbackUrl: string;
9
+ authMode: AuthModeType;
10
+ connect_session_id: number | null;
11
+ connection_config: Record<string, string>;
12
+ environment_id: number;
13
+ web_socket_client_id: string | undefined;
14
+ activity_log_id: string;
15
+ code_verifier: string | null;
16
+ request_token_secret: string | null;
17
+ }
18
+ export interface OAuthSession {
19
+ id: string;
20
+ providerConfigKey: string;
21
+ provider: string;
22
+ connectionId: string;
23
+ callbackUrl: string;
24
+ authMode: AuthModeType;
25
+ connectSessionId: number | null;
26
+ connectionConfig: Record<string, string>;
27
+ environmentId: number;
28
+ webSocketClientId: string | undefined;
29
+ activityLogId: string;
30
+ codeVerifier: string | null;
31
+ requestTokenSecret: string | null;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ }
@@ -9,6 +9,7 @@ export interface DBPlan extends Timestamps {
9
9
  orb_subscription_id: string | null;
10
10
  orb_future_plan: string | null;
11
11
  orb_future_plan_at: Date | null;
12
+ orb_subscribed_at: Date | null;
12
13
  trial_start_at: Date | null;
13
14
  trial_end_at: Date | null;
14
15
  trial_extension_count: number;
@@ -43,9 +43,7 @@ export interface BaseProvider {
43
43
  base_url: string;
44
44
  headers?: Record<string, string>;
45
45
  connection_config?: Record<string, string>;
46
- query?: {
47
- api_key: string;
48
- };
46
+ query?: Record<string, string>;
49
47
  retry?: RetryHeaderConfig;
50
48
  decompress?: boolean;
51
49
  paginate?: LinkPagination | CursorPagination | OffsetPagination;
@@ -155,6 +153,23 @@ export interface ProviderGithubApp extends BaseProvider {
155
153
  }
156
154
  export interface ProviderTwoStep extends Omit<BaseProvider, 'body_format'> {
157
155
  auth_mode: 'TWO_STEP';
156
+ signature?: {
157
+ protocol: 'RSA';
158
+ };
159
+ token?: {
160
+ signing_key: string;
161
+ expires_in_ms: number;
162
+ header: {
163
+ alg: string;
164
+ typ?: string;
165
+ };
166
+ payload: {
167
+ iss?: string;
168
+ scope?: string;
169
+ aud?: string;
170
+ sub?: string;
171
+ };
172
+ };
158
173
  token_request_method?: 'GET';
159
174
  token_headers?: Record<string, string>;
160
175
  token_response: {
@@ -49,4 +49,6 @@ export interface UserLogParameters {
49
49
  export interface TelemetryBag extends Record<string, number> {
50
50
  customLogs: number;
51
51
  proxyCalls: number;
52
+ durationMs: number;
53
+ memoryGb: number;
52
54
  }
package/dist/web/env.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export interface WindowEnv {
2
2
  apiUrl: string;
3
+ apiDownWatchPublicKey: string;
3
4
  publicUrl: string;
4
5
  connectUrl: string;
5
6
  gitHash: string | undefined;
@@ -47,6 +47,7 @@ export interface NangoAuthWebhookBodyBase extends NangoWebhookBase {
47
47
  endUser?: {
48
48
  endUserId: string;
49
49
  organizationId?: string | undefined;
50
+ tags: Record<string, string>;
50
51
  } | undefined;
51
52
  }
52
53
  export interface NangoAuthWebhookBodySuccess extends NangoAuthWebhookBodyBase {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
package/dist/auth/db.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { AuthModes } from './api.js';
2
- export interface OAuthSession {
3
- providerConfigKey: string;
4
- provider: string;
5
- connectionId: string;
6
- callbackUrl: string;
7
- authMode: AuthModes;
8
- id: string;
9
- connectionConfig: Record<string, string>;
10
- environmentId: number;
11
- webSocketClientId: string | undefined;
12
- codeVerifier: string;
13
- requestTokenSecret?: string;
14
- activityLogId: string;
15
- }