Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@apify/actor-templates": "^0.1.5",
"@apify/consts": "^2.36.0",
"@apify/input_schema": "^3.12.0",
"@apify/input_schema": "^3.17.0",
"@apify/utilities": "^2.15.1",
"@crawlee/memory-storage": "^3.12.0",
"@root/walk": "~1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getAjvValidator, getDefaultsFromInputSchema, readInputSchema } from '..
import { error, info, warning } from '../lib/outputs.js';
import { replaceSecretsValue } from '../lib/secrets.js';
import {
Ajv,
Ajv2019,
checkIfStorageIsEmpty,
getLocalInput,
getLocalKeyValueStorePath,
Expand Down Expand Up @@ -436,7 +436,7 @@ export class RunCommand extends ApifyCommand<typeof RunCommand> {
}

// Step 1: validate the input schema
const validator = new Ajv({ strict: false, unicodeRegExp: false });
const validator = new Ajv2019({ strict: false, unicodeRegExp: false });
validateInputSchema(validator, inputSchema); // This one throws an error in a case of invalid schema.

const defaults = getDefaultsFromInputSchema(inputSchema);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/validate-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Args } from '../lib/command-framework/args.js';
import { LOCAL_CONFIG_PATH } from '../lib/consts.js';
import { readInputSchema } from '../lib/input_schema.js';
import { info, success } from '../lib/outputs.js';
import { Ajv } from '../lib/utils.js';
import { Ajv2019 } from '../lib/utils.js';

export class ValidateInputSchemaCommand extends ApifyCommand<typeof ValidateInputSchemaCommand> {
static override name = 'validate-schema' as const;
Expand Down Expand Up @@ -45,7 +45,7 @@ export class ValidateInputSchemaCommand extends ApifyCommand<typeof ValidateInpu
info({ message: `Validating input schema embedded in '${LOCAL_CONFIG_PATH}'` });
}

const validator = new Ajv({ strict: false });
const validator = new Ajv2019({ strict: false });
validateInputSchema(validator, inputSchema); // This one throws an error in a case of invalid schema.
success({ message: 'Input schema is valid.' });
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/input_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { validateInputSchema } from '@apify/input_schema';

import { ACTOR_SPECIFICATION_FOLDER } from './consts.js';
import { warning } from './outputs.js';
import { Ajv, getJsonFileContent, getLocalConfig, getLocalKeyValueStorePath } from './utils.js';
import { Ajv2019, getJsonFileContent, getLocalConfig, getLocalKeyValueStorePath } from './utils.js';

const DEFAULT_INPUT_SCHEMA_PATHS = [
'.actor/INPUT_SCHEMA.json',
Expand Down Expand Up @@ -85,7 +85,7 @@ export const createPrefilledInputFileFromInputSchema = async (actorFolderDir: st
* It is not possible to install the package here because it is private
* We should move it to @apify/input_schema and use it from there.
*/
const validator = new Ajv({ strict: false });
const validator = new Ajv2019({ strict: false });
validateInputSchema(validator, inputSchema);

// inputFile = _.mapObject(inputSchema.properties as any, (fieldSchema) =>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { finished } from 'node:stream/promises';
import { DurationFormatter as SapphireDurationFormatter, TimeTypes } from '@sapphire/duration';
import { Timestamp } from '@sapphire/timestamp';
import AdmZip from 'adm-zip';
import _Ajv from 'ajv';
import _Ajv2019 from 'ajv/dist/2019.js';
import { type ActorRun, ApifyClient, type ApifyClientOptions, type Build } from 'apify-client';
import archiver from 'archiver';
import { AxiosHeaders } from 'axios';
Expand Down Expand Up @@ -47,7 +47,7 @@ import type { AuthJSON } from './types.js';

// Export AJV properly: https://github.com/ajv-validator/ajv/issues/2132
// Welcome to the state of JavaScript/TypeScript and CJS/ESM interop.
export const Ajv = _Ajv as unknown as typeof import('ajv').default;
export const Ajv2019 = _Ajv2019 as unknown as typeof import('ajv/dist/2019.js').default;

export const httpsGet = async (url: string) => {
return new Promise<IncomingMessage>((resolve, reject) => {
Expand Down
24 changes: 23 additions & 1 deletion test/__setup__/input-schemas/valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,29 @@
"default": false,
"groupCaption": "Options",
"groupDescription": "Various options for this Actor"
}
},
"person": {
"title": "Person",
"type": "object",
"description": "An example of a nested object",
"editor": "schemaBased",
"properties": {
"firstName": {
"type": "string",
"title": "First Name",
"description": "First name of the person",
"editor": "textfield"
},
"lastName": {
"type": "string",
"title": "Last Name",
"description": "Last name of the person",
"editor": "textfield"
}
},
"additionalProperties": false,
"required": ["lastName"]
}
},
"required": ["queries"]
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ __metadata:
languageName: node
linkType: hard

"@apify/input_schema@npm:^3.12.0":
version: 3.16.1
resolution: "@apify/input_schema@npm:3.16.1"
"@apify/input_schema@npm:^3.17.0":
version: 3.17.0
resolution: "@apify/input_schema@npm:3.17.0"
dependencies:
"@apify/consts": "npm:^2.43.0"
"@apify/input_secrets": "npm:^1.2.1"
acorn-loose: "npm:^8.4.0"
countries-list: "npm:^3.0.0"
peerDependencies:
ajv: ^8.0.0
checksum: 10c0/a590abda013d0d2bdd11c5b34122ebf02535d38ebee5b01b6e5f1005194b7c9afbd4844801ba9daabe0552e96d8d1f8624a4d80a4143d8cc99f6e15113982314
checksum: 10c0/9d6a761f2bfb91cecd4d84a4094eda6a7c512bcbc98d875441062c88a3a1e83260bf90d113b8d0063457cd8a37d205d95138584267c8ee69e8bb863719164109
languageName: node
linkType: hard

Expand Down Expand Up @@ -2434,7 +2434,7 @@ __metadata:
"@apify/actor-templates": "npm:^0.1.5"
"@apify/consts": "npm:^2.36.0"
"@apify/eslint-config": "npm:^1.0.0"
"@apify/input_schema": "npm:^3.12.0"
"@apify/input_schema": "npm:^3.17.0"
"@apify/tsconfig": "npm:^0.1.1"
"@apify/utilities": "npm:^2.15.1"
"@biomejs/biome": "npm:^2.0.0"
Expand Down
Loading