@json-to-office/jto 0.6.0 → 0.7.0
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/cli.js +29 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -3405,6 +3405,18 @@ import chalk9 from "chalk";
|
|
|
3405
3405
|
init_esm_shims();
|
|
3406
3406
|
import * as path2 from "path";
|
|
3407
3407
|
import * as fs from "fs";
|
|
3408
|
+
function buildServicesFromEnv() {
|
|
3409
|
+
const serverUrl = process.env.HIGHCHARTS_SERVER_URL;
|
|
3410
|
+
const apiKey = process.env.HIGHCHARTS_API_KEY;
|
|
3411
|
+
const apiKeyHeader = process.env.HIGHCHARTS_API_KEY_HEADER ?? "x-api-key";
|
|
3412
|
+
if (!serverUrl && !apiKey) return void 0;
|
|
3413
|
+
return {
|
|
3414
|
+
highcharts: {
|
|
3415
|
+
serverUrl,
|
|
3416
|
+
...apiKey && { headers: { [apiKeyHeader]: apiKey } }
|
|
3417
|
+
}
|
|
3418
|
+
};
|
|
3419
|
+
}
|
|
3408
3420
|
var DocxFormatAdapter = class {
|
|
3409
3421
|
name = "docx";
|
|
3410
3422
|
extension = ".docx";
|
|
@@ -3414,21 +3426,25 @@ var DocxFormatAdapter = class {
|
|
|
3414
3426
|
const core = await import("@json-to-office/core-docx");
|
|
3415
3427
|
const docDefinition = typeof json === "string" ? JSON.parse(json) : json;
|
|
3416
3428
|
const customThemes = await this.loadCustomThemes(options);
|
|
3429
|
+
const services = buildServicesFromEnv();
|
|
3417
3430
|
return await core.generateBufferFromJson(docDefinition, {
|
|
3418
|
-
customThemes
|
|
3431
|
+
customThemes,
|
|
3432
|
+
services
|
|
3419
3433
|
});
|
|
3420
3434
|
}
|
|
3421
3435
|
async createGenerator(plugins, options) {
|
|
3422
3436
|
const core = await import("@json-to-office/core-docx");
|
|
3423
3437
|
const hasPlugins = plugins.length > 0;
|
|
3424
3438
|
const pluginNames = plugins.map((p) => p.name);
|
|
3439
|
+
const services = buildServicesFromEnv();
|
|
3425
3440
|
if (!hasPlugins) {
|
|
3426
3441
|
return {
|
|
3427
3442
|
generateBuffer: async (document) => {
|
|
3428
3443
|
const docDefinition = typeof document === "string" ? JSON.parse(document) : document;
|
|
3429
3444
|
const customThemes2 = await this.loadCustomThemes(options);
|
|
3430
3445
|
return await core.generateBufferFromJson(docDefinition, {
|
|
3431
|
-
customThemes: customThemes2
|
|
3446
|
+
customThemes: customThemes2,
|
|
3447
|
+
services
|
|
3432
3448
|
});
|
|
3433
3449
|
},
|
|
3434
3450
|
hasPlugins: false,
|
|
@@ -3440,7 +3456,8 @@ var DocxFormatAdapter = class {
|
|
|
3440
3456
|
let generator = core.createDocumentGenerator({
|
|
3441
3457
|
theme,
|
|
3442
3458
|
customThemes,
|
|
3443
|
-
debug: process.env.DEBUG === "true"
|
|
3459
|
+
debug: process.env.DEBUG === "true",
|
|
3460
|
+
services
|
|
3444
3461
|
});
|
|
3445
3462
|
for (const plugin of plugins) {
|
|
3446
3463
|
generator = generator.addComponent(plugin);
|
|
@@ -3625,21 +3642,25 @@ var PptxFormatAdapter = class {
|
|
|
3625
3642
|
const core = await import("@json-to-office/core-pptx");
|
|
3626
3643
|
const docDefinition = typeof json === "string" ? JSON.parse(json) : json;
|
|
3627
3644
|
const customThemes = await this.loadCustomThemes(options);
|
|
3645
|
+
const services = buildServicesFromEnv();
|
|
3628
3646
|
return await core.generateBufferFromJson(docDefinition, {
|
|
3629
|
-
customThemes
|
|
3647
|
+
customThemes,
|
|
3648
|
+
services
|
|
3630
3649
|
});
|
|
3631
3650
|
}
|
|
3632
3651
|
async createGenerator(plugins, options) {
|
|
3633
3652
|
const core = await import("@json-to-office/core-pptx");
|
|
3634
3653
|
const hasPlugins = plugins.length > 0;
|
|
3635
3654
|
const pluginNames = plugins.map((p) => p.name);
|
|
3655
|
+
const services = buildServicesFromEnv();
|
|
3636
3656
|
if (!hasPlugins) {
|
|
3637
3657
|
return {
|
|
3638
3658
|
generateBuffer: async (document) => {
|
|
3639
3659
|
const docDefinition = typeof document === "string" ? JSON.parse(document) : document;
|
|
3640
3660
|
const customThemes2 = await this.loadCustomThemes(options);
|
|
3641
3661
|
return await core.generateBufferFromJson(docDefinition, {
|
|
3642
|
-
customThemes: customThemes2
|
|
3662
|
+
customThemes: customThemes2,
|
|
3663
|
+
services
|
|
3643
3664
|
});
|
|
3644
3665
|
},
|
|
3645
3666
|
hasPlugins: false,
|
|
@@ -3651,7 +3672,8 @@ var PptxFormatAdapter = class {
|
|
|
3651
3672
|
let generator = core.createPresentationGenerator({
|
|
3652
3673
|
theme,
|
|
3653
3674
|
customThemes,
|
|
3654
|
-
debug: process.env.DEBUG === "true"
|
|
3675
|
+
debug: process.env.DEBUG === "true",
|
|
3676
|
+
services
|
|
3655
3677
|
});
|
|
3656
3678
|
for (const plugin of plugins) {
|
|
3657
3679
|
generator = generator.addComponent(plugin);
|
|
@@ -5856,7 +5878,7 @@ ${chalk8.cyan("Health:")} ${url}/health
|
|
|
5856
5878
|
}
|
|
5857
5879
|
|
|
5858
5880
|
// src/cli.ts
|
|
5859
|
-
var PACKAGE_VERSION = true ? "0.
|
|
5881
|
+
var PACKAGE_VERSION = true ? "0.7.0" : "dev-mode";
|
|
5860
5882
|
function registerFormatCommands(parent, adapter) {
|
|
5861
5883
|
parent.addCommand(createGenerateCommand(adapter));
|
|
5862
5884
|
parent.addCommand(createValidateCommand(adapter));
|