agency-lang 0.0.19 → 0.0.21

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.
@@ -4,10 +4,6 @@ export const DEFAULT_SCHEMA = "z.string()";
4
4
  * Maps Agency types to Zod schema strings
5
5
  */
6
6
  export function mapTypeToZodSchema(variableType, typeAliases) {
7
- console.log({ variableType, typeAliases });
8
- if (!variableType) {
9
- throw new Error("Variable type is undefined");
10
- }
11
7
  if (variableType.type === "primitiveType") {
12
8
  switch (variableType.value.toLowerCase()) {
13
9
  case "number":
@@ -162,7 +162,6 @@ export class TypeScriptGenerator extends BaseGenerator {
162
162
  type: "primitiveType",
163
163
  value: "string",
164
164
  };
165
- console.log({ typeHint, typeAliases: this.typeAliases });
166
165
  const tsType = mapTypeToZodSchema(typeHint, this.typeAliases);
167
166
  properties[param.name] = tsType;
168
167
  });
@@ -307,7 +306,6 @@ export class TypeScriptGenerator extends BaseGenerator {
307
306
  type: "primitiveType",
308
307
  value: "string",
309
308
  };
310
- console.log(">>>", { variableType });
311
309
  const zodSchema = mapTypeToZodSchema(variableType, this.typeAliases);
312
310
  //console.log("Generated Zod schema for variable", variableName, "Variable type:", variableType, ":", zodSchema, "aliases:", this.typeAliases, "hints:", this.typeHints);
313
311
  const typeString = variableTypeToString(variableType, this.typeAliases);
@@ -4,7 +4,7 @@ import { optionalSemicolon } from "./parserUtils.js";
4
4
  export const primitiveTypeParser = trace("primitiveTypeParser", seqC(set("type", "primitiveType"), capture(or(str("number"), str("string"), str("boolean"), str("undefined"), str("null")), "value")));
5
5
  export const typeAliasVariableParser = trace("typeAliasVariableParser", seqC(set("type", "typeAliasVariable"), capture(many1WithJoin(varNameChar), "aliasName")));
6
6
  export const arrayTypeParser = (input) => {
7
- const parser = trace("arrayTypeParser", seqC(set("type", "arrayType"), capture(or(objectTypeParser, primitiveTypeParser), "elementType"), capture(count(str("[]")), "arrayDepth")));
7
+ const parser = trace("arrayTypeParser", seqC(set("type", "arrayType"), capture(or(objectTypeParser, primitiveTypeParser, typeAliasVariableParser), "elementType"), capture(count(str("[]")), "arrayDepth")));
8
8
  const result = parser(input);
9
9
  if (result.success) {
10
10
  // Wrap the elementType in ArrayType according to arrayDepth
@@ -23,7 +23,7 @@ export const arrayTypeParser = (input) => {
23
23
  }
24
24
  return result;
25
25
  };
26
- export const angleBracketsArrayTypeParser = trace("angleBracketsArrayTypeParser", seqC(set("type", "arrayType"), str("array"), char("<"), capture(primitiveTypeParser, "elementType"), char(">")));
26
+ export const angleBracketsArrayTypeParser = trace("angleBracketsArrayTypeParser", seqC(set("type", "arrayType"), str("array"), char("<"), capture(or(primitiveTypeParser, typeAliasVariableParser), "elementType"), char(">")));
27
27
  export const stringLiteralTypeParser = trace("stringLiteralTypeParser", seqC(set("type", "stringLiteralType"), char('"'), capture(many1Till(char('"')), "value"), char('"')));
28
28
  export const numberLiteralTypeParser = trace("numberLiteralTypeParser", seqC(set("type", "numberLiteralType"), capture(many1WithJoin(or(char("-"), char("."), digit)), "value")));
29
29
  export const booleanLiteralTypeParser = trace("booleanLiteralTypeParser", seqC(set("type", "booleanLiteralType"), capture(or(str("true"), str("false")), "value")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agency-lang",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "The Agency language",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {