@formspec/build 0.1.0-alpha.39 → 0.1.0-alpha.40

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
@@ -5813,6 +5813,7 @@ var init_static_build = __esm({
5813
5813
 
5814
5814
  // src/generators/discovered-schema.ts
5815
5815
  import * as ts7 from "typescript";
5816
+ import { analyzeMetadataForNodeWithChecker as analyzeMetadataForNodeWithChecker2 } from "@formspec/analysis/internal";
5816
5817
  import { IR_VERSION as IR_VERSION3 } from "@formspec/core/internals";
5817
5818
  function toDiscoveredTypeSchemas(result, resolvedMetadata) {
5818
5819
  return {
@@ -5886,6 +5887,32 @@ function omitApiName(metadata) {
5886
5887
  const { apiName: _apiName, ...rest } = metadata;
5887
5888
  return Object.keys(rest).length > 0 ? rest : void 0;
5888
5889
  }
5890
+ function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
5891
+ const declarationPolicy = getDeclarationMetadataPolicy(
5892
+ normalizeMetadataPolicy(options.metadata),
5893
+ declarationKind
5894
+ );
5895
+ if (metadata?.apiName === void 0 && declarationPolicy.apiName.mode === "require-explicit") {
5896
+ throw new Error(
5897
+ `Metadata policy requires explicit apiName for ${declarationKind} "${logicalName}" on the tsdoc surface.`
5898
+ );
5899
+ }
5900
+ if (metadata?.displayName === void 0 && declarationPolicy.displayName.mode === "require-explicit") {
5901
+ throw new Error(
5902
+ `Metadata policy requires explicit displayName for ${declarationKind} "${logicalName}" on the tsdoc surface.`
5903
+ );
5904
+ }
5905
+ if (metadata?.apiNamePlural === void 0 && declarationPolicy.apiName.pluralization.mode === "require-explicit") {
5906
+ throw new Error(
5907
+ `Metadata policy requires explicit apiNamePlural for ${declarationKind} "${logicalName}" on the tsdoc surface.`
5908
+ );
5909
+ }
5910
+ if (metadata?.displayNamePlural === void 0 && declarationPolicy.displayName.pluralization.mode === "require-explicit") {
5911
+ throw new Error(
5912
+ `Metadata policy requires explicit displayNamePlural for ${declarationKind} "${logicalName}" on the tsdoc surface.`
5913
+ );
5914
+ }
5915
+ }
5889
5916
  function describeRootType(rootType, typeRegistry, fallbackName) {
5890
5917
  if (rootType.kind !== "reference") {
5891
5918
  return {
@@ -6126,6 +6153,21 @@ function generateSchemasFromReturnType(options) {
6126
6153
  name: fallbackName
6127
6154
  });
6128
6155
  }
6156
+ function resolveDeclarationMetadata(options) {
6157
+ const analysis = analyzeMetadataForNodeWithChecker2({
6158
+ checker: options.context.checker,
6159
+ node: options.declaration,
6160
+ metadata: options.metadata,
6161
+ extensions: options.extensionRegistry?.extensions,
6162
+ buildContext: options.context
6163
+ });
6164
+ if (analysis === null) {
6165
+ return void 0;
6166
+ }
6167
+ const metadata = analysis.resolvedMetadata;
6168
+ enforceRequiredMetadata(metadata, analysis.declarationKind, analysis.logicalName, options);
6169
+ return metadata;
6170
+ }
6129
6171
  function unwrapPromiseType(checker, type) {
6130
6172
  if (!("getAwaitedType" in checker) || typeof checker.getAwaitedType !== "function") {
6131
6173
  return type;
@@ -6378,6 +6420,7 @@ __export(index_exports, {
6378
6420
  generateSchemasFromType: () => generateSchemasFromType,
6379
6421
  generateUiSchema: () => generateUiSchema,
6380
6422
  jsonSchema7Schema: () => jsonSchema7Schema,
6423
+ resolveDeclarationMetadata: () => resolveDeclarationMetadata,
6381
6424
  resolveModuleExport: () => resolveModuleExport,
6382
6425
  resolveModuleExportDeclaration: () => resolveModuleExportDeclaration,
6383
6426
  uiSchemaSchema: () => uiSchema,