@hawk.so/types 0.6.1 → 0.6.3

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/build/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './src/base/event/taskManagerItem';
10
10
  export * from './src/base/event/addons';
11
11
  export * from './src/base/integrations/integrationToken';
12
12
  export * from './src/base/project/ProjectTaskManager';
13
+ export * from './src/base/utm';
13
14
  export * from './src/base/workspace/GitHubIntegration';
14
15
  export * from './src/base/user/GitHubAuthorization';
15
16
  export * from './src/dbScheme/businessOperation';
package/build/index.js CHANGED
@@ -26,6 +26,7 @@ __exportStar(require("./src/base/event/taskManagerItem"), exports);
26
26
  __exportStar(require("./src/base/event/addons"), exports);
27
27
  __exportStar(require("./src/base/integrations/integrationToken"), exports);
28
28
  __exportStar(require("./src/base/project/ProjectTaskManager"), exports);
29
+ __exportStar(require("./src/base/utm"), exports);
29
30
  __exportStar(require("./src/base/workspace/GitHubIntegration"), exports);
30
31
  __exportStar(require("./src/base/user/GitHubAuthorization"), exports);
31
32
  __exportStar(require("./src/dbScheme/businessOperation"), exports);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * UTM parameters captured for analytics.
3
+ */
4
+ export interface Utm {
5
+ /**
6
+ * UTM source - identifies which site sent the traffic.
7
+ */
8
+ source?: string;
9
+ /**
10
+ * UTM medium - identifies what type of link was used.
11
+ */
12
+ medium?: string;
13
+ /**
14
+ * UTM campaign - identifies a specific product promotion or strategic campaign.
15
+ */
16
+ campaign?: string;
17
+ /**
18
+ * UTM content - identifies what specifically was clicked to bring the user to the site.
19
+ */
20
+ content?: string;
21
+ /**
22
+ * UTM term - identifies search terms.
23
+ */
24
+ term?: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,90 @@
1
1
  import type { ObjectId } from 'bson';
2
+ /**
3
+ * Defines what a promo code grants to the user or workspace
4
+ */
5
+ export type PromoCodeBenefitType = 'grant_plan' | 'percent_discount' | 'amount_discount' | 'fixed_price';
6
+ /**
7
+ * Grant plan benefit — assigns a tariff to workspace immediately
8
+ */
9
+ export interface GrantPlanPromoCodeBenefit {
10
+ /**
11
+ * Benefit type
12
+ */
13
+ type: 'grant_plan';
14
+ /**
15
+ * Tariff plan to grant to workspace
16
+ */
17
+ planId: ObjectId;
18
+ }
19
+ /**
20
+ * Reduces plan price by a percentage when purchasing a tariff
21
+ */
22
+ export interface PercentDiscountPromoCodeBenefit {
23
+ /**
24
+ * Benefit type
25
+ */
26
+ type: 'percent_discount';
27
+ /**
28
+ * Discount size in percent. Greater than 0, maximum 100
29
+ * @example 20
30
+ */
31
+ percent: number;
32
+ /**
33
+ * Plan ids this promo can be applied to.
34
+ * If not set or empty — applicable to any available plan
35
+ */
36
+ applicablePlanIds?: ObjectId[];
37
+ /**
38
+ * Minimum final price after discount.
39
+ * If not set — defaults to 1
40
+ */
41
+ minFinalPrice?: number;
42
+ }
43
+ /**
44
+ * Fixed amount discount benefit
45
+ */
46
+ export interface AmountDiscountPromoCodeBenefit {
47
+ /**
48
+ * Benefit type
49
+ */
50
+ type: 'amount_discount';
51
+ /**
52
+ * Discount size in money. Must be greater than 0
53
+ */
54
+ amount: number;
55
+ /**
56
+ * Plan ids this promo can be applied to.
57
+ * If not set or empty — applicable to any available plan
58
+ */
59
+ applicablePlanIds?: ObjectId[];
60
+ /**
61
+ * Minimum final price after discount.
62
+ * If not set — defaults to 1
63
+ */
64
+ minFinalPrice?: number;
65
+ }
66
+ /**
67
+ * Sets a fixed final price for selected plans when purchasing a tariff
68
+ */
69
+ export interface FixedPricePromoCodeBenefit {
70
+ /**
71
+ * Benefit type
72
+ */
73
+ type: 'fixed_price';
74
+ /**
75
+ * Final tariff price after promo is applied
76
+ */
77
+ amount: number;
78
+ /**
79
+ * Plan ids this promo can be applied to.
80
+ * If not set or empty — applicable to any available plan
81
+ */
82
+ applicablePlanIds?: ObjectId[];
83
+ }
84
+ /**
85
+ * Promo code benefit union
86
+ */
87
+ export type PromoCodeBenefit = GrantPlanPromoCodeBenefit | PercentDiscountPromoCodeBenefit | AmountDiscountPromoCodeBenefit | FixedPricePromoCodeBenefit;
2
88
  /**
3
89
  * Promo code representation in DataBase
4
90
  */
@@ -8,21 +94,24 @@ export interface PromoCodeDBScheme {
8
94
  */
9
95
  _id: ObjectId;
10
96
  /**
11
- * Normalized promo code value
97
+ * Promo code value entered by user.
98
+ * Normalized: trim + uppercase. Allowed: A-Z, 0-9, "-", "_". Must be unique
12
99
  * @example HAWK-2026
13
100
  */
14
- code: string;
101
+ value: string;
15
102
  /**
16
- * Tariff plan assigned by this promo code
103
+ * What this promo code grants
17
104
  */
18
- planId: ObjectId;
105
+ benefit: PromoCodeBenefit;
19
106
  /**
20
- * Maximum total usages count
107
+ * Maximum total successful usages count.
108
+ * If not set — no global limit
21
109
  * @example 100
22
110
  */
23
111
  limit?: number;
24
112
  /**
25
- * Date after which promo code cannot be used
113
+ * Date after which promo code cannot be used.
114
+ * If not set — no expiration
26
115
  * @example 2026-12-31T23:59:59.000Z
27
116
  */
28
117
  expiresAt?: Date;
@@ -1,4 +1,6 @@
1
1
  import type { ObjectId } from 'bson';
2
+ import type { PromoCodeBenefitType } from './promoCode.ts';
3
+ import type { Utm } from '../base/utm.ts';
2
4
  /**
3
5
  * Promo code usage representation in DataBase
4
6
  */
@@ -20,33 +22,32 @@ export interface PromoCodeUsageDBScheme {
20
22
  */
21
23
  workspaceId: ObjectId;
22
24
  /**
23
- * Date when promo code was applied
24
- * @example 2026-06-10T12:30:00.000Z
25
+ * Plan to which promo was applied or which was granted
25
26
  */
26
- appliedAt: Date;
27
+ planId?: ObjectId;
28
+ /**
29
+ * Benefit type at the moment of application
30
+ */
31
+ benefitType: PromoCodeBenefitType;
32
+ /**
33
+ * Plan price before promo, for discount promos
34
+ */
35
+ originalAmount?: number;
36
+ /**
37
+ * Final price after promo, for discount promos
38
+ */
39
+ finalAmount?: number;
40
+ /**
41
+ * Actual discount amount in money, for discount promos
42
+ */
43
+ discountAmount?: number;
27
44
  /**
28
45
  * UTM parameters captured when promo code was applied. Used for analytics purposes
29
46
  */
30
- utm?: {
31
- /**
32
- * UTM source - identifies which site sent the traffic
33
- */
34
- source?: string;
35
- /**
36
- * UTM medium - identifies what type of link was used
37
- */
38
- medium?: string;
39
- /**
40
- * UTM campaign - identifies a specific product promotion or strategic campaign
41
- */
42
- campaign?: string;
43
- /**
44
- * UTM content - identifies what specifically was clicked to bring the user to the site
45
- */
46
- content?: string;
47
- /**
48
- * UTM term - identifies search terms
49
- */
50
- term?: string;
51
- };
47
+ utm?: Utm;
48
+ /**
49
+ * Date when promo code was successfully applied
50
+ * @example 2026-06-10T12:30:00.000Z
51
+ */
52
+ appliedAt: Date;
52
53
  }
@@ -4,6 +4,7 @@ import type { BankCard } from './bankCard.ts';
4
4
  import type { MembershipDBScheme } from './membership.ts';
5
5
  import type { UserProjectsLastVisitDBScheme } from './userProjectsLastVisit.ts';
6
6
  import type { GitHubAuthorization } from '../base/user/GitHubAuthorization.ts';
7
+ import type { Utm } from '../base/utm.ts';
7
8
  /**
8
9
  * Interface representing how user is stored in DB
9
10
  */
@@ -57,28 +58,7 @@ export interface UserDBScheme {
57
58
  /**
58
59
  * UTM parameters from signup - Data form where user went to sign up. Used for analytics purposes
59
60
  */
60
- utm?: {
61
- /**
62
- * UTM source - identifies which site sent the traffic
63
- */
64
- source?: string;
65
- /**
66
- * UTM medium - identifies what type of link was used
67
- */
68
- medium?: string;
69
- /**
70
- * UTM campaign - identifies a specific product promotion or strategic campaign
71
- */
72
- campaign?: string;
73
- /**
74
- * UTM content - identifies what specifically was clicked to bring the user to the site
75
- */
76
- content?: string;
77
- /**
78
- * UTM term - identifies search terms
79
- */
80
- term?: string;
81
- };
61
+ utm?: Utm;
82
62
  /**
83
63
  * GitHub OAuth authorizations.
84
64
  * Used for user-to-server operations (e.g. Copilot assignment).
package/index.ts CHANGED
@@ -14,6 +14,7 @@ export * from './src/base/event/addons';
14
14
 
15
15
  export * from './src/base/integrations/integrationToken';
16
16
  export * from './src/base/project/ProjectTaskManager';
17
+ export * from './src/base/utm';
17
18
  export * from './src/base/workspace/GitHubIntegration';
18
19
  export * from './src/base/user/GitHubAuthorization';
19
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawk.so/types",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "TypeScript definitions for Hawk",
5
5
  "types": "build/index.d.ts",
6
6
  "main": "build/index.js",
@@ -0,0 +1,29 @@
1
+ /**
2
+ * UTM parameters captured for analytics.
3
+ */
4
+ export interface Utm {
5
+ /**
6
+ * UTM source - identifies which site sent the traffic.
7
+ */
8
+ source?: string;
9
+
10
+ /**
11
+ * UTM medium - identifies what type of link was used.
12
+ */
13
+ medium?: string;
14
+
15
+ /**
16
+ * UTM campaign - identifies a specific product promotion or strategic campaign.
17
+ */
18
+ campaign?: string;
19
+
20
+ /**
21
+ * UTM content - identifies what specifically was clicked to bring the user to the site.
22
+ */
23
+ content?: string;
24
+
25
+ /**
26
+ * UTM term - identifies search terms.
27
+ */
28
+ term?: string;
29
+ }
@@ -1,5 +1,114 @@
1
1
  import type { ObjectId } from 'bson';
2
2
 
3
+ /**
4
+ * Defines what a promo code grants to the user or workspace
5
+ */
6
+ export type PromoCodeBenefitType =
7
+ | 'grant_plan'
8
+ | 'percent_discount'
9
+ | 'amount_discount'
10
+ | 'fixed_price';
11
+
12
+ /**
13
+ * Grant plan benefit — assigns a tariff to workspace immediately
14
+ */
15
+ export interface GrantPlanPromoCodeBenefit {
16
+ /**
17
+ * Benefit type
18
+ */
19
+ type: 'grant_plan';
20
+
21
+ /**
22
+ * Tariff plan to grant to workspace
23
+ */
24
+ planId: ObjectId;
25
+ }
26
+
27
+ /**
28
+ * Reduces plan price by a percentage when purchasing a tariff
29
+ */
30
+ export interface PercentDiscountPromoCodeBenefit {
31
+ /**
32
+ * Benefit type
33
+ */
34
+ type: 'percent_discount';
35
+
36
+ /**
37
+ * Discount size in percent. Greater than 0, maximum 100
38
+ * @example 20
39
+ */
40
+ percent: number;
41
+
42
+ /**
43
+ * Plan ids this promo can be applied to.
44
+ * If not set or empty — applicable to any available plan
45
+ */
46
+ applicablePlanIds?: ObjectId[];
47
+
48
+ /**
49
+ * Minimum final price after discount.
50
+ * If not set — defaults to 1
51
+ */
52
+ minFinalPrice?: number;
53
+ }
54
+
55
+ /**
56
+ * Fixed amount discount benefit
57
+ */
58
+ export interface AmountDiscountPromoCodeBenefit {
59
+ /**
60
+ * Benefit type
61
+ */
62
+ type: 'amount_discount';
63
+
64
+ /**
65
+ * Discount size in money. Must be greater than 0
66
+ */
67
+ amount: number;
68
+
69
+ /**
70
+ * Plan ids this promo can be applied to.
71
+ * If not set or empty — applicable to any available plan
72
+ */
73
+ applicablePlanIds?: ObjectId[];
74
+
75
+ /**
76
+ * Minimum final price after discount.
77
+ * If not set — defaults to 1
78
+ */
79
+ minFinalPrice?: number;
80
+ }
81
+
82
+ /**
83
+ * Sets a fixed final price for selected plans when purchasing a tariff
84
+ */
85
+ export interface FixedPricePromoCodeBenefit {
86
+ /**
87
+ * Benefit type
88
+ */
89
+ type: 'fixed_price';
90
+
91
+ /**
92
+ * Final tariff price after promo is applied
93
+ */
94
+ amount: number;
95
+
96
+ /**
97
+ * Plan ids this promo can be applied to.
98
+ * If not set or empty — applicable to any available plan
99
+ */
100
+ applicablePlanIds?: ObjectId[];
101
+ }
102
+
103
+ /**
104
+ * Promo code benefit union
105
+ */
106
+ export type PromoCodeBenefit =
107
+ | GrantPlanPromoCodeBenefit
108
+ | PercentDiscountPromoCodeBenefit
109
+ | AmountDiscountPromoCodeBenefit
110
+ | FixedPricePromoCodeBenefit;
111
+
3
112
  /**
4
113
  * Promo code representation in DataBase
5
114
  */
@@ -10,24 +119,27 @@ export interface PromoCodeDBScheme {
10
119
  _id: ObjectId;
11
120
 
12
121
  /**
13
- * Normalized promo code value
122
+ * Promo code value entered by user.
123
+ * Normalized: trim + uppercase. Allowed: A-Z, 0-9, "-", "_". Must be unique
14
124
  * @example HAWK-2026
15
125
  */
16
- code: string;
126
+ value: string;
17
127
 
18
128
  /**
19
- * Tariff plan assigned by this promo code
129
+ * What this promo code grants
20
130
  */
21
- planId: ObjectId;
131
+ benefit: PromoCodeBenefit;
22
132
 
23
133
  /**
24
- * Maximum total usages count
134
+ * Maximum total successful usages count.
135
+ * If not set — no global limit
25
136
  * @example 100
26
137
  */
27
138
  limit?: number;
28
139
 
29
140
  /**
30
- * Date after which promo code cannot be used
141
+ * Date after which promo code cannot be used.
142
+ * If not set — no expiration
31
143
  * @example 2026-12-31T23:59:59.000Z
32
144
  */
33
145
  expiresAt?: Date;
@@ -1,4 +1,6 @@
1
1
  import type { ObjectId } from 'bson';
2
+ import type { PromoCodeBenefitType } from './promoCode.ts';
3
+ import type { Utm } from '../base/utm.ts';
2
4
 
3
5
  /**
4
6
  * Promo code usage representation in DataBase
@@ -25,38 +27,38 @@ export interface PromoCodeUsageDBScheme {
25
27
  workspaceId: ObjectId;
26
28
 
27
29
  /**
28
- * Date when promo code was applied
29
- * @example 2026-06-10T12:30:00.000Z
30
+ * Plan to which promo was applied or which was granted
30
31
  */
31
- appliedAt: Date;
32
+ planId?: ObjectId;
33
+
34
+ /**
35
+ * Benefit type at the moment of application
36
+ */
37
+ benefitType: PromoCodeBenefitType;
38
+
39
+ /**
40
+ * Plan price before promo, for discount promos
41
+ */
42
+ originalAmount?: number;
43
+
44
+ /**
45
+ * Final price after promo, for discount promos
46
+ */
47
+ finalAmount?: number;
48
+
49
+ /**
50
+ * Actual discount amount in money, for discount promos
51
+ */
52
+ discountAmount?: number;
32
53
 
33
54
  /**
34
55
  * UTM parameters captured when promo code was applied. Used for analytics purposes
35
56
  */
36
- utm?: {
37
- /**
38
- * UTM source - identifies which site sent the traffic
39
- */
40
- source?: string;
41
-
42
- /**
43
- * UTM medium - identifies what type of link was used
44
- */
45
- medium?: string;
46
-
47
- /**
48
- * UTM campaign - identifies a specific product promotion or strategic campaign
49
- */
50
- campaign?: string;
51
-
52
- /**
53
- * UTM content - identifies what specifically was clicked to bring the user to the site
54
- */
55
- content?: string;
56
-
57
- /**
58
- * UTM term - identifies search terms
59
- */
60
- term?: string;
61
- };
57
+ utm?: Utm;
58
+
59
+ /**
60
+ * Date when promo code was successfully applied
61
+ * @example 2026-06-10T12:30:00.000Z
62
+ */
63
+ appliedAt: Date;
62
64
  }
@@ -4,6 +4,7 @@ import type { BankCard } from './bankCard.ts';
4
4
  import type { MembershipDBScheme } from './membership.ts';
5
5
  import type { UserProjectsLastVisitDBScheme } from './userProjectsLastVisit.ts';
6
6
  import type { GitHubAuthorization } from '../base/user/GitHubAuthorization.ts';
7
+ import type { Utm } from '../base/utm.ts';
7
8
 
8
9
  /**
9
10
  * Interface representing how user is stored in DB
@@ -69,32 +70,7 @@ export interface UserDBScheme {
69
70
  /**
70
71
  * UTM parameters from signup - Data form where user went to sign up. Used for analytics purposes
71
72
  */
72
- utm?: {
73
- /**
74
- * UTM source - identifies which site sent the traffic
75
- */
76
- source?: string;
77
-
78
- /**
79
- * UTM medium - identifies what type of link was used
80
- */
81
- medium?: string;
82
-
83
- /**
84
- * UTM campaign - identifies a specific product promotion or strategic campaign
85
- */
86
- campaign?: string;
87
-
88
- /**
89
- * UTM content - identifies what specifically was clicked to bring the user to the site
90
- */
91
- content?: string;
92
-
93
- /**
94
- * UTM term - identifies search terms
95
- */
96
- term?: string;
97
- };
73
+ utm?: Utm;
98
74
 
99
75
  /**
100
76
  * GitHub OAuth authorizations.