@djangocfg/ext-base 1.0.0 → 1.0.1
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 +62 -174
- package/package.json +20 -6
- package/src/cli/index.ts +277 -0
- package/dist/api.cjs +0 -41
- package/dist/api.d.cts +0 -35
- package/dist/api.d.ts +0 -35
- package/dist/api.js +0 -2
- package/dist/auth.cjs +0 -10
- package/dist/auth.d.cts +0 -1
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -2
- package/dist/chunk-3RG5ZIWI.js +0 -8
- package/dist/chunk-MECBWZG4.js +0 -44
- package/dist/chunk-YQGNYUBX.js +0 -67
- package/dist/hooks.cjs +0 -190
- package/dist/hooks.d.cts +0 -96
- package/dist/hooks.d.ts +0 -96
- package/dist/hooks.js +0 -65
- package/dist/index.cjs +0 -131
- package/dist/index.d.cts +0 -246
- package/dist/index.d.ts +0 -246
- package/dist/index.js +0 -3
package/dist/hooks.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createExtensionLogger } from './chunk-YQGNYUBX.js';
|
|
2
|
-
export { createExtensionError, createExtensionLogger, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-YQGNYUBX.js';
|
|
3
|
-
import { isDevelopment } from './chunk-MECBWZG4.js';
|
|
4
|
-
export { createExtensionAPI, env, getApiUrl, getSharedAuthStorage, isClient, isDevelopment, isProduction, isServer, isStaticBuild, isTest } from './chunk-MECBWZG4.js';
|
|
5
|
-
import './chunk-3RG5ZIWI.js';
|
|
6
|
-
import { createContext, useEffect, useContext } from 'react';
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { SWRConfig } from 'swr';
|
|
9
|
-
|
|
10
|
-
function createExtensionContext({
|
|
11
|
-
displayName,
|
|
12
|
-
errorMessage
|
|
13
|
-
}) {
|
|
14
|
-
const Context = createContext(void 0);
|
|
15
|
-
Context.displayName = displayName;
|
|
16
|
-
const Provider = ({ value, children }) => {
|
|
17
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
18
|
-
};
|
|
19
|
-
const useContextHook = () => {
|
|
20
|
-
const context = useContext(Context);
|
|
21
|
-
if (context === void 0) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
errorMessage || `use${displayName} must be used within ${displayName}Provider`
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
return context;
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
Context,
|
|
30
|
-
Provider,
|
|
31
|
-
useContext: useContextHook
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
var DEFAULT_OPTIONS = {
|
|
35
|
-
revalidateOnFocus: false,
|
|
36
|
-
revalidateOnReconnect: false,
|
|
37
|
-
revalidateIfStale: false
|
|
38
|
-
};
|
|
39
|
-
var registeredExtensions = /* @__PURE__ */ new Set();
|
|
40
|
-
function ExtensionProvider({ children, metadata, options = {} }) {
|
|
41
|
-
const config = { ...DEFAULT_OPTIONS, ...options };
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (registeredExtensions.has(metadata.name)) {
|
|
44
|
-
if (isDevelopment) {
|
|
45
|
-
console.warn(
|
|
46
|
-
`[ExtensionProvider] Extension "${metadata.name}" is already registered. This might indicate that the extension is mounted multiple times.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
registeredExtensions.add(metadata.name);
|
|
52
|
-
if (isDevelopment) {
|
|
53
|
-
const logger = createExtensionLogger({ tag: "ext-base", level: "info" });
|
|
54
|
-
logger.info(
|
|
55
|
-
`Extension registered: ${metadata.displayName || metadata.name} v${metadata.version}`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
return () => {
|
|
59
|
-
registeredExtensions.delete(metadata.name);
|
|
60
|
-
};
|
|
61
|
-
}, [metadata.name, metadata.version, metadata.displayName]);
|
|
62
|
-
return /* @__PURE__ */ jsx(SWRConfig, { value: config, children });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { ExtensionProvider, createExtensionContext };
|
package/dist/index.cjs
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var consola = require('consola');
|
|
4
|
-
|
|
5
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
-
}) : x)(function(x) {
|
|
8
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// src/config/env.ts
|
|
13
|
-
var isDevelopment = process.env.NODE_ENV === "development";
|
|
14
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
15
|
-
var isTest = process.env.NODE_ENV === "test";
|
|
16
|
-
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
17
|
-
var isClient = typeof window !== "undefined";
|
|
18
|
-
var isServer = !isClient;
|
|
19
|
-
var getApiUrl = () => {
|
|
20
|
-
return process.env.NEXT_PUBLIC_API_URL || "";
|
|
21
|
-
};
|
|
22
|
-
var env = {
|
|
23
|
-
isDevelopment,
|
|
24
|
-
isProduction,
|
|
25
|
-
isTest,
|
|
26
|
-
isStaticBuild,
|
|
27
|
-
isClient,
|
|
28
|
-
isServer,
|
|
29
|
-
getApiUrl
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// src/api/createExtensionAPI.ts
|
|
33
|
-
function createExtensionAPI(APIClass) {
|
|
34
|
-
let storage;
|
|
35
|
-
try {
|
|
36
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
37
|
-
storage = accountsApi._storage;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
storage = void 0;
|
|
40
|
-
}
|
|
41
|
-
const apiUrl = isStaticBuild ? "" : getApiUrl();
|
|
42
|
-
return new APIClass(apiUrl, storage ? { storage } : void 0);
|
|
43
|
-
}
|
|
44
|
-
function getSharedAuthStorage() {
|
|
45
|
-
try {
|
|
46
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
47
|
-
return accountsApi._storage;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/utils/errors.ts
|
|
54
|
-
function isExtensionError(error) {
|
|
55
|
-
return typeof error === "object" && error !== null && "message" in error && "timestamp" in error;
|
|
56
|
-
}
|
|
57
|
-
function createExtensionError(error, code, details) {
|
|
58
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
-
return {
|
|
60
|
-
message,
|
|
61
|
-
code,
|
|
62
|
-
details,
|
|
63
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function formatErrorMessage(error) {
|
|
67
|
-
if (isExtensionError(error)) {
|
|
68
|
-
return error.code ? `[${error.code}] ${error.message}` : error.message;
|
|
69
|
-
}
|
|
70
|
-
if (error instanceof Error) {
|
|
71
|
-
return error.message;
|
|
72
|
-
}
|
|
73
|
-
return String(error);
|
|
74
|
-
}
|
|
75
|
-
function handleExtensionError(error, logger, callback) {
|
|
76
|
-
const extensionError = isExtensionError(error) ? error : createExtensionError(error);
|
|
77
|
-
if (logger) {
|
|
78
|
-
logger.error("Extension error:", extensionError);
|
|
79
|
-
}
|
|
80
|
-
if (callback) {
|
|
81
|
-
callback(extensionError);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
var isDevelopment2 = process.env.NODE_ENV === "development";
|
|
85
|
-
var LEVEL_MAP = {
|
|
86
|
-
debug: 4,
|
|
87
|
-
info: 3,
|
|
88
|
-
warn: 2,
|
|
89
|
-
error: 1
|
|
90
|
-
};
|
|
91
|
-
function createExtensionLogger(options) {
|
|
92
|
-
const { tag, level = "info", enabled = true } = options;
|
|
93
|
-
if (!enabled) {
|
|
94
|
-
const noop = () => {
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
info: noop,
|
|
98
|
-
warn: noop,
|
|
99
|
-
error: noop,
|
|
100
|
-
debug: noop,
|
|
101
|
-
success: noop
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
const logLevel = isDevelopment2 ? LEVEL_MAP[level] : LEVEL_MAP.error;
|
|
105
|
-
const consola$1 = consola.createConsola({
|
|
106
|
-
level: logLevel
|
|
107
|
-
}).withTag(tag);
|
|
108
|
-
return {
|
|
109
|
-
info: (...args) => consola$1.info(...args),
|
|
110
|
-
warn: (...args) => consola$1.warn(...args),
|
|
111
|
-
error: (...args) => consola$1.error(...args),
|
|
112
|
-
debug: (...args) => consola$1.debug(...args),
|
|
113
|
-
success: (...args) => consola$1.success(...args)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
exports.createExtensionAPI = createExtensionAPI;
|
|
118
|
-
exports.createExtensionError = createExtensionError;
|
|
119
|
-
exports.createExtensionLogger = createExtensionLogger;
|
|
120
|
-
exports.env = env;
|
|
121
|
-
exports.formatErrorMessage = formatErrorMessage;
|
|
122
|
-
exports.getApiUrl = getApiUrl;
|
|
123
|
-
exports.getSharedAuthStorage = getSharedAuthStorage;
|
|
124
|
-
exports.handleExtensionError = handleExtensionError;
|
|
125
|
-
exports.isClient = isClient;
|
|
126
|
-
exports.isDevelopment = isDevelopment;
|
|
127
|
-
exports.isExtensionError = isExtensionError;
|
|
128
|
-
exports.isProduction = isProduction;
|
|
129
|
-
exports.isServer = isServer;
|
|
130
|
-
exports.isStaticBuild = isStaticBuild;
|
|
131
|
-
exports.isTest = isTest;
|
package/dist/index.d.cts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
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
|
-
interface ExtensionMetadata {
|
|
57
|
-
/**
|
|
58
|
-
* Unique extension name (e.g., 'newsletter', 'payments')
|
|
59
|
-
*/
|
|
60
|
-
name: string;
|
|
61
|
-
/**
|
|
62
|
-
* Extension version (semver format recommended)
|
|
63
|
-
*/
|
|
64
|
-
version: string;
|
|
65
|
-
/**
|
|
66
|
-
* Extension author name or organization
|
|
67
|
-
*/
|
|
68
|
-
author: string;
|
|
69
|
-
/**
|
|
70
|
-
* Extension display name
|
|
71
|
-
*/
|
|
72
|
-
displayName?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Extension description
|
|
75
|
-
*/
|
|
76
|
-
description?: string;
|
|
77
|
-
/**
|
|
78
|
-
* GitHub repository URL
|
|
79
|
-
* @example 'https://github.com/username/repo'
|
|
80
|
-
*/
|
|
81
|
-
githubUrl?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Extension homepage URL
|
|
84
|
-
*/
|
|
85
|
-
homepage?: string;
|
|
86
|
-
/**
|
|
87
|
-
* License identifier (e.g., 'MIT', 'Apache-2.0')
|
|
88
|
-
*/
|
|
89
|
-
license?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Keywords for search and discovery
|
|
92
|
-
*/
|
|
93
|
-
keywords?: string[];
|
|
94
|
-
/**
|
|
95
|
-
* Extension icon URL or emoji
|
|
96
|
-
* @example '📧' or 'https://example.com/icon.png'
|
|
97
|
-
*/
|
|
98
|
-
icon?: string;
|
|
99
|
-
/**
|
|
100
|
-
* List of extension dependencies
|
|
101
|
-
* @example ['payments', 'auth']
|
|
102
|
-
*/
|
|
103
|
-
dependencies?: string[];
|
|
104
|
-
/**
|
|
105
|
-
* Minimum required DjangoCFG version
|
|
106
|
-
*/
|
|
107
|
-
minVersion?: string;
|
|
108
|
-
}
|
|
109
|
-
interface ExtensionProviderProps {
|
|
110
|
-
/**
|
|
111
|
-
* Extension metadata for registration
|
|
112
|
-
*/
|
|
113
|
-
metadata: ExtensionMetadata;
|
|
114
|
-
/**
|
|
115
|
-
* SWR configuration options
|
|
116
|
-
*/
|
|
117
|
-
options?: ExtensionContextOptions;
|
|
118
|
-
/**
|
|
119
|
-
* Child components
|
|
120
|
-
*/
|
|
121
|
-
children: ReactNode;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Error types for extension packages
|
|
126
|
-
*/
|
|
127
|
-
interface ExtensionError {
|
|
128
|
-
message: string;
|
|
129
|
-
code?: string;
|
|
130
|
-
details?: unknown;
|
|
131
|
-
timestamp: string;
|
|
132
|
-
}
|
|
133
|
-
type ErrorHandler = (error: Error | ExtensionError) => void;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Logger types for extension packages
|
|
137
|
-
*/
|
|
138
|
-
interface ExtensionLogger {
|
|
139
|
-
info: (...args: any[]) => void;
|
|
140
|
-
warn: (...args: any[]) => void;
|
|
141
|
-
error: (...args: any[]) => void;
|
|
142
|
-
debug: (...args: any[]) => void;
|
|
143
|
-
success: (...args: any[]) => void;
|
|
144
|
-
}
|
|
145
|
-
interface LoggerOptions {
|
|
146
|
-
tag: string;
|
|
147
|
-
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
148
|
-
enabled?: boolean;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Environment configuration utilities
|
|
153
|
-
*
|
|
154
|
-
* Safe to use in both client and server contexts.
|
|
155
|
-
* Can be imported from server-safe entry point.
|
|
156
|
-
*/
|
|
157
|
-
/**
|
|
158
|
-
* Check if running in development mode
|
|
159
|
-
*/
|
|
160
|
-
declare const isDevelopment: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Check if running in production mode
|
|
163
|
-
*/
|
|
164
|
-
declare const isProduction: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Check if running in test mode
|
|
167
|
-
*/
|
|
168
|
-
declare const isTest: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Check if this is a static build (Next.js export)
|
|
171
|
-
*/
|
|
172
|
-
declare const isStaticBuild: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Check if code is running on client side
|
|
175
|
-
* Safe to use in both client and server contexts
|
|
176
|
-
*/
|
|
177
|
-
declare const isClient: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Check if code is running on server side
|
|
180
|
-
* Safe to use in both client and server contexts
|
|
181
|
-
*/
|
|
182
|
-
declare const isServer: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Get API URL from environment
|
|
185
|
-
* Returns empty string if not set
|
|
186
|
-
*/
|
|
187
|
-
declare const getApiUrl: () => string;
|
|
188
|
-
/**
|
|
189
|
-
* Environment configuration object
|
|
190
|
-
*/
|
|
191
|
-
declare const env: {
|
|
192
|
-
readonly isDevelopment: boolean;
|
|
193
|
-
readonly isProduction: boolean;
|
|
194
|
-
readonly isTest: boolean;
|
|
195
|
-
readonly isStaticBuild: boolean;
|
|
196
|
-
readonly isClient: boolean;
|
|
197
|
-
readonly isServer: boolean;
|
|
198
|
-
readonly getApiUrl: () => string;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Error handling utilities for extension packages
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Checks if an error is an ExtensionError
|
|
207
|
-
*/
|
|
208
|
-
declare function isExtensionError(error: unknown): error is ExtensionError;
|
|
209
|
-
/**
|
|
210
|
-
* Creates an ExtensionError from any error
|
|
211
|
-
*/
|
|
212
|
-
declare function createExtensionError(error: unknown, code?: string, details?: unknown): ExtensionError;
|
|
213
|
-
/**
|
|
214
|
-
* Formats an error message for display
|
|
215
|
-
*/
|
|
216
|
-
declare function formatErrorMessage(error: unknown): string;
|
|
217
|
-
/**
|
|
218
|
-
* Safe error handler that logs and optionally calls callback
|
|
219
|
-
*/
|
|
220
|
-
declare function handleExtensionError(error: unknown, logger?: {
|
|
221
|
-
error: (...args: any[]) => void;
|
|
222
|
-
}, callback?: (error: ExtensionError) => void): void;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Logger factory for extension packages
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Creates a tagged logger for an extension
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* // In extension package
|
|
234
|
-
* export const logger = createExtensionLogger({
|
|
235
|
-
* tag: 'ext-newsletter',
|
|
236
|
-
* level: 'info'
|
|
237
|
-
* });
|
|
238
|
-
*
|
|
239
|
-
* // Usage
|
|
240
|
-
* logger.info('Campaign created:', campaignId);
|
|
241
|
-
* logger.error('Failed to send campaign:', error);
|
|
242
|
-
* ```
|
|
243
|
-
*/
|
|
244
|
-
declare function createExtensionLogger(options: LoggerOptions): ExtensionLogger;
|
|
245
|
-
|
|
246
|
-
export { type ErrorHandler, type ExtensionContextOptions, type ExtensionError, type ExtensionLogger, type ExtensionMetadata, type ExtensionProviderProps, type InfinitePaginationOptions, type InfinitePaginationReturn, type LoggerOptions, type PaginatedResponse, type PaginationParams, type PaginationState, createExtensionError, createExtensionLogger, env, formatErrorMessage, getApiUrl, handleExtensionError, isClient, isDevelopment, isExtensionError, isProduction, isServer, isStaticBuild, isTest };
|
package/dist/index.d.ts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
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
|
-
interface ExtensionMetadata {
|
|
57
|
-
/**
|
|
58
|
-
* Unique extension name (e.g., 'newsletter', 'payments')
|
|
59
|
-
*/
|
|
60
|
-
name: string;
|
|
61
|
-
/**
|
|
62
|
-
* Extension version (semver format recommended)
|
|
63
|
-
*/
|
|
64
|
-
version: string;
|
|
65
|
-
/**
|
|
66
|
-
* Extension author name or organization
|
|
67
|
-
*/
|
|
68
|
-
author: string;
|
|
69
|
-
/**
|
|
70
|
-
* Extension display name
|
|
71
|
-
*/
|
|
72
|
-
displayName?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Extension description
|
|
75
|
-
*/
|
|
76
|
-
description?: string;
|
|
77
|
-
/**
|
|
78
|
-
* GitHub repository URL
|
|
79
|
-
* @example 'https://github.com/username/repo'
|
|
80
|
-
*/
|
|
81
|
-
githubUrl?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Extension homepage URL
|
|
84
|
-
*/
|
|
85
|
-
homepage?: string;
|
|
86
|
-
/**
|
|
87
|
-
* License identifier (e.g., 'MIT', 'Apache-2.0')
|
|
88
|
-
*/
|
|
89
|
-
license?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Keywords for search and discovery
|
|
92
|
-
*/
|
|
93
|
-
keywords?: string[];
|
|
94
|
-
/**
|
|
95
|
-
* Extension icon URL or emoji
|
|
96
|
-
* @example '📧' or 'https://example.com/icon.png'
|
|
97
|
-
*/
|
|
98
|
-
icon?: string;
|
|
99
|
-
/**
|
|
100
|
-
* List of extension dependencies
|
|
101
|
-
* @example ['payments', 'auth']
|
|
102
|
-
*/
|
|
103
|
-
dependencies?: string[];
|
|
104
|
-
/**
|
|
105
|
-
* Minimum required DjangoCFG version
|
|
106
|
-
*/
|
|
107
|
-
minVersion?: string;
|
|
108
|
-
}
|
|
109
|
-
interface ExtensionProviderProps {
|
|
110
|
-
/**
|
|
111
|
-
* Extension metadata for registration
|
|
112
|
-
*/
|
|
113
|
-
metadata: ExtensionMetadata;
|
|
114
|
-
/**
|
|
115
|
-
* SWR configuration options
|
|
116
|
-
*/
|
|
117
|
-
options?: ExtensionContextOptions;
|
|
118
|
-
/**
|
|
119
|
-
* Child components
|
|
120
|
-
*/
|
|
121
|
-
children: ReactNode;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Error types for extension packages
|
|
126
|
-
*/
|
|
127
|
-
interface ExtensionError {
|
|
128
|
-
message: string;
|
|
129
|
-
code?: string;
|
|
130
|
-
details?: unknown;
|
|
131
|
-
timestamp: string;
|
|
132
|
-
}
|
|
133
|
-
type ErrorHandler = (error: Error | ExtensionError) => void;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Logger types for extension packages
|
|
137
|
-
*/
|
|
138
|
-
interface ExtensionLogger {
|
|
139
|
-
info: (...args: any[]) => void;
|
|
140
|
-
warn: (...args: any[]) => void;
|
|
141
|
-
error: (...args: any[]) => void;
|
|
142
|
-
debug: (...args: any[]) => void;
|
|
143
|
-
success: (...args: any[]) => void;
|
|
144
|
-
}
|
|
145
|
-
interface LoggerOptions {
|
|
146
|
-
tag: string;
|
|
147
|
-
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
148
|
-
enabled?: boolean;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Environment configuration utilities
|
|
153
|
-
*
|
|
154
|
-
* Safe to use in both client and server contexts.
|
|
155
|
-
* Can be imported from server-safe entry point.
|
|
156
|
-
*/
|
|
157
|
-
/**
|
|
158
|
-
* Check if running in development mode
|
|
159
|
-
*/
|
|
160
|
-
declare const isDevelopment: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Check if running in production mode
|
|
163
|
-
*/
|
|
164
|
-
declare const isProduction: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Check if running in test mode
|
|
167
|
-
*/
|
|
168
|
-
declare const isTest: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Check if this is a static build (Next.js export)
|
|
171
|
-
*/
|
|
172
|
-
declare const isStaticBuild: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Check if code is running on client side
|
|
175
|
-
* Safe to use in both client and server contexts
|
|
176
|
-
*/
|
|
177
|
-
declare const isClient: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Check if code is running on server side
|
|
180
|
-
* Safe to use in both client and server contexts
|
|
181
|
-
*/
|
|
182
|
-
declare const isServer: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Get API URL from environment
|
|
185
|
-
* Returns empty string if not set
|
|
186
|
-
*/
|
|
187
|
-
declare const getApiUrl: () => string;
|
|
188
|
-
/**
|
|
189
|
-
* Environment configuration object
|
|
190
|
-
*/
|
|
191
|
-
declare const env: {
|
|
192
|
-
readonly isDevelopment: boolean;
|
|
193
|
-
readonly isProduction: boolean;
|
|
194
|
-
readonly isTest: boolean;
|
|
195
|
-
readonly isStaticBuild: boolean;
|
|
196
|
-
readonly isClient: boolean;
|
|
197
|
-
readonly isServer: boolean;
|
|
198
|
-
readonly getApiUrl: () => string;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Error handling utilities for extension packages
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Checks if an error is an ExtensionError
|
|
207
|
-
*/
|
|
208
|
-
declare function isExtensionError(error: unknown): error is ExtensionError;
|
|
209
|
-
/**
|
|
210
|
-
* Creates an ExtensionError from any error
|
|
211
|
-
*/
|
|
212
|
-
declare function createExtensionError(error: unknown, code?: string, details?: unknown): ExtensionError;
|
|
213
|
-
/**
|
|
214
|
-
* Formats an error message for display
|
|
215
|
-
*/
|
|
216
|
-
declare function formatErrorMessage(error: unknown): string;
|
|
217
|
-
/**
|
|
218
|
-
* Safe error handler that logs and optionally calls callback
|
|
219
|
-
*/
|
|
220
|
-
declare function handleExtensionError(error: unknown, logger?: {
|
|
221
|
-
error: (...args: any[]) => void;
|
|
222
|
-
}, callback?: (error: ExtensionError) => void): void;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Logger factory for extension packages
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Creates a tagged logger for an extension
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* // In extension package
|
|
234
|
-
* export const logger = createExtensionLogger({
|
|
235
|
-
* tag: 'ext-newsletter',
|
|
236
|
-
* level: 'info'
|
|
237
|
-
* });
|
|
238
|
-
*
|
|
239
|
-
* // Usage
|
|
240
|
-
* logger.info('Campaign created:', campaignId);
|
|
241
|
-
* logger.error('Failed to send campaign:', error);
|
|
242
|
-
* ```
|
|
243
|
-
*/
|
|
244
|
-
declare function createExtensionLogger(options: LoggerOptions): ExtensionLogger;
|
|
245
|
-
|
|
246
|
-
export { type ErrorHandler, type ExtensionContextOptions, type ExtensionError, type ExtensionLogger, type ExtensionMetadata, type ExtensionProviderProps, type InfinitePaginationOptions, type InfinitePaginationReturn, type LoggerOptions, type PaginatedResponse, type PaginationParams, type PaginationState, createExtensionError, createExtensionLogger, env, formatErrorMessage, getApiUrl, handleExtensionError, isClient, isDevelopment, isExtensionError, isProduction, isServer, isStaticBuild, isTest };
|
package/dist/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { createExtensionError, createExtensionLogger, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-YQGNYUBX.js';
|
|
2
|
-
export { createExtensionAPI, env, getApiUrl, getSharedAuthStorage, isClient, isDevelopment, isProduction, isServer, isStaticBuild, isTest } from './chunk-MECBWZG4.js';
|
|
3
|
-
import './chunk-3RG5ZIWI.js';
|