@nangohq/types 0.63.0 → 0.64.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.
@@ -12,7 +12,23 @@ export interface BillingClient {
12
12
  upgrade: (opts: {
13
13
  subscriptionId: string;
14
14
  planExternalId: string;
15
- immediate: boolean;
15
+ }) => Promise<Result<{
16
+ pendingChangeId: string;
17
+ amountInCents: number | null;
18
+ }>>;
19
+ downgrade: (opts: {
20
+ subscriptionId: string;
21
+ planExternalId: string;
22
+ }) => Promise<Result<void>>;
23
+ applyPendingChanges: (opts: {
24
+ pendingChangeId: string;
25
+ /**
26
+ * format: dollar.cent = 0.00
27
+ */
28
+ amount: string;
29
+ }) => Promise<Result<void>>;
30
+ cancelPendingChanges: (opts: {
31
+ pendingChangeId: string;
16
32
  }) => Promise<Result<void>>;
17
33
  verifyWebhookSignature(body: string, headers: Record<string, unknown>, secret: string): Result<true>;
18
34
  getPlanById(planId: string): Promise<Result<BillingPlan>>;
@@ -23,6 +39,8 @@ export interface BillingCustomer {
23
39
  }
24
40
  export interface BillingSubscription {
25
41
  id: string;
42
+ pendingChangeId?: string | undefined;
43
+ planExternalId: string;
26
44
  }
27
45
  export interface BillingUsageMetric {
28
46
  id: string;
@@ -42,7 +42,8 @@ export type GetConnectionsCount = Endpoint<{
42
42
  };
43
43
  };
44
44
  }>;
45
- export type ApiPublicConnection = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key'> & {
45
+ export type ApiPublicConnection = Pick<DBConnection, 'id' | 'connection_id'> & {
46
+ provider_config_key: string;
46
47
  created: string;
47
48
  metadata: Record<string, unknown> | null;
48
49
  provider: string;
@@ -86,7 +87,8 @@ export type GetConnection = Endpoint<{
86
87
  };
87
88
  };
88
89
  }>;
89
- export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key' | 'connection_config'> & {
90
+ export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id' | 'connection_config'> & {
91
+ provider_config_key: string;
90
92
  created_at: string;
91
93
  updated_at: string;
92
94
  last_fetched_at: string | null;
@@ -1,4 +1,4 @@
1
- import type { NangoModel, NangoSyncEndpointOld, NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml/index.js';
1
+ import type { NangoSyncEndpointOld, NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml/index.js';
2
2
  import type { OnEventType } from '../scripts/on-events/api.js';
3
3
  import type { Merge } from 'type-fest';
4
4
  export interface IncomingScriptFiles {
@@ -30,7 +30,6 @@ export interface PreBuiltAction {
30
30
  models: string[];
31
31
  attributes?: object | undefined;
32
32
  metadata?: NangoConfigMetadata | undefined;
33
- model_schema: string | NangoModel[];
34
33
  providerConfigKey: string;
35
34
  provider: string;
36
35
  is_public: boolean;
@@ -40,7 +39,7 @@ export interface PreBuiltAction {
40
39
  nango_config_id?: number;
41
40
  fileBody?: IncomingScriptFiles;
42
41
  endpoints: NangoSyncEndpointV2[];
43
- input?: NangoModel | LegacySyncModelSchema | undefined;
42
+ input?: string | undefined;
44
43
  version?: string | null;
45
44
  }
46
45
  export interface PreBuiltSync {
@@ -50,7 +49,6 @@ export interface PreBuiltSync {
50
49
  auto_start?: boolean | undefined;
51
50
  attributes?: object | undefined;
52
51
  metadata?: NangoConfigMetadata | undefined;
53
- model_schema: string | NangoModel[];
54
52
  track_deletes: boolean;
55
53
  providerConfigKey: string;
56
54
  provider: string;
@@ -61,7 +59,7 @@ export interface PreBuiltSync {
61
59
  nango_config_id?: number;
62
60
  fileBody?: IncomingScriptFiles;
63
61
  endpoints: NangoSyncEndpointV2[];
64
- input?: NangoModel | LegacySyncModelSchema | undefined;
62
+ input?: string | undefined;
65
63
  version?: string | null;
66
64
  }
67
65
  export type PreBuiltFlowConfig = PreBuiltAction | PreBuiltSync;
@@ -72,7 +70,6 @@ export interface CLIDeployFlowConfig {
72
70
  auto_start?: boolean;
73
71
  attributes?: object | undefined;
74
72
  metadata?: NangoConfigMetadata | undefined;
75
- model_schema: string | NangoModel[];
76
73
  endpoints?: (NangoSyncEndpointV2 | NangoSyncEndpointOld)[] | undefined;
77
74
  track_deletes: boolean;
78
75
  providerConfigKey: string;
@@ -1,4 +1,3 @@
1
- import type { LegacySyncModelSchema } from './incomingFlow.js';
2
1
  import type { ScriptTypeLiteral } from '../nangoYaml/index.js';
3
2
  export interface SyncDeploymentResult {
4
3
  name: string;
@@ -6,7 +5,7 @@ export interface SyncDeploymentResult {
6
5
  providerConfigKey: string;
7
6
  type: ScriptTypeLiteral;
8
7
  last_deployed?: Date;
9
- input?: string | LegacySyncModelSchema | undefined | null;
8
+ input?: string | undefined | null;
10
9
  models: string | string[];
11
10
  id?: number | undefined;
12
11
  runs?: string | null;
@@ -1,5 +1,5 @@
1
- import type { LegacySyncModelSchema, NangoConfigMetadata } from '../deploy/incomingFlow.js';
2
- import type { NangoModel, NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml/index.js';
1
+ import type { NangoConfigMetadata } from '../deploy/incomingFlow.js';
2
+ import type { NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml/index.js';
3
3
  import type { JSONSchema7 } from 'json-schema';
4
4
  export interface NangoSyncConfig {
5
5
  name: string;
@@ -12,14 +12,13 @@ export interface NangoSyncConfig {
12
12
  metadata?: NangoConfigMetadata;
13
13
  track_deletes?: boolean;
14
14
  returns: string[];
15
- models: NangoModel[] | LegacySyncModelSchema[];
16
15
  endpoints: NangoSyncEndpointV2[];
17
16
  is_public?: boolean | null;
18
17
  pre_built?: boolean | null;
19
18
  version?: string | null;
20
19
  last_deployed?: string | null;
21
20
  id?: number;
22
- input?: NangoModel | LegacySyncModelSchema | undefined;
21
+ input?: string | undefined;
23
22
  sync_type?: SyncTypeLiteral;
24
23
  webhookSubscriptions?: string[];
25
24
  enabled?: boolean;
@@ -2,7 +2,7 @@ import type { Timestamps } from '../db.js';
2
2
  export interface DBPlan extends Timestamps {
3
3
  id: number;
4
4
  account_id: number;
5
- name: string;
5
+ name: 'free' | 'starter' | 'starter-legacy' | 'growth' | 'scale-legacy' | 'growth-legacy' | 'enterprise';
6
6
  stripe_customer_id: string | null;
7
7
  stripe_payment_id: string | null;
8
8
  orb_customer_id: string | null;
@@ -14,12 +14,6 @@ export interface DBPlan extends Timestamps {
14
14
  trial_extension_count: number;
15
15
  trial_end_notified_at: Date | null;
16
16
  trial_expired: boolean | null;
17
- /**
18
- * Limit the number of connections with active scripts
19
- * Set to null to remove limit
20
- * @default 3
21
- */
22
- connection_with_scripts_max: number | null;
23
17
  /**
24
18
  * Limit the number of total non-deleted connections
25
19
  * Set to null to remove limit
@@ -31,6 +25,16 @@ export interface DBPlan extends Timestamps {
31
25
  * @default 2
32
26
  */
33
27
  environments_max: number;
28
+ /**
29
+ * Limit the number of actions that can be triggered in a month
30
+ * @default 1000
31
+ */
32
+ monthly_actions_max: number | null;
33
+ /**
34
+ * Limit the amount of monthly active records (Records created or updated in a month)
35
+ * @default 5000
36
+ */
37
+ monthly_active_records_max: number | null;
34
38
  /**
35
39
  * Limit the minimum frequency of a sync
36
40
  * Not used yet
@@ -16,11 +16,13 @@ export type PostPlanExtendTrial = Endpoint<{
16
16
  };
17
17
  }>;
18
18
  export interface PlanDefinition {
19
- code: string;
19
+ code: DBPlan['name'];
20
20
  title: string;
21
21
  description: string;
22
- canUpgrade: boolean;
23
- canDowngrade: false;
22
+ canChange: boolean;
23
+ nextPlan: string[] | null;
24
+ prevPlan: string[] | null;
25
+ basePrice?: number;
24
26
  /**
25
27
  * OrbId is the custom external_plan_id that we can setup
26
28
  * It's handy because you can set the same id in staging and prod
@@ -29,6 +31,14 @@ export interface PlanDefinition {
29
31
  cta?: string;
30
32
  hidden?: boolean;
31
33
  flags: Omit<Partial<DBPlan>, 'id' | 'account_id'>;
34
+ display?: {
35
+ featuresHeading?: string;
36
+ features: {
37
+ title: string;
38
+ sub?: string;
39
+ }[];
40
+ sub?: string;
41
+ };
32
42
  }
33
43
  export type GetPlans = Endpoint<{
34
44
  Method: 'GET';
@@ -40,6 +50,16 @@ export type GetPlans = Endpoint<{
40
50
  data: PlanDefinition[];
41
51
  };
42
52
  }>;
53
+ export type GetPlan = Endpoint<{
54
+ Method: 'GET';
55
+ Path: '/api/v1/plans/current';
56
+ Querystring: {
57
+ env: string;
58
+ };
59
+ Success: {
60
+ data: ApiPlan;
61
+ };
62
+ }>;
43
63
  export type GetUsage = Endpoint<{
44
64
  Method: 'GET';
45
65
  Path: '/api/v1/plans/usage';
@@ -54,3 +74,20 @@ export type GetUsage = Endpoint<{
54
74
  };
55
75
  };
56
76
  }>;
77
+ export type PostPlanChange = Endpoint<{
78
+ Method: 'POST';
79
+ Path: '/api/v1/plans/change';
80
+ Querystring: {
81
+ env: string;
82
+ };
83
+ Body: {
84
+ orbId: string;
85
+ };
86
+ Success: {
87
+ data: {
88
+ success: true;
89
+ } | {
90
+ paymentIntent: any;
91
+ };
92
+ };
93
+ }>;
@@ -46,7 +46,7 @@ export interface RetryHeaderConfig {
46
46
  at?: string;
47
47
  after?: string;
48
48
  remaining?: string;
49
- error_code?: number;
49
+ error_code?: string[];
50
50
  in_body?: {
51
51
  path: string;
52
52
  value?: string;
@@ -33,6 +33,7 @@ export interface NangoProps {
33
33
  endUserId: string | null;
34
34
  orgId: string | null;
35
35
  } | null;
36
+ heartbeatTimeoutSecs?: number | undefined;
36
37
  axios?: {
37
38
  request?: AxiosInterceptorManager<AxiosRequestConfig>;
38
39
  response?: {
@@ -11,7 +11,7 @@ export interface DBSyncConfig extends TimestampsAndDeleted {
11
11
  models: string[];
12
12
  active: boolean;
13
13
  runs: string | null;
14
- model_schema: LegacySyncModelSchema[] | NangoModel[] | null;
14
+ model_schema?: LegacySyncModelSchema[] | NangoModel[] | null | undefined;
15
15
  environment_id: number;
16
16
  track_deletes: boolean;
17
17
  type: ScriptTypeLiteral;
package/dist/web/env.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface WindowEnv {
9
9
  publicLogoDevKey: string;
10
10
  publicKoalaApiUrl: string;
11
11
  publicKoalaCdnUrl: string;
12
+ publicStripeKey: string;
12
13
  isCloud: boolean;
13
14
  features: {
14
15
  logs: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",