Skip to content

Commit

Permalink
fix: [#4545] Please upgrade zod package - botbuilder-dialogs (#4563)
Browse files Browse the repository at this point in the history
* remove zod in botbuilder-dialogs

* update support for TS

* update botbuilder api signature

* update bf-schema api signature

* set zod versions

* remove skip

* fix lint

---------

Co-authored-by: JhontSouth <[email protected]>
  • Loading branch information
sw-joelmut and JhontSouth authored Nov 9, 2023
1 parent 36fc0d0 commit 6abfddf
Show file tree
Hide file tree
Showing 24 changed files with 185 additions and 207 deletions.
41 changes: 19 additions & 22 deletions libraries/adaptive-expressions/etc/adaptive-expressions.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class BoolExpression extends ExpressionProperty<boolean> {

// @public
export class BoolExpressionConverter {
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_2" needs to be exported by the entry point index.d.ts
convert(value: Input_2 | BoolExpression): BoolExpression;
}

Expand Down Expand Up @@ -330,7 +330,7 @@ export class Clause extends Expression {
// @public
export class CommonRegex {
static CreateRegex(pattern: string): RegExp;
}
}

// @public (undocumented)
export class CommonRegexLexer extends Lexer {
Expand Down Expand Up @@ -1010,15 +1010,15 @@ export interface CommonRegexVisitor<Result> extends ParseTreeVisitor<Result> {
// @public
export class ComparisonEvaluator extends ExpressionEvaluator {
constructor(type: string, func: (arg0: any[]) => boolean, validator: ValidateExpressionDelegate, verify?: VerifyExpression);
}
}

// @public
export class Constant extends Expression {
constructor(value: any);
deepEquals(other: Expression): boolean;
toString(): string;
value: any;
}
}

// @public
export function convertCSharpDateTimeToDayjs(fmtString: string): string;
Expand Down Expand Up @@ -1099,9 +1099,9 @@ export class EnumExpression<T> extends ExpressionProperty<T> {
// @public
export class EnumExpressionConverter<T> {
constructor(enumValue: unknown);
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_3" needs to be exported by the entry point index.d.ts
convert(value: Input_3<T> | EnumExpression<T>): EnumExpression<T>;
}
}

// @public
export type EvaluateExpressionDelegate = (expression: Expression, state: MemoryInterface, options: Options) => ValueWithError;
Expand Down Expand Up @@ -1518,7 +1518,7 @@ export class ExpressionEvaluator {
tryEvaluate: (expression: Expression, state: MemoryInterface, options: Options) => ValueWithError;
type: string;
validateExpression: (expression: Expression) => void;
}
}

// @public
export class ExpressionFunctions {
Expand Down Expand Up @@ -2054,7 +2054,7 @@ export class IntExpression extends ExpressionProperty<number> {

// @public
export class IntExpressionConverter {
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_4" needs to be exported by the entry point index.d.ts
convert(value: Input_4 | IntExpression): IntExpression;
}

Expand Down Expand Up @@ -2677,7 +2677,7 @@ export interface MemoryInterface {
// @public
export class MultivariateNumericEvaluator extends ExpressionEvaluator {
constructor(type: string, func: (args: any[]) => number, verify?: VerifyExpression);
}
}

// @public (undocumented)
export class NameContext extends ParserRuleContext {
Expand Down Expand Up @@ -2707,8 +2707,7 @@ class Node_2 {
toString(builder?: string[], indent?: number): string;
tree: TriggerTree;
readonly triggers: Trigger[];
}

}
export { Node_2 as Node }

// @public (undocumented)
Expand Down Expand Up @@ -2789,14 +2788,14 @@ export class NumberExpression extends ExpressionProperty<number> {

// @public
export class NumberExpressionConverter {
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_5" needs to be exported by the entry point index.d.ts
convert(value: Input_5 | NumberExpression): NumberExpression;
}

// @public
export class NumberTransformEvaluator extends ExpressionEvaluator {
constructor(type: string, func: (args: any[]) => number);
}
}

// @public (undocumented)
export class NumericAtomContext extends PrimaryExpressionContext {
Expand All @@ -2814,7 +2813,7 @@ export class NumericAtomContext extends PrimaryExpressionContext {
// @public
export class NumericEvaluator extends ExpressionEvaluator {
constructor(type: string, func: (args: any[]) => any);
}
}

// @public
export class ObjectExpression<T> extends ExpressionProperty<T> {
Expand All @@ -2823,7 +2822,7 @@ export class ObjectExpression<T> extends ExpressionProperty<T> {

// @public
export class ObjectExpressionConverter<T extends object = {}> {
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_6" needs to be exported by the entry point index.d.ts
convert(value: Input_6<T> | ObjectExpression<T>): ObjectExpression<T>;
}

Expand Down Expand Up @@ -3102,7 +3101,6 @@ enum ReturnType_2 {
Object = 4,
String = 8
}

export { ReturnType_2 as ReturnType }

// @public (undocumented)
Expand Down Expand Up @@ -3240,7 +3238,7 @@ export class StringExpression extends ExpressionProperty<string> {

// @public
export class StringExpressionConverter {
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input_7" needs to be exported by the entry point index.d.ts
convert(value: Input_7 | StringExpression): StringExpression;
}

Expand Down Expand Up @@ -3311,14 +3309,14 @@ export class TextContentContext extends ParserRuleContext {
// @public
export class TimeTransformEvaluator extends ExpressionEvaluator {
constructor(type: string, func: (timestamp: Date, numOfTransformation: number) => Date);
}
}

// @public
export class TimeZoneConverter {
static ianaToWindows(ianaTimeZoneId: string): string;
static verifyTimeZoneStr(timezoneStr: string): boolean;
static windowsToIana(windowsTimeZoneId: string): string;
}
}

// @public
export class Trigger {
Expand All @@ -3329,7 +3327,7 @@ export class Trigger {
readonly originalExpression: Expression;
relationship(other: Trigger, comparers: PredicateComparers): RelationshipType;
toString(builder?: string[], indent?: number): string;
}
}

// @public
export class TriggerTree {
Expand All @@ -3345,7 +3343,7 @@ export class TriggerTree {
totalTriggers: number;
treeToString(indent?: number): string;
verifyTree(): Node_2;
}
}

// @public (undocumented)
export class TripleOpExpContext extends ExpressionContext {
Expand Down Expand Up @@ -3413,7 +3411,6 @@ export type ValueWithError = {
// @public
export type VerifyExpression = (value: any, expression: Expression, child: number) => string | undefined;


// (No @packageDocumentation comment for this package)

```
17 changes: 8 additions & 9 deletions libraries/botbuilder-ai/etc/botbuilder-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export interface AnswerSpanResponse {
text: string;
}

// Warning: (ae-forgotten-export) The symbol "QnAMakerClient" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QnAMakerTelemetryClient" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QnAMakerClient_2" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QnAMakerTelemetryClient_2" needs to be exported by the entry point index.d.ts
//
// @public
export class CustomQuestionAnswering implements QnAMakerClient_2, QnAMakerTelemetryClient_2 {
Expand Down Expand Up @@ -94,7 +94,7 @@ export class CustomQuestionAnswering implements QnAMakerClient_2, QnAMakerTeleme
[key: string]: number;
}): Promise<void>;
get telemetryClient(): BotTelemetryClient;
}
}

// @public
export interface DateTimeSpec {
Expand Down Expand Up @@ -228,7 +228,7 @@ export class LuisAdaptiveRecognizer extends Recognizer implements LuisAdaptiveRe
// (undocumented)
static $kind: string;
applicationId: StringExpression;
// Warning: (ae-forgotten-export) The symbol "DynamicList" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "DynamicList_2" needs to be exported by the entry point index.d.ts
dynamicLists: ArrayExpression<DynamicList_2>;
endpoint: StringExpression;
endpointKey: StringExpression;
Expand Down Expand Up @@ -287,7 +287,7 @@ export class LuisBotComponent extends BotComponent {
export class LuisComponentRegistration extends ComponentRegistration {
constructor();
getDeclarativeTypes(_resourceExplorer: unknown): ComponentDeclarativeTypes[];
}
}

// @public
export interface LuisPredictionOptions extends msRest.RequestOptionsBase {
Expand Down Expand Up @@ -327,7 +327,7 @@ export class LuisRecognizer implements LuisRecognizerTelemetryClient {
}>;
get telemetryClient(): BotTelemetryClient;
static topIntent(results?: RecognizerResult, defaultIntent?: string, minScore?: number): string;
}
}

// @public (undocumented)
export interface LuisRecognizerOptions {
Expand Down Expand Up @@ -467,7 +467,7 @@ export class QnAMaker implements QnAMakerClient, QnAMakerTelemetryClient {
[key: string]: number;
}): Promise<void>;
get telemetryClient(): BotTelemetryClient;
}
}

// @public (undocumented)
export const QNAMAKER_TRACE_LABEL = "QnAMaker Trace";
Expand Down Expand Up @@ -499,7 +499,7 @@ export const QnAMakerClientKey: unique symbol;
export class QnAMakerComponentRegistration extends ComponentRegistration {
constructor();
getDeclarativeTypes(_resourceExplorer: unknown): ComponentDeclarativeTypes[];
}
}

// Warning: (ae-forgotten-export) The symbol "QnAMakerDialogConfiguration" needs to be exported by the entry point index.d.ts
//
Expand Down Expand Up @@ -742,7 +742,6 @@ export function validateExternalEntity(entity: ExternalEntity): void;
// @public
export function validateListElement(element: ListElement): void;


// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"botbuilder-dialogs-adaptive-runtime": "4.1.6",
"botbuilder-dialogs-adaptive-runtime-core": "4.1.6",
"mime": "^2.5.2",
"zod": "~1.11.17"
"zod": "^3.22.4"
},
"scripts": {
"build": "tsc -b",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"botbuilder-dialogs-adaptive-runtime": "4.1.6",
"botbuilder-dialogs-adaptive-runtime-core": "4.1.6",
"express": "^4.17.3",
"zod": "~1.11.17"
"zod": "^3.22.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"botbuilder-dialogs-adaptive-runtime": "4.1.6",
"botbuilder-dialogs-adaptive-runtime-core": "4.1.6",
"restify": "^8.5.1",
"zod": "~1.11.17"
"zod": "^3.22.4"
},
"scripts": {
"build": "tsc -b",
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-dialogs-adaptive-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"botframework-connector": "4.1.6",
"nconf": "0.11.4",
"yargs-parser": "^20.2.7",
"zod": "~1.11.17"
"zod": "^3.22.4"
},
"devDependencies": {
"@types/nconf": "0.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ export class Configuration implements CoreConfiguration {
try {
return t.optional().parse(this.get(path));
} catch (err) {
if (z.instanceof(z.ZodError).check(err)) {
err.errors.forEach((error) => (error.path = [...this.prefix, ...path, ...error.path]));
const zodError = z.instanceof(z.ZodError).safeParse(err);
if (zodError.success) {
zodError.data.errors.forEach((error) => (error.path = [...this.prefix, ...path, ...error.path]));
}

throw err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```ts

/// <reference types="node" />

import { Activity } from 'botbuilder-core';
import { BotComponent } from 'botbuilder-core';
import { ClientRequest } from 'http';
Expand Down Expand Up @@ -155,7 +157,6 @@ class CustomEvent_2<T = unknown> extends TestAction implements CustomEventConfig
name: string;
value?: T;
}

export { CustomEvent_2 as CustomEvent }

// @public (undocumented)
Expand Down Expand Up @@ -215,14 +216,14 @@ export class MockLuisLoader implements CustomDeserializer<MockLuisRecognizer, Lu
constructor(_resourceExplorer: ResourceExplorer, _configuration?: Record<string, string>);
// (undocumented)
load(config: LuisAdaptiveRecognizerConfiguration, type: Newable<MockLuisRecognizer>): MockLuisRecognizer;
}
}

// @public
export class MockLuisRecognizer extends Recognizer {
constructor(recognizer: LuisAdaptiveRecognizer, resourceDir: string, name: string);
// (undocumented)
recognize(dialogContext: DialogContext, activity: Activity, telemetryProperties?: Record<string, string>, telemetryMetrics?: Record<string, number>): Promise<RecognizerResult>;
}
}

// @public
export class MockSettingsMiddleware implements Middleware {
Expand Down Expand Up @@ -386,7 +387,6 @@ export interface UserTypingConfiguration {
user?: string;
}


// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion libraries/botbuilder-dialogs-adaptive-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"murmurhash-js": "^1.0.0",
"nock": "^11.9.1",
"url-parse": "^1.5.9",
"zod": "~1.11.17"
"zod": "^3.22.4"
},
"devDependencies": {
"botbuilder": "4.1.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class UserActivity extends TestAction implements UserActivityConfiguratio
activity.from = { ...activity.from };
activity.from.id = this.user;
activity.from.name = this.user;
} else if (z.record(z.unknown()).check(this.activity?.from)) {
} else if (z.record(z.unknown()).safeParse(this.activity?.from).success) {
activity.from = { ...this.activity.from };
}

Expand Down
Loading

0 comments on commit 6abfddf

Please sign in to comment.