@open-wa/wa-automate 4.37.3 → 4.37.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.
@@ -1,5 +1,51 @@
1
- import { getConfigWithCase } from '../src/utils/configSchema'
2
1
  import { writeJsonSync } from 'fs-extra';
2
+ import { createGenerator } from "ts-json-schema-generator";
3
+ import {paramCase, constantCase} from "change-case";
4
+
5
+ const defaultConfig = {
6
+ path: "../api/model/config.ts",
7
+ tsconfig: "../../tsconfig.json",
8
+ type: "ConfigObject",
9
+ };
10
+
11
+ const getConfigWithCase = (config ?: {
12
+ path: string,
13
+ tsconfig: string,
14
+ type: string,
15
+ }) : unknown => {
16
+ if(!config) config = defaultConfig;
17
+ const schema = createGenerator(config).createSchema(config.type);
18
+ const ignoredConfigs = [
19
+ 'useStealth',
20
+ 'chromiumArgs',
21
+ 'executablePath',
22
+ 'skipBrokenMethodsCheck',
23
+ 'inDocker',
24
+ 'autoRefresh',
25
+ 'bypassCSP',
26
+ 'throwErrorOnTosBlock',
27
+ 'killProcessOnBrowserClose',
28
+ 'cloudUploadOptions',
29
+ 'qrRefreshS'
30
+ ]
31
+ //only convert simple types
32
+ // const configs = Object.keys(schema.definitions.ConfigObject.properties).map(key=>({...schema.definitions.ConfigObject.properties[key],key})).filter(({type,key})=>type&&!ignoredConfigs.includes(key));
33
+ const configs = Object.entries((schema.definitions.ConfigObject as any).properties).map(([key,entry] : any)=>{
34
+ if(key==='sessionData') {
35
+ entry.type = 'string';
36
+ entry.description = 'The base64 encoded sessionData used to restore a session.'
37
+ delete entry.anyOf;
38
+ }
39
+ if(key==='licenseKey') {
40
+ entry.type = 'string';
41
+ entry.description = 'The license key to use with the session.'
42
+ delete entry.anyOf;
43
+ }
44
+ return {...entry,key}
45
+ }).filter(({type,key})=>type&&!ignoredConfigs.includes(key));
46
+ const configWithCases = configs.map(o=>({env:`WA_${constantCase(o.key)}`,p:paramCase(o.key),...o}))
47
+ return configWithCases;
48
+ }
3
49
 
4
50
  const configWithCases = getConfigWithCase({
5
51
  path: "../src/api/model/config.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.37.3",
3
+ "version": "4.37.4",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -89,6 +89,7 @@
89
89
  "husky": "^7.0.0",
90
90
  "line-reader": "^0.4.0",
91
91
  "marked": "^4.0.10",
92
+ "ts-json-schema-generator": "^0.97.0",
92
93
  "node-emoji": "^1.10.0",
93
94
  "onchange": "^7.0.2",
94
95
  "precise-commits": "^1.0.2",
@@ -163,7 +164,6 @@
163
164
  "terminal-link": "^2.1.1",
164
165
  "terminate": "^2.5.0",
165
166
  "traverse": "^0.6.6",
166
- "ts-json-schema-generator": "^0.97.0",
167
167
  "ts-morph": "^12.0.0",
168
168
  "type-fest": "^1.1.1",
169
169
  "update-notifier": "^5.0.0",
@@ -1,5 +0,0 @@
1
- export declare const getConfigWithCase: (config?: {
2
- path: string;
3
- tsconfig: string;
4
- type: string;
5
- }) => unknown;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfigWithCase = void 0;
4
- const ts_json_schema_generator_1 = require("ts-json-schema-generator");
5
- const change_case_1 = require("change-case");
6
- const defaultConfig = {
7
- path: "../api/model/config.ts",
8
- tsconfig: "../../tsconfig.json",
9
- type: "ConfigObject",
10
- };
11
- const getConfigWithCase = (config) => {
12
- if (!config)
13
- config = defaultConfig;
14
- const schema = (0, ts_json_schema_generator_1.createGenerator)(config).createSchema(config.type);
15
- const ignoredConfigs = [
16
- 'useStealth',
17
- 'chromiumArgs',
18
- 'executablePath',
19
- 'skipBrokenMethodsCheck',
20
- 'inDocker',
21
- 'autoRefresh',
22
- 'bypassCSP',
23
- 'throwErrorOnTosBlock',
24
- 'killProcessOnBrowserClose',
25
- 'cloudUploadOptions',
26
- 'qrRefreshS'
27
- ];
28
- //only convert simple types
29
- // const configs = Object.keys(schema.definitions.ConfigObject.properties).map(key=>({...schema.definitions.ConfigObject.properties[key],key})).filter(({type,key})=>type&&!ignoredConfigs.includes(key));
30
- const configs = Object.entries(schema.definitions.ConfigObject.properties).map(([key, entry]) => {
31
- if (key === 'sessionData') {
32
- entry.type = 'string';
33
- entry.description = 'The base64 encoded sessionData used to restore a session.';
34
- delete entry.anyOf;
35
- }
36
- if (key === 'licenseKey') {
37
- entry.type = 'string';
38
- entry.description = 'The license key to use with the session.';
39
- delete entry.anyOf;
40
- }
41
- return Object.assign(Object.assign({}, entry), { key });
42
- }).filter(({ type, key }) => type && !ignoredConfigs.includes(key));
43
- const configWithCases = configs.map(o => (Object.assign({ env: `WA_${(0, change_case_1.constantCase)(o.key)}`, p: (0, change_case_1.paramCase)(o.key) }, o)));
44
- return configWithCases;
45
- };
46
- exports.getConfigWithCase = getConfigWithCase;