@ace-sdk/core 2.7.0 → 2.8.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.
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Subscription Types for ACE SDK
3
+ *
4
+ * Types for handling subscription status, usage metrics,
5
+ * and billing-related error responses from the ACE server.
6
+ *
7
+ * @package @ace-sdk/core
8
+ * @since v2.8.0
9
+ */
10
+ // =============================================================================
11
+ // Type Guards
12
+ // =============================================================================
13
+ /**
14
+ * Check if error response is quota exceeded
15
+ */
16
+ export function isQuotaError(data) {
17
+ return typeof data === 'object' && data !== null && data.error === 'quota_exceeded';
18
+ }
19
+ /**
20
+ * Check if error response is feature not available
21
+ */
22
+ export function isFeatureError(data) {
23
+ return typeof data === 'object' && data !== null && data.error === 'feature_not_available';
24
+ }
25
+ /**
26
+ * Check if error response is payment required
27
+ */
28
+ export function isPaymentRequiredError(data) {
29
+ return typeof data === 'object' && data !== null && data.error === 'payment_required';
30
+ }
31
+ /**
32
+ * Check if error response is account blocked
33
+ */
34
+ export function isAccountBlockedError(data) {
35
+ return typeof data === 'object' && data !== null && data.error === 'account_blocked';
36
+ }
37
+ /**
38
+ * Check if error response is insufficient permissions
39
+ */
40
+ export function isPermissionsError(data) {
41
+ return typeof data === 'object' && data !== null && data.error === 'insufficient_permissions';
42
+ }
43
+ // =============================================================================
44
+ // Helper Functions
45
+ // =============================================================================
46
+ /**
47
+ * Parse plan string into type and tier
48
+ * @param plan - Plan string like "individual/free" or "team/pro"
49
+ */
50
+ export function parsePlan(plan) {
51
+ const [type, tier] = plan.split('/');
52
+ const subscriptionType = type === 'team' ? 'team' : 'individual';
53
+ const planTier = tier === 'pro' ? 'pro' :
54
+ tier === 'basic' ? 'basic' : 'free';
55
+ return { type: subscriptionType, tier: planTier };
56
+ }
57
+ /**
58
+ * Calculate usage percentage
59
+ */
60
+ export function getUsagePercentage(metric) {
61
+ if (metric.limit <= 0)
62
+ return 0;
63
+ return Math.min(100, Math.round((metric.used / metric.limit) * 100));
64
+ }
65
+ /**
66
+ * Check if a metric is near limit (>80%)
67
+ */
68
+ export function isNearLimit(metric, threshold = 80) {
69
+ return getUsagePercentage(metric) >= threshold;
70
+ }
71
+ /**
72
+ * Check if a metric has exceeded its limit
73
+ */
74
+ export function isOverLimit(metric) {
75
+ return metric.limit > 0 && metric.used >= metric.limit;
76
+ }
77
+ /**
78
+ * Get feature availability based on plan
79
+ */
80
+ export function getFeatures(type, tier) {
81
+ return {
82
+ teams: type === 'team',
83
+ sharing: type === 'team' ? tier !== 'free' : tier === 'pro',
84
+ apiAccess: tier !== 'free',
85
+ prioritySupport: tier === 'pro'
86
+ };
87
+ }
88
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/types/subscription.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmKH,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAK,IAAY,CAAC,KAAK,KAAK,gBAAgB,CAAC;AAC/F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAK,IAAY,CAAC,KAAK,KAAK,uBAAuB,CAAC;AACtG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAa;IAClD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAK,IAAY,CAAC,KAAK,KAAK,kBAAkB,CAAC;AACjG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAK,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,OAAO,MAAM,CAAC,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAsB,EAAE,IAAc;IAChE,OAAO;QACL,KAAK,EAAE,IAAI,KAAK,MAAM;QACtB,OAAO,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK;QAC3D,SAAS,EAAE,IAAI,KAAK,MAAM;QAC1B,eAAe,EAAE,IAAI,KAAK,KAAK;KAChC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ace-sdk/core",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "ACE Core - Shared library for ACE pattern learning (HTTP client, caching, config, types)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",