@anvil-works/anvil-cli 0.8.0-canary.2 → 0.8.0-canary.4

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.
package/dist/cli.js CHANGED
@@ -15863,7 +15863,8 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
15863
15863
  if (PYTHON_KEYWORDS.has(value)) pushIssue(issues, path, "must be a valid Python identifier (not a keyword)");
15864
15864
  }
15865
15865
  const componentTypeSpec_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
15866
- const DEP_ID_RE = /^dep_[A-Za-z0-9]+$/;
15866
+ const LEGACY_CUSTOM_COMPONENT_SPEC_RE = /^form:(?:([^:]+):)?(.+)$/;
15867
+ const PACKAGE_QUALIFIED_FORM_NAME_RE = /^([^.]+)\.(.+)$/;
15867
15868
  const componentTypeSpec_PYTHON_KEYWORDS = new Set([
15868
15869
  "False",
15869
15870
  "None",
@@ -15903,32 +15904,17 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
15903
15904
  "match",
15904
15905
  "case"
15905
15906
  ]);
15906
- const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form)";
15907
+ const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form, form:APP_ID:Package.Form)";
15907
15908
  const COMPONENT_TYPE_REFERENCE_MESSAGE = "must be a known Anvil component type (see componentIcons.ts), a form: reference, or a package-qualified form reference (Package.Form)";
15908
15909
  function isValidIdentifierSegment(value) {
15909
15910
  return value.length > 0 && componentTypeSpec_IDENTIFIER_RE.test(value) && !componentTypeSpec_PYTHON_KEYWORDS.has(value);
15910
15911
  }
15911
15912
  function isValidLegacyFormTypeReference(typeName) {
15912
- if (!typeName.startsWith("form:")) return false;
15913
- const rest = typeName.slice(5);
15914
- if (0 === rest.length) return false;
15915
- let classPath = rest;
15916
- if (rest.startsWith("dep_")) {
15917
- const splitIndex = rest.indexOf(":");
15918
- if (splitIndex <= 0) return false;
15919
- const depId = rest.slice(0, splitIndex);
15920
- if (!DEP_ID_RE.test(depId)) return false;
15921
- classPath = rest.slice(splitIndex + 1);
15922
- }
15923
- if (0 === classPath.length) return false;
15924
- return classPath.split(".").every((part)=>isValidIdentifierSegment(part));
15913
+ return LEGACY_CUSTOM_COMPONENT_SPEC_RE.test(typeName);
15925
15914
  }
15926
15915
  function isValidPackageQualifiedComponentType(typeName) {
15927
15916
  if (typeName.startsWith("anvil.")) return false;
15928
- if (!typeName.includes(".")) return false;
15929
- const parts = typeName.split(".");
15930
- if (parts.length < 2) return false;
15931
- return parts.every((part)=>isValidIdentifierSegment(part));
15917
+ return PACKAGE_QUALIFIED_FORM_NAME_RE.test(typeName);
15932
15918
  }
15933
15919
  function componentTypeSpec_pushIssue(issues, path, message) {
15934
15920
  issues.push({
@@ -16037,7 +16023,7 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16037
16023
  const bindingPath = `${path}[${index}]`;
16038
16024
  if (!isPlainObject(binding)) return void formTemplateValidation_pushIssue(issues, bindingPath, "must be an object");
16039
16025
  if ("string" != typeof binding.property || 0 === binding.property.length) formTemplateValidation_pushIssue(issues, `${bindingPath}.property`, "must be a non-empty string");
16040
- if ("string" != typeof binding.code || 0 === binding.code.length) formTemplateValidation_pushIssue(issues, `${bindingPath}.code`, "must be a non-empty string");
16026
+ if ("string" != typeof binding.code) formTemplateValidation_pushIssue(issues, `${bindingPath}.code`, "must be a string");
16041
16027
  if (void 0 !== binding.writeback && "boolean" != typeof binding.writeback) formTemplateValidation_pushIssue(issues, `${bindingPath}.writeback`, "must be a boolean");
16042
16028
  });
16043
16029
  }
@@ -16353,7 +16339,7 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16353
16339
  function validateParsedHtmlTemplate(parsed) {
16354
16340
  return validateFormTemplateData(parsed);
16355
16341
  }
16356
- function validateFormTemplateHtml(htmlContent, parseHtml = form_template_parser_namespaceObject.parseSerializedHtml) {
16342
+ function validateFormTemplateHtml(htmlContent, parseHtml = form_template_parser_namespaceObject.parseSerializedHtml, options = {}) {
16357
16343
  const { frontmatter, body, bodyStartOffset } = splitHtmlFormTemplateFrontmatter(htmlContent);
16358
16344
  if (null !== frontmatter) {
16359
16345
  const frontmatterIssues = validateHtmlFrontmatter(frontmatter);
@@ -16366,7 +16352,10 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16366
16352
  let parsed;
16367
16353
  try {
16368
16354
  parsed = parseHtml(body, {
16369
- warnings: true
16355
+ warnings: true,
16356
+ ...options.formSpecPackageContext ? {
16357
+ formSpecPackageContext: options.formSpecPackageContext
16358
+ } : {}
16370
16359
  });
16371
16360
  } catch (error) {
16372
16361
  return {
@@ -17016,7 +17005,7 @@ print(json.dumps({"issues": issues}))
17016
17005
  currentDir = parentDir;
17017
17006
  }
17018
17007
  }
17019
- function validatePath(filePath, fileContent) {
17008
+ function validatePath(filePath, fileContent, options = {}) {
17020
17009
  const target = inferValidationTarget(filePath);
17021
17010
  const existingPath = resolveExistingPath(filePath);
17022
17011
  const appRoot = findAnvilAppRoot(filePath);
@@ -17089,7 +17078,9 @@ print(json.dumps({"issues": issues}))
17089
17078
  ]
17090
17079
  };
17091
17080
  }
17092
- const result = validateFormTemplateHtml(fileContent);
17081
+ const result = validateFormTemplateHtml(fileContent, void 0, {
17082
+ formSpecPackageContext: options.formSpecPackageContext
17083
+ });
17093
17084
  return result.ok ? validPathResult(target, result.warnings) : {
17094
17085
  ...result,
17095
17086
  target
@@ -23302,7 +23293,7 @@ print(json.dumps({"issues": issues}))
23302
23293
  walk(dir);
23303
23294
  return files.sort();
23304
23295
  }
23305
- function validateSingleFile(file) {
23296
+ async function validateSingleFile(file) {
23306
23297
  let fileContent;
23307
23298
  try {
23308
23299
  fileContent = (0, external_fs_.readFileSync)(file, "utf8");
@@ -23320,7 +23311,10 @@ print(json.dumps({"issues": issues}))
23320
23311
  ]
23321
23312
  };
23322
23313
  }
23323
- const result = validatePath(file, fileContent);
23314
+ const formSpecPackageContext = "form_template.html" === inferValidationTarget(file) ? await buildFormSpecPackageContext(file) : void 0;
23315
+ const result = validatePath(file, fileContent, {
23316
+ formSpecPackageContext
23317
+ });
23324
23318
  if (result.ok) return {
23325
23319
  file,
23326
23320
  type: result.target,
@@ -23355,8 +23349,8 @@ print(json.dumps({"issues": issues}))
23355
23349
  function logValidationWarnings(fileResult) {
23356
23350
  for (const warning of fileResult.warnings ?? [])logger_logger.warn(formatValidationWarning(fileResult.file, warning));
23357
23351
  }
23358
- function handleValidateFile(file) {
23359
- const fileResult = validateSingleFile(file);
23352
+ async function handleValidateFile(file) {
23353
+ const fileResult = await validateSingleFile(file);
23360
23354
  if (fileResult.valid) {
23361
23355
  if (getGlobalOutputConfig().jsonMode) logJsonResult(true, {
23362
23356
  data: {
@@ -23391,7 +23385,7 @@ print(json.dumps({"issues": issues}))
23391
23385
  }
23392
23386
  process.exitCode = 1;
23393
23387
  }
23394
- function handleValidateDirectory(dir) {
23388
+ async function handleValidateDirectory(dir) {
23395
23389
  const files = collectValidationFiles(dir);
23396
23390
  if (0 === files.length) {
23397
23391
  const error = `No supported files found under ${dir}`;
@@ -23407,7 +23401,7 @@ print(json.dumps({"issues": issues}))
23407
23401
  process.exitCode = 1;
23408
23402
  return;
23409
23403
  }
23410
- const fileResults = files.map(validateSingleFile);
23404
+ const fileResults = await Promise.all(files.map(validateSingleFile));
23411
23405
  const failedResults = fileResults.filter((result)=>!result.valid);
23412
23406
  if (getGlobalOutputConfig().jsonMode) logJsonResult(0 === failedResults.length, {
23413
23407
  error: failedResults.length > 0 ? "Validation failed" : void 0,
@@ -23540,7 +23534,7 @@ print(json.dumps({"issues": issues}))
23540
23534
  program.command("update").description("Update anvil to the latest version").alias("u").action(async ()=>{
23541
23535
  await handleUpdateCommand();
23542
23536
  });
23543
- program.command("validate").description("Validate Anvil app files by path or directory (anvil.yaml, client_code/**/*.yaml, client_code/**/*.html, client_code/**/*.py, or server_code/**/*.py)").argument("<path>", "Path to file or directory").action((file)=>{
23537
+ program.command("validate").description("Validate Anvil app files by path or directory (anvil.yaml, client_code/**/*.yaml, client_code/**/*.html, client_code/**/*.py, or server_code/**/*.py)").argument("<path>", "Path to file or directory").action(async (file)=>{
23544
23538
  let pathStat;
23545
23539
  try {
23546
23540
  pathStat = (0, external_fs_.statSync)(file);
@@ -23549,8 +23543,8 @@ print(json.dumps({"issues": issues}))
23549
23543
  process.exitCode = 1;
23550
23544
  return;
23551
23545
  }
23552
- if (pathStat.isDirectory()) return void handleValidateDirectory(file);
23553
- handleValidateFile(file);
23546
+ if (pathStat.isDirectory()) return void await handleValidateDirectory(file);
23547
+ await handleValidateFile(file);
23554
23548
  });
23555
23549
  if (watchCommand) {
23556
23550
  const watchOptions = watchCommand.options.map((opt)=>{
@@ -1,5 +1,5 @@
1
1
  import type { ValidationIssue } from "./validators";
2
- export declare const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form)";
2
+ export declare const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form, form:APP_ID:Package.Form)";
3
3
  export declare const COMPONENT_TYPE_REFERENCE_MESSAGE = "must be a known Anvil component type (see componentIcons.ts), a form: reference, or a package-qualified form reference (Package.Form)";
4
4
  export declare function isValidLegacyFormTypeReference(typeName: string): boolean;
5
5
  export declare function isValidPackageQualifiedComponentType(typeName: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"componentTypeSpec.d.ts","sourceRoot":"","sources":["../src/componentTypeSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA6CpD,eAAO,MAAM,kCAAkC,kFACoC,CAAC;AAEpF,eAAO,MAAM,gCAAgC,0IAC8F,CAAC;AAM5I,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA0BxE;AAED,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAY9E;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAWlH;AAMD,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,EAAE,EACzB,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAC,QAwBjD"}
1
+ {"version":3,"file":"componentTypeSpec.d.ts","sourceRoot":"","sources":["../src/componentTypeSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA8CpD,eAAO,MAAM,kCAAkC,4GAC8D,CAAC;AAE9G,eAAO,MAAM,gCAAgC,0IAC8F,CAAC;AAM5I,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExE;AAED,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAK9E;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAWlH;AAMD,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,EAAE,EACzB,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAC,QAwBjD"}
package/dist/index.js CHANGED
@@ -15892,7 +15892,8 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
15892
15892
  if (PYTHON_KEYWORDS.has(value)) pushIssue(issues, path, "must be a valid Python identifier (not a keyword)");
15893
15893
  }
15894
15894
  const componentTypeSpec_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
15895
- const DEP_ID_RE = /^dep_[A-Za-z0-9]+$/;
15895
+ const LEGACY_CUSTOM_COMPONENT_SPEC_RE = /^form:(?:([^:]+):)?(.+)$/;
15896
+ const PACKAGE_QUALIFIED_FORM_NAME_RE = /^([^.]+)\.(.+)$/;
15896
15897
  const componentTypeSpec_PYTHON_KEYWORDS = new Set([
15897
15898
  "False",
15898
15899
  "None",
@@ -15932,32 +15933,17 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
15932
15933
  "match",
15933
15934
  "case"
15934
15935
  ]);
15935
- const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form)";
15936
+ const LEGACY_FORM_TYPE_REFERENCE_MESSAGE = "must be a valid form: reference (form:Module.Form, form:dep_xxx:Package.Form, form:APP_ID:Package.Form)";
15936
15937
  const COMPONENT_TYPE_REFERENCE_MESSAGE = "must be a known Anvil component type (see componentIcons.ts), a form: reference, or a package-qualified form reference (Package.Form)";
15937
15938
  function isValidIdentifierSegment(value) {
15938
15939
  return value.length > 0 && componentTypeSpec_IDENTIFIER_RE.test(value) && !componentTypeSpec_PYTHON_KEYWORDS.has(value);
15939
15940
  }
15940
15941
  function isValidLegacyFormTypeReference(typeName) {
15941
- if (!typeName.startsWith("form:")) return false;
15942
- const rest = typeName.slice(5);
15943
- if (0 === rest.length) return false;
15944
- let classPath = rest;
15945
- if (rest.startsWith("dep_")) {
15946
- const splitIndex = rest.indexOf(":");
15947
- if (splitIndex <= 0) return false;
15948
- const depId = rest.slice(0, splitIndex);
15949
- if (!DEP_ID_RE.test(depId)) return false;
15950
- classPath = rest.slice(splitIndex + 1);
15951
- }
15952
- if (0 === classPath.length) return false;
15953
- return classPath.split(".").every((part)=>isValidIdentifierSegment(part));
15942
+ return LEGACY_CUSTOM_COMPONENT_SPEC_RE.test(typeName);
15954
15943
  }
15955
15944
  function isValidPackageQualifiedComponentType(typeName) {
15956
15945
  if (typeName.startsWith("anvil.")) return false;
15957
- if (!typeName.includes(".")) return false;
15958
- const parts = typeName.split(".");
15959
- if (parts.length < 2) return false;
15960
- return parts.every((part)=>isValidIdentifierSegment(part));
15946
+ return PACKAGE_QUALIFIED_FORM_NAME_RE.test(typeName);
15961
15947
  }
15962
15948
  function componentTypeSpec_pushIssue(issues, path, message) {
15963
15949
  issues.push({
@@ -16066,7 +16052,7 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16066
16052
  const bindingPath = `${path}[${index}]`;
16067
16053
  if (!isPlainObject(binding)) return void formTemplateValidation_pushIssue(issues, bindingPath, "must be an object");
16068
16054
  if ("string" != typeof binding.property || 0 === binding.property.length) formTemplateValidation_pushIssue(issues, `${bindingPath}.property`, "must be a non-empty string");
16069
- if ("string" != typeof binding.code || 0 === binding.code.length) formTemplateValidation_pushIssue(issues, `${bindingPath}.code`, "must be a non-empty string");
16055
+ if ("string" != typeof binding.code) formTemplateValidation_pushIssue(issues, `${bindingPath}.code`, "must be a string");
16070
16056
  if (void 0 !== binding.writeback && "boolean" != typeof binding.writeback) formTemplateValidation_pushIssue(issues, `${bindingPath}.writeback`, "must be a boolean");
16071
16057
  });
16072
16058
  }
@@ -16382,7 +16368,7 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16382
16368
  function validateParsedHtmlTemplate(parsed) {
16383
16369
  return validateFormTemplateData(parsed);
16384
16370
  }
16385
- function validateFormTemplateHtml(htmlContent, parseHtml = form_template_parser_namespaceObject.parseSerializedHtml) {
16371
+ function validateFormTemplateHtml(htmlContent, parseHtml = form_template_parser_namespaceObject.parseSerializedHtml, options = {}) {
16386
16372
  const { frontmatter, body, bodyStartOffset } = splitHtmlFormTemplateFrontmatter(htmlContent);
16387
16373
  if (null !== frontmatter) {
16388
16374
  const frontmatterIssues = validateHtmlFrontmatter(frontmatter);
@@ -16395,7 +16381,10 @@ Promise.resolve(executeGitCredentialOperation(process.argv[2] || "get", {
16395
16381
  let parsed;
16396
16382
  try {
16397
16383
  parsed = parseHtml(body, {
16398
- warnings: true
16384
+ warnings: true,
16385
+ ...options.formSpecPackageContext ? {
16386
+ formSpecPackageContext: options.formSpecPackageContext
16387
+ } : {}
16399
16388
  });
16400
16389
  } catch (error) {
16401
16390
  return {
@@ -17045,7 +17034,7 @@ print(json.dumps({"issues": issues}))
17045
17034
  currentDir = parentDir;
17046
17035
  }
17047
17036
  }
17048
- function validatePath(filePath, fileContent) {
17037
+ function validatePath(filePath, fileContent, options = {}) {
17049
17038
  const target = inferValidationTarget(filePath);
17050
17039
  const existingPath = resolveExistingPath(filePath);
17051
17040
  const appRoot = findAnvilAppRoot(filePath);
@@ -17118,7 +17107,9 @@ print(json.dumps({"issues": issues}))
17118
17107
  ]
17119
17108
  };
17120
17109
  }
17121
- const result = validateFormTemplateHtml(fileContent);
17110
+ const result = validateFormTemplateHtml(fileContent, void 0, {
17111
+ formSpecPackageContext: options.formSpecPackageContext
17112
+ });
17122
17113
  return result.ok ? validPathResult(target, result.warnings) : {
17123
17114
  ...result,
17124
17115
  target
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuDpC,KAAK,sBAAsB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,S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13 @@
1
- import { type ParsedHtmlTemplate } from "@anvil-works/form-template-parser";
1
+ import { type FormSpecPackageContext, type ParsedHtmlTemplate } from "@anvil-works/form-template-parser";
2
2
  import type { FormTemplateValidationResult, ValidationIssue } from "./validators";
3
3
  type ParseHtmlOptions = {
4
4
  warnings?: boolean;
5
+ formSpecPackageContext?: FormSpecPackageContext;
5
6
  };
6
7
  type ParseHtml = (html: string, options?: ParseHtmlOptions) => ParsedHtmlTemplate;
8
+ export type ValidateFormTemplateHtmlOptions = {
9
+ formSpecPackageContext?: FormSpecPackageContext;
10
+ };
7
11
  export declare function splitHtmlFormTemplateFrontmatter(htmlContent: string): {
8
12
  frontmatter: string | null;
9
13
  body: string;
@@ -11,6 +15,6 @@ export declare function splitHtmlFormTemplateFrontmatter(htmlContent: string): {
11
15
  };
12
16
  export declare function validateHtmlFrontmatter(frontmatterYaml: string): ValidationIssue[];
13
17
  export declare function validateParsedHtmlTemplate(parsed: ParsedHtmlTemplate): ValidationIssue[];
14
- export declare function validateFormTemplateHtml(htmlContent: string, parseHtml?: ParseHtml): FormTemplateValidationResult;
18
+ export declare function validateFormTemplateHtml(htmlContent: string, parseHtml?: ParseHtml, options?: ValidateFormTemplateHtmlOptions): FormTemplateValidationResult;
15
19
  export {};
16
20
  //# sourceMappingURL=validateFormTemplateHtml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateFormTemplateHtml.d.ts","sourceRoot":"","sources":["../src/validateFormTemplateHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,kBAAkB,EAC1B,MAAM,mCAAmC,CAAC;AAM3C,OAAO,KAAK,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAmClF,KAAK,gBAAgB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC/C,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,kBAAkB,C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AM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CAExF;AAED,wBAAgB,wBAAwB,CACpC,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,SAA4C,EACvD,OAAO,GAAE,+BAAoC,GAC9C,4BAA4B,CA8C9B"}
@@ -1,3 +1,4 @@
1
+ import type { FormSpecPackageContext } from "@anvil-works/form-template-parser";
1
2
  export type ValidationIssue = {
2
3
  path: string;
3
4
  message: string;
@@ -43,6 +44,9 @@ export type ValidatePathResult = {
43
44
  issues: ValidationIssue[];
44
45
  warnings?: ValidationIssue[];
45
46
  };
47
+ export type ValidatePathOptions = {
48
+ formSpecPackageContext?: FormSpecPackageContext;
49
+ };
46
50
  export declare function formatValidationPath(path: string): string;
47
51
  /**
48
52
  * Validates form_template.yaml structure
@@ -62,5 +66,5 @@ export declare function findAnvilAppRoot(filePath: string): string | null;
62
66
  * - any form HTML under `client_code/` with a `.html` suffix
63
67
  * - any Python file under `client_code/` or `server_code/`
64
68
  */
65
- export declare function validatePath(filePath: string, fileContent: string): ValidatePathResult;
69
+ export declare function validatePath(filePath: string, fileContent: string, options?: ValidatePathOptions): ValidatePathResult;
66
70
  //# sourceMappingURL=validators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAA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;GAMG;AACH,wBAAgB,YAAY,CACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,mBAAwB,GAClC,kBAAkB,CAsIpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvil-works/anvil-cli",
3
- "version": "0.8.0-canary.2",
3
+ "version": "0.8.0-canary.4",
4
4
  "description": "CLI tool for developing Anvil apps locally",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/api.d.ts",
@@ -64,7 +64,7 @@
64
64
  "typescript": "^5.9.3"
65
65
  },
66
66
  "dependencies": {
67
- "@anvil-works/form-template-parser": "0.0.4",
67
+ "@anvil-works/form-template-parser": "0.0.5",
68
68
  "@napi-rs/keyring": "^1.2.0",
69
69
  "@types/inquirer": "^9.0.9",
70
70
  "@types/js-yaml": "^4.0.9",