@skalpgg/sdk 1.9.0 → 1.10.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.
package/README.md CHANGED
@@ -67,6 +67,9 @@ Create the key on the API keys page of your dashboard. Each key is bound to one
67
67
  | `coupons.create({ code, discountType?, discountPercent?, discountAmount?, validFrom?, validTo?, maxUses?, subscriptionDuration?, subscriptionMonths?, ... })` / `coupons.update(id, { ... })` / `coupons.delete(id)` | `coupons:write` |
68
68
  | `customers.list({ search?, limit?, offset? })` / `customers.get(id)` | `customers:read` |
69
69
  | `customers.create({ email, name?, note? })` / `customers.update(id, { name?, note? })` / `customers.delete(id)` | `customers:write` |
70
+ | `levels.get()` / `levels.customer(email)` | `customers:read` |
71
+ | `levels.giveXp(email, amount, reason?)` | `customers:write` |
72
+ | `levels.setProductRule(productIds, rule)` | `products:write` |
70
73
  | `feedback.list({ productId?, rating?, limit?, offset? })` / `feedback.get(id)` | `feedback:read` |
71
74
  | `feedback.reply(id, { message })` / `feedback.appeal(id, { reason })` | `feedback:write` |
72
75
  | `queries.list({ status?, limit?, offset? })` / `queries.get(id)` | `queries:read` |
@@ -143,6 +146,33 @@ Coupons take `validFrom`, `validTo` as an ISO string or a `Date`; `coupons.updat
143
146
 
144
147
  `me()` returns the store and the key you are using, with its scopes. `checkout.create` takes `player`, a `name` and game `ids` such as `steamid64` or `mc_name`, when your server already knows who gets the order. Orders carry `serviceFee`, the buyer fee included in `amount`, and customers carry `spent`, one total per currency.
145
148
 
149
+ ## Buyer levels
150
+
151
+ When a store has levels on, buyers earn 10 XP for every unit of store currency they spend. `levels.get()` returns the ladder and any running XP boost. `levels.customer(email)` returns one buyer's XP, level and level discount. An email without an account comes back at level 1 with 0 XP. `levels.giveXp` adds XP, or takes it away with a negative amount, up to 1,000,000 at a time. The buyer needs a Skalp account, and a store with levels off answers 400 `LEVELS_DISABLED`.
152
+
153
+ ```ts
154
+ const { level, xpToNext } = await skalp.levels.giveXp('buyer@example.com', 250, 'Won the weekend event')
155
+ ```
156
+
157
+ Each tier carries its perks: `discountPercent`, a one-time `gift` coupon, a Discord role, `gemMultiplier` for Ametysty and `gameReward` (only its `label`; the command stays private). `badgeUrl` is the image the seller uploaded for the level, or `null` for the built-in badge. `levels.customer` returns the buyer's `gemMultiplier` and `badgeUrl` too.
158
+
159
+ ### Level-locked products
160
+
161
+ A product with `minLevel` can only be bought from that level up. Buyers below it still see it. Pick one of three rules:
162
+
163
+ - Level only: `minLevel` alone. The lock stays until you clear it.
164
+ - Early access: `minLevel` plus `earlyAccessHours` (1 to 720). That level buys first, everyone else after the hours run out. On a product that is not out yet, the hours start when it goes live; on a live product they start now and come back as `minLevelUntil`.
165
+ - Until a date: `minLevel` plus `minLevelUntil`.
166
+
167
+ Send `earlyAccessHours` or `minLevelUntil`, not both (400 `LEVEL_RULE_CONFLICT`). `minLevel: null` clears the rule. `products.create` and `products.update` take these fields; `levels.setProductRule` sets one rule on up to 100 products at once and returns every product that has a rule. `earlyAccessHours` is only in your own API responses, never on the storefront.
168
+
169
+ ```ts
170
+ await skalp.levels.setProductRule(['prod_1', 'prod_2'], { minLevel: 4, earlyAccessHours: 48 })
171
+ await skalp.levels.setProductRule(['prod_1'], null)
172
+ ```
173
+
174
+ `customer.level_up` and `customer.level_down` are not in the default webhook list: subscribe to them by name. `data` carries `email`, `userId`, `level`, `previousLevel`, `xp` and the `tier` the buyer is on now.
175
+
146
176
  ## Support and access rules
147
177
 
148
178
  `feedback` and `queries` expose product reviews and buyer conversations. `queries.reply`, `close` and `reopen` return the whole conversation with its `messages`. `blacklist` and `whitelist` use the same calls, each with its own read and write scope; a whitelisted buyer is never blocked by a blacklist rule.
@@ -1,6 +1,6 @@
1
- import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
1
+ import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.9.0";
3
+ export declare const VERSION = "1.10.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
@@ -82,6 +82,12 @@ export declare class Skalp {
82
82
  update: (id: string, { name, note }: UpdateCustomerParams) => Promise<Customer>;
83
83
  delete: (id: string) => Promise<Deleted>;
84
84
  };
85
+ readonly levels: {
86
+ get: () => Promise<StoreLevels>;
87
+ customer: (email: string) => Promise<CustomerLevel>;
88
+ giveXp: (email: string, amount: number, reason?: string) => Promise<CustomerLevel>;
89
+ setProductRule: (productIds: Array<string>, rule: LevelProductRule | null) => Promise<LevelProducts>;
90
+ };
85
91
  readonly feedback: {
86
92
  list: ({ productId, rating, limit, offset }?: ListFeedbackParams) => Promise<FeedbackList>;
87
93
  get: (id: string) => Promise<Feedback>;
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Skalp = exports.SkalpSignatureError = exports.SkalpConnectionError = exports.SkalpError = exports.VERSION = void 0;
4
- exports.VERSION = '1.9.0';
4
+ exports.VERSION = '1.10.0';
5
5
  const SIGNATURE_HEADER = 'skalp-signature';
6
6
  const SIGNATURE_TOLERANCE_SECONDS = 300;
7
7
  const PRODUCT_PAGE = 100;
@@ -83,6 +83,9 @@ const PRODUCT_FIELDS = [
83
83
  'customFields',
84
84
  'minQuantity',
85
85
  'maxQuantity',
86
+ 'minLevel',
87
+ 'minLevelUntil',
88
+ 'earlyAccessHours',
86
89
  'volumeDiscounts',
87
90
  'upsells',
88
91
  'prices',
@@ -233,6 +236,12 @@ class Skalp {
233
236
  update: (id, { name, note }) => this.#request('PATCH', `/v1/customers/${segment(id)}`, { body: { name, note } }),
234
237
  delete: (id) => this.#request('DELETE', `/v1/customers/${segment(id)}`),
235
238
  };
239
+ levels = {
240
+ get: () => this.#request('GET', '/v1/levels'),
241
+ customer: (email) => this.#request('GET', `/v1/levels/customers/${segment(email)}`),
242
+ giveXp: (email, amount, reason) => this.#request('POST', `/v1/levels/customers/${segment(email)}/xp`, { body: { amount, reason } }),
243
+ setProductRule: (productIds, rule) => this.#request('PATCH', '/v1/levels/products', { body: { productIds, rule } }),
244
+ };
236
245
  feedback = {
237
246
  list: ({ productId, rating, limit, offset } = {}) => this.#request('GET', '/v1/feedback', { query: { productId, rating, limit, offset } }),
238
247
  get: (id) => this.#request('GET', `/v1/feedback/${segment(id)}`),
@@ -58,6 +58,11 @@ export interface Order {
58
58
  serviceFee: number | null;
59
59
  sellerPaymentFee: number | null;
60
60
  couponCode: string | null;
61
+ levelDiscount?: {
62
+ level: number;
63
+ percent: number;
64
+ amount: number;
65
+ } | null;
61
66
  productId: string;
62
67
  productName: string;
63
68
  productSlug: string;
@@ -249,6 +254,9 @@ export interface Product {
249
254
  minQuantity: number;
250
255
  /** null allows up to 1000. */
251
256
  maxQuantity: number | null;
257
+ minLevel: number | null;
258
+ minLevelUntil: string | null;
259
+ earlyAccessHours: number | null;
252
260
  volumeDiscounts: Array<VolumeDiscount>;
253
261
  /** Products offered on this product's checkout page. */
254
262
  upsells: Array<ProductUpsell>;
@@ -322,6 +330,9 @@ interface ProductFields {
322
330
  /** SERIAL, LICENSE, SERVICE and GAME one-time products only. */
323
331
  minQuantity?: number;
324
332
  maxQuantity?: number | null;
333
+ minLevel?: number | null;
334
+ minLevelUntil?: string | Date | null;
335
+ earlyAccessHours?: number | null;
325
336
  /** Up to 10 tiers; the list replaces the old one, [] or null removes them all. */
326
337
  volumeDiscounts?: Array<VolumeDiscount> | null;
327
338
  /** Up to 3 one-time products of the store; the list replaces the old one, [] or null removes them all. */
@@ -580,6 +591,65 @@ export interface UpdateCustomerParams {
580
591
  name?: string | null;
581
592
  note?: string | null;
582
593
  }
594
+ export type LevelGiftType = 'PERCENT' | 'FIXED';
595
+ export interface LevelGift {
596
+ type: LevelGiftType;
597
+ value: number;
598
+ }
599
+ export interface LevelTier {
600
+ level: number;
601
+ xp: number;
602
+ name: string | null;
603
+ discountPercent: number;
604
+ gift: LevelGift | null;
605
+ discordRoleId: string | null;
606
+ discordRoleName: string | null;
607
+ gemMultiplier: number;
608
+ gameReward: LevelGameReward | null;
609
+ badgeUrl: string | null;
610
+ }
611
+ export interface LevelGameReward {
612
+ label: string;
613
+ }
614
+ export interface LevelBoost {
615
+ multiplier: number;
616
+ endsAt: string;
617
+ }
618
+ export interface StoreLevels {
619
+ enabled: boolean;
620
+ xpPerUnit: number;
621
+ tiers: Array<LevelTier>;
622
+ boost: LevelBoost | null;
623
+ }
624
+ export interface LevelProductRule {
625
+ minLevel: number;
626
+ minLevelUntil?: string | Date | null;
627
+ earlyAccessHours?: number | null;
628
+ }
629
+ export interface LevelProduct {
630
+ id: string;
631
+ name: string;
632
+ slug: string;
633
+ status: ProductStatus;
634
+ image: string | null;
635
+ minLevel: number | null;
636
+ minLevelUntil: string | null;
637
+ earlyAccessHours: number | null;
638
+ }
639
+ export interface LevelProducts {
640
+ products: Array<LevelProduct>;
641
+ }
642
+ export interface CustomerLevel {
643
+ email: string;
644
+ xp: number;
645
+ level: number;
646
+ next: LevelTier | null;
647
+ xpToNext: number;
648
+ progress: number;
649
+ discountPercent: number;
650
+ gemMultiplier: number;
651
+ badgeUrl: string | null;
652
+ }
583
653
  export interface FeedbackReply {
584
654
  id: string;
585
655
  content: string;
@@ -1052,6 +1122,15 @@ export interface SubscriptionCheckoutExpiredData {
1052
1122
  currency: string;
1053
1123
  metadata: Record<string, unknown>;
1054
1124
  }
1125
+ export interface CustomerLevelEventData {
1126
+ storeId: string;
1127
+ email: string | null;
1128
+ userId: string;
1129
+ level: number;
1130
+ previousLevel: number;
1131
+ xp: number;
1132
+ tier: LevelTier;
1133
+ }
1055
1134
  export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.canceled', OrderEventData> | Envelope<'order.replaced', OrderReplacedData> | Envelope<'order.paid' | 'purchase.completed', OrderPaidData> | Envelope<'order.refunded', OrderRefundedData> | Envelope<'order.disputed' | 'account.suspend', OrderDisputedData> | Envelope<'account.restore', AccountRestoreData> | Envelope<'subscription.created' | 'subscription.updated' | 'subscription.trial_started' | 'subscription.trial_ended', SubscriptionEventData> | Envelope<'subscription.upcoming', SubscriptionEventData & {
1056
1135
  amountDue: number;
1057
1136
  nextPaymentAttempt: string | null;
@@ -1076,6 +1155,6 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1076
1155
  disputeId: string;
1077
1156
  disputeStatus: 'open' | 'won' | 'lost';
1078
1157
  disputeReason: string | null;
1079
- }> | Envelope<'product.created' | 'product.updated', ProductEventData> | Envelope<'product.stock', ProductStockData> | Envelope<'query.created' | 'query.replied', QueryEventData> | Envelope<'feedback.received', FeedbackReceivedData> | Envelope<'webhook.test', WebhookTestData>;
1158
+ }> | Envelope<'product.created' | 'product.updated', ProductEventData> | Envelope<'product.stock', ProductStockData> | Envelope<'query.created' | 'query.replied', QueryEventData> | Envelope<'feedback.received', FeedbackReceivedData> | Envelope<'customer.level_up' | 'customer.level_down', CustomerLevelEventData> | Envelope<'webhook.test', WebhookTestData>;
1080
1159
  export type SkalpEventType = SkalpEvent['type'];
1081
1160
  export {};
@@ -1,6 +1,6 @@
1
- import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
1
+ import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.9.0";
3
+ export declare const VERSION = "1.10.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
@@ -82,6 +82,12 @@ export declare class Skalp {
82
82
  update: (id: string, { name, note }: UpdateCustomerParams) => Promise<Customer>;
83
83
  delete: (id: string) => Promise<Deleted>;
84
84
  };
85
+ readonly levels: {
86
+ get: () => Promise<StoreLevels>;
87
+ customer: (email: string) => Promise<CustomerLevel>;
88
+ giveXp: (email: string, amount: number, reason?: string) => Promise<CustomerLevel>;
89
+ setProductRule: (productIds: Array<string>, rule: LevelProductRule | null) => Promise<LevelProducts>;
90
+ };
85
91
  readonly feedback: {
86
92
  list: ({ productId, rating, limit, offset }?: ListFeedbackParams) => Promise<FeedbackList>;
87
93
  get: (id: string) => Promise<Feedback>;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '1.9.0';
1
+ export const VERSION = '1.10.0';
2
2
  const SIGNATURE_HEADER = 'skalp-signature';
3
3
  const SIGNATURE_TOLERANCE_SECONDS = 300;
4
4
  const PRODUCT_PAGE = 100;
@@ -77,6 +77,9 @@ const PRODUCT_FIELDS = [
77
77
  'customFields',
78
78
  'minQuantity',
79
79
  'maxQuantity',
80
+ 'minLevel',
81
+ 'minLevelUntil',
82
+ 'earlyAccessHours',
80
83
  'volumeDiscounts',
81
84
  'upsells',
82
85
  'prices',
@@ -227,6 +230,12 @@ export class Skalp {
227
230
  update: (id, { name, note }) => this.#request('PATCH', `/v1/customers/${segment(id)}`, { body: { name, note } }),
228
231
  delete: (id) => this.#request('DELETE', `/v1/customers/${segment(id)}`),
229
232
  };
233
+ levels = {
234
+ get: () => this.#request('GET', '/v1/levels'),
235
+ customer: (email) => this.#request('GET', `/v1/levels/customers/${segment(email)}`),
236
+ giveXp: (email, amount, reason) => this.#request('POST', `/v1/levels/customers/${segment(email)}/xp`, { body: { amount, reason } }),
237
+ setProductRule: (productIds, rule) => this.#request('PATCH', '/v1/levels/products', { body: { productIds, rule } }),
238
+ };
230
239
  feedback = {
231
240
  list: ({ productId, rating, limit, offset } = {}) => this.#request('GET', '/v1/feedback', { query: { productId, rating, limit, offset } }),
232
241
  get: (id) => this.#request('GET', `/v1/feedback/${segment(id)}`),
@@ -58,6 +58,11 @@ export interface Order {
58
58
  serviceFee: number | null;
59
59
  sellerPaymentFee: number | null;
60
60
  couponCode: string | null;
61
+ levelDiscount?: {
62
+ level: number;
63
+ percent: number;
64
+ amount: number;
65
+ } | null;
61
66
  productId: string;
62
67
  productName: string;
63
68
  productSlug: string;
@@ -249,6 +254,9 @@ export interface Product {
249
254
  minQuantity: number;
250
255
  /** null allows up to 1000. */
251
256
  maxQuantity: number | null;
257
+ minLevel: number | null;
258
+ minLevelUntil: string | null;
259
+ earlyAccessHours: number | null;
252
260
  volumeDiscounts: Array<VolumeDiscount>;
253
261
  /** Products offered on this product's checkout page. */
254
262
  upsells: Array<ProductUpsell>;
@@ -322,6 +330,9 @@ interface ProductFields {
322
330
  /** SERIAL, LICENSE, SERVICE and GAME one-time products only. */
323
331
  minQuantity?: number;
324
332
  maxQuantity?: number | null;
333
+ minLevel?: number | null;
334
+ minLevelUntil?: string | Date | null;
335
+ earlyAccessHours?: number | null;
325
336
  /** Up to 10 tiers; the list replaces the old one, [] or null removes them all. */
326
337
  volumeDiscounts?: Array<VolumeDiscount> | null;
327
338
  /** Up to 3 one-time products of the store; the list replaces the old one, [] or null removes them all. */
@@ -580,6 +591,65 @@ export interface UpdateCustomerParams {
580
591
  name?: string | null;
581
592
  note?: string | null;
582
593
  }
594
+ export type LevelGiftType = 'PERCENT' | 'FIXED';
595
+ export interface LevelGift {
596
+ type: LevelGiftType;
597
+ value: number;
598
+ }
599
+ export interface LevelTier {
600
+ level: number;
601
+ xp: number;
602
+ name: string | null;
603
+ discountPercent: number;
604
+ gift: LevelGift | null;
605
+ discordRoleId: string | null;
606
+ discordRoleName: string | null;
607
+ gemMultiplier: number;
608
+ gameReward: LevelGameReward | null;
609
+ badgeUrl: string | null;
610
+ }
611
+ export interface LevelGameReward {
612
+ label: string;
613
+ }
614
+ export interface LevelBoost {
615
+ multiplier: number;
616
+ endsAt: string;
617
+ }
618
+ export interface StoreLevels {
619
+ enabled: boolean;
620
+ xpPerUnit: number;
621
+ tiers: Array<LevelTier>;
622
+ boost: LevelBoost | null;
623
+ }
624
+ export interface LevelProductRule {
625
+ minLevel: number;
626
+ minLevelUntil?: string | Date | null;
627
+ earlyAccessHours?: number | null;
628
+ }
629
+ export interface LevelProduct {
630
+ id: string;
631
+ name: string;
632
+ slug: string;
633
+ status: ProductStatus;
634
+ image: string | null;
635
+ minLevel: number | null;
636
+ minLevelUntil: string | null;
637
+ earlyAccessHours: number | null;
638
+ }
639
+ export interface LevelProducts {
640
+ products: Array<LevelProduct>;
641
+ }
642
+ export interface CustomerLevel {
643
+ email: string;
644
+ xp: number;
645
+ level: number;
646
+ next: LevelTier | null;
647
+ xpToNext: number;
648
+ progress: number;
649
+ discountPercent: number;
650
+ gemMultiplier: number;
651
+ badgeUrl: string | null;
652
+ }
583
653
  export interface FeedbackReply {
584
654
  id: string;
585
655
  content: string;
@@ -1052,6 +1122,15 @@ export interface SubscriptionCheckoutExpiredData {
1052
1122
  currency: string;
1053
1123
  metadata: Record<string, unknown>;
1054
1124
  }
1125
+ export interface CustomerLevelEventData {
1126
+ storeId: string;
1127
+ email: string | null;
1128
+ userId: string;
1129
+ level: number;
1130
+ previousLevel: number;
1131
+ xp: number;
1132
+ tier: LevelTier;
1133
+ }
1055
1134
  export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.canceled', OrderEventData> | Envelope<'order.replaced', OrderReplacedData> | Envelope<'order.paid' | 'purchase.completed', OrderPaidData> | Envelope<'order.refunded', OrderRefundedData> | Envelope<'order.disputed' | 'account.suspend', OrderDisputedData> | Envelope<'account.restore', AccountRestoreData> | Envelope<'subscription.created' | 'subscription.updated' | 'subscription.trial_started' | 'subscription.trial_ended', SubscriptionEventData> | Envelope<'subscription.upcoming', SubscriptionEventData & {
1056
1135
  amountDue: number;
1057
1136
  nextPaymentAttempt: string | null;
@@ -1076,6 +1155,6 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1076
1155
  disputeId: string;
1077
1156
  disputeStatus: 'open' | 'won' | 'lost';
1078
1157
  disputeReason: string | null;
1079
- }> | Envelope<'product.created' | 'product.updated', ProductEventData> | Envelope<'product.stock', ProductStockData> | Envelope<'query.created' | 'query.replied', QueryEventData> | Envelope<'feedback.received', FeedbackReceivedData> | Envelope<'webhook.test', WebhookTestData>;
1158
+ }> | Envelope<'product.created' | 'product.updated', ProductEventData> | Envelope<'product.stock', ProductStockData> | Envelope<'query.created' | 'query.replied', QueryEventData> | Envelope<'feedback.received', FeedbackReceivedData> | Envelope<'customer.level_up' | 'customer.level_down', CustomerLevelEventData> | Envelope<'webhook.test', WebhookTestData>;
1080
1159
  export type SkalpEventType = SkalpEvent['type'];
1081
1160
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalpgg/sdk",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Official Skalp SDK for Node.js and edge runtimes: checkout, subscriptions, catalog and key stock, webhooks and license verification.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://skalp.gg/docs/sdk",