@autumnsgrove/groveengine 0.4.12 → 0.5.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,137 @@
1
+ /**
2
+ * GroveAuth Client Types
3
+ *
4
+ * Type definitions for integrating with GroveAuth service.
5
+ */
6
+ export interface GroveAuthConfig {
7
+ /** Client ID registered with GroveAuth */
8
+ clientId: string;
9
+ /** Client secret for token exchange (keep secure!) */
10
+ clientSecret: string;
11
+ /** OAuth callback URL for this application */
12
+ redirectUri: string;
13
+ /** GroveAuth base URL (defaults to https://auth.grove.place) */
14
+ authBaseUrl?: string;
15
+ }
16
+ export interface TokenResponse {
17
+ access_token: string;
18
+ token_type: "Bearer";
19
+ expires_in: number;
20
+ refresh_token: string;
21
+ scope: string;
22
+ }
23
+ export interface TokenInfo {
24
+ active: boolean;
25
+ sub?: string;
26
+ email?: string;
27
+ name?: string;
28
+ exp?: number;
29
+ iat?: number;
30
+ client_id?: string;
31
+ }
32
+ export interface UserInfo {
33
+ sub: string;
34
+ email: string;
35
+ name: string | null;
36
+ picture: string | null;
37
+ provider: "google" | "github" | "magic_code";
38
+ }
39
+ export interface LoginUrlResult {
40
+ url: string;
41
+ state: string;
42
+ codeVerifier: string;
43
+ }
44
+ export type SubscriptionTier = "starter" | "professional" | "business";
45
+ export interface UserSubscription {
46
+ id: string;
47
+ user_id: string;
48
+ tier: SubscriptionTier;
49
+ post_limit: number | null;
50
+ post_count: number;
51
+ grace_period_start: string | null;
52
+ grace_period_days: number;
53
+ stripe_customer_id: string | null;
54
+ stripe_subscription_id: string | null;
55
+ billing_period_start: string | null;
56
+ billing_period_end: string | null;
57
+ custom_domain: string | null;
58
+ custom_domain_verified: number;
59
+ created_at: string;
60
+ updated_at: string;
61
+ }
62
+ export interface SubscriptionStatus {
63
+ tier: SubscriptionTier;
64
+ post_count: number;
65
+ post_limit: number | null;
66
+ posts_remaining: number | null;
67
+ percentage_used: number | null;
68
+ is_at_limit: boolean;
69
+ is_in_grace_period: boolean;
70
+ grace_period_days_remaining: number | null;
71
+ can_create_post: boolean;
72
+ upgrade_required: boolean;
73
+ }
74
+ export interface SubscriptionResponse {
75
+ subscription: UserSubscription;
76
+ status: SubscriptionStatus;
77
+ }
78
+ export interface CanPostResponse {
79
+ allowed: boolean;
80
+ status: SubscriptionStatus;
81
+ subscription: UserSubscription;
82
+ }
83
+ /**
84
+ * Post limits per subscription tier.
85
+ *
86
+ * Business rationale:
87
+ * - Starter (250 posts): Entry-level tier for hobbyists, personal bloggers,
88
+ * and users testing the platform. ~1 post/day for 8 months.
89
+ * - Professional (2,000 posts): For active content creators, small businesses,
90
+ * and dedicated bloggers. ~1 post/day for 5+ years.
91
+ * - Business (unlimited): For enterprises, agencies, and power users who need
92
+ * no restrictions. Includes custom domain support.
93
+ *
94
+ * Grace period: When users hit their limit, they have 14 days to upgrade or
95
+ * delete posts before their account becomes read-only.
96
+ *
97
+ * @see docs/implementing-post-limits.md for full specification
98
+ */
99
+ export declare const TIER_POST_LIMITS: Record<SubscriptionTier, number | null>;
100
+ /**
101
+ * Human-readable tier names for UI display.
102
+ */
103
+ export declare const TIER_NAMES: Record<SubscriptionTier, string>;
104
+ /**
105
+ * OAuth/API error response structure from GroveAuth.
106
+ * Used to parse error responses from the authentication API.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const response = await fetch('/token');
111
+ * if (!response.ok) {
112
+ * const error: AuthError = await response.json();
113
+ * console.error(error.error, error.error_description);
114
+ * }
115
+ * ```
116
+ */
117
+ export interface AuthError {
118
+ /** OAuth error code (e.g., 'invalid_grant', 'access_denied') */
119
+ error: string;
120
+ /** Human-readable error description (OAuth standard) */
121
+ error_description?: string;
122
+ /** Alternative message field used by some endpoints */
123
+ message?: string;
124
+ }
125
+ /**
126
+ * Client-side error class for GroveAuth operations.
127
+ * Thrown when authentication or subscription operations fail.
128
+ */
129
+ export declare class GroveAuthError extends Error {
130
+ /** Error code (e.g., 'invalid_user_id', 'subscription_error') */
131
+ readonly code: string;
132
+ /** HTTP status code from the response */
133
+ readonly statusCode: number;
134
+ constructor(code: string, message: string, statusCode?: number);
135
+ /** Alias for statusCode for compatibility */
136
+ get status(): number;
137
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * GroveAuth Client Types
3
+ *
4
+ * Type definitions for integrating with GroveAuth service.
5
+ */
6
+ // =============================================================================
7
+ // POST LIMIT CONSTANTS
8
+ // =============================================================================
9
+ /**
10
+ * Post limits per subscription tier.
11
+ *
12
+ * Business rationale:
13
+ * - Starter (250 posts): Entry-level tier for hobbyists, personal bloggers,
14
+ * and users testing the platform. ~1 post/day for 8 months.
15
+ * - Professional (2,000 posts): For active content creators, small businesses,
16
+ * and dedicated bloggers. ~1 post/day for 5+ years.
17
+ * - Business (unlimited): For enterprises, agencies, and power users who need
18
+ * no restrictions. Includes custom domain support.
19
+ *
20
+ * Grace period: When users hit their limit, they have 14 days to upgrade or
21
+ * delete posts before their account becomes read-only.
22
+ *
23
+ * @see docs/implementing-post-limits.md for full specification
24
+ */
25
+ export const TIER_POST_LIMITS = {
26
+ starter: 250, // For hobbyists and personal blogs
27
+ professional: 2000, // For active bloggers and small businesses
28
+ business: null, // Unlimited for enterprises and power users
29
+ };
30
+ /**
31
+ * Human-readable tier names for UI display.
32
+ */
33
+ export const TIER_NAMES = {
34
+ starter: "Starter",
35
+ professional: "Professional",
36
+ business: "Business",
37
+ };
38
+ /**
39
+ * Client-side error class for GroveAuth operations.
40
+ * Thrown when authentication or subscription operations fail.
41
+ */
42
+ export class GroveAuthError extends Error {
43
+ /** Error code (e.g., 'invalid_user_id', 'subscription_error') */
44
+ code;
45
+ /** HTTP status code from the response */
46
+ statusCode;
47
+ constructor(code, message, statusCode = 400) {
48
+ super(message);
49
+ this.name = "GroveAuthError";
50
+ this.code = code;
51
+ this.statusCode = statusCode;
52
+ }
53
+ /** Alias for statusCode for compatibility */
54
+ get status() {
55
+ return this.statusCode;
56
+ }
57
+ }
package/dist/index.d.ts CHANGED
@@ -6,9 +6,11 @@ export { default as MobileTOC } from './components/custom/MobileTOC.svelte';
6
6
  export { default as CollapsibleSection } from './components/custom/CollapsibleSection.svelte';
7
7
  export { default as MarkdownEditor } from './components/admin/MarkdownEditor.svelte';
8
8
  export { default as GutterManager } from './components/admin/GutterManager.svelte';
9
+ export { QuotaWidget, QuotaWarning, UpgradePrompt } from './components/quota/index';
9
10
  export { default as ImageGallery } from './ui/components/gallery/ImageGallery.svelte';
10
11
  export { default as Lightbox } from './ui/components/gallery/Lightbox.svelte';
11
12
  export { default as LightboxCaption } from './ui/components/gallery/LightboxCaption.svelte';
12
13
  export { default as ZoomableImage } from './ui/components/gallery/ZoomableImage.svelte';
13
14
  export * from './ui/index';
14
15
  export { cn } from './utils/cn';
16
+ export * from './groveauth/index';
package/dist/index.js CHANGED
@@ -9,6 +9,8 @@ export { default as CollapsibleSection } from './components/custom/CollapsibleSe
9
9
  // Admin components
10
10
  export { default as MarkdownEditor } from './components/admin/MarkdownEditor.svelte';
11
11
  export { default as GutterManager } from './components/admin/GutterManager.svelte';
12
+ // Quota components
13
+ export { QuotaWidget, QuotaWarning, UpgradePrompt } from './components/quota/index';
12
14
  // Gallery components (from UI module)
13
15
  export { default as ImageGallery } from './ui/components/gallery/ImageGallery.svelte';
14
16
  export { default as Lightbox } from './ui/components/gallery/Lightbox.svelte';
@@ -18,3 +20,5 @@ export { default as ZoomableImage } from './ui/components/gallery/ZoomableImage.
18
20
  export * from './ui/index';
19
21
  // Utilities
20
22
  export { cn } from './utils/cn';
23
+ // GroveAuth client (re-export for convenience)
24
+ export * from './groveauth/index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autumnsgrove/groveengine",
3
- "version": "0.4.12",
3
+ "version": "0.5.0",
4
4
  "description": "Multi-tenant blog engine for Grove Platform. Features gutter annotations, markdown editing, magic code auth, and Cloudflare Workers deployment.",
5
5
  "author": "AutumnsGrove",
6
6
  "license": "MIT",