@kodaris/krubble-http 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/LICENSE +14 -0
- package/dist/http.d.ts +122 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +146 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/krubble-http.bundled.js +148 -0
- package/dist/krubble-http.bundled.js.map +1 -0
- package/dist/krubble-http.bundled.min.js +2 -0
- package/dist/krubble-http.bundled.min.js.map +1 -0
- package/dist/krubble-http.umd.js +158 -0
- package/dist/krubble-http.umd.js.map +1 -0
- package/dist/krubble-http.umd.min.js +2 -0
- package/dist/krubble-http.umd.min.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Kodaris Software License and Notice
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Kodara Inc. ("Kodaris") and/or its affiliates. All rights reserved.
|
|
4
|
+
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5
|
+
|
|
6
|
+
This code ("Software") may be used and modified by your organization as long as it is being served by and only in conjunction with a Kodaris system. It cannot be used or distributed by itself or in third party products, or used when not functioning with a Kodaris system. The Software is confidential information of Kodaris and may not be disclosed outside of your organization.
|
|
7
|
+
|
|
8
|
+
The Software is and shall remain a proprietary product of Kodaris. Kodaris and Kodaris's suppliers shall retain ownership of all patents, copyrights, trademarks, trade secrets and other proprietary rights relating to or residing in the Software and the Kodaris platform and system. Except for the scope of use specified above, you shall have no right, title or interest in or to the Software. The Software is licensed, not sold, to you for use only under the terms of this Notice and the license agreement accompanying the file download.
|
|
9
|
+
|
|
10
|
+
This Software is distributed for the benefit of and use by Kodaris customers and Kodaris partners, but is provided "AS IS," WITHOUT ANY WARRANTY. KODARIS HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY.
|
|
11
|
+
|
|
12
|
+
KODARIS SHALL NOT BE LIABLE TO YOU FOR ANY INDIRECT, EXEMPLARY, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES OF ANY KIND (INCLUDING WITHOUT LIMITATION LOSS OF DATA, EQUIPMENT DOWNTIME OR LOST PROFITS), EVEN IF KODARIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU.
|
|
13
|
+
|
|
14
|
+
Please contact Kodaris, 2011 Commerce Dr Suite A111 Peachtree City, GA 30269, visit www.kodaris.com, or email support@kodaris.com if you need additional information or have any questions.
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kodaris/krubble-http
|
|
3
|
+
*
|
|
4
|
+
* HTTP client for making API requests with automatic base URL handling
|
|
5
|
+
* and Kodaris API conveniences (CSRF tokens, credentials).
|
|
6
|
+
*
|
|
7
|
+
* ## Usage
|
|
8
|
+
*
|
|
9
|
+
* ### Web App (UMD)
|
|
10
|
+
* ```html
|
|
11
|
+
* <script src="krubble-http.umd.js"></script>
|
|
12
|
+
* <script>
|
|
13
|
+
* // Configure once at startup
|
|
14
|
+
* kr.http.configure({
|
|
15
|
+
* baseUrl: 'https://kodaris.com',
|
|
16
|
+
* devUrl: 'https://localhost:4201'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Make requests
|
|
20
|
+
* kr.http.fetch({
|
|
21
|
+
* url: '/api/system/customer/list',
|
|
22
|
+
* method: 'POST',
|
|
23
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
24
|
+
* })
|
|
25
|
+
* .then(response => response.json())
|
|
26
|
+
* .then(data => console.log(data));
|
|
27
|
+
* </script>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### Angular / ESM
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // app.config.ts - configure once at startup
|
|
33
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
34
|
+
*
|
|
35
|
+
* KRHttp.configure({
|
|
36
|
+
* baseUrl: 'https://kodaris.com',
|
|
37
|
+
* devUrl: 'https://localhost:4201'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // In a service or component
|
|
41
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
42
|
+
*
|
|
43
|
+
* getCustomers() {
|
|
44
|
+
* return KRHttp.fetch({
|
|
45
|
+
* url: '/api/system/customer/list',
|
|
46
|
+
* method: 'POST',
|
|
47
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
48
|
+
* })
|
|
49
|
+
* .then(response => response.json());
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## URL Resolution
|
|
54
|
+
* - On localhost: uses `devUrl` if configured, otherwise `baseUrl`
|
|
55
|
+
* - On production: always uses `baseUrl`
|
|
56
|
+
* - If URL starts with 'http', it's used as-is (no base URL prepended)
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Options for making an HTTP request.
|
|
60
|
+
*/
|
|
61
|
+
export interface KRHttpRequest {
|
|
62
|
+
/** The URL path (e.g., '/api/customers') or full URL */
|
|
63
|
+
url: string;
|
|
64
|
+
/** HTTP method (GET, POST, PUT, DELETE, etc.). Defaults to GET */
|
|
65
|
+
method?: string;
|
|
66
|
+
/** Request headers */
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
/** Request body (typically JSON.stringify'd object) */
|
|
69
|
+
body?: string;
|
|
70
|
+
/** URL query parameters */
|
|
71
|
+
params?: Record<string, string>;
|
|
72
|
+
/** Credentials mode for the request */
|
|
73
|
+
credentials?: RequestCredentials;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Configuration options for the HTTP client.
|
|
77
|
+
*/
|
|
78
|
+
export interface KRHttpConfig {
|
|
79
|
+
/** Base URL for production requests */
|
|
80
|
+
baseUrl?: string;
|
|
81
|
+
/** Base URL for development (used when on localhost) */
|
|
82
|
+
devUrl?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* HTTP client with static methods for making API requests.
|
|
86
|
+
* Automatically handles base URL resolution and Kodaris API conveniences.
|
|
87
|
+
*/
|
|
88
|
+
export declare class KRHttp {
|
|
89
|
+
/** Base URL for production requests */
|
|
90
|
+
static _baseUrl: string;
|
|
91
|
+
/** Base URL for development (localhost) */
|
|
92
|
+
static _devUrl: string;
|
|
93
|
+
/**
|
|
94
|
+
* Configure the HTTP client. Call once at application startup.
|
|
95
|
+
*
|
|
96
|
+
* @param config - Configuration options
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* KRHttp.configure({
|
|
100
|
+
* baseUrl: 'https://kodaris.com',
|
|
101
|
+
* devUrl: 'https://localhost:4201'
|
|
102
|
+
* });
|
|
103
|
+
*/
|
|
104
|
+
static configure(config: KRHttpConfig): void;
|
|
105
|
+
/**
|
|
106
|
+
* Make an HTTP request.
|
|
107
|
+
*
|
|
108
|
+
* @param options - Request options
|
|
109
|
+
* @returns Promise resolving to the Response object
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* KRHttp.fetch({
|
|
113
|
+
* url: '/api/system/customer/list',
|
|
114
|
+
* method: 'POST',
|
|
115
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
116
|
+
* })
|
|
117
|
+
* .then(response => response.json())
|
|
118
|
+
* .then(data => console.log(data));
|
|
119
|
+
*/
|
|
120
|
+
static fetch(options: KRHttpRequest): Promise<Response>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,uCAAuC;IACvC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,MAAM;IAEf,uCAAuC;IACvC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAM;IAC7B,2CAA2C;IAC3C,MAAM,CAAC,OAAO,EAAE,MAAM,CAAM;IAE5B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAS5C;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD1D"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kodaris/krubble-http
|
|
3
|
+
*
|
|
4
|
+
* HTTP client for making API requests with automatic base URL handling
|
|
5
|
+
* and Kodaris API conveniences (CSRF tokens, credentials).
|
|
6
|
+
*
|
|
7
|
+
* ## Usage
|
|
8
|
+
*
|
|
9
|
+
* ### Web App (UMD)
|
|
10
|
+
* ```html
|
|
11
|
+
* <script src="krubble-http.umd.js"></script>
|
|
12
|
+
* <script>
|
|
13
|
+
* // Configure once at startup
|
|
14
|
+
* kr.http.configure({
|
|
15
|
+
* baseUrl: 'https://kodaris.com',
|
|
16
|
+
* devUrl: 'https://localhost:4201'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Make requests
|
|
20
|
+
* kr.http.fetch({
|
|
21
|
+
* url: '/api/system/customer/list',
|
|
22
|
+
* method: 'POST',
|
|
23
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
24
|
+
* })
|
|
25
|
+
* .then(response => response.json())
|
|
26
|
+
* .then(data => console.log(data));
|
|
27
|
+
* </script>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### Angular / ESM
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // app.config.ts - configure once at startup
|
|
33
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
34
|
+
*
|
|
35
|
+
* KRHttp.configure({
|
|
36
|
+
* baseUrl: 'https://kodaris.com',
|
|
37
|
+
* devUrl: 'https://localhost:4201'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // In a service or component
|
|
41
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
42
|
+
*
|
|
43
|
+
* getCustomers() {
|
|
44
|
+
* return KRHttp.fetch({
|
|
45
|
+
* url: '/api/system/customer/list',
|
|
46
|
+
* method: 'POST',
|
|
47
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
48
|
+
* })
|
|
49
|
+
* .then(response => response.json());
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## URL Resolution
|
|
54
|
+
* - On localhost: uses `devUrl` if configured, otherwise `baseUrl`
|
|
55
|
+
* - On production: always uses `baseUrl`
|
|
56
|
+
* - If URL starts with 'http', it's used as-is (no base URL prepended)
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* HTTP client with static methods for making API requests.
|
|
60
|
+
* Automatically handles base URL resolution and Kodaris API conveniences.
|
|
61
|
+
*/
|
|
62
|
+
export class KRHttp {
|
|
63
|
+
/**
|
|
64
|
+
* Configure the HTTP client. Call once at application startup.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Configuration options
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* KRHttp.configure({
|
|
70
|
+
* baseUrl: 'https://kodaris.com',
|
|
71
|
+
* devUrl: 'https://localhost:4201'
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
static configure(config) {
|
|
75
|
+
if (config.baseUrl !== undefined) {
|
|
76
|
+
KRHttp._baseUrl = config.baseUrl;
|
|
77
|
+
}
|
|
78
|
+
if (config.devUrl !== undefined) {
|
|
79
|
+
KRHttp._devUrl = config.devUrl;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Make an HTTP request.
|
|
84
|
+
*
|
|
85
|
+
* @param options - Request options
|
|
86
|
+
* @returns Promise resolving to the Response object
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* KRHttp.fetch({
|
|
90
|
+
* url: '/api/system/customer/list',
|
|
91
|
+
* method: 'POST',
|
|
92
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
93
|
+
* })
|
|
94
|
+
* .then(response => response.json())
|
|
95
|
+
* .then(data => console.log(data));
|
|
96
|
+
*/
|
|
97
|
+
static fetch(options) {
|
|
98
|
+
let url = options.url;
|
|
99
|
+
let finalBaseUrl = KRHttp._baseUrl;
|
|
100
|
+
if (window.location.hostname === 'localhost' && KRHttp._devUrl) {
|
|
101
|
+
finalBaseUrl = KRHttp._devUrl;
|
|
102
|
+
}
|
|
103
|
+
// Add on the default base url if user
|
|
104
|
+
// has not provided the full url
|
|
105
|
+
if (url.indexOf('http') !== 0) {
|
|
106
|
+
url = finalBaseUrl + url;
|
|
107
|
+
}
|
|
108
|
+
if (options.params) {
|
|
109
|
+
url += '?';
|
|
110
|
+
Object.keys(options.params).forEach((key, keyIdx) => {
|
|
111
|
+
if (keyIdx > 0) {
|
|
112
|
+
url += '&';
|
|
113
|
+
}
|
|
114
|
+
url += `${key}=${options.params[key]}`;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (!options.headers) {
|
|
118
|
+
options.headers = {};
|
|
119
|
+
}
|
|
120
|
+
if (!options.headers['Content-Type']) {
|
|
121
|
+
options.headers['Content-Type'] = 'application/json';
|
|
122
|
+
}
|
|
123
|
+
options.credentials = 'include';
|
|
124
|
+
// User and Customer apis require CSRF tokens on non-GET requests
|
|
125
|
+
let token;
|
|
126
|
+
if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
|
|
127
|
+
token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
token = Promise.resolve(null);
|
|
131
|
+
}
|
|
132
|
+
return token
|
|
133
|
+
.then(res => res?.json())
|
|
134
|
+
.then(res => {
|
|
135
|
+
if (res?.data) {
|
|
136
|
+
options.headers['X-CSRF-TOKEN'] = res.data;
|
|
137
|
+
}
|
|
138
|
+
return fetch(url, options);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** Base URL for production requests */
|
|
143
|
+
KRHttp._baseUrl = '';
|
|
144
|
+
/** Base URL for development (localhost) */
|
|
145
|
+
KRHttp._devUrl = '';
|
|
146
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;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.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;AAC1B,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kodaris/krubble-http
|
|
3
|
+
*
|
|
4
|
+
* HTTP client for making API requests with automatic base URL handling
|
|
5
|
+
* and Kodaris API conveniences (CSRF tokens, credentials).
|
|
6
|
+
*
|
|
7
|
+
* ## Usage
|
|
8
|
+
*
|
|
9
|
+
* ### Web App (UMD)
|
|
10
|
+
* ```html
|
|
11
|
+
* <script src="krubble-http.umd.js"></script>
|
|
12
|
+
* <script>
|
|
13
|
+
* // Configure once at startup
|
|
14
|
+
* kr.http.configure({
|
|
15
|
+
* baseUrl: 'https://kodaris.com',
|
|
16
|
+
* devUrl: 'https://localhost:4201'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Make requests
|
|
20
|
+
* kr.http.fetch({
|
|
21
|
+
* url: '/api/system/customer/list',
|
|
22
|
+
* method: 'POST',
|
|
23
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
24
|
+
* })
|
|
25
|
+
* .then(response => response.json())
|
|
26
|
+
* .then(data => console.log(data));
|
|
27
|
+
* </script>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### Angular / ESM
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // app.config.ts - configure once at startup
|
|
33
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
34
|
+
*
|
|
35
|
+
* KRHttp.configure({
|
|
36
|
+
* baseUrl: 'https://kodaris.com',
|
|
37
|
+
* devUrl: 'https://localhost:4201'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // In a service or component
|
|
41
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
42
|
+
*
|
|
43
|
+
* getCustomers() {
|
|
44
|
+
* return KRHttp.fetch({
|
|
45
|
+
* url: '/api/system/customer/list',
|
|
46
|
+
* method: 'POST',
|
|
47
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
48
|
+
* })
|
|
49
|
+
* .then(response => response.json());
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## URL Resolution
|
|
54
|
+
* - On localhost: uses `devUrl` if configured, otherwise `baseUrl`
|
|
55
|
+
* - On production: always uses `baseUrl`
|
|
56
|
+
* - If URL starts with 'http', it's used as-is (no base URL prepended)
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* HTTP client with static methods for making API requests.
|
|
60
|
+
* Automatically handles base URL resolution and Kodaris API conveniences.
|
|
61
|
+
*/
|
|
62
|
+
class KRHttp {
|
|
63
|
+
/**
|
|
64
|
+
* Configure the HTTP client. Call once at application startup.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Configuration options
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* KRHttp.configure({
|
|
70
|
+
* baseUrl: 'https://kodaris.com',
|
|
71
|
+
* devUrl: 'https://localhost:4201'
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
static configure(config) {
|
|
75
|
+
if (config.baseUrl !== undefined) {
|
|
76
|
+
KRHttp._baseUrl = config.baseUrl;
|
|
77
|
+
}
|
|
78
|
+
if (config.devUrl !== undefined) {
|
|
79
|
+
KRHttp._devUrl = config.devUrl;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Make an HTTP request.
|
|
84
|
+
*
|
|
85
|
+
* @param options - Request options
|
|
86
|
+
* @returns Promise resolving to the Response object
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* KRHttp.fetch({
|
|
90
|
+
* url: '/api/system/customer/list',
|
|
91
|
+
* method: 'POST',
|
|
92
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
93
|
+
* })
|
|
94
|
+
* .then(response => response.json())
|
|
95
|
+
* .then(data => console.log(data));
|
|
96
|
+
*/
|
|
97
|
+
static fetch(options) {
|
|
98
|
+
let url = options.url;
|
|
99
|
+
let finalBaseUrl = KRHttp._baseUrl;
|
|
100
|
+
if (window.location.hostname === 'localhost' && KRHttp._devUrl) {
|
|
101
|
+
finalBaseUrl = KRHttp._devUrl;
|
|
102
|
+
}
|
|
103
|
+
// Add on the default base url if user
|
|
104
|
+
// has not provided the full url
|
|
105
|
+
if (url.indexOf('http') !== 0) {
|
|
106
|
+
url = finalBaseUrl + url;
|
|
107
|
+
}
|
|
108
|
+
if (options.params) {
|
|
109
|
+
url += '?';
|
|
110
|
+
Object.keys(options.params).forEach((key, keyIdx) => {
|
|
111
|
+
if (keyIdx > 0) {
|
|
112
|
+
url += '&';
|
|
113
|
+
}
|
|
114
|
+
url += `${key}=${options.params[key]}`;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (!options.headers) {
|
|
118
|
+
options.headers = {};
|
|
119
|
+
}
|
|
120
|
+
if (!options.headers['Content-Type']) {
|
|
121
|
+
options.headers['Content-Type'] = 'application/json';
|
|
122
|
+
}
|
|
123
|
+
options.credentials = 'include';
|
|
124
|
+
// User and Customer apis require CSRF tokens on non-GET requests
|
|
125
|
+
let token;
|
|
126
|
+
if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
|
|
127
|
+
token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
token = Promise.resolve(null);
|
|
131
|
+
}
|
|
132
|
+
return token
|
|
133
|
+
.then(res => res?.json())
|
|
134
|
+
.then(res => {
|
|
135
|
+
if (res?.data) {
|
|
136
|
+
options.headers['X-CSRF-TOKEN'] = res.data;
|
|
137
|
+
}
|
|
138
|
+
return fetch(url, options);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** Base URL for production requests */
|
|
143
|
+
KRHttp._baseUrl = '';
|
|
144
|
+
/** Base URL for development (localhost) */
|
|
145
|
+
KRHttp._devUrl = '';
|
|
146
|
+
|
|
147
|
+
export { KRHttp, KRHttp as http };
|
|
148
|
+
//# sourceMappingURL=krubble-http.bundled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"krubble-http.bundled.js","sources":["http.js"],"sourcesContent":["/**\n * @kodaris/krubble-http\n *\n * HTTP client for making API requests with automatic base URL handling\n * and Kodaris API conveniences (CSRF tokens, credentials).\n *\n * ## Usage\n *\n * ### Web App (UMD)\n * ```html\n * <script src=\"krubble-http.umd.js\"></script>\n * <script>\n * // Configure once at startup\n * kr.http.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // Make requests\n * kr.http.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n * </script>\n * ```\n *\n * ### Angular / ESM\n * ```typescript\n * // app.config.ts - configure once at startup\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // In a service or component\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * getCustomers() {\n * return KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json());\n * }\n * ```\n *\n * ## URL Resolution\n * - On localhost: uses `devUrl` if configured, otherwise `baseUrl`\n * - On production: always uses `baseUrl`\n * - If URL starts with 'http', it's used as-is (no base URL prepended)\n */\n/**\n * HTTP client with static methods for making API requests.\n * Automatically handles base URL resolution and Kodaris API conveniences.\n */\nexport class KRHttp {\n /**\n * Configure the HTTP client. Call once at application startup.\n *\n * @param config - Configuration options\n *\n * @example\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n */\n static configure(config) {\n if (config.baseUrl !== undefined) {\n KRHttp._baseUrl = config.baseUrl;\n }\n if (config.devUrl !== undefined) {\n KRHttp._devUrl = config.devUrl;\n }\n }\n /**\n * Make an HTTP request.\n *\n * @param options - Request options\n * @returns Promise resolving to the Response object\n *\n * @example\n * KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n */\n static fetch(options) {\n let url = options.url;\n let finalBaseUrl = KRHttp._baseUrl;\n if (window.location.hostname === 'localhost' && KRHttp._devUrl) {\n finalBaseUrl = KRHttp._devUrl;\n }\n // Add on the default base url if user\n // has not provided the full url\n if (url.indexOf('http') !== 0) {\n url = finalBaseUrl + url;\n }\n if (options.params) {\n url += '?';\n Object.keys(options.params).forEach((key, keyIdx) => {\n if (keyIdx > 0) {\n url += '&';\n }\n url += `${key}=${options.params[key]}`;\n });\n }\n if (!options.headers) {\n options.headers = {};\n }\n if (!options.headers['Content-Type']) {\n options.headers['Content-Type'] = 'application/json';\n }\n options.credentials = 'include';\n // User and Customer apis require CSRF tokens on non-GET requests\n let token;\n if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {\n token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });\n }\n else {\n token = Promise.resolve(null);\n }\n return token\n .then(res => res?.json())\n .then(res => {\n if (res?.data) {\n options.headers['X-CSRF-TOKEN'] = res.data;\n }\n return fetch(url, options);\n });\n }\n}\n/** Base URL for production requests */\nKRHttp._baseUrl = '';\n/** Base URL for development (localhost) */\nKRHttp._devUrl = '';\n//# sourceMappingURL=http.js.map"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,MAAM,CAAC;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,SAAS,CAAC,MAAM,EAAE;AAC7B,QAAQ,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;AAC1C,YAAY,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO;AAC5C,QAAQ;AACR,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;AACzC,YAAY,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM;AAC1C,QAAQ;AACR,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,KAAK,CAAC,OAAO,EAAE;AAC1B,QAAQ,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG;AAC7B,QAAQ,IAAI,YAAY,GAAG,MAAM,CAAC,QAAQ;AAC1C,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE;AACxE,YAAY,YAAY,GAAG,MAAM,CAAC,OAAO;AACzC,QAAQ;AACR;AACA;AACA,QAAQ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AAI,CAAC,GAAG,IAAI,GAAG,EAAE,IAAI,EAAE;AACpC,aAAa,IAAI,CAAC,GAAG,IAAI;AACzB,YAAY,IAAI,GAAG,EAAE,IAAI,EAAE;AAC3B,gBAAgB,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,IAAI;AAC1D,YAAY;AACZ,YAAY,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC;AACtC,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;AACA;AACA,MAAM,CAAC,QAAQ,GAAG,EAAE;AACpB;AACA,MAAM,CAAC,OAAO,GAAG,EAAE;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class e{static configure(a){void 0!==a.baseUrl&&(e._baseUrl=a.baseUrl),void 0!==a.devUrl&&(e._devUrl=a.devUrl)}static fetch(a){let r,t=a.url,s=e._baseUrl;return"localhost"===window.location.hostname&&e._devUrl&&(s=e._devUrl),0!==t.indexOf("http")&&(t=s+t),a.params&&(t+="?",Object.keys(a.params).forEach(((e,r)=>{r>0&&(t+="&"),t+=`${e}=${a.params[e]}`}))),a.headers||(a.headers={}),a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),a.credentials="include",r=t.indexOf("/api/user/")>-1||t.indexOf("/api/customer/")>-1?fetch(`${s}/api/user/customer/authToken`,{credentials:"include"}):Promise.resolve(null),r.then((e=>e?.json())).then((e=>(e?.data&&(a.headers["X-CSRF-TOKEN"]=e.data),fetch(t,a))))}}e._baseUrl="",e._devUrl="";export{e as KRHttp,e as http};
|
|
2
|
+
//# sourceMappingURL=krubble-http.bundled.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"krubble-http.bundled.min.js","sources":["http.js"],"sourcesContent":["/**\n * @kodaris/krubble-http\n *\n * HTTP client for making API requests with automatic base URL handling\n * and Kodaris API conveniences (CSRF tokens, credentials).\n *\n * ## Usage\n *\n * ### Web App (UMD)\n * ```html\n * <script src=\"krubble-http.umd.js\"></script>\n * <script>\n * // Configure once at startup\n * kr.http.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // Make requests\n * kr.http.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n * </script>\n * ```\n *\n * ### Angular / ESM\n * ```typescript\n * // app.config.ts - configure once at startup\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // In a service or component\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * getCustomers() {\n * return KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json());\n * }\n * ```\n *\n * ## URL Resolution\n * - On localhost: uses `devUrl` if configured, otherwise `baseUrl`\n * - On production: always uses `baseUrl`\n * - If URL starts with 'http', it's used as-is (no base URL prepended)\n */\n/**\n * HTTP client with static methods for making API requests.\n * Automatically handles base URL resolution and Kodaris API conveniences.\n */\nexport class KRHttp {\n /**\n * Configure the HTTP client. Call once at application startup.\n *\n * @param config - Configuration options\n *\n * @example\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n */\n static configure(config) {\n if (config.baseUrl !== undefined) {\n KRHttp._baseUrl = config.baseUrl;\n }\n if (config.devUrl !== undefined) {\n KRHttp._devUrl = config.devUrl;\n }\n }\n /**\n * Make an HTTP request.\n *\n * @param options - Request options\n * @returns Promise resolving to the Response object\n *\n * @example\n * KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n */\n static fetch(options) {\n let url = options.url;\n let finalBaseUrl = KRHttp._baseUrl;\n if (window.location.hostname === 'localhost' && KRHttp._devUrl) {\n finalBaseUrl = KRHttp._devUrl;\n }\n // Add on the default base url if user\n // has not provided the full url\n if (url.indexOf('http') !== 0) {\n url = finalBaseUrl + url;\n }\n if (options.params) {\n url += '?';\n Object.keys(options.params).forEach((key, keyIdx) => {\n if (keyIdx > 0) {\n url += '&';\n }\n url += `${key}=${options.params[key]}`;\n });\n }\n if (!options.headers) {\n options.headers = {};\n }\n if (!options.headers['Content-Type']) {\n options.headers['Content-Type'] = 'application/json';\n }\n options.credentials = 'include';\n // User and Customer apis require CSRF tokens on non-GET requests\n let token;\n if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {\n token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });\n }\n else {\n token = Promise.resolve(null);\n }\n return token\n .then(res => res?.json())\n .then(res => {\n if (res?.data) {\n options.headers['X-CSRF-TOKEN'] = res.data;\n }\n return fetch(url, options);\n });\n }\n}\n/** Base URL for production requests */\nKRHttp._baseUrl = '';\n/** Base URL for development (localhost) */\nKRHttp._devUrl = '';\n//# sourceMappingURL=http.js.map"],"names":["KRHttp","configure","config","undefined","baseUrl","_baseUrl","devUrl","_devUrl","fetch","options","token","url","finalBaseUrl","window","location","hostname","indexOf","params","Object","keys","forEach","key","keyIdx","headers","credentials","Promise","resolve","then","res","json","data"],"mappings":"AA6DO,MAAMA,EAYT,gBAAOC,CAAUC,QACUC,IAAnBD,EAAOE,UACPJ,EAAOK,SAAWH,EAAOE,cAEPD,IAAlBD,EAAOI,SACPN,EAAOO,QAAUL,EAAOI,OAEhC,CAgBA,YAAOE,CAAMC,GACT,IA2BIC,EA3BAC,EAAMF,EAAQE,IACdC,EAAeZ,EAAOK,SAiC1B,MAhCiC,cAA7BQ,OAAOC,SAASC,UAA4Bf,EAAOO,UACnDK,EAAeZ,EAAOO,SAIE,IAAxBI,EAAIK,QAAQ,UACZL,EAAMC,EAAeD,GAErBF,EAAQQ,SACRN,GAAO,IACPO,OAAOC,KAAKV,EAAQQ,QAAQG,SAAQ,CAACC,EAAKC,KAClCA,EAAS,IACTX,GAAO,KAEXA,GAAO,GAAGU,KAAOZ,EAAQQ,OAAOI,IAAM,KAGzCZ,EAAQc,UACTd,EAAQc,QAAU,CAAA,GAEjBd,EAAQc,QAAQ,kBACjBd,EAAQc,QAAQ,gBAAkB,oBAEtCd,EAAQe,YAAc,UAIlBd,EADAC,EAAIK,QAAQ,eAAgB,GAAML,EAAIK,QAAQ,qBACtCR,MAAM,GAAGI,gCAA4C,CAAEY,YAAa,YAGpEC,QAAQC,QAAQ,MAErBhB,EACFiB,MAAKC,GAAOA,GAAKC,SACjBF,MAAKC,IACFA,GAAKE,OACLrB,EAAQc,QAAQ,gBAAkBK,EAAIE,MAEnCtB,MAAMG,EAAKF,KAE1B,EAGJT,EAAOK,SAAW,GAElBL,EAAOO,QAAU"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.kr = global.kr || {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @kodaris/krubble-http
|
|
9
|
+
*
|
|
10
|
+
* HTTP client for making API requests with automatic base URL handling
|
|
11
|
+
* and Kodaris API conveniences (CSRF tokens, credentials).
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ### Web App (UMD)
|
|
16
|
+
* ```html
|
|
17
|
+
* <script src="krubble-http.umd.js"></script>
|
|
18
|
+
* <script>
|
|
19
|
+
* // Configure once at startup
|
|
20
|
+
* kr.http.configure({
|
|
21
|
+
* baseUrl: 'https://kodaris.com',
|
|
22
|
+
* devUrl: 'https://localhost:4201'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Make requests
|
|
26
|
+
* kr.http.fetch({
|
|
27
|
+
* url: '/api/system/customer/list',
|
|
28
|
+
* method: 'POST',
|
|
29
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
30
|
+
* })
|
|
31
|
+
* .then(response => response.json())
|
|
32
|
+
* .then(data => console.log(data));
|
|
33
|
+
* </script>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ### Angular / ESM
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // app.config.ts - configure once at startup
|
|
39
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
40
|
+
*
|
|
41
|
+
* KRHttp.configure({
|
|
42
|
+
* baseUrl: 'https://kodaris.com',
|
|
43
|
+
* devUrl: 'https://localhost:4201'
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // In a service or component
|
|
47
|
+
* import { KRHttp } from '@kodaris/krubble-http';
|
|
48
|
+
*
|
|
49
|
+
* getCustomers() {
|
|
50
|
+
* return KRHttp.fetch({
|
|
51
|
+
* url: '/api/system/customer/list',
|
|
52
|
+
* method: 'POST',
|
|
53
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
54
|
+
* })
|
|
55
|
+
* .then(response => response.json());
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* ## URL Resolution
|
|
60
|
+
* - On localhost: uses `devUrl` if configured, otherwise `baseUrl`
|
|
61
|
+
* - On production: always uses `baseUrl`
|
|
62
|
+
* - If URL starts with 'http', it's used as-is (no base URL prepended)
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* HTTP client with static methods for making API requests.
|
|
66
|
+
* Automatically handles base URL resolution and Kodaris API conveniences.
|
|
67
|
+
*/
|
|
68
|
+
class KRHttp {
|
|
69
|
+
/**
|
|
70
|
+
* Configure the HTTP client. Call once at application startup.
|
|
71
|
+
*
|
|
72
|
+
* @param config - Configuration options
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* KRHttp.configure({
|
|
76
|
+
* baseUrl: 'https://kodaris.com',
|
|
77
|
+
* devUrl: 'https://localhost:4201'
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
static configure(config) {
|
|
81
|
+
if (config.baseUrl !== undefined) {
|
|
82
|
+
KRHttp._baseUrl = config.baseUrl;
|
|
83
|
+
}
|
|
84
|
+
if (config.devUrl !== undefined) {
|
|
85
|
+
KRHttp._devUrl = config.devUrl;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Make an HTTP request.
|
|
90
|
+
*
|
|
91
|
+
* @param options - Request options
|
|
92
|
+
* @returns Promise resolving to the Response object
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* KRHttp.fetch({
|
|
96
|
+
* url: '/api/system/customer/list',
|
|
97
|
+
* method: 'POST',
|
|
98
|
+
* body: JSON.stringify({ page: 0, size: 20 })
|
|
99
|
+
* })
|
|
100
|
+
* .then(response => response.json())
|
|
101
|
+
* .then(data => console.log(data));
|
|
102
|
+
*/
|
|
103
|
+
static fetch(options) {
|
|
104
|
+
let url = options.url;
|
|
105
|
+
let finalBaseUrl = KRHttp._baseUrl;
|
|
106
|
+
if (window.location.hostname === 'localhost' && KRHttp._devUrl) {
|
|
107
|
+
finalBaseUrl = KRHttp._devUrl;
|
|
108
|
+
}
|
|
109
|
+
// Add on the default base url if user
|
|
110
|
+
// has not provided the full url
|
|
111
|
+
if (url.indexOf('http') !== 0) {
|
|
112
|
+
url = finalBaseUrl + url;
|
|
113
|
+
}
|
|
114
|
+
if (options.params) {
|
|
115
|
+
url += '?';
|
|
116
|
+
Object.keys(options.params).forEach((key, keyIdx) => {
|
|
117
|
+
if (keyIdx > 0) {
|
|
118
|
+
url += '&';
|
|
119
|
+
}
|
|
120
|
+
url += `${key}=${options.params[key]}`;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (!options.headers) {
|
|
124
|
+
options.headers = {};
|
|
125
|
+
}
|
|
126
|
+
if (!options.headers['Content-Type']) {
|
|
127
|
+
options.headers['Content-Type'] = 'application/json';
|
|
128
|
+
}
|
|
129
|
+
options.credentials = 'include';
|
|
130
|
+
// User and Customer apis require CSRF tokens on non-GET requests
|
|
131
|
+
let token;
|
|
132
|
+
if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
|
|
133
|
+
token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
token = Promise.resolve(null);
|
|
137
|
+
}
|
|
138
|
+
return token
|
|
139
|
+
.then(res => res?.json())
|
|
140
|
+
.then(res => {
|
|
141
|
+
if (res?.data) {
|
|
142
|
+
options.headers['X-CSRF-TOKEN'] = res.data;
|
|
143
|
+
}
|
|
144
|
+
return fetch(url, options);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** Base URL for production requests */
|
|
149
|
+
KRHttp._baseUrl = '';
|
|
150
|
+
/** Base URL for development (localhost) */
|
|
151
|
+
KRHttp._devUrl = '';
|
|
152
|
+
|
|
153
|
+
exports.KRHttp = KRHttp;
|
|
154
|
+
exports.http = KRHttp;
|
|
155
|
+
|
|
156
|
+
}));
|
|
157
|
+
(function(e){Object.keys(e).forEach(function(k){if(k.startsWith('KR')&&typeof e[k]==='function'){e[k.slice(2)]=e[k];}});})(kr);
|
|
158
|
+
//# sourceMappingURL=krubble-http.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"krubble-http.umd.js","sources":["http.js"],"sourcesContent":["/**\n * @kodaris/krubble-http\n *\n * HTTP client for making API requests with automatic base URL handling\n * and Kodaris API conveniences (CSRF tokens, credentials).\n *\n * ## Usage\n *\n * ### Web App (UMD)\n * ```html\n * <script src=\"krubble-http.umd.js\"></script>\n * <script>\n * // Configure once at startup\n * kr.http.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // Make requests\n * kr.http.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n * </script>\n * ```\n *\n * ### Angular / ESM\n * ```typescript\n * // app.config.ts - configure once at startup\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // In a service or component\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * getCustomers() {\n * return KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json());\n * }\n * ```\n *\n * ## URL Resolution\n * - On localhost: uses `devUrl` if configured, otherwise `baseUrl`\n * - On production: always uses `baseUrl`\n * - If URL starts with 'http', it's used as-is (no base URL prepended)\n */\n/**\n * HTTP client with static methods for making API requests.\n * Automatically handles base URL resolution and Kodaris API conveniences.\n */\nexport class KRHttp {\n /**\n * Configure the HTTP client. Call once at application startup.\n *\n * @param config - Configuration options\n *\n * @example\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n */\n static configure(config) {\n if (config.baseUrl !== undefined) {\n KRHttp._baseUrl = config.baseUrl;\n }\n if (config.devUrl !== undefined) {\n KRHttp._devUrl = config.devUrl;\n }\n }\n /**\n * Make an HTTP request.\n *\n * @param options - Request options\n * @returns Promise resolving to the Response object\n *\n * @example\n * KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n */\n static fetch(options) {\n let url = options.url;\n let finalBaseUrl = KRHttp._baseUrl;\n if (window.location.hostname === 'localhost' && KRHttp._devUrl) {\n finalBaseUrl = KRHttp._devUrl;\n }\n // Add on the default base url if user\n // has not provided the full url\n if (url.indexOf('http') !== 0) {\n url = finalBaseUrl + url;\n }\n if (options.params) {\n url += '?';\n Object.keys(options.params).forEach((key, keyIdx) => {\n if (keyIdx > 0) {\n url += '&';\n }\n url += `${key}=${options.params[key]}`;\n });\n }\n if (!options.headers) {\n options.headers = {};\n }\n if (!options.headers['Content-Type']) {\n options.headers['Content-Type'] = 'application/json';\n }\n options.credentials = 'include';\n // User and Customer apis require CSRF tokens on non-GET requests\n let token;\n if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {\n token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });\n }\n else {\n token = Promise.resolve(null);\n }\n return token\n .then(res => res?.json())\n .then(res => {\n if (res?.data) {\n options.headers['X-CSRF-TOKEN'] = res.data;\n }\n return fetch(url, options);\n });\n }\n}\n/** Base URL for production requests */\nKRHttp._baseUrl = '';\n/** Base URL for development (localhost) */\nKRHttp._devUrl = '';\n//# sourceMappingURL=http.js.map"],"names":[],"mappings":";;;;;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,MAAM,CAAC;IACpB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,OAAO,SAAS,CAAC,MAAM,EAAE;IAC7B,QAAQ,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;IAC1C,YAAY,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO;IAC5C,QAAQ;IACR,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EA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G,kBAAkB;IAChE,QAAQ;IACR,QAAQ,OAAO,CAAC,WAAW,GAAG,SAAS;IACvC;IACA,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE;IAClF,YAAY,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,4BAA4B,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;IACpG,QAAQ;IACR,aAAa;IACb,YAAY,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IACzC,QAAQ;IACR,QAAQ,OAAO;IACf,aAAa,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,IAAI,EAAE;IACpC,aAAa,IAAI,CAAC,GAAG,IAAI;IACzB,YAAY,IAAI,GAAG,EAAE,IAAI,EAAE;IAC3B,gBAAgB,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,IAAI;IAC1D,YAAY;IACZ,YAAY,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ;IACA;IACA,MAAM,CAAC,QAAQ,GAAG,EAAE;IACpB;IACA,MAAM,CAAC,OAAO,GAAG,EAAE;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).kr=e.kr||{})}(this,(function(e){"use strict";class t{static configure(e){void 0!==e.baseUrl&&(t._baseUrl=e.baseUrl),void 0!==e.devUrl&&(t._devUrl=e.devUrl)}static fetch(e){let s,n=e.url,r=t._baseUrl;return"localhost"===window.location.hostname&&t._devUrl&&(r=t._devUrl),0!==n.indexOf("http")&&(n=r+n),e.params&&(n+="?",Object.keys(e.params).forEach(((t,s)=>{s>0&&(n+="&"),n+=`${t}=${e.params[t]}`}))),e.headers||(e.headers={}),e.headers["Content-Type"]||(e.headers["Content-Type"]="application/json"),e.credentials="include",s=n.indexOf("/api/user/")>-1||n.indexOf("/api/customer/")>-1?fetch(`${r}/api/user/customer/authToken`,{credentials:"include"}):Promise.resolve(null),s.then((e=>e?.json())).then((t=>(t?.data&&(e.headers["X-CSRF-TOKEN"]=t.data),fetch(n,e))))}}t._baseUrl="",t._devUrl="",e.KRHttp=t,e.http=t})),function(e){Object.keys(e).forEach((function(t){t.startsWith("KR")&&"function"==typeof e[t]&&(e[t.slice(2)]=e[t])}))}(kr);
|
|
2
|
+
//# sourceMappingURL=krubble-http.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"krubble-http.umd.min.js","sources":["http.js"],"sourcesContent":["/**\n * @kodaris/krubble-http\n *\n * HTTP client for making API requests with automatic base URL handling\n * and Kodaris API conveniences (CSRF tokens, credentials).\n *\n * ## Usage\n *\n * ### Web App (UMD)\n * ```html\n * <script src=\"krubble-http.umd.js\"></script>\n * <script>\n * // Configure once at startup\n * kr.http.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // Make requests\n * kr.http.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n * </script>\n * ```\n *\n * ### Angular / ESM\n * ```typescript\n * // app.config.ts - configure once at startup\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n *\n * // In a service or component\n * import { KRHttp } from '@kodaris/krubble-http';\n *\n * getCustomers() {\n * return KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json());\n * }\n * ```\n *\n * ## URL Resolution\n * - On localhost: uses `devUrl` if configured, otherwise `baseUrl`\n * - On production: always uses `baseUrl`\n * - If URL starts with 'http', it's used as-is (no base URL prepended)\n */\n/**\n * HTTP client with static methods for making API requests.\n * Automatically handles base URL resolution and Kodaris API conveniences.\n */\nexport class KRHttp {\n /**\n * Configure the HTTP client. Call once at application startup.\n *\n * @param config - Configuration options\n *\n * @example\n * KRHttp.configure({\n * baseUrl: 'https://kodaris.com',\n * devUrl: 'https://localhost:4201'\n * });\n */\n static configure(config) {\n if (config.baseUrl !== undefined) {\n KRHttp._baseUrl = config.baseUrl;\n }\n if (config.devUrl !== undefined) {\n KRHttp._devUrl = config.devUrl;\n }\n }\n /**\n * Make an HTTP request.\n *\n * @param options - Request options\n * @returns Promise resolving to the Response object\n *\n * @example\n * KRHttp.fetch({\n * url: '/api/system/customer/list',\n * method: 'POST',\n * body: JSON.stringify({ page: 0, size: 20 })\n * })\n * .then(response => response.json())\n * .then(data => console.log(data));\n */\n static fetch(options) {\n let url = options.url;\n let finalBaseUrl = KRHttp._baseUrl;\n if (window.location.hostname === 'localhost' && KRHttp._devUrl) {\n finalBaseUrl = KRHttp._devUrl;\n }\n // Add on the default base url if user\n // has not provided the full url\n if (url.indexOf('http') !== 0) {\n url = finalBaseUrl + url;\n }\n if (options.params) {\n url += '?';\n Object.keys(options.params).forEach((key, keyIdx) => {\n if (keyIdx > 0) {\n url += '&';\n }\n url += `${key}=${options.params[key]}`;\n });\n }\n if (!options.headers) {\n options.headers = {};\n }\n if (!options.headers['Content-Type']) {\n options.headers['Content-Type'] = 'application/json';\n }\n options.credentials = 'include';\n // User and Customer apis require CSRF tokens on non-GET requests\n let token;\n if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {\n token = fetch(`${finalBaseUrl}/api/user/customer/authToken`, { credentials: 'include' });\n }\n else {\n token = Promise.resolve(null);\n }\n return token\n .then(res => res?.json())\n .then(res => {\n if (res?.data) {\n options.headers['X-CSRF-TOKEN'] = res.data;\n }\n return fetch(url, options);\n });\n }\n}\n/** Base URL for production requests */\nKRHttp._baseUrl = '';\n/** Base URL for development (localhost) */\nKRHttp._devUrl = '';\n//# sourceMappingURL=http.js.map"],"names":["KRHttp","configure","config","undefined","baseUrl","_baseUrl","devUrl","_devUrl","fetch","options","token","url","finalBaseUrl","window","location","hostname","indexOf","params","Object","keys","forEach","key","keyIdx","headers","credentials","Promise","resolve","then","res","json","data"],"mappings":"gPA6DO,MAAMA,EAYT,gBAAOC,CAAUC,QACUC,IAAnBD,EAAOE,UACPJ,EAAOK,SAAWH,EAAOE,cAEPD,IAAlBD,EAAOI,SACPN,EAAOO,QAAUL,EAAOI,OAEhC,CAgBA,YAAOE,CAAMC,GACT,IA2BIC,EA3BAC,EAAMF,EAAQE,IACdC,EAAeZ,EAAOK,SAiC1B,MAhCiC,cAA7BQ,OAAOC,SAASC,UAA4Bf,EAAOO,UACnDK,EAAeZ,EAAOO,SAIE,IAAxBI,EAAIK,QAAQ,UACZL,EAAMC,EAAeD,GAErBF,EAAQQ,SACRN,GAAO,IACPO,OAAOC,KAAKV,EAAQQ,QAAQG,SAAQ,CAACC,EAAKC,KAClCA,EAAS,IACTX,GAAO,KAEXA,GAAO,GAAGU,KAAOZ,EAAQQ,OAAOI,IAAM,KAGzCZ,EAAQc,UACTd,EAAQc,QAAU,CAAA,GAEjBd,EAAQc,QAAQ,kBACjBd,EAAQc,QAAQ,gBAAkB,oBAEtCd,EAAQe,YAAc,UAIlBd,EADAC,EAAIK,QAAQ,eAAgB,GAAML,EAAIK,QAAQ,qBACtCR,MAAM,GAAGI,gCAA4C,CAAEY,YAAa,YAGpEC,QAAQC,QAAQ,MAErBhB,EACFiB,MAAKC,GAAOA,GAAKC,SACjBF,MAAKC,IACFA,GAAKE,OACLrB,EAAQc,QAAQ,gBAAkBK,EAAIE,MAEnCtB,MAAMG,EAAKF,KAE1B,EAGJT,EAAOK,SAAW,GAElBL,EAAOO,QAAU"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kodaris/krubble-http",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Krubble HTTP client",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run clean && tsc && npm run build:bundle",
|
|
20
|
+
"build:bundle": "rollup -c",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"dev": "tsc --watch",
|
|
23
|
+
"watch": "tsc --watch",
|
|
24
|
+
"lint": "eslint src"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
28
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
29
|
+
"rollup": "^4.9.0",
|
|
30
|
+
"typescript": "^5.6.3"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"http-client",
|
|
34
|
+
"api",
|
|
35
|
+
"fetch"
|
|
36
|
+
],
|
|
37
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
38
|
+
}
|