Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
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
726 changes: 343 additions & 383 deletions .vscode/launch.json

Large diffs are not rendered by default.

158 changes: 30 additions & 128 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/chatdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"node-fetch": "~2.6.0",
"please-upgrade-node": "^3.0.1",
"semver": "^5.5.1",
"tslib": "^1.9.3",
"tslib": "^2.0.3",
"window-size": "^1.1.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"is-ci":"2.0.0",
"latest-version": "^4.0.0",
"semver": "^5.5.1",
"tslib": "^1.9.3"
"tslib": "^2.0.3"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"cli-ux": "~4.9.3",
"debug": "^4.1.1",
"fs-extra": "^7.0.1",
"tslib": "~1.10.0"
"tslib": "^2.0.3"
},
"devDependencies": {
"@oclif/plugin-help": "^2.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@oclif/errors": "~1.2.2",
"cli-ux": "^5.3.0",
"fs-extra": "^7.0.1",
"tslib": "^1.10.0"
"tslib": "^2.0.3"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"os": "~0.1.1",
"path": "^0.12.7",
"seedrandom": "~3.0.5",
"tslib": "^1.10.0",
"tslib": "^2.0.3",
"xml2js": "^0.4.19",
"json-ptr": "~1.3.0",
"json-schema-merge-allof": "~0.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/dialog/src/library/dialogTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export * from './schemaTracker';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as st from './schemaTracker';
import glob from 'globby';
import parser from '@apidevtools/json-schema-ref-parser'

let clone = require('clone')
const clone = require('clone')
const glob = require('globby');

// Top-level dialog definition that would be found in a file.
export class Dialog {
Expand Down
23 changes: 12 additions & 11 deletions packages/dialog/src/library/schemaMerger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import * as nuget from '@snyk/nuget-semver'
import * as os from 'os'
import * as ppath from 'path'
import * as xp from 'xml2js'
import Validator from 'ajv'
import glob from 'globby'
import Ajv = require('ajv');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is discussed here: ajv-validator/ajv#1230

It looks like upgrading to v7 would give us better ES import support, but it's not a trivial upgrade so I'm moving back to require for this (and globby which appears to have a similar problem).

import parser from '@apidevtools/json-schema-ref-parser'
import {JsonPointer as ptr} from 'json-ptr'

let allof: any = require('json-schema-merge-allof')
let clone: any = require('clone')
let getUri: any = require('get-uri')
let util: any = require('util')
let exec: any = util.promisify(require('child_process').exec)
const allof = require('json-schema-merge-allof')
const clone = require('clone')
const getUri = require('get-uri')
const glob = require('globby')
const util = require('util')

const exec = util.promisify(require('child_process').exec)

// Walk over JSON object, stopping if true from walker.
// Walker gets the current value, the parent object and full path to that object
Expand Down Expand Up @@ -280,7 +281,7 @@ export class SchemaMerger {
private readonly files: Map<string, Map<string, PathComponent[]>> = new Map<string, Map<string, PathComponent[]>>()

// Validator for checking schema
private readonly validator = new Validator()
private readonly validator = new Ajv()

// $schema that defines allowed component .schema
private metaSchemaId = ''
Expand Down Expand Up @@ -784,7 +785,7 @@ export class SchemaMerger {
// Validate against component schema
private validateSchema(schema: any): void {
if (!this.validator.validate('componentSchema', schema)) {
for (let error of this.validator.errors as Validator.ErrorObject[]) {
for (let error of this.validator.errors as Ajv.ErrorObject[]) {
this.schemaError(error)
}
this.validator.errors = undefined
Expand All @@ -794,7 +795,7 @@ export class SchemaMerger {
// Validate against UI schema
private validateUISchema(schema: any): void {
if (!this.validator.validate('UISchema', schema)) {
for (let error of this.validator.errors as Validator.ErrorObject[]) {
for (let error of this.validator.errors as Ajv.ErrorObject[]) {
this.schemaError(error)
}
this.validator.errors = undefined
Expand Down Expand Up @@ -1717,7 +1718,7 @@ export class SchemaMerger {
}

// Error in schema validity
private schemaError(err: Validator.ErrorObject): void {
private schemaError(err: Ajv.ErrorObject): void {
this.error(`${this.currentFile}: ${err.dataPath} error: ${err.message}`)
this.failed = true
}
Expand Down
13 changes: 8 additions & 5 deletions packages/dialog/src/library/schemaTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import ajv from 'ajv';
import Ajv = require('ajv')
import parser from '@apidevtools/json-schema-ref-parser'

let getUri: any = require('get-uri')
Expand All @@ -28,16 +28,15 @@ export class SchemaTracker {
// Map from dialog path to kind.
pathToKind: Map<string, string>

private readonly validator: ajv.Ajv
private readonly validator = new Ajv({logger: false});

constructor() {
this.kindToKind = new Map<string, Kind>()
this.pathToKind = new Map<string, string>()
// NOTE: This is so that ajv doesn't complain about extra keywords around $ref
this.validator = new ajv({logger: false})
}

async getValidator(schemaPath: string): Promise<[ajv.ValidateFunction, boolean]> {
async getValidator(schemaPath: string): Promise<[Ajv.ValidateFunction, boolean]> {
let validator = this.validator.getSchema(schemaPath)
let added = false
if (!validator) {
Expand Down Expand Up @@ -82,11 +81,15 @@ export class SchemaTracker {
this.validator.addSchema(metaSchema, metaSchemaName)
}
this.validator.addSchema(fullSchema, schemaPath)
validator = this.validator.getSchema(schemaPath) as ajv.ValidateFunction
validator = this.validator.getSchema(schemaPath)
if (!validator) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a bit of safety rather than relying on casting to implicitly remove the potential for an undefined result.

throw new Error(`Could not get validator for schema ${schemaPath}`)
}
} catch (err) {
throw new Error(`Could not use schema ${schemaPath}\n${err.message}`)
}
}

return [validator, added]
}

Expand Down
2 changes: 1 addition & 1 deletion packages/lg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"delay": "^4.3.0",
"fs-extra": "^8.1.0",
"lodash": "^4.17.15",
"tslib": "^1.10.0",
"tslib": "^2.0.3",
"read-text-file": "^1.1.0",
"readline-sync": "^1.4.10",
"node-fetch": "^2.1.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/lu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lodash": "^4.17.19",
"node-fetch": "~2.6.0",
"semver": "^5.5.1",
"tslib": "^1.10.0"
"tslib": "^2.0.3"
},
"devDependencies": {
"@types/chai": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/luis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"fs-extra": "^8.1.0",
"lodash": "^4.17.19",
"node-fetch": "~2.6.0",
"tslib": "^1.10.0",
"tslib": "^2.0.3",
"username": "^4.1.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@oclif/config": "~1.13.3",
"@oclif/plugin-plugins": "~1.7.9",
"cli-ux": "^5.4.1",
"tslib": "^1.10.0"
"tslib": "^2.0.3"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/qnamaker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"readline-sync": "^1.4.9",
"rimraf": "^2.6.3",
"semver": "^5.5.1",
"tslib": "^1.10.0",
"tslib": "^2.0.3",
"window-size": "^1.1.0",
"username": "^4.1.0"
},
Expand Down