@autobe/agent 0.22.0 → 0.22.1

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.
Files changed (49) hide show
  1. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +3 -3
  2. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +1 -1
  3. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  4. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  5. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  6. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +1 -1
  7. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  8. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +2 -2
  9. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  10. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +2 -2
  11. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  12. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +2 -2
  13. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  14. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  15. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js +59 -0
  16. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -0
  17. package/lib/agent/src/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  18. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +17 -11
  19. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  20. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +5 -1
  21. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  22. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  23. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  24. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  25. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  26. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +3 -9
  27. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  28. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +2 -9
  29. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  30. package/lib/constants/AutoBeSystemPromptConstant.d.ts +3 -3
  31. package/lib/index.mjs +74 -49
  32. package/lib/index.mjs.map +1 -1
  33. package/lib/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  34. package/lib/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  35. package/package.json +6 -6
  36. package/src/constants/AutoBeSystemPromptConstant.ts +3 -3
  37. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -2
  38. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +2 -2
  39. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +2 -2
  40. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +66 -0
  41. package/src/orchestrate/test/compile/completeTestCode.ts +10 -12
  42. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +11 -0
  43. package/src/orchestrate/test/orchestrateTestCorrect.ts +11 -18
  44. package/src/orchestrate/test/orchestrateTestWrite.ts +10 -18
  45. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  46. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +0 -35
  47. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +0 -1
  48. package/lib/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  49. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +0 -41
@@ -17,8 +17,8 @@ import { transformInterfaceComplementHistories } from "./histories/transformInte
17
17
  import { IAutoBeInterfaceComplementApplication } from "./structures/IAutoBeInterfaceComplementApplication";
18
18
  import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
19
19
  import { JsonSchemaNamingConvention } from "./utils/JsonSchemaNamingConvention";
20
+ import { JsonSchemaValidator } from "./utils/JsonSchemaValidator";
20
21
  import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
21
- import { validateAuthorizationSchema } from "./utils/validateAuthorizationSchema";
22
22
 
23
23
  export function orchestrateInterfaceComplement<Model extends ILlmSchema.Model>(
24
24
  ctx: AutoBeContext<Model>,
@@ -143,7 +143,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
143
143
  }
144
144
 
145
145
  const errors: IValidation.IError[] = [];
146
- validateAuthorizationSchema({
146
+ JsonSchemaValidator.validate({
147
147
  errors,
148
148
  schemas: result.data.schemas,
149
149
  path: "$input.schemas",
@@ -19,8 +19,8 @@ import { transformInterfaceSchemaHistories } from "./histories/transformInterfac
19
19
  import { IAutoBeInterfaceSchemaApplication } from "./structures/IAutoBeInterfaceSchemaApplication";
20
20
  import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
21
21
  import { JsonSchemaNamingConvention } from "./utils/JsonSchemaNamingConvention";
22
+ import { JsonSchemaValidator } from "./utils/JsonSchemaValidator";
22
23
  import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
23
- import { validateAuthorizationSchema } from "./utils/validateAuthorizationSchema";
24
24
 
25
25
  export async function orchestrateInterfaceSchemas<
26
26
  Model extends ILlmSchema.Model,
@@ -196,7 +196,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
196
196
 
197
197
  // Check all IAuthorized types
198
198
  const errors: IValidation.IError[] = [];
199
- validateAuthorizationSchema({
199
+ JsonSchemaValidator.validate({
200
200
  errors,
201
201
  schemas: result.data.schemas,
202
202
  path: "$input.schemas",
@@ -18,8 +18,8 @@ import { transformInterfaceSchemasReviewHistories } from "./histories/transformI
18
18
  import { IAutoBeInterfaceSchemasReviewApplication } from "./structures/IAutobeInterfaceSchemasReviewApplication";
19
19
  import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
20
20
  import { JsonSchemaNamingConvention } from "./utils/JsonSchemaNamingConvention";
21
+ import { JsonSchemaValidator } from "./utils/JsonSchemaValidator";
21
22
  import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
22
- import { validateAuthorizationSchema } from "./utils/validateAuthorizationSchema";
23
23
 
24
24
  export async function orchestrateInterfaceSchemasReview<
25
25
  Model extends ILlmSchema.Model,
@@ -150,7 +150,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
150
150
  }
151
151
 
152
152
  const errors: IValidation.IError[] = [];
153
- validateAuthorizationSchema({
153
+ JsonSchemaValidator.validate({
154
154
  errors,
155
155
  schemas: result.data.content,
156
156
  path: "$input.content",
@@ -0,0 +1,66 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
3
+ import { IValidation } from "typia";
4
+ import { Escaper } from "typia/lib/utils/Escaper";
5
+
6
+ export namespace JsonSchemaValidator {
7
+ export interface IProps {
8
+ errors: IValidation.IError[];
9
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
10
+ path: string;
11
+ }
12
+
13
+ export const validate = (props: IProps): void => {
14
+ authorization(props);
15
+ validateKey(props);
16
+ };
17
+
18
+ const authorization = (props: IProps): void => {
19
+ for (const [key, value] of Object.entries(props.schemas)) {
20
+ if (!key.endsWith(".IAuthorized")) continue;
21
+
22
+ // Check if it's an object type
23
+ if (AutoBeOpenApiTypeChecker.isObject(value) === false) {
24
+ props.errors.push({
25
+ path: `${props.path}.${key}`,
26
+ expected: `AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IObject>`,
27
+ value: value,
28
+ description: `${key} must be an object type for authorization responses`,
29
+ });
30
+ continue;
31
+ }
32
+
33
+ // Check if token property exists
34
+ value.properties ??= {};
35
+ value.properties["token"] = {
36
+ $ref: "#/components/schemas/IAuthorizationToken",
37
+ description: "JWT token information for authentication",
38
+ } as AutoBeOpenApi.IJsonSchemaDescriptive.IReference;
39
+
40
+ value.required ??= [];
41
+ if (value.required.includes("token") === false)
42
+ value.required.push("token");
43
+ }
44
+ };
45
+
46
+ const validateKey = (props: IProps): void => {
47
+ for (const key of Object.keys(props.schemas)) {
48
+ const variable: boolean = key.split(".").every(Escaper.variable);
49
+ if (variable === false)
50
+ props.errors.push({
51
+ path: `${props.path}[${JSON.stringify(key)}]`,
52
+ expected: "Valid variable name",
53
+ value: key,
54
+ description: StringUtil.trim`
55
+ JSON schema type name must be a valid variable name.
56
+
57
+ Even though JSON schema type name allows dot(.) character, but
58
+ each segment separated by dot(.) must be a valid variable name.
59
+
60
+ Current key name ${JSON.stringify(key)} is not valid. Change
61
+ it to a valid variable name at the next time.
62
+ `,
63
+ });
64
+ }
65
+ };
66
+ }
@@ -1,28 +1,26 @@
1
1
  import { StringUtil } from "@autobe/utils";
2
+ import { ILlmSchema } from "@samchon/openapi";
2
3
 
4
+ import { AutoBeContext } from "../../../context/AutoBeContext";
3
5
  import { IAutoBeTestScenarioArtifacts } from "../structures/IAutoBeTestScenarioArtifacts";
4
6
  import { getTestImportStatements } from "./getTestImportStatements";
5
7
 
6
- export function completeTestCode(
8
+ export const completeTestCode = async <Model extends ILlmSchema.Model>(
9
+ ctx: AutoBeContext<Model>,
7
10
  artifacts: IAutoBeTestScenarioArtifacts,
8
11
  code: string,
9
- ): string {
12
+ ): Promise<string> => {
13
+ const compiler = await ctx.compiler();
14
+ code = await compiler.typescript.beautify(code);
10
15
  code = code
11
16
  .split("\r\n")
12
17
  .join("\n")
13
18
  .split("\n")
14
19
  .filter((str) => str.trim().startsWith("import") === false)
15
20
  .join("\n");
16
-
17
- // code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
18
- // code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
19
- // code = code.replaceAll(
20
- // 'string & Format<"uuid">',
21
- // 'string & tags.Format<"uuid">',
22
- // );
23
- return StringUtil.trim`
21
+ return await compiler.typescript.beautify(StringUtil.trim`
24
22
  ${getTestImportStatements(artifacts.document)}
25
23
 
26
24
  ${code}
27
- `;
28
- }
25
+ `);
26
+ };
@@ -18,11 +18,22 @@ const singleton = new Singleton(async (compiler: IAutoBeTestCompiler) => {
18
18
  if (content === undefined) throw new Error(`File not found: ${location}`);
19
19
  return { [location]: content };
20
20
  };
21
+ const filter = (
22
+ closure: (key: string) => boolean,
23
+ ): Record<string, string> => {
24
+ const entries = Object.entries(records).filter(([key]) => closure(key));
25
+ return Object.fromEntries(entries);
26
+ };
21
27
  return {
22
28
  ...external("node_modules/@nestia/e2e/lib/ArrayUtil.d.ts"),
23
29
  ...external("node_modules/@nestia/e2e/lib/RandomGenerator.d.ts"),
24
30
  ...external("node_modules/@nestia/e2e/lib/TestValidator.d.ts"),
25
31
  ...external("node_modules/@nestia/fetcher/lib/IConnection.d.ts"),
32
+ ...external("node_modules/@samchon/openapi/lib/http/HttpError.d.ts"),
26
33
  ...external("node_modules/typia/lib/module.d.ts"),
34
+ ...filter(
35
+ (key) =>
36
+ key.startsWith("node_modules/typia/lib/tags") && key.endsWith(".d.ts"),
37
+ ),
27
38
  } satisfies Record<string, string>;
28
39
  });
@@ -18,7 +18,6 @@ import { transformTestCorrectHistories } from "./histories/transformTestCorrectH
18
18
  import { IAutoBeTestCorrectApplication } from "./structures/IAutoBeTestCorrectApplication";
19
19
  import { IAutoBeTestFunction } from "./structures/IAutoBeTestFunction";
20
20
  import { IAutoBeTestFunctionFailure } from "./structures/IAutoBeTestFunctionFailure";
21
- import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
22
21
  import { IAutoBeTestWriteResult } from "./structures/IAutoBeTestWriteResult";
23
22
 
24
23
  export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
@@ -74,6 +73,7 @@ const compile = async <Model extends ILlmSchema.Model>(
74
73
  scenario: func.scenario,
75
74
  location: func.location,
76
75
  content: func.script,
76
+ // result,
77
77
  },
78
78
  result,
79
79
  created_at: new Date().toISOString(),
@@ -118,7 +118,6 @@ const correct = async <Model extends ILlmSchema.Model>(
118
118
  ]),
119
119
  controller: createController({
120
120
  model: ctx.model,
121
- artifacts: content.artifacts,
122
121
  build: (next) => {
123
122
  pointer.value = next;
124
123
  },
@@ -133,15 +132,16 @@ const correct = async <Model extends ILlmSchema.Model>(
133
132
  });
134
133
  if (pointer.value === null) throw new Error("Failed to modify test code.");
135
134
 
136
- const compiler: IAutoBeCompiler = await ctx.compiler();
137
- if (pointer.value.revise)
138
- pointer.value.revise.final = await compiler.typescript.beautify(
139
- pointer.value.revise.final,
140
- );
141
- else
142
- pointer.value.draft = await compiler.typescript.beautify(
143
- pointer.value.draft,
144
- );
135
+ pointer.value.revise.final = await completeTestCode(
136
+ ctx,
137
+ content.artifacts,
138
+ pointer.value.revise.final,
139
+ );
140
+ pointer.value.draft = await completeTestCode(
141
+ ctx,
142
+ content.artifacts,
143
+ pointer.value.draft,
144
+ );
145
145
 
146
146
  ctx.dispatch({
147
147
  type: "testCorrect",
@@ -178,7 +178,6 @@ const correct = async <Model extends ILlmSchema.Model>(
178
178
 
179
179
  const createController = <Model extends ILlmSchema.Model>(props: {
180
180
  model: Model;
181
- artifacts: IAutoBeTestScenarioArtifacts;
182
181
  build: (next: IAutoBeTestCorrectApplication.IProps) => void;
183
182
  }): IAgenticaController.IClass<Model> => {
184
183
  assertSchemaModel(props.model);
@@ -192,12 +191,6 @@ const createController = <Model extends ILlmSchema.Model>(props: {
192
191
  application,
193
192
  execute: {
194
193
  rewrite: (next) => {
195
- next.draft = completeTestCode(props.artifacts, next.draft);
196
- if (next.revise)
197
- next.revise.final = completeTestCode(
198
- props.artifacts,
199
- next.revise.final,
200
- );
201
194
  props.build(next);
202
195
  },
203
196
  } satisfies IAutoBeTestCorrectApplication,
@@ -3,7 +3,6 @@ import {
3
3
  AutoBeProgressEventBase,
4
4
  AutoBeTestScenario,
5
5
  AutoBeTestWriteEvent,
6
- IAutoBeCompiler,
7
6
  } from "@autobe/interface";
8
7
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
9
8
  import { IPointer } from "tstl";
@@ -76,7 +75,6 @@ async function process<Model extends ILlmSchema.Model>(
76
75
  histories: await transformTestWriteHistories(ctx, scenario, artifacts),
77
76
  controller: createController({
78
77
  model: ctx.model,
79
- artifacts,
80
78
  build: (next) => {
81
79
  pointer.value = next;
82
80
  },
@@ -90,15 +88,16 @@ async function process<Model extends ILlmSchema.Model>(
90
88
  throw new Error("Failed to create test code.");
91
89
  }
92
90
 
93
- const compiler: IAutoBeCompiler = await ctx.compiler();
94
- if (pointer.value.revise)
95
- pointer.value.revise.final = await compiler.typescript.beautify(
96
- pointer.value.revise.final,
97
- );
98
- else
99
- pointer.value.draft = await compiler.typescript.beautify(
100
- pointer.value.draft,
101
- );
91
+ pointer.value.revise.final = await completeTestCode(
92
+ ctx,
93
+ artifacts,
94
+ pointer.value.revise.final,
95
+ );
96
+ pointer.value.draft = await completeTestCode(
97
+ ctx,
98
+ artifacts,
99
+ pointer.value.draft,
100
+ );
102
101
  return {
103
102
  type: "testWrite",
104
103
  id: v7(),
@@ -118,7 +117,6 @@ async function process<Model extends ILlmSchema.Model>(
118
117
 
119
118
  function createController<Model extends ILlmSchema.Model>(props: {
120
119
  model: Model;
121
- artifacts: IAutoBeTestScenarioArtifacts;
122
120
  build: (next: IAutoBeTestWriteApplication.IProps) => void;
123
121
  }): IAgenticaController.IClass<Model> {
124
122
  assertSchemaModel(props.model);
@@ -132,12 +130,6 @@ function createController<Model extends ILlmSchema.Model>(props: {
132
130
  application,
133
131
  execute: {
134
132
  write: (next) => {
135
- next.draft = completeTestCode(props.artifacts, next.draft);
136
- if (next.revise)
137
- next.revise.final = completeTestCode(
138
- props.artifacts,
139
- next.revise.final,
140
- );
141
133
  props.build(next);
142
134
  },
143
135
  } satisfies IAutoBeTestWriteApplication,
@@ -1,7 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { IValidation } from "typia";
3
- export declare const validateAuthorizationSchema: (props: {
4
- errors: IValidation.IError[];
5
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
6
- path: string;
7
- }) => void;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateAuthorizationSchema = void 0;
4
- const validateAuthorizationSchema = (props) => {
5
- var _a, _b;
6
- for (const [key, value] of Object.entries(props.schemas)) {
7
- if (!key.endsWith(".IAuthorized"))
8
- continue;
9
- // Check if it's an object type
10
- if (!isObjectSchema(value)) {
11
- props.errors.push({
12
- path: `${props.path}.${key}`,
13
- expected: `AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IObject>`,
14
- value: value,
15
- description: `${key} must be an object type for authorization responses`,
16
- });
17
- continue;
18
- }
19
- // Check if token property exists
20
- (_a = value.properties) !== null && _a !== void 0 ? _a : (value.properties = {});
21
- value.properties["token"] = {
22
- $ref: "#/components/schemas/IAuthorizationToken",
23
- description: "JWT token information for authentication",
24
- };
25
- (_b = value.required) !== null && _b !== void 0 ? _b : (value.required = []);
26
- if (value.required.includes("token") === false) {
27
- value.required.push("token");
28
- }
29
- }
30
- };
31
- exports.validateAuthorizationSchema = validateAuthorizationSchema;
32
- const isObjectSchema = (schema) => {
33
- return "type" in schema && schema.type === "object";
34
- };
35
- //# sourceMappingURL=validateAuthorizationSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateAuthorizationSchema.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/interface/utils/validateAuthorizationSchema.ts"],"names":[],"mappings":";;;AAGO,MAAM,2BAA2B,GAAG,CAAC,KAI3C,EAAQ,EAAE;;IACT,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC;YAAE,SAAS;QAE5C,+BAA+B;QAC/B,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE;gBAC5B,QAAQ,EAAE,yEAAyE;gBACnF,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,GAAG,GAAG,qDAAqD;aACzE,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,iCAAiC;QACjC,MAAA,KAAK,CAAC,UAAU,oCAAhB,KAAK,CAAC,UAAU,GAAK,EAAE,EAAC;QACxB,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;YAC1B,IAAI,EAAE,0CAA0C;YAChD,WAAW,EAAE,0CAA0C;SACL,CAAC;QAErD,MAAA,KAAK,CAAC,QAAQ,oCAAd,KAAK,CAAC,QAAQ,GAAK,EAAE,EAAC;QACtB,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE,CAAC;YAC/C,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AA/BW,QAAA,2BAA2B,+BA+BtC;AAEF,MAAM,cAAc,GAAG,CACrB,MAA4C,EACY,EAAE;IAC1D,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtD,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { IValidation } from "typia";
3
- export declare const validateAuthorizationSchema: (props: {
4
- errors: IValidation.IError[];
5
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
6
- path: string;
7
- }) => void;
@@ -1,41 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { IValidation } from "typia";
3
-
4
- export const validateAuthorizationSchema = (props: {
5
- errors: IValidation.IError[];
6
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
7
- path: string;
8
- }): void => {
9
- for (const [key, value] of Object.entries(props.schemas)) {
10
- if (!key.endsWith(".IAuthorized")) continue;
11
-
12
- // Check if it's an object type
13
- if (!isObjectSchema(value)) {
14
- props.errors.push({
15
- path: `${props.path}.${key}`,
16
- expected: `AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IObject>`,
17
- value: value,
18
- description: `${key} must be an object type for authorization responses`,
19
- });
20
- continue;
21
- }
22
-
23
- // Check if token property exists
24
- value.properties ??= {};
25
- value.properties["token"] = {
26
- $ref: "#/components/schemas/IAuthorizationToken",
27
- description: "JWT token information for authentication",
28
- } as AutoBeOpenApi.IJsonSchemaDescriptive.IReference;
29
-
30
- value.required ??= [];
31
- if (value.required.includes("token") === false) {
32
- value.required.push("token");
33
- }
34
- }
35
- };
36
-
37
- const isObjectSchema = (
38
- schema: AutoBeOpenApi.IJsonSchemaDescriptive,
39
- ): schema is AutoBeOpenApi.IJsonSchemaDescriptive.IObject => {
40
- return "type" in schema && schema.type === "object";
41
- };