@djangocfg/ext-base 1.0.3 → 1.0.4
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 +134 -8
- package/dist/api.cjs +40 -0
- package/dist/api.d.cts +35 -0
- package/dist/api.d.ts +35 -0
- package/dist/api.js +2 -0
- package/dist/auth.cjs +10 -0
- package/dist/auth.d.cts +1 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +2 -0
- package/dist/chunk-3RG5ZIWI.js +8 -0
- package/dist/chunk-UXTBBEO5.js +237 -0
- package/dist/chunk-VJEGYVBV.js +140 -0
- package/dist/cli.mjs +530 -0
- package/dist/hooks.cjs +437 -0
- package/dist/hooks.d.cts +97 -0
- package/dist/hooks.d.ts +97 -0
- package/dist/hooks.js +95 -0
- package/dist/index.cjs +345 -0
- package/dist/index.d.cts +363 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.js +3 -0
- package/package.json +3 -1
- package/src/cli/index.ts +281 -15
- package/src/context/ExtensionProvider.tsx +67 -4
- package/src/extensionConfig.ts +77 -28
- package/templates/extension-template/README.md.template +30 -0
- package/templates/extension-template/package.json.template +2 -1
- package/templates/extension-template/playground/.gitignore.template +34 -0
- package/templates/extension-template/playground/CLAUDE.md +35 -0
- package/templates/extension-template/playground/README.md.template +76 -0
- package/templates/extension-template/playground/app/globals.css.template +19 -0
- package/templates/extension-template/playground/app/layout.tsx.template +30 -0
- package/templates/extension-template/playground/app/page.tsx.template +44 -0
- package/templates/extension-template/playground/next.config.ts.template +62 -0
- package/templates/extension-template/playground/package.json.template +33 -0
- package/templates/extension-template/playground/tsconfig.json.template +27 -0
- package/templates/extension-template/src/contexts/__PROVIDER_NAME__Context.tsx +1 -1
- package/templates/extension-template/src/contexts/__PROVIDER_NAME__ExtensionProvider.tsx +1 -0
- package/templates/extension-template/src/index.ts +12 -4
- package/templates/extension-template/src/utils/withSmartProvider.tsx +70 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export { createExtensionAPI, getSharedAuthStorage } from './api.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pagination types for extension packages
|
|
6
|
+
*/
|
|
7
|
+
interface PaginatedResponse<T> {
|
|
8
|
+
results: T[];
|
|
9
|
+
count: number;
|
|
10
|
+
next?: number | null;
|
|
11
|
+
previous?: number | null;
|
|
12
|
+
next_page?: number | null;
|
|
13
|
+
previous_page?: number | null;
|
|
14
|
+
has_next?: boolean;
|
|
15
|
+
has_previous?: boolean;
|
|
16
|
+
total_pages?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PaginationParams {
|
|
19
|
+
page?: number;
|
|
20
|
+
page_size?: number;
|
|
21
|
+
ordering?: string;
|
|
22
|
+
}
|
|
23
|
+
interface PaginationState {
|
|
24
|
+
page: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
totalCount: number;
|
|
27
|
+
totalPages: number;
|
|
28
|
+
hasNext: boolean;
|
|
29
|
+
hasPrevious: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface InfinitePaginationReturn<T> {
|
|
32
|
+
items: T[];
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
isLoadingMore: boolean;
|
|
35
|
+
error: any;
|
|
36
|
+
hasMore: boolean;
|
|
37
|
+
totalCount: number;
|
|
38
|
+
loadMore: () => void;
|
|
39
|
+
refresh: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
interface InfinitePaginationOptions {
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
revalidateFirstPage?: boolean;
|
|
44
|
+
parallel?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Context and provider types for extension packages
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
interface ExtensionContextOptions {
|
|
52
|
+
revalidateOnFocus?: boolean;
|
|
53
|
+
revalidateOnReconnect?: boolean;
|
|
54
|
+
revalidateIfStale?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Extension category types
|
|
58
|
+
*/
|
|
59
|
+
type ExtensionCategory = 'forms' | 'payments' | 'content' | 'support' | 'utilities' | 'analytics' | 'security' | 'integration' | 'other';
|
|
60
|
+
/**
|
|
61
|
+
* Extension categories with display names for CLI and UI
|
|
62
|
+
*/
|
|
63
|
+
declare const EXTENSION_CATEGORIES: Array<{
|
|
64
|
+
title: string;
|
|
65
|
+
value: ExtensionCategory;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Code example for extension documentation
|
|
69
|
+
*/
|
|
70
|
+
interface ExtensionExample {
|
|
71
|
+
/**
|
|
72
|
+
* Example title
|
|
73
|
+
*/
|
|
74
|
+
title: string;
|
|
75
|
+
/**
|
|
76
|
+
* Example description
|
|
77
|
+
*/
|
|
78
|
+
description?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Code snippet
|
|
81
|
+
*/
|
|
82
|
+
code: string;
|
|
83
|
+
/**
|
|
84
|
+
* Programming language for syntax highlighting
|
|
85
|
+
*/
|
|
86
|
+
language: string;
|
|
87
|
+
}
|
|
88
|
+
interface ExtensionMetadata {
|
|
89
|
+
/**
|
|
90
|
+
* Unique extension name (e.g., 'newsletter', 'payments')
|
|
91
|
+
*/
|
|
92
|
+
name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Extension version (semver format recommended)
|
|
95
|
+
*/
|
|
96
|
+
version: string;
|
|
97
|
+
/**
|
|
98
|
+
* Extension author name or organization
|
|
99
|
+
*/
|
|
100
|
+
author: string;
|
|
101
|
+
/**
|
|
102
|
+
* Extension display name
|
|
103
|
+
*/
|
|
104
|
+
displayName?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Extension description
|
|
107
|
+
*/
|
|
108
|
+
description?: string;
|
|
109
|
+
/**
|
|
110
|
+
* GitHub repository URL
|
|
111
|
+
* @example 'https://github.com/username/repo'
|
|
112
|
+
*/
|
|
113
|
+
githubUrl?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Extension homepage URL
|
|
116
|
+
*/
|
|
117
|
+
homepage?: string;
|
|
118
|
+
/**
|
|
119
|
+
* License identifier (e.g., 'MIT', 'Apache-2.0')
|
|
120
|
+
*/
|
|
121
|
+
license?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Keywords for search and discovery
|
|
124
|
+
*/
|
|
125
|
+
keywords?: string[];
|
|
126
|
+
/**
|
|
127
|
+
* Minimum required DjangoCFG version
|
|
128
|
+
*/
|
|
129
|
+
minVersion?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Extension category for marketplace organization
|
|
132
|
+
*/
|
|
133
|
+
category?: ExtensionCategory;
|
|
134
|
+
/**
|
|
135
|
+
* Tags for search and filtering
|
|
136
|
+
*/
|
|
137
|
+
tags?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* List of key features
|
|
140
|
+
*/
|
|
141
|
+
features?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* npm package URL
|
|
144
|
+
* @example 'https://www.npmjs.com/package/@djangocfg/ext-newsletter'
|
|
145
|
+
*/
|
|
146
|
+
npmUrl?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Marketplace-safe ID (package name with @ and / replaced by -)
|
|
149
|
+
* @example '@djangocfg/ext-newsletter' -> 'djangocfg-ext-newsletter'
|
|
150
|
+
*/
|
|
151
|
+
marketplaceId?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Marketplace URL
|
|
154
|
+
* @example 'https://hub.djangocfg.com/extensions/djangocfg-ext-newsletter'
|
|
155
|
+
*/
|
|
156
|
+
marketplaceUrl?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Installation command
|
|
159
|
+
* @example 'pnpm add @djangocfg/ext-newsletter'
|
|
160
|
+
*/
|
|
161
|
+
installCommand?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Download URL for npm tarball
|
|
164
|
+
* @example 'https://registry.npmjs.org/@djangocfg/ext-newsletter/-/ext-newsletter-1.0.0.tgz'
|
|
165
|
+
*/
|
|
166
|
+
downloadUrl?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Code examples for documentation
|
|
169
|
+
*/
|
|
170
|
+
examples?: ExtensionExample[];
|
|
171
|
+
/**
|
|
172
|
+
* npm package dependencies
|
|
173
|
+
*/
|
|
174
|
+
packageDependencies?: Record<string, string>;
|
|
175
|
+
/**
|
|
176
|
+
* npm peer dependencies
|
|
177
|
+
*/
|
|
178
|
+
packagePeerDependencies?: Record<string, string>;
|
|
179
|
+
/**
|
|
180
|
+
* npm dev dependencies
|
|
181
|
+
*/
|
|
182
|
+
packageDevDependencies?: Record<string, string>;
|
|
183
|
+
/**
|
|
184
|
+
* README content in markdown
|
|
185
|
+
*/
|
|
186
|
+
readme?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Preview image URL (1200x630 recommended)
|
|
189
|
+
* @example 'https://unpkg.com/@djangocfg/ext-leads@latest/preview.svg'
|
|
190
|
+
*/
|
|
191
|
+
preview?: string;
|
|
192
|
+
/**
|
|
193
|
+
* GitHub stars count
|
|
194
|
+
*/
|
|
195
|
+
githubStars?: number;
|
|
196
|
+
}
|
|
197
|
+
interface ExtensionProviderProps {
|
|
198
|
+
/**
|
|
199
|
+
* Extension metadata for registration
|
|
200
|
+
*/
|
|
201
|
+
metadata: ExtensionMetadata;
|
|
202
|
+
/**
|
|
203
|
+
* SWR configuration options
|
|
204
|
+
*/
|
|
205
|
+
options?: ExtensionContextOptions;
|
|
206
|
+
/**
|
|
207
|
+
* Child components
|
|
208
|
+
*/
|
|
209
|
+
children: ReactNode;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Error types for extension packages
|
|
214
|
+
*/
|
|
215
|
+
interface ExtensionError {
|
|
216
|
+
message: string;
|
|
217
|
+
code?: string;
|
|
218
|
+
details?: unknown;
|
|
219
|
+
timestamp: string;
|
|
220
|
+
}
|
|
221
|
+
type ErrorHandler = (error: Error | ExtensionError) => void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Logger types for extension packages
|
|
225
|
+
*/
|
|
226
|
+
interface ExtensionLogger {
|
|
227
|
+
info: (...args: any[]) => void;
|
|
228
|
+
warn: (...args: any[]) => void;
|
|
229
|
+
error: (...args: any[]) => void;
|
|
230
|
+
debug: (...args: any[]) => void;
|
|
231
|
+
success: (...args: any[]) => void;
|
|
232
|
+
}
|
|
233
|
+
interface LoggerOptions {
|
|
234
|
+
tag: string;
|
|
235
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
236
|
+
enabled?: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Base extension configuration
|
|
241
|
+
*/
|
|
242
|
+
declare const extensionConfig: ExtensionMetadata;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Extension configuration and environment utilities
|
|
246
|
+
*/
|
|
247
|
+
declare const isDevelopment: boolean;
|
|
248
|
+
declare const isProduction: boolean;
|
|
249
|
+
declare const isStaticBuild: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Get API URL from environment or default
|
|
252
|
+
*/
|
|
253
|
+
declare function getApiUrl(): string;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Error handling utilities for extension packages
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Checks if an error is an ExtensionError
|
|
261
|
+
*/
|
|
262
|
+
declare function isExtensionError(error: unknown): error is ExtensionError;
|
|
263
|
+
/**
|
|
264
|
+
* Creates an ExtensionError from any error
|
|
265
|
+
*/
|
|
266
|
+
declare function createExtensionError(error: unknown, code?: string, details?: unknown): ExtensionError;
|
|
267
|
+
/**
|
|
268
|
+
* Formats an error message for display
|
|
269
|
+
*/
|
|
270
|
+
declare function formatErrorMessage(error: unknown): string;
|
|
271
|
+
/**
|
|
272
|
+
* Safe error handler that logs and optionally calls callback
|
|
273
|
+
*/
|
|
274
|
+
declare function handleExtensionError(error: unknown, logger?: {
|
|
275
|
+
error: (...args: any[]) => void;
|
|
276
|
+
}, callback?: (error: ExtensionError) => void): void;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Helper to create extension configuration from package.json
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Package.json structure
|
|
284
|
+
*/
|
|
285
|
+
interface PackageJson {
|
|
286
|
+
name: string;
|
|
287
|
+
version: string;
|
|
288
|
+
description?: string;
|
|
289
|
+
keywords?: string[];
|
|
290
|
+
author?: string | {
|
|
291
|
+
name: string;
|
|
292
|
+
email?: string;
|
|
293
|
+
url?: string;
|
|
294
|
+
};
|
|
295
|
+
license?: string;
|
|
296
|
+
homepage?: string;
|
|
297
|
+
repository?: string | {
|
|
298
|
+
type: string;
|
|
299
|
+
url: string;
|
|
300
|
+
directory?: string;
|
|
301
|
+
};
|
|
302
|
+
dependencies?: Record<string, string>;
|
|
303
|
+
peerDependencies?: Record<string, string>;
|
|
304
|
+
devDependencies?: Record<string, string>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Manual metadata fields that must be provided
|
|
308
|
+
*/
|
|
309
|
+
interface ExtensionConfigInput {
|
|
310
|
+
/**
|
|
311
|
+
* Extension short name (e.g., 'leads', 'payments')
|
|
312
|
+
*/
|
|
313
|
+
name: string;
|
|
314
|
+
/**
|
|
315
|
+
* Display name for marketplace
|
|
316
|
+
*/
|
|
317
|
+
displayName: string;
|
|
318
|
+
/**
|
|
319
|
+
* Extension category
|
|
320
|
+
*/
|
|
321
|
+
category: ExtensionMetadata['category'];
|
|
322
|
+
/**
|
|
323
|
+
* Key features list
|
|
324
|
+
*/
|
|
325
|
+
features: string[];
|
|
326
|
+
/**
|
|
327
|
+
* Code examples (optional)
|
|
328
|
+
*/
|
|
329
|
+
examples?: ExtensionMetadata['examples'];
|
|
330
|
+
/**
|
|
331
|
+
* Minimum required DjangoCFG version (optional)
|
|
332
|
+
*/
|
|
333
|
+
minVersion?: string;
|
|
334
|
+
/**
|
|
335
|
+
* GitHub stars count (optional)
|
|
336
|
+
*/
|
|
337
|
+
githubStars?: number;
|
|
338
|
+
}
|
|
339
|
+
declare function createExtensionConfig(packageJson: PackageJson, config: ExtensionConfigInput): ExtensionMetadata;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Logger factory for extension packages
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Creates a tagged logger for an extension
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* // In extension package
|
|
351
|
+
* export const logger = createExtensionLogger({
|
|
352
|
+
* tag: 'ext-newsletter',
|
|
353
|
+
* level: 'info'
|
|
354
|
+
* });
|
|
355
|
+
*
|
|
356
|
+
* // Usage
|
|
357
|
+
* logger.info('Campaign created:', campaignId);
|
|
358
|
+
* logger.error('Failed to send campaign:', error);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare function createExtensionLogger(options: LoggerOptions): ExtensionLogger;
|
|
362
|
+
|
|
363
|
+
export { EXTENSION_CATEGORIES, type ErrorHandler, type ExtensionCategory, type ExtensionConfigInput, type ExtensionContextOptions, type ExtensionError, type ExtensionExample, type ExtensionLogger, type ExtensionMetadata, type ExtensionProviderProps, type InfinitePaginationOptions, type InfinitePaginationReturn, type LoggerOptions, type PaginatedResponse, type PaginationParams, type PaginationState, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, getApiUrl, handleExtensionError, isDevelopment, isExtensionError, isProduction, isStaticBuild };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export { createExtensionAPI, getSharedAuthStorage } from './api.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pagination types for extension packages
|
|
6
|
+
*/
|
|
7
|
+
interface PaginatedResponse<T> {
|
|
8
|
+
results: T[];
|
|
9
|
+
count: number;
|
|
10
|
+
next?: number | null;
|
|
11
|
+
previous?: number | null;
|
|
12
|
+
next_page?: number | null;
|
|
13
|
+
previous_page?: number | null;
|
|
14
|
+
has_next?: boolean;
|
|
15
|
+
has_previous?: boolean;
|
|
16
|
+
total_pages?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PaginationParams {
|
|
19
|
+
page?: number;
|
|
20
|
+
page_size?: number;
|
|
21
|
+
ordering?: string;
|
|
22
|
+
}
|
|
23
|
+
interface PaginationState {
|
|
24
|
+
page: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
totalCount: number;
|
|
27
|
+
totalPages: number;
|
|
28
|
+
hasNext: boolean;
|
|
29
|
+
hasPrevious: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface InfinitePaginationReturn<T> {
|
|
32
|
+
items: T[];
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
isLoadingMore: boolean;
|
|
35
|
+
error: any;
|
|
36
|
+
hasMore: boolean;
|
|
37
|
+
totalCount: number;
|
|
38
|
+
loadMore: () => void;
|
|
39
|
+
refresh: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
interface InfinitePaginationOptions {
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
revalidateFirstPage?: boolean;
|
|
44
|
+
parallel?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Context and provider types for extension packages
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
interface ExtensionContextOptions {
|
|
52
|
+
revalidateOnFocus?: boolean;
|
|
53
|
+
revalidateOnReconnect?: boolean;
|
|
54
|
+
revalidateIfStale?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Extension category types
|
|
58
|
+
*/
|
|
59
|
+
type ExtensionCategory = 'forms' | 'payments' | 'content' | 'support' | 'utilities' | 'analytics' | 'security' | 'integration' | 'other';
|
|
60
|
+
/**
|
|
61
|
+
* Extension categories with display names for CLI and UI
|
|
62
|
+
*/
|
|
63
|
+
declare const EXTENSION_CATEGORIES: Array<{
|
|
64
|
+
title: string;
|
|
65
|
+
value: ExtensionCategory;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Code example for extension documentation
|
|
69
|
+
*/
|
|
70
|
+
interface ExtensionExample {
|
|
71
|
+
/**
|
|
72
|
+
* Example title
|
|
73
|
+
*/
|
|
74
|
+
title: string;
|
|
75
|
+
/**
|
|
76
|
+
* Example description
|
|
77
|
+
*/
|
|
78
|
+
description?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Code snippet
|
|
81
|
+
*/
|
|
82
|
+
code: string;
|
|
83
|
+
/**
|
|
84
|
+
* Programming language for syntax highlighting
|
|
85
|
+
*/
|
|
86
|
+
language: string;
|
|
87
|
+
}
|
|
88
|
+
interface ExtensionMetadata {
|
|
89
|
+
/**
|
|
90
|
+
* Unique extension name (e.g., 'newsletter', 'payments')
|
|
91
|
+
*/
|
|
92
|
+
name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Extension version (semver format recommended)
|
|
95
|
+
*/
|
|
96
|
+
version: string;
|
|
97
|
+
/**
|
|
98
|
+
* Extension author name or organization
|
|
99
|
+
*/
|
|
100
|
+
author: string;
|
|
101
|
+
/**
|
|
102
|
+
* Extension display name
|
|
103
|
+
*/
|
|
104
|
+
displayName?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Extension description
|
|
107
|
+
*/
|
|
108
|
+
description?: string;
|
|
109
|
+
/**
|
|
110
|
+
* GitHub repository URL
|
|
111
|
+
* @example 'https://github.com/username/repo'
|
|
112
|
+
*/
|
|
113
|
+
githubUrl?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Extension homepage URL
|
|
116
|
+
*/
|
|
117
|
+
homepage?: string;
|
|
118
|
+
/**
|
|
119
|
+
* License identifier (e.g., 'MIT', 'Apache-2.0')
|
|
120
|
+
*/
|
|
121
|
+
license?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Keywords for search and discovery
|
|
124
|
+
*/
|
|
125
|
+
keywords?: string[];
|
|
126
|
+
/**
|
|
127
|
+
* Minimum required DjangoCFG version
|
|
128
|
+
*/
|
|
129
|
+
minVersion?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Extension category for marketplace organization
|
|
132
|
+
*/
|
|
133
|
+
category?: ExtensionCategory;
|
|
134
|
+
/**
|
|
135
|
+
* Tags for search and filtering
|
|
136
|
+
*/
|
|
137
|
+
tags?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* List of key features
|
|
140
|
+
*/
|
|
141
|
+
features?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* npm package URL
|
|
144
|
+
* @example 'https://www.npmjs.com/package/@djangocfg/ext-newsletter'
|
|
145
|
+
*/
|
|
146
|
+
npmUrl?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Marketplace-safe ID (package name with @ and / replaced by -)
|
|
149
|
+
* @example '@djangocfg/ext-newsletter' -> 'djangocfg-ext-newsletter'
|
|
150
|
+
*/
|
|
151
|
+
marketplaceId?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Marketplace URL
|
|
154
|
+
* @example 'https://hub.djangocfg.com/extensions/djangocfg-ext-newsletter'
|
|
155
|
+
*/
|
|
156
|
+
marketplaceUrl?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Installation command
|
|
159
|
+
* @example 'pnpm add @djangocfg/ext-newsletter'
|
|
160
|
+
*/
|
|
161
|
+
installCommand?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Download URL for npm tarball
|
|
164
|
+
* @example 'https://registry.npmjs.org/@djangocfg/ext-newsletter/-/ext-newsletter-1.0.0.tgz'
|
|
165
|
+
*/
|
|
166
|
+
downloadUrl?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Code examples for documentation
|
|
169
|
+
*/
|
|
170
|
+
examples?: ExtensionExample[];
|
|
171
|
+
/**
|
|
172
|
+
* npm package dependencies
|
|
173
|
+
*/
|
|
174
|
+
packageDependencies?: Record<string, string>;
|
|
175
|
+
/**
|
|
176
|
+
* npm peer dependencies
|
|
177
|
+
*/
|
|
178
|
+
packagePeerDependencies?: Record<string, string>;
|
|
179
|
+
/**
|
|
180
|
+
* npm dev dependencies
|
|
181
|
+
*/
|
|
182
|
+
packageDevDependencies?: Record<string, string>;
|
|
183
|
+
/**
|
|
184
|
+
* README content in markdown
|
|
185
|
+
*/
|
|
186
|
+
readme?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Preview image URL (1200x630 recommended)
|
|
189
|
+
* @example 'https://unpkg.com/@djangocfg/ext-leads@latest/preview.svg'
|
|
190
|
+
*/
|
|
191
|
+
preview?: string;
|
|
192
|
+
/**
|
|
193
|
+
* GitHub stars count
|
|
194
|
+
*/
|
|
195
|
+
githubStars?: number;
|
|
196
|
+
}
|
|
197
|
+
interface ExtensionProviderProps {
|
|
198
|
+
/**
|
|
199
|
+
* Extension metadata for registration
|
|
200
|
+
*/
|
|
201
|
+
metadata: ExtensionMetadata;
|
|
202
|
+
/**
|
|
203
|
+
* SWR configuration options
|
|
204
|
+
*/
|
|
205
|
+
options?: ExtensionContextOptions;
|
|
206
|
+
/**
|
|
207
|
+
* Child components
|
|
208
|
+
*/
|
|
209
|
+
children: ReactNode;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Error types for extension packages
|
|
214
|
+
*/
|
|
215
|
+
interface ExtensionError {
|
|
216
|
+
message: string;
|
|
217
|
+
code?: string;
|
|
218
|
+
details?: unknown;
|
|
219
|
+
timestamp: string;
|
|
220
|
+
}
|
|
221
|
+
type ErrorHandler = (error: Error | ExtensionError) => void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Logger types for extension packages
|
|
225
|
+
*/
|
|
226
|
+
interface ExtensionLogger {
|
|
227
|
+
info: (...args: any[]) => void;
|
|
228
|
+
warn: (...args: any[]) => void;
|
|
229
|
+
error: (...args: any[]) => void;
|
|
230
|
+
debug: (...args: any[]) => void;
|
|
231
|
+
success: (...args: any[]) => void;
|
|
232
|
+
}
|
|
233
|
+
interface LoggerOptions {
|
|
234
|
+
tag: string;
|
|
235
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
236
|
+
enabled?: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Base extension configuration
|
|
241
|
+
*/
|
|
242
|
+
declare const extensionConfig: ExtensionMetadata;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Extension configuration and environment utilities
|
|
246
|
+
*/
|
|
247
|
+
declare const isDevelopment: boolean;
|
|
248
|
+
declare const isProduction: boolean;
|
|
249
|
+
declare const isStaticBuild: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Get API URL from environment or default
|
|
252
|
+
*/
|
|
253
|
+
declare function getApiUrl(): string;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Error handling utilities for extension packages
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Checks if an error is an ExtensionError
|
|
261
|
+
*/
|
|
262
|
+
declare function isExtensionError(error: unknown): error is ExtensionError;
|
|
263
|
+
/**
|
|
264
|
+
* Creates an ExtensionError from any error
|
|
265
|
+
*/
|
|
266
|
+
declare function createExtensionError(error: unknown, code?: string, details?: unknown): ExtensionError;
|
|
267
|
+
/**
|
|
268
|
+
* Formats an error message for display
|
|
269
|
+
*/
|
|
270
|
+
declare function formatErrorMessage(error: unknown): string;
|
|
271
|
+
/**
|
|
272
|
+
* Safe error handler that logs and optionally calls callback
|
|
273
|
+
*/
|
|
274
|
+
declare function handleExtensionError(error: unknown, logger?: {
|
|
275
|
+
error: (...args: any[]) => void;
|
|
276
|
+
}, callback?: (error: ExtensionError) => void): void;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Helper to create extension configuration from package.json
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Package.json structure
|
|
284
|
+
*/
|
|
285
|
+
interface PackageJson {
|
|
286
|
+
name: string;
|
|
287
|
+
version: string;
|
|
288
|
+
description?: string;
|
|
289
|
+
keywords?: string[];
|
|
290
|
+
author?: string | {
|
|
291
|
+
name: string;
|
|
292
|
+
email?: string;
|
|
293
|
+
url?: string;
|
|
294
|
+
};
|
|
295
|
+
license?: string;
|
|
296
|
+
homepage?: string;
|
|
297
|
+
repository?: string | {
|
|
298
|
+
type: string;
|
|
299
|
+
url: string;
|
|
300
|
+
directory?: string;
|
|
301
|
+
};
|
|
302
|
+
dependencies?: Record<string, string>;
|
|
303
|
+
peerDependencies?: Record<string, string>;
|
|
304
|
+
devDependencies?: Record<string, string>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Manual metadata fields that must be provided
|
|
308
|
+
*/
|
|
309
|
+
interface ExtensionConfigInput {
|
|
310
|
+
/**
|
|
311
|
+
* Extension short name (e.g., 'leads', 'payments')
|
|
312
|
+
*/
|
|
313
|
+
name: string;
|
|
314
|
+
/**
|
|
315
|
+
* Display name for marketplace
|
|
316
|
+
*/
|
|
317
|
+
displayName: string;
|
|
318
|
+
/**
|
|
319
|
+
* Extension category
|
|
320
|
+
*/
|
|
321
|
+
category: ExtensionMetadata['category'];
|
|
322
|
+
/**
|
|
323
|
+
* Key features list
|
|
324
|
+
*/
|
|
325
|
+
features: string[];
|
|
326
|
+
/**
|
|
327
|
+
* Code examples (optional)
|
|
328
|
+
*/
|
|
329
|
+
examples?: ExtensionMetadata['examples'];
|
|
330
|
+
/**
|
|
331
|
+
* Minimum required DjangoCFG version (optional)
|
|
332
|
+
*/
|
|
333
|
+
minVersion?: string;
|
|
334
|
+
/**
|
|
335
|
+
* GitHub stars count (optional)
|
|
336
|
+
*/
|
|
337
|
+
githubStars?: number;
|
|
338
|
+
}
|
|
339
|
+
declare function createExtensionConfig(packageJson: PackageJson, config: ExtensionConfigInput): ExtensionMetadata;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Logger factory for extension packages
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Creates a tagged logger for an extension
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* // In extension package
|
|
351
|
+
* export const logger = createExtensionLogger({
|
|
352
|
+
* tag: 'ext-newsletter',
|
|
353
|
+
* level: 'info'
|
|
354
|
+
* });
|
|
355
|
+
*
|
|
356
|
+
* // Usage
|
|
357
|
+
* logger.info('Campaign created:', campaignId);
|
|
358
|
+
* logger.error('Failed to send campaign:', error);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare function createExtensionLogger(options: LoggerOptions): ExtensionLogger;
|
|
362
|
+
|
|
363
|
+
export { EXTENSION_CATEGORIES, type ErrorHandler, type ExtensionCategory, type ExtensionConfigInput, type ExtensionContextOptions, type ExtensionError, type ExtensionExample, type ExtensionLogger, type ExtensionMetadata, type ExtensionProviderProps, type InfinitePaginationOptions, type InfinitePaginationReturn, type LoggerOptions, type PaginatedResponse, type PaginationParams, type PaginationState, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, getApiUrl, handleExtensionError, isDevelopment, isExtensionError, isProduction, isStaticBuild };
|