apify-schema-tools 2.0.4 → 2.0.5
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/.cspell/custom-dictionary.txt +1 -0
- package/.husky/pre-commit +0 -8
- package/CHANGELOG.md +6 -0
- package/biome.json +121 -9
- package/dist/apify-schema-tools.d.ts +1 -0
- package/dist/apify-schema-tools.d.ts.map +1 -1
- package/dist/apify-schema-tools.js +125 -106
- package/dist/apify-schema-tools.js.map +1 -1
- package/dist/apify.d.ts +1 -1
- package/dist/apify.d.ts.map +1 -1
- package/dist/apify.js +4 -2
- package/dist/apify.js.map +1 -1
- package/dist/configuration.d.ts +17 -16
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +8 -1
- package/dist/configuration.js.map +1 -1
- package/dist/json-schemas.d.ts.map +1 -1
- package/dist/json-schemas.js +31 -21
- package/dist/json-schemas.js.map +1 -1
- package/dist/typescript.d.ts.map +1 -1
- package/dist/typescript.js +242 -189
- package/dist/typescript.js.map +1 -1
- package/package.json +16 -5
- package/samples/all-defaults/src/generated/input-utils.ts +3 -1
- package/samples/deep-merged-schemas/src/generated/input-utils.ts +3 -1
- package/samples/merged-schemas/src/generated/input-utils.ts +3 -1
- package/samples/package-json-config/package.json +8 -2
- package/samples/package-json-config/src/custom-generated/input-utils.ts +3 -1
- package/src/apify-schema-tools.ts +171 -150
- package/src/apify.ts +6 -4
- package/src/configuration.ts +14 -5
- package/src/json-schemas.ts +44 -22
- package/src/typescript.ts +299 -199
- package/test/apify-schema-tools.test.ts +47 -123
- package/test/apify.test.ts +8 -6
- package/test/common.ts +2 -2
- package/test/configuration.test.ts +1 -1
- package/test/json-schemas.test.ts +1 -2
- package/test/typescript.test.ts +3 -5
- package/tsconfig.json +1 -1
package/.husky/pre-commit
CHANGED
|
@@ -20,14 +20,6 @@ cd samples/package-json-config
|
|
|
20
20
|
node $EXEC_PATH check
|
|
21
21
|
cd ../..
|
|
22
22
|
|
|
23
|
-
echo "Checking for .only() in test files..."
|
|
24
|
-
|
|
25
|
-
# Check for .only( in test files
|
|
26
|
-
if grep -r "\.only(" --include="*.test.ts" .; then
|
|
27
|
-
echo "Error: found \".only(\" in test files. Please remove focused tests before committing."
|
|
28
|
-
exit 1
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
23
|
echo "Running tests..."
|
|
32
24
|
|
|
33
25
|
npm test
|
package/CHANGELOG.md
CHANGED
package/biome.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.1.0/schema.json",
|
|
3
3
|
"vcs": {
|
|
4
4
|
"enabled": true,
|
|
5
5
|
"clientKind": "git",
|
|
@@ -7,25 +7,137 @@
|
|
|
7
7
|
},
|
|
8
8
|
"files": {
|
|
9
9
|
"ignoreUnknown": false,
|
|
10
|
-
"
|
|
10
|
+
"includes": ["**"]
|
|
11
11
|
},
|
|
12
12
|
"formatter": {
|
|
13
13
|
"enabled": true,
|
|
14
14
|
"indentStyle": "tab",
|
|
15
15
|
"lineWidth": 120
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"javascript": {
|
|
18
|
+
"formatter": {
|
|
19
|
+
"quoteStyle": "double"
|
|
20
|
+
}
|
|
19
21
|
},
|
|
22
|
+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
20
23
|
"linter": {
|
|
21
24
|
"enabled": true,
|
|
25
|
+
"domains": {
|
|
26
|
+
"test": "all",
|
|
27
|
+
"project": "all"
|
|
28
|
+
},
|
|
22
29
|
"rules": {
|
|
23
|
-
"recommended": true
|
|
30
|
+
"recommended": true,
|
|
31
|
+
"complexity": {
|
|
32
|
+
"noExcessiveCognitiveComplexity": "on",
|
|
33
|
+
"noExcessiveNestedTestSuites": "on",
|
|
34
|
+
"noForEach": "on",
|
|
35
|
+
"noUselessStringConcat": "on",
|
|
36
|
+
"noVoid": "on",
|
|
37
|
+
"useSimplifiedLogicExpression": "on",
|
|
38
|
+
"useWhile": "on"
|
|
39
|
+
},
|
|
40
|
+
"correctness": {
|
|
41
|
+
"noPrivateImports": "on",
|
|
42
|
+
"noUndeclaredDependencies": "on",
|
|
43
|
+
"noUndeclaredVariables": "on"
|
|
44
|
+
},
|
|
45
|
+
"nursery": {
|
|
46
|
+
"noAwaitInLoop": "on",
|
|
47
|
+
"noBitwiseOperators": "on",
|
|
48
|
+
"noConstantBinaryExpression": "on",
|
|
49
|
+
"noExcessiveLinesPerFunction": "on",
|
|
50
|
+
"noImportCycles": "on",
|
|
51
|
+
"noMagicNumbers": "on",
|
|
52
|
+
"noShadow": "on",
|
|
53
|
+
"noUnassignedVariables": "on",
|
|
54
|
+
"noUselessBackrefInRegex": "on",
|
|
55
|
+
"useAdjacentGetterSetter": "on",
|
|
56
|
+
"useIterableCallbackReturn": "on",
|
|
57
|
+
"useJsonImportAttribute": "on",
|
|
58
|
+
"useNumericSeparators": "on",
|
|
59
|
+
"useObjectSpread": "on"
|
|
60
|
+
},
|
|
61
|
+
"performance": {
|
|
62
|
+
"noBarrelFile": "on",
|
|
63
|
+
"noDelete": "on",
|
|
64
|
+
"noNamespaceImport": "on",
|
|
65
|
+
"noReExportAll": "on",
|
|
66
|
+
"useTopLevelRegex": "on"
|
|
67
|
+
},
|
|
68
|
+
"style": {
|
|
69
|
+
"noCommonJs": "on",
|
|
70
|
+
"noDefaultExport": "on",
|
|
71
|
+
"noDoneCallback": "on",
|
|
72
|
+
"noEnum": "on",
|
|
73
|
+
"noExportedImports": "on",
|
|
74
|
+
"noInferrableTypes": "on",
|
|
75
|
+
"noNamespace": "on",
|
|
76
|
+
"noNegationElse": "on",
|
|
77
|
+
"noNestedTernary": "on",
|
|
78
|
+
"noParameterAssign": "on",
|
|
79
|
+
"noParameterProperties": "on",
|
|
80
|
+
"noProcessEnv": "on",
|
|
81
|
+
"noUnusedTemplateLiteral": "on",
|
|
82
|
+
"noUselessElse": "on",
|
|
83
|
+
"noYodaExpression": "on",
|
|
84
|
+
"useAsConstAssertion": "on",
|
|
85
|
+
"useAtIndex": "on",
|
|
86
|
+
"useBlockStatements": "on",
|
|
87
|
+
"useCollapsedElseIf": "on",
|
|
88
|
+
"useCollapsedIf": "on",
|
|
89
|
+
"useConsistentArrayType": "on",
|
|
90
|
+
"useConsistentBuiltinInstantiation": "on",
|
|
91
|
+
"useConsistentMemberAccessibility": "on",
|
|
92
|
+
"useDefaultParameterLast": "on",
|
|
93
|
+
"useDefaultSwitchClause": "on",
|
|
94
|
+
"useExplicitLengthCheck": "on",
|
|
95
|
+
"useFilenamingConvention": "on",
|
|
96
|
+
"useForOf": "on",
|
|
97
|
+
"useNamingConvention": "on",
|
|
98
|
+
"useNodeAssertStrict": "on",
|
|
99
|
+
"useNumberNamespace": "on",
|
|
100
|
+
"useShorthandAssign": "on",
|
|
101
|
+
"useSingleVarDeclarator": "on",
|
|
102
|
+
"useThrowNewError": "on",
|
|
103
|
+
"useThrowOnlyError": "on",
|
|
104
|
+
"useTrimStartEnd": "on"
|
|
105
|
+
},
|
|
106
|
+
"suspicious": {
|
|
107
|
+
"noDuplicateTestHooks": "on",
|
|
108
|
+
"noEmptyBlockStatements": "on",
|
|
109
|
+
"noEvolvingTypes": "on",
|
|
110
|
+
"noExportsInTest": "on",
|
|
111
|
+
"noFocusedTests": "on",
|
|
112
|
+
"noMisplacedAssertion": "on",
|
|
113
|
+
"useNumberToFixedDigitsArgument": "on"
|
|
114
|
+
}
|
|
24
115
|
}
|
|
25
116
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"
|
|
117
|
+
"overrides": [
|
|
118
|
+
{
|
|
119
|
+
"includes": ["test/**"],
|
|
120
|
+
"linter": {
|
|
121
|
+
"rules": {
|
|
122
|
+
"nursery": {
|
|
123
|
+
"noExcessiveLinesPerFunction": "off",
|
|
124
|
+
"noMagicNumbers": "off"
|
|
125
|
+
},
|
|
126
|
+
"style": {
|
|
127
|
+
"useNamingConvention": "off"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"includes": ["samples/**"],
|
|
134
|
+
"linter": {
|
|
135
|
+
"rules": {
|
|
136
|
+
"correctness": {
|
|
137
|
+
"noUndeclaredDependencies": "off"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
29
141
|
}
|
|
30
|
-
|
|
142
|
+
]
|
|
31
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apify-schema-tools.d.ts","sourceRoot":"","sources":["../src/apify-schema-tools.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"apify-schema-tools.d.ts","sourceRoot":"","sources":["../src/apify-schema-tools.ts"],"names":[],"mappings":";AAEA,oGAAoG"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/** biome-ignore-all lint/style/useNamingConvention: the package `argparse` uses snake_case names */
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
import { ArgumentDefaultsHelpFormatter, ArgumentParser } from "argparse";
|
|
5
|
-
import { ACTOR_CONFIG_PATH, DATASET_SCHEMA_FIELD, filterValidInputSchemaProperties,
|
|
6
|
+
import { ACTOR_CONFIG_PATH, DATASET_SCHEMA_FIELD, filterValidInputSchemaProperties, generateInputDefaultsTsFileContent, getPathRelativeToActorConfig, } from "./apify.js";
|
|
6
7
|
import { addCommonCLIArgs, parseConfigurationFromFileOrDefault, writeConfigurationToPackageJson, } from "./configuration.js";
|
|
7
8
|
import { readFile, writeFile } from "./filesystem.js";
|
|
8
9
|
import { compareSchemas, mergeObjectSchemas, readJsonSchema, readJsonSchemaField, writeJsonSchema, writeSchemaToField, } from "./json-schemas.js";
|
|
@@ -35,6 +36,44 @@ initParser.add_argument("--only-config-file", {
|
|
|
35
36
|
action: "store_true",
|
|
36
37
|
default: false,
|
|
37
38
|
});
|
|
39
|
+
function initializeInputSchema(args) {
|
|
40
|
+
if (!existsSync(args.input_schema)) {
|
|
41
|
+
throw new Error("The current Actor does not have an input schema.");
|
|
42
|
+
}
|
|
43
|
+
const inputSchema = readJsonSchema(args.input_schema);
|
|
44
|
+
writeJsonSchema(args.src_input, inputSchema);
|
|
45
|
+
console.log(`Input schema initialized at ${args.src_input}`);
|
|
46
|
+
if (args.add_input) {
|
|
47
|
+
writeJsonSchema(args.add_input, { type: "object", properties: {} });
|
|
48
|
+
console.log(`Additional input schema initialized at ${args.add_input}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function initializeDatasetSchema(args) {
|
|
52
|
+
if (!existsSync(ACTOR_CONFIG_PATH)) {
|
|
53
|
+
throw new Error(`The current Actor does not have an ${ACTOR_CONFIG_PATH} configuration file.`);
|
|
54
|
+
}
|
|
55
|
+
const actorConfig = JSON.parse(readFile(ACTOR_CONFIG_PATH));
|
|
56
|
+
const relativeDatasetPath = getPathRelativeToActorConfig(args.dataset_schema);
|
|
57
|
+
if (actorConfig.storages?.dataset !== relativeDatasetPath) {
|
|
58
|
+
writeFile(ACTOR_CONFIG_PATH, JSON.stringify({
|
|
59
|
+
...actorConfig,
|
|
60
|
+
storages: {
|
|
61
|
+
...actorConfig.storages,
|
|
62
|
+
dataset: relativeDatasetPath,
|
|
63
|
+
},
|
|
64
|
+
}, null, 4));
|
|
65
|
+
console.log(`Updated ${ACTOR_CONFIG_PATH} to use the dataset schema at ${args.dataset_schema}`);
|
|
66
|
+
}
|
|
67
|
+
if (!existsSync(args.dataset_schema)) {
|
|
68
|
+
writeFile(args.dataset_schema, JSON.stringify({
|
|
69
|
+
actorSpecification: 1,
|
|
70
|
+
[DATASET_SCHEMA_FIELD]: { type: "object", properties: {} },
|
|
71
|
+
}, null, 4));
|
|
72
|
+
console.log(`Dataset schema initialized at ${args.dataset_schema}`);
|
|
73
|
+
}
|
|
74
|
+
const datasetItemSchema = readJsonSchemaField(args.dataset_schema, DATASET_SCHEMA_FIELD);
|
|
75
|
+
writeJsonSchema(args.src_dataset, datasetItemSchema);
|
|
76
|
+
}
|
|
38
77
|
function init(args) {
|
|
39
78
|
if (args.only_config_file && args.no_config_file) {
|
|
40
79
|
throw new Error("The options --only-config-file and --no-config-file were defined together: doing nothing.");
|
|
@@ -49,42 +88,10 @@ function init(args) {
|
|
|
49
88
|
return;
|
|
50
89
|
}
|
|
51
90
|
if (args.input.includes("input")) {
|
|
52
|
-
|
|
53
|
-
throw new Error("The current Actor does not have an input schema.");
|
|
54
|
-
}
|
|
55
|
-
const inputSchema = readJsonSchema(args.input_schema);
|
|
56
|
-
writeJsonSchema(args.src_input, inputSchema);
|
|
57
|
-
console.log(`Input schema initialized at ${args.src_input}`);
|
|
58
|
-
if (args.add_input) {
|
|
59
|
-
writeJsonSchema(args.add_input, { type: "object", properties: {} });
|
|
60
|
-
console.log(`Additional input schema initialized at ${args.add_input}`);
|
|
61
|
-
}
|
|
91
|
+
initializeInputSchema(args);
|
|
62
92
|
}
|
|
63
93
|
if (args.input.includes("dataset")) {
|
|
64
|
-
|
|
65
|
-
throw new Error(`The current Actor does not have an ${ACTOR_CONFIG_PATH} configuration file.`);
|
|
66
|
-
}
|
|
67
|
-
const actorConfig = JSON.parse(readFile(ACTOR_CONFIG_PATH));
|
|
68
|
-
const relativeDatasetPath = getPathRelativeToActorConfig(args.dataset_schema);
|
|
69
|
-
if (actorConfig.storages?.dataset !== relativeDatasetPath) {
|
|
70
|
-
writeFile(ACTOR_CONFIG_PATH, JSON.stringify({
|
|
71
|
-
...actorConfig,
|
|
72
|
-
storages: {
|
|
73
|
-
...actorConfig.storages,
|
|
74
|
-
dataset: relativeDatasetPath,
|
|
75
|
-
},
|
|
76
|
-
}, null, 4));
|
|
77
|
-
console.log(`Updated ${ACTOR_CONFIG_PATH} to use the dataset schema at ${args.dataset_schema}`);
|
|
78
|
-
}
|
|
79
|
-
if (!existsSync(args.dataset_schema)) {
|
|
80
|
-
writeFile(args.dataset_schema, JSON.stringify({
|
|
81
|
-
actorSpecification: 1,
|
|
82
|
-
[DATASET_SCHEMA_FIELD]: { type: "object", properties: {} },
|
|
83
|
-
}, null, 4));
|
|
84
|
-
console.log(`Dataset schema initialized at ${args.dataset_schema}`);
|
|
85
|
-
}
|
|
86
|
-
const datasetItemSchema = readJsonSchemaField(args.dataset_schema, DATASET_SCHEMA_FIELD);
|
|
87
|
-
writeJsonSchema(args.src_dataset, datasetItemSchema);
|
|
94
|
+
initializeDatasetSchema(args);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
initParser.set_defaults({ func: init });
|
|
@@ -95,38 +102,44 @@ const syncParser = subparsers.add_parser("sync", {
|
|
|
95
102
|
addCommonCLIArgs(syncParser, configuration);
|
|
96
103
|
syncParser.add_argument(DEEP_MERGE_PARAM, DEEP_MERGE_OPTIONS);
|
|
97
104
|
syncParser.add_argument("--include-input-utils", {
|
|
98
|
-
help: "include input utilities in the generated TypeScript files:
|
|
105
|
+
help: "include input utilities in the generated TypeScript files: 'input' input and 'ts-types' output are required",
|
|
99
106
|
choices: ["true", "false"],
|
|
100
107
|
default: "true",
|
|
101
108
|
});
|
|
109
|
+
function handleInputSync(args) {
|
|
110
|
+
let inputSchema = readJsonSchema(args.src_input);
|
|
111
|
+
if (args.add_input) {
|
|
112
|
+
inputSchema = mergeObjectSchemas(inputSchema, readJsonSchema(args.add_input), args.deep_merge);
|
|
113
|
+
}
|
|
114
|
+
if (args.output.includes("json-schemas")) {
|
|
115
|
+
writeJsonSchema(args.input_schema, filterValidInputSchemaProperties(inputSchema));
|
|
116
|
+
}
|
|
117
|
+
if (args.output.includes("ts-types")) {
|
|
118
|
+
writeTypeScriptFile(join(args.output_ts_dir, "input.ts"), serializeTypeScriptInterface("Input", jsonSchemaToTypeScriptInterface(inputSchema)));
|
|
119
|
+
if (args.include_input_utils === "true") {
|
|
120
|
+
writeTypeScriptFile(join(args.output_ts_dir, "input-utils.ts"), generateInputDefaultsTsFileContent(inputSchema));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function handleDatasetSync(args) {
|
|
125
|
+
let datasetSchema = readJsonSchema(args.src_dataset);
|
|
126
|
+
if (args.add_dataset) {
|
|
127
|
+
datasetSchema = mergeObjectSchemas(datasetSchema, readJsonSchema(args.add_dataset), args.deep_merge);
|
|
128
|
+
}
|
|
129
|
+
if (args.output.includes("json-schemas")) {
|
|
130
|
+
writeSchemaToField(args.dataset_schema, datasetSchema, DATASET_SCHEMA_FIELD);
|
|
131
|
+
}
|
|
132
|
+
if (args.output.includes("ts-types")) {
|
|
133
|
+
writeTypeScriptFile(join(args.output_ts_dir, "dataset.ts"), serializeTypeScriptInterface("DatasetItem", jsonSchemaToTypeScriptInterface(datasetSchema)));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
102
136
|
function sync(args) {
|
|
103
137
|
console.log("Syncing schemas...");
|
|
104
138
|
if (args.input.includes("input")) {
|
|
105
|
-
|
|
106
|
-
if (args.add_input) {
|
|
107
|
-
inputSchema = mergeObjectSchemas(inputSchema, readJsonSchema(args.add_input), args.deep_merge);
|
|
108
|
-
}
|
|
109
|
-
if (args.output.includes("json-schemas")) {
|
|
110
|
-
writeJsonSchema(args.input_schema, filterValidInputSchemaProperties(inputSchema));
|
|
111
|
-
}
|
|
112
|
-
if (args.output.includes("ts-types")) {
|
|
113
|
-
writeTypeScriptFile(join(args.output_ts_dir, "input.ts"), serializeTypeScriptInterface("Input", jsonSchemaToTypeScriptInterface(inputSchema)));
|
|
114
|
-
if (args.include_input_utils === "true") {
|
|
115
|
-
writeTypeScriptFile(join(args.output_ts_dir, "input-utils.ts"), generateInputDefaultsTSFileContent(inputSchema));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
139
|
+
handleInputSync(args);
|
|
118
140
|
}
|
|
119
141
|
if (args.input.includes("dataset")) {
|
|
120
|
-
|
|
121
|
-
if (args.add_dataset) {
|
|
122
|
-
datasetSchema = mergeObjectSchemas(datasetSchema, readJsonSchema(args.add_dataset), args.deep_merge);
|
|
123
|
-
}
|
|
124
|
-
if (args.output.includes("json-schemas")) {
|
|
125
|
-
writeSchemaToField(args.dataset_schema, datasetSchema, DATASET_SCHEMA_FIELD);
|
|
126
|
-
}
|
|
127
|
-
if (args.output.includes("ts-types")) {
|
|
128
|
-
writeTypeScriptFile(join(args.output_ts_dir, "dataset.ts"), serializeTypeScriptInterface("DatasetItem", jsonSchemaToTypeScriptInterface(datasetSchema)));
|
|
129
|
-
}
|
|
142
|
+
handleDatasetSync(args);
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
syncParser.set_defaults({ func: sync });
|
|
@@ -141,60 +154,66 @@ checkParser.add_argument("--ignore-descriptions", {
|
|
|
141
154
|
action: "store_true",
|
|
142
155
|
default: false,
|
|
143
156
|
});
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
process.exit(1);
|
|
157
|
-
}
|
|
157
|
+
function checkInputSchemas(args) {
|
|
158
|
+
let sourceInputSchema = readJsonSchema(args.src_input);
|
|
159
|
+
if (args.add_input) {
|
|
160
|
+
sourceInputSchema = mergeObjectSchemas(sourceInputSchema, readJsonSchema(args.add_input), args.deep_merge);
|
|
161
|
+
}
|
|
162
|
+
const generatedInputSchema = filterValidInputSchemaProperties(sourceInputSchema);
|
|
163
|
+
if (args.output.includes("json-schemas")) {
|
|
164
|
+
const outputInputSchema = readJsonSchema(args.input_schema);
|
|
165
|
+
const isInputSchemaCoherent = compareSchemas(generatedInputSchema, outputInputSchema, args.ignore_descriptions);
|
|
166
|
+
if (!isInputSchemaCoherent) {
|
|
167
|
+
console.error("Input schema validation failed: the input schema does not match the source schema.");
|
|
168
|
+
process.exit(1);
|
|
158
169
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
}
|
|
171
|
+
if (args.output.includes("ts-types")) {
|
|
172
|
+
const inputTsContent = readFile(join(args.output_ts_dir, "input.ts"));
|
|
173
|
+
const inputTsInterface = parseTypeScriptInterface(removeTypeScriptHeader(inputTsContent));
|
|
174
|
+
const sourceInputTsInterface = jsonSchemaToTypeScriptInterface(sourceInputSchema);
|
|
175
|
+
const isTsInputCoherent = compareTypescriptInterfaces(sourceInputTsInterface, inputTsInterface, args.ignore_descriptions);
|
|
176
|
+
if (!isTsInputCoherent) {
|
|
177
|
+
console.error("Input TypeScript interface validation failed: the TypeScript interface does not match the source schema.");
|
|
178
|
+
process.exit(1);
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
}
|
|
182
|
+
function checkDatasetSchemas(args) {
|
|
183
|
+
let sourceDatasetSchema = readJsonSchema(args.src_dataset);
|
|
184
|
+
if (args.add_dataset) {
|
|
185
|
+
sourceDatasetSchema = mergeObjectSchemas(sourceDatasetSchema, readJsonSchema(args.add_dataset), args.deep_merge);
|
|
186
|
+
}
|
|
187
|
+
if (args.output.includes("json-schemas")) {
|
|
188
|
+
const outputDatasetSchema = readJsonSchemaField(args.dataset_schema, DATASET_SCHEMA_FIELD);
|
|
189
|
+
if (!outputDatasetSchema) {
|
|
190
|
+
console.error(`Dataset schema field "${DATASET_SCHEMA_FIELD}" not found in ${args.dataset_schema}.`);
|
|
191
|
+
process.exit(1);
|
|
174
192
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
process.exit(1);
|
|
180
|
-
}
|
|
181
|
-
const isDatasetSchemaCoherent = compareSchemas(sourceDatasetSchema, outputDatasetSchema, args.ignore_descriptions);
|
|
182
|
-
if (!isDatasetSchemaCoherent) {
|
|
183
|
-
console.error("Dataset schema validation failed: the dataset schema does not match the source schema.");
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
193
|
+
const isDatasetSchemaCoherent = compareSchemas(sourceDatasetSchema, outputDatasetSchema, args.ignore_descriptions);
|
|
194
|
+
if (!isDatasetSchemaCoherent) {
|
|
195
|
+
console.error("Dataset schema validation failed: the dataset schema does not match the source schema.");
|
|
196
|
+
process.exit(1);
|
|
186
197
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
}
|
|
199
|
+
if (args.output.includes("ts-types")) {
|
|
200
|
+
const datasetTsContent = readFile(join(args.output_ts_dir, "dataset.ts"));
|
|
201
|
+
const datasetTsInterface = parseTypeScriptInterface(removeTypeScriptHeader(datasetTsContent));
|
|
202
|
+
const sourceDatasetTsInterface = jsonSchemaToTypeScriptInterface(sourceDatasetSchema);
|
|
203
|
+
const isTsDatasetCoherent = compareTypescriptInterfaces(sourceDatasetTsInterface, datasetTsInterface, args.ignore_descriptions);
|
|
204
|
+
if (!isTsDatasetCoherent) {
|
|
205
|
+
console.error("Dataset TypeScript interface validation failed: the TypeScript interface does not match the source schema.");
|
|
206
|
+
process.exit(1);
|
|
196
207
|
}
|
|
197
208
|
}
|
|
209
|
+
}
|
|
210
|
+
function check(args) {
|
|
211
|
+
if (args.input.includes("input")) {
|
|
212
|
+
checkInputSchemas(args);
|
|
213
|
+
}
|
|
214
|
+
if (args.input.includes("dataset")) {
|
|
215
|
+
checkDatasetSchemas(args);
|
|
216
|
+
}
|
|
198
217
|
console.log("Check passed.");
|
|
199
218
|
}
|
|
200
219
|
checkParser.set_defaults({ func: check });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apify-schema-tools.js","sourceRoot":"","sources":["../src/apify-schema-tools.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE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,IAAI,CAAC,mBAAmB,CACxB,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CACZ,4GAA4G,CAC5G,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,KAAK,CAAC,IAAe;IAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC9B,CAAC;AAED,WAAW,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE1C,oBAAoB;AAEpB,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;AAC3C,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/apify.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare function filterValidInputSchemaProperties(schema: ObjectSchema):
|
|
|
7
7
|
* the default values for the input schema, and the interface for the input
|
|
8
8
|
* with the default values filled in.
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function generateInputDefaultsTsFileContent(inputSchema: ObjectSchema): string;
|
|
11
11
|
export declare const DATASET_SCHEMA_FIELD = "fields";
|
|
12
12
|
//# sourceMappingURL=apify.d.ts.map
|
package/dist/apify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apify.d.ts","sourceRoot":"","sources":["../src/apify.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"apify.d.ts","sourceRoot":"","sources":["../src/apify.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnF,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjE;AA+CD,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAQnF;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,YAAY,GAAG,MAAM,CA2EpF;AAED,eAAO,MAAM,oBAAoB,WAAW,CAAC"}
|
package/dist/apify.js
CHANGED
|
@@ -54,7 +54,7 @@ export function filterValidInputSchemaProperties(schema) {
|
|
|
54
54
|
* the default values for the input schema, and the interface for the input
|
|
55
55
|
* with the default values filled in.
|
|
56
56
|
*/
|
|
57
|
-
export function
|
|
57
|
+
export function generateInputDefaultsTsFileContent(inputSchema) {
|
|
58
58
|
const defaultValues = {};
|
|
59
59
|
for (const [property, definition] of Object.entries(inputSchema.properties ?? {})) {
|
|
60
60
|
if ("default" in definition) {
|
|
@@ -105,7 +105,9 @@ export function getInputWithDefaultValues(input?: Input | null): InputWithDefaul
|
|
|
105
105
|
}${requiredParamsWithoutDefaults.length > 0
|
|
106
106
|
? `
|
|
107
107
|
if (!input) {
|
|
108
|
-
throw new Error(\`Input is required, because the following fields are required: $\{
|
|
108
|
+
throw new Error(\`Input is required, because the following fields are required: $\{
|
|
109
|
+
REQUIRED_INPUT_FIELDS_WITHOUT_DEFAULT.join(", ")
|
|
110
|
+
\}\`);
|
|
109
111
|
}`
|
|
110
112
|
: ""}
|
|
111
113
|
${areThereDefaults
|
package/dist/apify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apify.js","sourceRoot":"","sources":["../src/apify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,
|
|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G,CAAC,CAAC;QACzC,CAAC;IACF,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAE7E,OAAO;;;;EAKP,gBAAgB;QACf,CAAC,CAAC;0BACsB,yBAAyB,CAAC,gBAAgB,CAAC;;;;qDAIhB,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG;QAC/F,CAAC,CAAC;;;iEAIJ;;uDAEuD,IAAI,CAAC,SAAS,CAAC,6BAA6B,EAAE,IAAI,EAAE,IAAI,CAAC;;;;;;IAO9G,6BAA6B,CAAC,MAAM,GAAG,CAAC;QACvC,CAAC,CAAC;;;;;GAKF;QACA,CAAC,CAAC,EACJ;EAEA,gBAAgB;QACf,CAAC,CAAC;;;;IAIA;QACF,CAAC,CAAC;8BAEJ;;CAEC,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC"}
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useNamingConvention: parsed CLI arguments are in snake_case */
|
|
1
2
|
import type { ArgumentParser } from "argparse";
|
|
2
|
-
import
|
|
3
|
+
import { type infer as zodInfer } from "zod/v4";
|
|
3
4
|
declare const INPUTS: readonly ["input", "dataset"];
|
|
4
5
|
declare const OUTPUTS: readonly ["json-schemas", "ts-types"];
|
|
5
6
|
type Input = (typeof INPUTS)[number];
|
|
6
7
|
type Output = (typeof OUTPUTS)[number];
|
|
7
|
-
export interface
|
|
8
|
+
export interface CommonCliArgs {
|
|
8
9
|
input: Input[];
|
|
9
10
|
output: Output[];
|
|
10
11
|
src_input: string;
|
|
@@ -15,29 +16,29 @@ export interface CommonCLIArgs {
|
|
|
15
16
|
dataset_schema: string;
|
|
16
17
|
output_ts_dir: string;
|
|
17
18
|
}
|
|
18
|
-
export declare const Configuration: zod.ZodObject<{
|
|
19
|
-
input: zod.ZodDefault<zod.ZodArray<zod.ZodEnum<{
|
|
19
|
+
export declare const Configuration: import("zod/v4").ZodObject<{
|
|
20
|
+
input: import("zod/v4").ZodDefault<import("zod/v4").ZodArray<import("zod/v4").ZodEnum<{
|
|
20
21
|
input: "input";
|
|
21
22
|
dataset: "dataset";
|
|
22
23
|
}>>>;
|
|
23
|
-
output: zod.ZodDefault<zod.ZodArray<zod.ZodEnum<{
|
|
24
|
+
output: import("zod/v4").ZodDefault<import("zod/v4").ZodArray<import("zod/v4").ZodEnum<{
|
|
24
25
|
"json-schemas": "json-schemas";
|
|
25
26
|
"ts-types": "ts-types";
|
|
26
27
|
}>>>;
|
|
27
|
-
srcInput: zod.ZodDefault<zod.ZodString>;
|
|
28
|
-
srcDataset: zod.ZodDefault<zod.ZodString>;
|
|
29
|
-
addInput: zod.ZodOptional<zod.ZodString>;
|
|
30
|
-
addDataset: zod.ZodOptional<zod.ZodString>;
|
|
31
|
-
inputSchema: zod.ZodDefault<zod.ZodString>;
|
|
32
|
-
datasetSchema: zod.ZodDefault<zod.ZodString>;
|
|
33
|
-
outputTSDir: zod.ZodDefault<zod.ZodString>;
|
|
34
|
-
}, zod
|
|
35
|
-
export declare function parseConfigurationFromFileOrDefault():
|
|
36
|
-
export declare function writeConfigurationToPackageJson(args:
|
|
28
|
+
srcInput: import("zod/v4").ZodDefault<import("zod/v4").ZodString>;
|
|
29
|
+
srcDataset: import("zod/v4").ZodDefault<import("zod/v4").ZodString>;
|
|
30
|
+
addInput: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
|
|
31
|
+
addDataset: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
|
|
32
|
+
inputSchema: import("zod/v4").ZodDefault<import("zod/v4").ZodString>;
|
|
33
|
+
datasetSchema: import("zod/v4").ZodDefault<import("zod/v4").ZodString>;
|
|
34
|
+
outputTSDir: import("zod/v4").ZodDefault<import("zod/v4").ZodString>;
|
|
35
|
+
}, import("zod/v4/core").$strip>;
|
|
36
|
+
export declare function parseConfigurationFromFileOrDefault(): zodInfer<typeof Configuration>;
|
|
37
|
+
export declare function writeConfigurationToPackageJson(args: CommonCliArgs): void;
|
|
37
38
|
/**
|
|
38
39
|
* This function will set as default values the configuration from package.json, or the default one.
|
|
39
40
|
* In this way, the CLI arguments can override the configuration.
|
|
40
41
|
*/
|
|
41
|
-
export declare function addCommonCLIArgs(parser: ArgumentParser, configuration:
|
|
42
|
+
export declare function addCommonCLIArgs(parser: ArgumentParser, configuration: zodInfer<typeof Configuration>): void;
|
|
42
43
|
export {};
|
|
43
44
|
//# sourceMappingURL=configuration.d.ts.map
|