@major-tech/resource-client 0.2.2 → 0.2.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/bin/generate-clients.mjs +57 -26
- package/dist/base.cjs +7 -2
- package/dist/base.cjs.map +2 -2
- package/dist/base.d.ts +6 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +6 -1
- package/dist/base.js.map +1 -1
- package/package.json +1 -1
package/bin/generate-clients.mjs
CHANGED
|
@@ -27,13 +27,35 @@ const __dirname = path.dirname(__filename);
|
|
|
27
27
|
// User's project root (where the command is run from)
|
|
28
28
|
const projectRoot = process.cwd();
|
|
29
29
|
const resourcesConfigPath = path.join(projectRoot, 'resources.json');
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
function getClientsDir() {
|
|
32
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
33
|
+
if (fs.existsSync(srcDir)) {
|
|
34
|
+
return path.join(srcDir, 'clients');
|
|
35
|
+
}
|
|
36
|
+
return path.join(projectRoot, 'clients');
|
|
37
|
+
}
|
|
31
38
|
|
|
32
39
|
/**
|
|
33
40
|
* Client template
|
|
34
41
|
*/
|
|
35
|
-
function clientTemplate(data) {
|
|
36
|
-
|
|
42
|
+
function clientTemplate(data, framework) {
|
|
43
|
+
const isNextJs = framework === 'nextjs';
|
|
44
|
+
|
|
45
|
+
const imports = [
|
|
46
|
+
`import { ${data.clientClass} } from '@major-tech/resource-client';`,
|
|
47
|
+
isNextJs ? `import { headers } from 'next/headers';` : ''
|
|
48
|
+
].filter(Boolean).join('\n');
|
|
49
|
+
|
|
50
|
+
const getHeadersConfig = isNextJs ? `
|
|
51
|
+
getHeaders: async () => {
|
|
52
|
+
const h = await headers();
|
|
53
|
+
return {
|
|
54
|
+
'x-major-user-jwt': h.get('x-major-user-jwt') || '',
|
|
55
|
+
};
|
|
56
|
+
},` : '';
|
|
57
|
+
|
|
58
|
+
return `${imports}
|
|
37
59
|
|
|
38
60
|
/**
|
|
39
61
|
* ${data.description}
|
|
@@ -45,8 +67,8 @@ function clientTemplate(data) {
|
|
|
45
67
|
* DO NOT EDIT - Auto-generated by @major-tech/resource-client
|
|
46
68
|
*/
|
|
47
69
|
|
|
48
|
-
const BASE_URL = import.meta.env.MAJOR_API_BASE_URL || 'https://api.prod.major.build';
|
|
49
|
-
const MAJOR_JWT_TOKEN = import.meta.env.MAJOR_JWT_TOKEN;
|
|
70
|
+
const BASE_URL = ${isNextJs ? 'process.env.MAJOR_API_BASE_URL' : 'import.meta.env.MAJOR_API_BASE_URL'} || 'https://api.prod.major.build';
|
|
71
|
+
const MAJOR_JWT_TOKEN = ${isNextJs ? 'process.env.MAJOR_JWT_TOKEN' : 'import.meta.env.MAJOR_JWT_TOKEN'};
|
|
50
72
|
|
|
51
73
|
class ${data.clientName}Singleton {
|
|
52
74
|
private static instance: ${data.clientClass} | null = null;
|
|
@@ -58,7 +80,7 @@ class ${data.clientName}Singleton {
|
|
|
58
80
|
majorJwtToken: MAJOR_JWT_TOKEN,
|
|
59
81
|
applicationId: '${data.applicationId}',
|
|
60
82
|
resourceId: '${data.resourceId}',
|
|
61
|
-
fetch: (...args) => fetch(...args)
|
|
83
|
+
fetch: (...args) => fetch(...args),${getHeadersConfig}
|
|
62
84
|
});
|
|
63
85
|
}
|
|
64
86
|
return ${data.clientName}Singleton.instance;
|
|
@@ -127,7 +149,7 @@ function getClientClass(type) {
|
|
|
127
149
|
return typeMap[type] || 'PostgresResourceClient';
|
|
128
150
|
}
|
|
129
151
|
|
|
130
|
-
function generateClientFile(resource) {
|
|
152
|
+
function generateClientFile(resource, framework) {
|
|
131
153
|
const clientName = toCamelCase(resource.name) + 'Client';
|
|
132
154
|
const clientClass = getClientClass(resource.type);
|
|
133
155
|
|
|
@@ -138,7 +160,7 @@ function generateClientFile(resource) {
|
|
|
138
160
|
resourceId: resource.id,
|
|
139
161
|
applicationId: resource.applicationId,
|
|
140
162
|
clientName,
|
|
141
|
-
});
|
|
163
|
+
}, framework);
|
|
142
164
|
}
|
|
143
165
|
|
|
144
166
|
function generateIndexFile(resources) {
|
|
@@ -155,11 +177,12 @@ function generateIndexFile(resources) {
|
|
|
155
177
|
return indexTemplate({ exports });
|
|
156
178
|
}
|
|
157
179
|
|
|
158
|
-
function addResource(resourceId, name, type, description, applicationId) {
|
|
180
|
+
function addResource(resourceId, name, type, description, applicationId, framework) {
|
|
159
181
|
const validTypes = ['database-postgresql', 'database-dynamodb', 'api-hubspot', 'api-custom', 'storage-s3'];
|
|
160
182
|
if (!validTypes.includes(type)) {
|
|
161
183
|
console.error(`❌ Invalid type: ${type}`);
|
|
162
184
|
console.log(` Valid types: ${validTypes.join(', ')}`);
|
|
185
|
+
console.log(` Your resource-client version might be out of date. Try running 'pnpm update @major-tech/resource-client'`)
|
|
163
186
|
process.exit(1);
|
|
164
187
|
}
|
|
165
188
|
|
|
@@ -191,13 +214,13 @@ function addResource(resourceId, name, type, description, applicationId) {
|
|
|
191
214
|
console.log(` Type: ${type}`);
|
|
192
215
|
console.log(` ID: ${resourceId}`);
|
|
193
216
|
|
|
194
|
-
regenerateClients(resources);
|
|
217
|
+
regenerateClients(resources, framework);
|
|
195
218
|
}
|
|
196
219
|
|
|
197
220
|
/**
|
|
198
221
|
* Remove a resource by name
|
|
199
222
|
*/
|
|
200
|
-
function removeResource(name) {
|
|
223
|
+
function removeResource(name, framework) {
|
|
201
224
|
const resources = loadResources();
|
|
202
225
|
const index = resources.findIndex(r => r.name === name);
|
|
203
226
|
|
|
@@ -212,7 +235,7 @@ function removeResource(name) {
|
|
|
212
235
|
console.log(`✅ Removed resource: ${removed.name}`);
|
|
213
236
|
console.log(` ID: ${removed.id}`);
|
|
214
237
|
|
|
215
|
-
regenerateClients(resources);
|
|
238
|
+
regenerateClients(resources, framework);
|
|
216
239
|
}
|
|
217
240
|
|
|
218
241
|
/**
|
|
@@ -238,7 +261,9 @@ function listResources() {
|
|
|
238
261
|
/**
|
|
239
262
|
* Regenerate all client files
|
|
240
263
|
*/
|
|
241
|
-
function regenerateClients(resources) {
|
|
264
|
+
function regenerateClients(resources, framework) {
|
|
265
|
+
const clientsDir = getClientsDir();
|
|
266
|
+
|
|
242
267
|
// Ensure clients directory exists
|
|
243
268
|
if (!fs.existsSync(clientsDir)) {
|
|
244
269
|
fs.mkdirSync(clientsDir, { recursive: true });
|
|
@@ -254,7 +279,7 @@ function regenerateClients(resources) {
|
|
|
254
279
|
resources.forEach(resource => {
|
|
255
280
|
const fileName = toCamelCase(resource.name) + '.ts';
|
|
256
281
|
const filePath = path.join(clientsDir, fileName);
|
|
257
|
-
const code = generateClientFile(resource);
|
|
282
|
+
const code = generateClientFile(resource, framework);
|
|
258
283
|
fs.writeFileSync(filePath, code, 'utf-8');
|
|
259
284
|
});
|
|
260
285
|
|
|
@@ -264,6 +289,9 @@ function regenerateClients(resources) {
|
|
|
264
289
|
fs.writeFileSync(indexPath, indexCode, 'utf-8');
|
|
265
290
|
|
|
266
291
|
console.log(`✅ Generated ${resources.length} client(s) in ${clientsDir}`);
|
|
292
|
+
if (framework) {
|
|
293
|
+
console.log(` Framework: ${framework}`);
|
|
294
|
+
}
|
|
267
295
|
}
|
|
268
296
|
|
|
269
297
|
/**
|
|
@@ -273,10 +301,19 @@ function main() {
|
|
|
273
301
|
const args = process.argv.slice(2);
|
|
274
302
|
const command = args[0];
|
|
275
303
|
|
|
304
|
+
// Extract --framework flag
|
|
305
|
+
const frameworkIndex = args.indexOf('--framework');
|
|
306
|
+
let framework = undefined;
|
|
307
|
+
if (frameworkIndex !== -1 && args[frameworkIndex + 1]) {
|
|
308
|
+
framework = args[frameworkIndex + 1];
|
|
309
|
+
// Remove --framework and its value from args
|
|
310
|
+
args.splice(frameworkIndex, 2);
|
|
311
|
+
}
|
|
312
|
+
|
|
276
313
|
if (!command) {
|
|
277
314
|
console.log('Usage:');
|
|
278
|
-
console.log(' npx @major-tech/resource-client add <resource_id> <name> <type> <description> <application_id>');
|
|
279
|
-
console.log(' npx @major-tech/resource-client remove <name>');
|
|
315
|
+
console.log(' npx @major-tech/resource-client add <resource_id> <name> <type> <description> <application_id> [--framework <nextjs|vite>]');
|
|
316
|
+
console.log(' npx @major-tech/resource-client remove <name> [--framework <nextjs|vite>]');
|
|
280
317
|
console.log(' npx @major-tech/resource-client list');
|
|
281
318
|
console.log('\nTypes: database-postgresql | database-dynamodb | api-hubspot | api-custom | storage-s3');
|
|
282
319
|
return;
|
|
@@ -287,10 +324,10 @@ function main() {
|
|
|
287
324
|
const [, resourceId, name, type, description, applicationId] = args;
|
|
288
325
|
if (!resourceId || !name || !type || !description || !applicationId) {
|
|
289
326
|
console.error('❌ Missing arguments');
|
|
290
|
-
console.log('Usage: add <resource_id> <name> <type> <description> <application_id>');
|
|
327
|
+
console.log('Usage: add <resource_id> <name> <type> <description> <application_id> [--framework <nextjs|vite>]');
|
|
291
328
|
process.exit(1);
|
|
292
329
|
}
|
|
293
|
-
addResource(resourceId, name, type, description, applicationId);
|
|
330
|
+
addResource(resourceId, name, type, description, applicationId, framework);
|
|
294
331
|
break;
|
|
295
332
|
}
|
|
296
333
|
|
|
@@ -300,7 +337,7 @@ function main() {
|
|
|
300
337
|
console.error('❌ Missing name');
|
|
301
338
|
process.exit(1);
|
|
302
339
|
}
|
|
303
|
-
removeResource(name);
|
|
340
|
+
removeResource(name, framework);
|
|
304
341
|
break;
|
|
305
342
|
}
|
|
306
343
|
|
|
@@ -308,13 +345,7 @@ function main() {
|
|
|
308
345
|
listResources();
|
|
309
346
|
break;
|
|
310
347
|
}
|
|
311
|
-
|
|
312
|
-
case 'regenerate': {
|
|
313
|
-
const resources = loadResources();
|
|
314
|
-
regenerateClients(resources);
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
|
|
348
|
+
|
|
318
349
|
default: {
|
|
319
350
|
console.error(`❌ Unknown command: ${command}`);
|
|
320
351
|
process.exit(1);
|
package/dist/base.cjs
CHANGED
|
@@ -34,7 +34,8 @@ class BaseResourceClient {
|
|
|
34
34
|
majorJwtToken: config.majorJwtToken,
|
|
35
35
|
applicationId: config.applicationId,
|
|
36
36
|
resourceId: config.resourceId,
|
|
37
|
-
fetch: config.fetch || globalThis.fetch
|
|
37
|
+
fetch: config.fetch || globalThis.fetch,
|
|
38
|
+
getHeaders: config.getHeaders
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
async invokeRaw(payload, invocationKey) {
|
|
@@ -43,12 +44,16 @@ class BaseResourceClient {
|
|
|
43
44
|
payload,
|
|
44
45
|
invocationKey
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
let headers = {
|
|
47
48
|
"Content-Type": "application/json"
|
|
48
49
|
};
|
|
49
50
|
if (this.config.majorJwtToken) {
|
|
50
51
|
headers["x-major-jwt"] = this.config.majorJwtToken;
|
|
51
52
|
}
|
|
53
|
+
if (this.config.getHeaders) {
|
|
54
|
+
const extraHeaders = await this.config.getHeaders();
|
|
55
|
+
headers = { ...headers, ...extraHeaders };
|
|
56
|
+
}
|
|
52
57
|
try {
|
|
53
58
|
const response = await this.config.fetch(url, {
|
|
54
59
|
method: "POST",
|
package/dist/base.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/base.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ResourceInvokePayload,\n InvokeResponse,\n InvokeRequest,\n} from \"./schemas\";\nimport { ResourceInvokeError } from \"./errors\";\n\nexport interface BaseClientConfig {\n baseUrl: string;\n majorJwtToken?: string;\n applicationId: string;\n resourceId: string;\n fetch?: typeof fetch;\n}\n\nexport abstract class BaseResourceClient {\n protected readonly config: {\n baseUrl: string;\n majorJwtToken?: string;\n applicationId: string;\n resourceId: string;\n fetch: typeof fetch;\n };\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, \"\"),\n majorJwtToken: config.majorJwtToken,\n applicationId: config.applicationId,\n resourceId: config.resourceId,\n fetch: config.fetch || globalThis.fetch,\n };\n }\n\n protected async invokeRaw(\n payload: ResourceInvokePayload,\n invocationKey: string,\n ): Promise<InvokeResponse> {\n const url = `${this.config.baseUrl}/internal/apps/v1/${this.config.applicationId}/resource/${this.config.resourceId}/invoke`;\n \n const body: InvokeRequest = {\n payload,\n invocationKey,\n };\n\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAKA;;;;;AAAA,oBAAoC;
|
|
4
|
+
"sourcesContent": ["import type {\n ResourceInvokePayload,\n InvokeResponse,\n InvokeRequest,\n} from \"./schemas\";\nimport { ResourceInvokeError } from \"./errors\";\n\nexport interface BaseClientConfig {\n baseUrl: string;\n majorJwtToken?: string;\n applicationId: string;\n resourceId: string;\n fetch?: typeof fetch;\n /**\n * Optional function to get additional headers (e.g. for auth)\n * Useful for Next.js Server Components where headers() must be called dynamically\n */\n getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;\n}\n\nexport abstract class BaseResourceClient {\n protected readonly config: {\n baseUrl: string;\n majorJwtToken?: string;\n applicationId: string;\n resourceId: string;\n fetch: typeof fetch;\n getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;\n };\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, \"\"),\n majorJwtToken: config.majorJwtToken,\n applicationId: config.applicationId,\n resourceId: config.resourceId,\n fetch: config.fetch || globalThis.fetch,\n getHeaders: config.getHeaders,\n };\n }\n\n protected async invokeRaw(\n payload: ResourceInvokePayload,\n invocationKey: string,\n ): Promise<InvokeResponse> {\n const url = `${this.config.baseUrl}/internal/apps/v1/${this.config.applicationId}/resource/${this.config.resourceId}/invoke`;\n \n const body: InvokeRequest = {\n payload,\n invocationKey,\n };\n\n let headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (this.config.majorJwtToken) {\n headers[\"x-major-jwt\"] = this.config.majorJwtToken;\n }\n\n if (this.config.getHeaders) {\n const extraHeaders = await this.config.getHeaders();\n headers = { ...headers, ...extraHeaders };\n }\n\n try {\n const response = await this.config.fetch(url, {\n method: \"POST\",\n headers,\n credentials: \"include\",\n body: JSON.stringify(body),\n });\n\n const data = await response.json();\n return data as InvokeResponse;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new ResourceInvokeError(`Failed to invoke resource: ${message}`);\n }\n }\n}\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAKA;;;;;AAAA,oBAAoC;AAe9B,MAAgB,mBAAkB;EAfxC,OAewC;;;EACnB;EASnB,YAAY,QAAwB;AAClC,SAAK,SAAS;MACZ,SAAS,OAAO,QAAQ,QAAQ,OAAO,EAAE;MACzC,eAAe,OAAO;MACtB,eAAe,OAAO;MACtB,YAAY,OAAO;MACnB,OAAO,OAAO,SAAS,WAAW;MAClC,YAAY,OAAO;;EAEvB;EAEU,MAAM,UACd,SACA,eAAqB;AAErB,UAAM,MAAM,GAAG,KAAK,OAAO,OAAO,qBAAqB,KAAK,OAAO,aAAa,aAAa,KAAK,OAAO,UAAU;AAEnH,UAAM,OAAsB;MAC1B;MACA;;AAGF,QAAI,UAAkC;MACpC,gBAAgB;;AAGlB,QAAI,KAAK,OAAO,eAAe;AAC7B,cAAQ,aAAa,IAAI,KAAK,OAAO;IACvC;AAEA,QAAI,KAAK,OAAO,YAAY;AAC1B,YAAM,eAAe,MAAM,KAAK,OAAO,WAAU;AACjD,gBAAU,EAAE,GAAG,SAAS,GAAG,aAAY;IACzC;AAEA,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,OAAO,MAAM,KAAK;QAC5C,QAAQ;QACR;QACA,aAAa;QACb,MAAM,KAAK,UAAU,IAAI;OAC1B;AAED,YAAM,OAAO,MAAM,SAAS,KAAI;AAChC,aAAO;IACT,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,YAAM,IAAI,kCAAoB,8BAA8B,OAAO,EAAE;IACvE;EACF;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/base.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface BaseClientConfig {
|
|
|
5
5
|
applicationId: string;
|
|
6
6
|
resourceId: string;
|
|
7
7
|
fetch?: typeof fetch;
|
|
8
|
+
/**
|
|
9
|
+
* Optional function to get additional headers (e.g. for auth)
|
|
10
|
+
* Useful for Next.js Server Components where headers() must be called dynamically
|
|
11
|
+
*/
|
|
12
|
+
getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
8
13
|
}
|
|
9
14
|
export declare abstract class BaseResourceClient {
|
|
10
15
|
protected readonly config: {
|
|
@@ -13,6 +18,7 @@ export declare abstract class BaseResourceClient {
|
|
|
13
18
|
applicationId: string;
|
|
14
19
|
resourceId: string;
|
|
15
20
|
fetch: typeof fetch;
|
|
21
|
+
getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
16
22
|
};
|
|
17
23
|
constructor(config: BaseClientConfig);
|
|
18
24
|
protected invokeRaw(payload: ResourceInvokePayload, invocationKey: string): Promise<InvokeResponse>;
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EAEf,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EAEf,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7E;AAED,8BAAsB,kBAAkB;IACtC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC7E,CAAC;gBAEU,MAAM,EAAE,gBAAgB;cAWpB,SAAS,CACvB,OAAO,EAAE,qBAAqB,EAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,CAAC;CAoC3B"}
|
package/dist/base.js
CHANGED
|
@@ -8,6 +8,7 @@ export class BaseResourceClient {
|
|
|
8
8
|
applicationId: config.applicationId,
|
|
9
9
|
resourceId: config.resourceId,
|
|
10
10
|
fetch: config.fetch || globalThis.fetch,
|
|
11
|
+
getHeaders: config.getHeaders,
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
async invokeRaw(payload, invocationKey) {
|
|
@@ -16,12 +17,16 @@ export class BaseResourceClient {
|
|
|
16
17
|
payload,
|
|
17
18
|
invocationKey,
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
let headers = {
|
|
20
21
|
"Content-Type": "application/json",
|
|
21
22
|
};
|
|
22
23
|
if (this.config.majorJwtToken) {
|
|
23
24
|
headers["x-major-jwt"] = this.config.majorJwtToken;
|
|
24
25
|
}
|
|
26
|
+
if (this.config.getHeaders) {
|
|
27
|
+
const extraHeaders = await this.config.getHeaders();
|
|
28
|
+
headers = { ...headers, ...extraHeaders };
|
|
29
|
+
}
|
|
25
30
|
try {
|
|
26
31
|
const response = await this.config.fetch(url, {
|
|
27
32
|
method: "POST",
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAe/C,MAAM,OAAgB,kBAAkB;IACnB,MAAM,CAOvB;IAEF,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YAC1C,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,SAAS,CACvB,OAA8B,EAC9B,aAAqB;QAErB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,qBAAqB,IAAI,CAAC,MAAM,CAAC,aAAa,aAAa,IAAI,CAAC,MAAM,CAAC,UAAU,SAAS,CAAC;QAE7H,MAAM,IAAI,GAAkB;YAC1B,OAAO;YACP,aAAa;SACd,CAAC;QAEF,IAAI,OAAO,GAA2B;YACpC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC9B,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QACrD,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACpD,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC5C,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;aAC3B,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAsB,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,mBAAmB,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED