@hawk.so/types 0.6.0-rc.2 → 0.6.2
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 +2 -0
- package/build/index.js +2 -0
- package/build/src/dbScheme/promoCode.d.ts +133 -0
- package/build/src/dbScheme/promoCode.js +2 -0
- package/build/src/dbScheme/promoCodeUsage.d.ts +73 -0
- package/build/src/dbScheme/promoCodeUsage.js +2 -0
- package/index.ts +2 -0
- package/package.json +1 -1
- package/src/dbScheme/promoCode.ts +164 -0
- package/src/dbScheme/promoCodeUsage.ts +88 -0
package/build/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export * from './src/dbScheme/notificationsChannelSettings';
|
|
|
19
19
|
export * from './src/dbScheme/membership';
|
|
20
20
|
export * from './src/dbScheme/userProjectsLastVisit';
|
|
21
21
|
export * from './src/dbScheme/plan';
|
|
22
|
+
export * from './src/dbScheme/promoCode';
|
|
23
|
+
export * from './src/dbScheme/promoCodeUsage';
|
|
22
24
|
export * from './src/dbScheme/project';
|
|
23
25
|
export * from './src/dbScheme/projectNotificationsRule';
|
|
24
26
|
export * from './src/dbScheme/release';
|
package/build/index.js
CHANGED
|
@@ -35,6 +35,8 @@ __exportStar(require("./src/dbScheme/notificationsChannelSettings"), exports);
|
|
|
35
35
|
__exportStar(require("./src/dbScheme/membership"), exports);
|
|
36
36
|
__exportStar(require("./src/dbScheme/userProjectsLastVisit"), exports);
|
|
37
37
|
__exportStar(require("./src/dbScheme/plan"), exports);
|
|
38
|
+
__exportStar(require("./src/dbScheme/promoCode"), exports);
|
|
39
|
+
__exportStar(require("./src/dbScheme/promoCodeUsage"), exports);
|
|
38
40
|
__exportStar(require("./src/dbScheme/project"), exports);
|
|
39
41
|
__exportStar(require("./src/dbScheme/projectNotificationsRule"), exports);
|
|
40
42
|
__exportStar(require("./src/dbScheme/release"), exports);
|
|
@@ -0,0 +1,133 @@
|
|
|
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;
|
|
88
|
+
/**
|
|
89
|
+
* Promo code representation in DataBase
|
|
90
|
+
*/
|
|
91
|
+
export interface PromoCodeDBScheme {
|
|
92
|
+
/**
|
|
93
|
+
* Promo code id
|
|
94
|
+
*/
|
|
95
|
+
_id: ObjectId;
|
|
96
|
+
/**
|
|
97
|
+
* Promo code value entered by user.
|
|
98
|
+
* Normalized: trim + uppercase. Allowed: A-Z, 0-9, "-", "_". Must be unique
|
|
99
|
+
* @example HAWK-2026
|
|
100
|
+
*/
|
|
101
|
+
value: string;
|
|
102
|
+
/**
|
|
103
|
+
* What this promo code grants
|
|
104
|
+
*/
|
|
105
|
+
benefit: PromoCodeBenefit;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum total successful usages count.
|
|
108
|
+
* If not set — no global limit
|
|
109
|
+
* @example 100
|
|
110
|
+
*/
|
|
111
|
+
limit?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Date after which promo code cannot be used.
|
|
114
|
+
* If not set — no expiration
|
|
115
|
+
* @example 2026-12-31T23:59:59.000Z
|
|
116
|
+
*/
|
|
117
|
+
expiresAt?: Date;
|
|
118
|
+
/**
|
|
119
|
+
* Date when promo code was created
|
|
120
|
+
* @example 2026-06-10T12:00:00.000Z
|
|
121
|
+
*/
|
|
122
|
+
createdAt: Date;
|
|
123
|
+
/**
|
|
124
|
+
* Date when promo code was updated
|
|
125
|
+
* @example 2026-06-10T12:00:00.000Z
|
|
126
|
+
*/
|
|
127
|
+
updatedAt: Date;
|
|
128
|
+
/**
|
|
129
|
+
* User or system id that created promo code
|
|
130
|
+
* @example 507f1f77bcf86cd799439013
|
|
131
|
+
*/
|
|
132
|
+
createdBy: string;
|
|
133
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ObjectId } from 'bson';
|
|
2
|
+
import type { PromoCodeBenefitType } from './promoCode.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Promo code usage representation in DataBase
|
|
5
|
+
*/
|
|
6
|
+
export interface PromoCodeUsageDBScheme {
|
|
7
|
+
/**
|
|
8
|
+
* Promo code usage id
|
|
9
|
+
*/
|
|
10
|
+
_id: ObjectId;
|
|
11
|
+
/**
|
|
12
|
+
* Applied promo code id
|
|
13
|
+
*/
|
|
14
|
+
promoCodeId: ObjectId;
|
|
15
|
+
/**
|
|
16
|
+
* User who applied promo code
|
|
17
|
+
*/
|
|
18
|
+
userId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Workspace where promo code was applied
|
|
21
|
+
*/
|
|
22
|
+
workspaceId: ObjectId;
|
|
23
|
+
/**
|
|
24
|
+
* Plan to which promo was applied or which was granted
|
|
25
|
+
*/
|
|
26
|
+
planId?: ObjectId;
|
|
27
|
+
/**
|
|
28
|
+
* Benefit type at the moment of application
|
|
29
|
+
*/
|
|
30
|
+
benefitType: PromoCodeBenefitType;
|
|
31
|
+
/**
|
|
32
|
+
* Plan price before promo, for discount promos
|
|
33
|
+
*/
|
|
34
|
+
originalAmount?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Final price after promo, for discount promos
|
|
37
|
+
*/
|
|
38
|
+
finalAmount?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Actual discount amount in money, for discount promos
|
|
41
|
+
*/
|
|
42
|
+
discountAmount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* UTM parameters captured when promo code was applied. Used for analytics purposes
|
|
45
|
+
*/
|
|
46
|
+
utm?: {
|
|
47
|
+
/**
|
|
48
|
+
* UTM source - identifies which site sent the traffic
|
|
49
|
+
*/
|
|
50
|
+
source?: string;
|
|
51
|
+
/**
|
|
52
|
+
* UTM medium - identifies what type of link was used
|
|
53
|
+
*/
|
|
54
|
+
medium?: string;
|
|
55
|
+
/**
|
|
56
|
+
* UTM campaign - identifies a specific product promotion or strategic campaign
|
|
57
|
+
*/
|
|
58
|
+
campaign?: string;
|
|
59
|
+
/**
|
|
60
|
+
* UTM content - identifies what specifically was clicked to bring the user to the site
|
|
61
|
+
*/
|
|
62
|
+
content?: string;
|
|
63
|
+
/**
|
|
64
|
+
* UTM term - identifies search terms
|
|
65
|
+
*/
|
|
66
|
+
term?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Date when promo code was successfully applied
|
|
70
|
+
* @example 2026-06-10T12:30:00.000Z
|
|
71
|
+
*/
|
|
72
|
+
appliedAt: Date;
|
|
73
|
+
}
|
package/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ export * from './src/dbScheme/notificationsChannelSettings';
|
|
|
24
24
|
export * from './src/dbScheme/membership';
|
|
25
25
|
export * from './src/dbScheme/userProjectsLastVisit';
|
|
26
26
|
export * from './src/dbScheme/plan';
|
|
27
|
+
export * from './src/dbScheme/promoCode';
|
|
28
|
+
export * from './src/dbScheme/promoCodeUsage';
|
|
27
29
|
export * from './src/dbScheme/project';
|
|
28
30
|
export * from './src/dbScheme/projectNotificationsRule';
|
|
29
31
|
export * from './src/dbScheme/release';
|
package/package.json
CHANGED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { ObjectId } from 'bson';
|
|
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
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Promo code representation in DataBase
|
|
114
|
+
*/
|
|
115
|
+
export interface PromoCodeDBScheme {
|
|
116
|
+
/**
|
|
117
|
+
* Promo code id
|
|
118
|
+
*/
|
|
119
|
+
_id: ObjectId;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Promo code value entered by user.
|
|
123
|
+
* Normalized: trim + uppercase. Allowed: A-Z, 0-9, "-", "_". Must be unique
|
|
124
|
+
* @example HAWK-2026
|
|
125
|
+
*/
|
|
126
|
+
value: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* What this promo code grants
|
|
130
|
+
*/
|
|
131
|
+
benefit: PromoCodeBenefit;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Maximum total successful usages count.
|
|
135
|
+
* If not set — no global limit
|
|
136
|
+
* @example 100
|
|
137
|
+
*/
|
|
138
|
+
limit?: number;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Date after which promo code cannot be used.
|
|
142
|
+
* If not set — no expiration
|
|
143
|
+
* @example 2026-12-31T23:59:59.000Z
|
|
144
|
+
*/
|
|
145
|
+
expiresAt?: Date;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Date when promo code was created
|
|
149
|
+
* @example 2026-06-10T12:00:00.000Z
|
|
150
|
+
*/
|
|
151
|
+
createdAt: Date;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Date when promo code was updated
|
|
155
|
+
* @example 2026-06-10T12:00:00.000Z
|
|
156
|
+
*/
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* User or system id that created promo code
|
|
161
|
+
* @example 507f1f77bcf86cd799439013
|
|
162
|
+
*/
|
|
163
|
+
createdBy: string;
|
|
164
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ObjectId } from 'bson';
|
|
2
|
+
import type { PromoCodeBenefitType } from './promoCode.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Promo code usage representation in DataBase
|
|
6
|
+
*/
|
|
7
|
+
export interface PromoCodeUsageDBScheme {
|
|
8
|
+
/**
|
|
9
|
+
* Promo code usage id
|
|
10
|
+
*/
|
|
11
|
+
_id: ObjectId;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Applied promo code id
|
|
15
|
+
*/
|
|
16
|
+
promoCodeId: ObjectId;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* User who applied promo code
|
|
20
|
+
*/
|
|
21
|
+
userId: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Workspace where promo code was applied
|
|
25
|
+
*/
|
|
26
|
+
workspaceId: ObjectId;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Plan to which promo was applied or which was granted
|
|
30
|
+
*/
|
|
31
|
+
planId?: ObjectId;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Benefit type at the moment of application
|
|
35
|
+
*/
|
|
36
|
+
benefitType: PromoCodeBenefitType;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Plan price before promo, for discount promos
|
|
40
|
+
*/
|
|
41
|
+
originalAmount?: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Final price after promo, for discount promos
|
|
45
|
+
*/
|
|
46
|
+
finalAmount?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Actual discount amount in money, for discount promos
|
|
50
|
+
*/
|
|
51
|
+
discountAmount?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* UTM parameters captured when promo code was applied. Used for analytics purposes
|
|
55
|
+
*/
|
|
56
|
+
utm?: {
|
|
57
|
+
/**
|
|
58
|
+
* UTM source - identifies which site sent the traffic
|
|
59
|
+
*/
|
|
60
|
+
source?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* UTM medium - identifies what type of link was used
|
|
64
|
+
*/
|
|
65
|
+
medium?: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* UTM campaign - identifies a specific product promotion or strategic campaign
|
|
69
|
+
*/
|
|
70
|
+
campaign?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* UTM content - identifies what specifically was clicked to bring the user to the site
|
|
74
|
+
*/
|
|
75
|
+
content?: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* UTM term - identifies search terms
|
|
79
|
+
*/
|
|
80
|
+
term?: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Date when promo code was successfully applied
|
|
85
|
+
* @example 2026-06-10T12:30:00.000Z
|
|
86
|
+
*/
|
|
87
|
+
appliedAt: Date;
|
|
88
|
+
}
|