@djangocfg/ext-base 1.0.7 → 1.0.9

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/dist/api.cjs CHANGED
@@ -16,6 +16,12 @@ function getApiUrl() {
16
16
  }
17
17
 
18
18
  // src/api/createExtensionAPI.ts
19
+ function initializeExtensionAPI(configureAPIFn) {
20
+ const apiUrl = isStaticBuild ? "" : getApiUrl();
21
+ if (apiUrl) {
22
+ configureAPIFn({ baseUrl: apiUrl });
23
+ }
24
+ }
19
25
  function createExtensionAPI(APIClass) {
20
26
  let storage;
21
27
  try {
@@ -38,3 +44,4 @@ function getSharedAuthStorage() {
38
44
 
39
45
  exports.createExtensionAPI = createExtensionAPI;
40
46
  exports.getSharedAuthStorage = getSharedAuthStorage;
47
+ exports.initializeExtensionAPI = initializeExtensionAPI;
package/dist/api.d.cts CHANGED
@@ -3,6 +3,30 @@
3
3
  *
4
4
  * Provides consistent API setup across all extensions with shared authentication
5
5
  */
6
+ /**
7
+ * Initialize extension API global singleton for hooks and fetchers
8
+ *
9
+ * Call this before using any generated hooks to configure the global API instance.
10
+ *
11
+ * @param configureAPIFn - The configureAPI function from your generated api-instance.ts
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // In your extension's api/index.ts
16
+ * import { initializeExtensionAPI, createExtensionAPI } from '@djangocfg/ext-base/api';
17
+ * import { API } from './generated/ext_support';
18
+ * import { configureAPI } from './generated/ext_support/api-instance';
19
+ *
20
+ * // Initialize global singleton for hooks
21
+ * initializeExtensionAPI(configureAPI);
22
+ *
23
+ * // Create instance for direct usage
24
+ * export const apiSupport = createExtensionAPI(API);
25
+ * ```
26
+ */
27
+ declare function initializeExtensionAPI(configureAPIFn: (config: {
28
+ baseUrl: string;
29
+ }) => void): void;
6
30
  /**
7
31
  * Creates an extension API instance with shared authentication storage
8
32
  *
@@ -32,4 +56,4 @@ declare function createExtensionAPI<T>(APIClass: new (url: string, options?: any
32
56
  */
33
57
  declare function getSharedAuthStorage(): any | undefined;
34
58
 
35
- export { createExtensionAPI, getSharedAuthStorage };
59
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI };
package/dist/api.d.ts CHANGED
@@ -3,6 +3,30 @@
3
3
  *
4
4
  * Provides consistent API setup across all extensions with shared authentication
5
5
  */
6
+ /**
7
+ * Initialize extension API global singleton for hooks and fetchers
8
+ *
9
+ * Call this before using any generated hooks to configure the global API instance.
10
+ *
11
+ * @param configureAPIFn - The configureAPI function from your generated api-instance.ts
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // In your extension's api/index.ts
16
+ * import { initializeExtensionAPI, createExtensionAPI } from '@djangocfg/ext-base/api';
17
+ * import { API } from './generated/ext_support';
18
+ * import { configureAPI } from './generated/ext_support/api-instance';
19
+ *
20
+ * // Initialize global singleton for hooks
21
+ * initializeExtensionAPI(configureAPI);
22
+ *
23
+ * // Create instance for direct usage
24
+ * export const apiSupport = createExtensionAPI(API);
25
+ * ```
26
+ */
27
+ declare function initializeExtensionAPI(configureAPIFn: (config: {
28
+ baseUrl: string;
29
+ }) => void): void;
6
30
  /**
7
31
  * Creates an extension API instance with shared authentication storage
8
32
  *
@@ -32,4 +56,4 @@ declare function createExtensionAPI<T>(APIClass: new (url: string, options?: any
32
56
  */
33
57
  declare function getSharedAuthStorage(): any | undefined;
34
58
 
35
- export { createExtensionAPI, getSharedAuthStorage };
59
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI };
package/dist/api.js CHANGED
@@ -1,2 +1,2 @@
1
- export { createExtensionAPI, getSharedAuthStorage } from './chunk-ZUKKEJUN.js';
1
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI } from './chunk-Q4CMDWOR.js';
2
2
  import './chunk-3RG5ZIWI.js';
@@ -1,4 +1,4 @@
1
- import { package_default } from './chunk-ZUKKEJUN.js';
1
+ import { package_default } from './chunk-Q4CMDWOR.js';
2
2
  import { createConsola } from 'consola';
3
3
 
4
4
  // src/types/context.ts
@@ -3,7 +3,7 @@ import { __require } from './chunk-3RG5ZIWI.js';
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@djangocfg/ext-base",
6
- version: "1.0.6",
6
+ version: "1.0.8",
7
7
  description: "Base utilities and common code for DjangoCFG extensions",
8
8
  keywords: [
9
9
  "django",
@@ -117,6 +117,12 @@ function getApiUrl() {
117
117
  }
118
118
 
119
119
  // src/api/createExtensionAPI.ts
120
+ function initializeExtensionAPI(configureAPIFn) {
121
+ const apiUrl = isStaticBuild ? "" : getApiUrl();
122
+ if (apiUrl) {
123
+ configureAPIFn({ baseUrl: apiUrl });
124
+ }
125
+ }
120
126
  function createExtensionAPI(APIClass) {
121
127
  let storage;
122
128
  try {
@@ -137,4 +143,4 @@ function getSharedAuthStorage() {
137
143
  }
138
144
  }
139
145
 
140
- export { createExtensionAPI, getApiUrl, getSharedAuthStorage, isDevelopment, isProduction, isStaticBuild, package_default };
146
+ export { createExtensionAPI, getApiUrl, getSharedAuthStorage, initializeExtensionAPI, isDevelopment, isProduction, isStaticBuild, package_default };
package/dist/hooks.cjs CHANGED
@@ -33,7 +33,7 @@ var EXTENSION_CATEGORIES = [
33
33
  // package.json
34
34
  var package_default = {
35
35
  name: "@djangocfg/ext-base",
36
- version: "1.0.6",
36
+ version: "1.0.8",
37
37
  description: "Base utilities and common code for DjangoCFG extensions",
38
38
  keywords: [
39
39
  "django",
@@ -253,6 +253,12 @@ function getApiUrl() {
253
253
  }
254
254
 
255
255
  // src/api/createExtensionAPI.ts
256
+ function initializeExtensionAPI(configureAPIFn) {
257
+ const apiUrl = isStaticBuild ? "" : getApiUrl();
258
+ if (apiUrl) {
259
+ configureAPIFn({ baseUrl: apiUrl });
260
+ }
261
+ }
256
262
  function createExtensionAPI(APIClass) {
257
263
  let storage;
258
264
  try {
@@ -431,6 +437,7 @@ exports.formatErrorMessage = formatErrorMessage;
431
437
  exports.getApiUrl = getApiUrl;
432
438
  exports.getSharedAuthStorage = getSharedAuthStorage;
433
439
  exports.handleExtensionError = handleExtensionError;
440
+ exports.initializeExtensionAPI = initializeExtensionAPI;
434
441
  exports.isDevelopment = isDevelopment;
435
442
  exports.isExtensionError = isExtensionError;
436
443
  exports.isProduction = isProduction;
package/dist/hooks.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ExtensionProviderProps } from './index.cjs';
2
2
  export { EXTENSION_CATEGORIES, ErrorHandler, ExtensionCategory, ExtensionConfigInput, ExtensionContextOptions, ExtensionError, ExtensionExample, ExtensionLogger, ExtensionMetadata, InfinitePaginationOptions, InfinitePaginationReturn, LoggerOptions, PaginatedResponse, PaginationParams, PaginationState, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, getApiUrl, handleExtensionError, isDevelopment, isExtensionError, isProduction, isStaticBuild } from './index.cjs';
3
- export { createExtensionAPI, getSharedAuthStorage } from './api.cjs';
3
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI } from './api.cjs';
4
4
  import { Context, ReactNode, ReactElement } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
package/dist/hooks.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ExtensionProviderProps } from './index.js';
2
2
  export { EXTENSION_CATEGORIES, ErrorHandler, ExtensionCategory, ExtensionConfigInput, ExtensionContextOptions, ExtensionError, ExtensionExample, ExtensionLogger, ExtensionMetadata, InfinitePaginationOptions, InfinitePaginationReturn, LoggerOptions, PaginatedResponse, PaginationParams, PaginationState, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, getApiUrl, handleExtensionError, isDevelopment, isExtensionError, isProduction, isStaticBuild } from './index.js';
3
- export { createExtensionAPI, getSharedAuthStorage } from './api.js';
3
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI } from './api.js';
4
4
  import { Context, ReactNode, ReactElement } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
package/dist/hooks.js CHANGED
@@ -1,7 +1,7 @@
1
- import { createExtensionLogger } from './chunk-2BEEQFEX.js';
2
- export { EXTENSION_CATEGORIES, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-2BEEQFEX.js';
3
- import { isDevelopment } from './chunk-ZUKKEJUN.js';
4
- export { createExtensionAPI, getApiUrl, getSharedAuthStorage, isDevelopment, isProduction, isStaticBuild } from './chunk-ZUKKEJUN.js';
1
+ import { createExtensionLogger } from './chunk-LTTAG6XA.js';
2
+ export { EXTENSION_CATEGORIES, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-LTTAG6XA.js';
3
+ import { isDevelopment } from './chunk-Q4CMDWOR.js';
4
+ export { createExtensionAPI, getApiUrl, getSharedAuthStorage, initializeExtensionAPI, isDevelopment, isProduction, isStaticBuild } from './chunk-Q4CMDWOR.js';
5
5
  import './chunk-3RG5ZIWI.js';
6
6
  import React, { createContext, useEffect, useContext } from 'react';
7
7
  import { jsx, Fragment } from 'react/jsx-runtime';
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ var EXTENSION_CATEGORIES = [
25
25
  // package.json
26
26
  var package_default = {
27
27
  name: "@djangocfg/ext-base",
28
- version: "1.0.6",
28
+ version: "1.0.8",
29
29
  description: "Base utilities and common code for DjangoCFG extensions",
30
30
  keywords: [
31
31
  "django",
@@ -245,6 +245,12 @@ function getApiUrl() {
245
245
  }
246
246
 
247
247
  // src/api/createExtensionAPI.ts
248
+ function initializeExtensionAPI(configureAPIFn) {
249
+ const apiUrl = isStaticBuild ? "" : getApiUrl();
250
+ if (apiUrl) {
251
+ configureAPIFn({ baseUrl: apiUrl });
252
+ }
253
+ }
248
254
  function createExtensionAPI(APIClass) {
249
255
  let storage;
250
256
  try {
@@ -339,6 +345,7 @@ exports.formatErrorMessage = formatErrorMessage;
339
345
  exports.getApiUrl = getApiUrl;
340
346
  exports.getSharedAuthStorage = getSharedAuthStorage;
341
347
  exports.handleExtensionError = handleExtensionError;
348
+ exports.initializeExtensionAPI = initializeExtensionAPI;
342
349
  exports.isDevelopment = isDevelopment;
343
350
  exports.isExtensionError = isExtensionError;
344
351
  exports.isProduction = isProduction;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- export { createExtensionAPI, getSharedAuthStorage } from './api.cjs';
2
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI } from './api.cjs';
3
3
 
4
4
  /**
5
5
  * Pagination types for extension packages
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- export { createExtensionAPI, getSharedAuthStorage } from './api.js';
2
+ export { createExtensionAPI, getSharedAuthStorage, initializeExtensionAPI } from './api.js';
3
3
 
4
4
  /**
5
5
  * Pagination types for extension packages
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { EXTENSION_CATEGORIES, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-2BEEQFEX.js';
2
- export { createExtensionAPI, getApiUrl, getSharedAuthStorage, isDevelopment, isProduction, isStaticBuild } from './chunk-ZUKKEJUN.js';
1
+ export { EXTENSION_CATEGORIES, createExtensionConfig, createExtensionError, createExtensionLogger, extensionConfig, formatErrorMessage, handleExtensionError, isExtensionError } from './chunk-LTTAG6XA.js';
2
+ export { createExtensionAPI, getApiUrl, getSharedAuthStorage, initializeExtensionAPI, isDevelopment, isProduction, isStaticBuild } from './chunk-Q4CMDWOR.js';
3
3
  import './chunk-3RG5ZIWI.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ext-base",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Base utilities and common code for DjangoCFG extensions",
5
5
  "keywords": [
6
6
  "django",
@@ -73,10 +73,10 @@
73
73
  "cli:info": "tsx src/cli/index.ts info"
74
74
  },
75
75
  "peerDependencies": {
76
- "@djangocfg/api": "^2.1.43",
76
+ "@djangocfg/api": "^2.1.107",
77
77
  "consola": "^3.4.2",
78
- "react": "^18 || ^19",
79
- "react-dom": "^18 || ^19",
78
+ "react": "^19",
79
+ "react-dom": "^19",
80
80
  "swr": "^2.3.7"
81
81
  },
82
82
  "dependencies": {
@@ -86,8 +86,8 @@
86
86
  "prompts": "^2.4.2"
87
87
  },
88
88
  "devDependencies": {
89
- "@djangocfg/api": "^2.1.43",
90
- "@djangocfg/typescript-config": "^2.1.43",
89
+ "@djangocfg/api": "^2.1.107",
90
+ "@djangocfg/typescript-config": "^2.1.107",
91
91
  "@types/node": "^24.7.2",
92
92
  "@types/prompts": "^2.4.9",
93
93
  "@types/react": "^19.0.0",
@@ -6,6 +6,36 @@
6
6
 
7
7
  import { getApiUrl, isStaticBuild } from '../config';
8
8
 
9
+ /**
10
+ * Initialize extension API global singleton for hooks and fetchers
11
+ *
12
+ * Call this before using any generated hooks to configure the global API instance.
13
+ *
14
+ * @param configureAPIFn - The configureAPI function from your generated api-instance.ts
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // In your extension's api/index.ts
19
+ * import { initializeExtensionAPI, createExtensionAPI } from '@djangocfg/ext-base/api';
20
+ * import { API } from './generated/ext_support';
21
+ * import { configureAPI } from './generated/ext_support/api-instance';
22
+ *
23
+ * // Initialize global singleton for hooks
24
+ * initializeExtensionAPI(configureAPI);
25
+ *
26
+ * // Create instance for direct usage
27
+ * export const apiSupport = createExtensionAPI(API);
28
+ * ```
29
+ */
30
+ export function initializeExtensionAPI(
31
+ configureAPIFn: (config: { baseUrl: string }) => void
32
+ ): void {
33
+ const apiUrl = isStaticBuild ? '' : getApiUrl();
34
+ if (apiUrl) {
35
+ configureAPIFn({ baseUrl: apiUrl });
36
+ }
37
+ }
38
+
9
39
  /**
10
40
  * Creates an extension API instance with shared authentication storage
11
41
  *