@azure-tools/typespec-azure-resource-manager 0.72.0-dev.0 → 0.72.0-dev.10

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 (47) hide show
  1. package/README.md +6 -0
  2. package/dist/src/linter.d.ts.map +1 -1
  3. package/dist/src/linter.js +12 -0
  4. package/dist/src/linter.js.map +1 -1
  5. package/dist/src/operations.d.ts +1 -1
  6. package/dist/src/operations.d.ts.map +1 -1
  7. package/dist/src/operations.js +6 -6
  8. package/dist/src/operations.js.map +1 -1
  9. package/dist/src/resource.d.ts +10 -6
  10. package/dist/src/resource.d.ts.map +1 -1
  11. package/dist/src/resource.js +267 -162
  12. package/dist/src/resource.js.map +1 -1
  13. package/dist/src/rules/arm-feature-file-usage-discourage.js +1 -1
  14. package/dist/src/rules/arm-feature-file-usage-discourage.js.map +1 -1
  15. package/dist/src/rules/list-operation-missing-pageable.d.ts +4 -0
  16. package/dist/src/rules/list-operation-missing-pageable.d.ts.map +1 -0
  17. package/dist/src/rules/list-operation-missing-pageable.js +45 -0
  18. package/dist/src/rules/list-operation-missing-pageable.js.map +1 -0
  19. package/dist/src/rules/list-response-envelope.d.ts +4 -0
  20. package/dist/src/rules/list-response-envelope.d.ts.map +1 -0
  21. package/dist/src/rules/list-response-envelope.js +94 -0
  22. package/dist/src/rules/list-response-envelope.js.map +1 -0
  23. package/dist/src/rules/lro-response-mismatch.d.ts +11 -0
  24. package/dist/src/rules/lro-response-mismatch.d.ts.map +1 -0
  25. package/dist/src/rules/lro-response-mismatch.js +265 -0
  26. package/dist/src/rules/lro-response-mismatch.js.map +1 -0
  27. package/dist/src/rules/no-query-in-collection.d.ts +4 -0
  28. package/dist/src/rules/no-query-in-collection.d.ts.map +1 -0
  29. package/dist/src/rules/no-query-in-collection.js +43 -0
  30. package/dist/src/rules/no-query-in-collection.js.map +1 -0
  31. package/dist/src/rules/no-query-in-point-op.d.ts +4 -0
  32. package/dist/src/rules/no-query-in-point-op.d.ts.map +1 -0
  33. package/dist/src/rules/no-query-in-point-op.js +50 -0
  34. package/dist/src/rules/no-query-in-point-op.js.map +1 -0
  35. package/dist/src/rules/use-application-json-content-type.d.ts +4 -0
  36. package/dist/src/rules/use-application-json-content-type.d.ts.map +1 -0
  37. package/dist/src/rules/use-application-json-content-type.js +59 -0
  38. package/dist/src/rules/use-application-json-content-type.js.map +1 -0
  39. package/dist/src/rules/utils.d.ts +4 -0
  40. package/dist/src/rules/utils.d.ts.map +1 -1
  41. package/dist/src/rules/utils.js +11 -0
  42. package/dist/src/rules/utils.js.map +1 -1
  43. package/lib/common-types/billing-data.tsp +1 -1
  44. package/lib/models.tsp +2 -2
  45. package/lib/parameters.tsp +3 -6
  46. package/lib/responses.tsp +4 -5
  47. package/package.json +12 -12
@@ -393,7 +393,7 @@ function getResourceScope(knownResources, resource, resourcesToProcess) {
393
393
  return undefined;
394
394
  }
395
395
  function isVariableSegment(segment) {
396
- return (segment.startsWith("{") && segment.endsWith("}")) || segment === "default";
396
+ return segment.startsWith("{") && segment.endsWith("}");
397
397
  }
398
398
  /**
399
399
  * Extracts the scope prefix from a resource instance path.
@@ -418,149 +418,210 @@ function normalizePathForScopeComparison(path) {
418
418
  .map((s) => (isVariableSegment(s) ? "{}" : s.toLowerCase()))
419
419
  .join("/");
420
420
  }
421
- function getResourceInfo(program, operation, resourceModel) {
422
- const pathInfo = getResourcePathElements(operation.httpOperation.path, operation.kind);
423
- // First, try to get resource info from the path when it contains /providers/
424
- if (pathInfo !== undefined) {
425
- return {
426
- ...pathInfo,
427
- resourceName: operation.resourceName ?? operation.operationGroup,
428
- };
421
+ function normalizePathForResourceIdentity(path) {
422
+ return path
423
+ .split("/")
424
+ .map((s) => (isVariableSegment(s) ? "{}" : s.toLowerCase()))
425
+ .join("/");
426
+ }
427
+ function trimScopePrefix(path) {
428
+ const scopePrefix = getScopePrefix(path);
429
+ return scopePrefix === "" ? path : path.slice(scopePrefix.length);
430
+ }
431
+ function isResourceIdentityOperation(kind) {
432
+ return kind === "read" || kind === "createOrUpdate";
433
+ }
434
+ function isInstanceLifecycleOperation(kind) {
435
+ switch (kind) {
436
+ case "read":
437
+ case "createOrUpdate":
438
+ case "update":
439
+ case "delete":
440
+ case "checkExistence":
441
+ return true;
442
+ default:
443
+ return false;
429
444
  }
430
- // If the path does not contain /providers/, we can still identify the resource
431
- // because an ARM operations decorator was executed on this operation (e.g.
432
- // @armResourceRead, @armResourceCreateOrUpdate, etc.). Use the ARM provider
433
- // namespace and the path structure to construct resource info.
434
- const fallback = getResourceInfoFromArmOperation(program, operation.httpOperation.path, operation.kind, operation.operation, resourceModel);
435
- if (fallback === undefined)
445
+ }
446
+ function getResourceInfo(operation) {
447
+ const pathInfo = parseArmResourceInstancePath(operation.httpOperation.path);
448
+ if (pathInfo === undefined)
436
449
  return undefined;
437
450
  return {
438
- ...fallback,
451
+ ...pathInfo,
439
452
  resourceName: operation.resourceName ?? operation.operationGroup,
440
453
  };
441
454
  }
442
- export function getResourcePathElements(path, kind) {
455
+ export function parseArmResourceInstancePath(path) {
443
456
  const segments = path.split("/").filter((s) => s.length > 0);
444
457
  const providerIndex = segments.findLastIndex((s) => s === "providers");
445
- if (providerIndex === -1 || providerIndex === segments.length - 1)
458
+ if (providerIndex === -1) {
459
+ return parseKnownProviderlessResourcePath(path, segments);
460
+ }
461
+ if (providerIndex === segments.length - 1)
446
462
  return undefined;
447
463
  const provider = segments[providerIndex + 1];
464
+ if (isVariableSegment(provider))
465
+ return undefined;
466
+ const resourceSegments = segments.slice(providerIndex + 2);
467
+ if (resourceSegments.length === 0 || resourceSegments.length % 2 !== 0)
468
+ return undefined;
448
469
  const typeSegments = [];
449
470
  const instanceSegments = segments.slice(0, providerIndex + 2);
450
- for (let i = providerIndex + 2; i < segments.length; i += 2) {
451
- if (isVariableSegment(segments[i])) {
452
- break;
453
- }
454
- if (i + 1 < segments.length && isVariableSegment(segments[i + 1])) {
455
- typeSegments.push(segments[i]);
456
- instanceSegments.push(segments[i]);
457
- instanceSegments.push(segments[i + 1]);
458
- }
459
- else if (i + 1 === segments.length) {
460
- switch (kind) {
461
- case "list":
462
- typeSegments.push(segments[i]);
463
- instanceSegments.push(segments[i]);
464
- instanceSegments.push("{name}");
465
- break;
466
- default:
467
- break;
468
- }
469
- break;
470
- }
471
+ for (let i = 0; i < resourceSegments.length; i += 2) {
472
+ const typeSegment = resourceSegments[i];
473
+ const nameSegment = resourceSegments[i + 1];
474
+ if (typeSegment === undefined || nameSegment === undefined)
475
+ return undefined;
476
+ if (isVariableSegment(typeSegment))
477
+ return undefined;
478
+ typeSegments.push(typeSegment);
479
+ instanceSegments.push(typeSegment);
480
+ instanceSegments.push(nameSegment);
471
481
  }
472
- if (provider !== undefined && typeSegments.length > 0) {
482
+ return {
483
+ resourceType: {
484
+ provider: provider,
485
+ types: typeSegments,
486
+ },
487
+ resourceInstancePath: `/${instanceSegments.join("/")}`,
488
+ };
489
+ }
490
+ function parseKnownProviderlessResourcePath(path, segments) {
491
+ if (segments.length === 0) {
473
492
  return {
474
493
  resourceType: {
475
- provider: provider,
476
- types: typeSegments,
494
+ provider: "Microsoft.Resources",
495
+ types: ["tenants"],
496
+ },
497
+ resourceInstancePath: "/",
498
+ };
499
+ }
500
+ if (segments.length === 2 &&
501
+ segments[0].toLowerCase() === "subscriptions" &&
502
+ isVariableSegment(segments[1])) {
503
+ return {
504
+ resourceType: {
505
+ provider: "Microsoft.Resources",
506
+ types: ["subscriptions"],
507
+ },
508
+ resourceInstancePath: `/${segments.join("/")}`,
509
+ };
510
+ }
511
+ if (segments.length === 4 &&
512
+ segments[0].toLowerCase() === "subscriptions" &&
513
+ isVariableSegment(segments[1]) &&
514
+ segments[2].toLowerCase() === "resourcegroups" &&
515
+ isVariableSegment(segments[3])) {
516
+ return {
517
+ resourceType: {
518
+ provider: "Microsoft.Resources",
519
+ types: ["resourceGroups"],
520
+ },
521
+ resourceInstancePath: `/${segments.join("/")}`,
522
+ };
523
+ }
524
+ if (segments.length === 1 && isVariableSegment(segments[0])) {
525
+ return {
526
+ resourceType: {
527
+ provider: "",
528
+ types: [],
477
529
  },
478
- resourceInstancePath: `/${instanceSegments.join("/")}`,
530
+ resourceInstancePath: path,
479
531
  };
480
532
  }
481
533
  return undefined;
482
534
  }
483
- /**
484
- * Construct resource path info for an ARM resource operation whose path does not
485
- * contain a /providers/ segment. This relies on the fact that an ARM operations
486
- * decorator was executed on the operation, so we know it belongs to a resource.
487
- * The provider namespace is resolved from the operation's namespace.
488
- */
489
- function getResourceInfoFromArmOperation(program, path, kind, operation, resourceModel) {
490
- const provider = operation.namespace
491
- ? getArmProviderNamespace(program, operation.namespace)
492
- : undefined;
493
- if (provider === undefined)
494
- return undefined;
535
+ function isListOperationPrefixMatch(operation, resource) {
536
+ const operationPath = normalizePathForResourceIdentity(operation.httpOperation.path);
537
+ const resourcePath = normalizePathForResourceIdentity(resource.resourceInstancePath);
538
+ return resourcePath.startsWith(`${operationPath}/`);
539
+ }
540
+ function isListOperationResourceTypeMatch(operation, resource) {
541
+ const operationPath = normalizePathForResourceIdentity(operation.httpOperation.path);
542
+ const resourcePath = normalizePathForResourceIdentity(resource.resourceInstancePath);
543
+ return isSameResourceTypePath(operationPath, resourcePath);
544
+ }
545
+ function getListMatchDistance(operation, resource) {
546
+ const operationPath = trimScopePrefix(normalizePathForResourceIdentity(operation.httpOperation.path));
547
+ const resourcePath = trimScopePrefix(normalizePathForResourceIdentity(resource.resourceInstancePath));
548
+ return resourcePath.length - operationPath.length;
549
+ }
550
+ function isSameResourceTypePath(leftPath, rightPath) {
551
+ const left = parseArmResourceCollectionPath(leftPath);
552
+ const right = parseArmResourceInstancePath(rightPath)?.resourceType;
553
+ if (left === undefined || right === undefined)
554
+ return false;
555
+ return (left.provider.toLowerCase() === right.provider.toLowerCase() &&
556
+ left.types.map((x) => x.toLowerCase()).join("/") ===
557
+ right.types.map((x) => x.toLowerCase()).join("/"));
558
+ }
559
+ function parseArmResourceCollectionPath(path) {
495
560
  const segments = path.split("/").filter((s) => s.length > 0);
496
- // Find the innermost resource type segment by scanning forward.
497
- // The resource type segment is a non-variable segment followed by either
498
- // a variable segment (instance path) or end-of-path (list operation).
499
- let resourceTypeIndex = -1;
500
- for (let i = 0; i < segments.length; i++) {
501
- if (!isVariableSegment(segments[i])) {
502
- if (i + 1 < segments.length && isVariableSegment(segments[i + 1])) {
503
- // Non-variable followed by variable: this is a resource type/instance pair
504
- resourceTypeIndex = i;
505
- }
506
- else if (i + 1 === segments.length && kind === "list") {
507
- // Terminal non-variable segment in a list operation: this is the resource type
508
- resourceTypeIndex = i;
509
- }
510
- }
511
- }
512
- if (resourceTypeIndex === -1) {
513
- // For generic resources, the path may consist entirely of variable segments
514
- // (e.g. /{resourceId}). Use the raw path as the instance path.
515
- if (segments.length > 0 && segments.every((s) => isVariableSegment(s))) {
516
- return {
517
- resourceType: {
518
- provider: provider,
519
- types: [],
520
- },
521
- resourceInstancePath: path,
522
- };
523
- }
561
+ const providerIndex = segments.findLastIndex((s) => s.toLowerCase() === "providers");
562
+ if (providerIndex === -1 || providerIndex === segments.length - 1)
563
+ return undefined;
564
+ const provider = segments[providerIndex + 1];
565
+ if (isVariableSegment(provider))
524
566
  return undefined;
567
+ const resourceSegments = segments.slice(providerIndex + 2);
568
+ if (resourceSegments.length === 0)
569
+ return undefined;
570
+ const types = [];
571
+ for (let i = 0; i < resourceSegments.length; i += 2) {
572
+ const typeSegment = resourceSegments[i];
573
+ if (typeSegment === undefined || isVariableSegment(typeSegment))
574
+ return undefined;
575
+ types.push(typeSegment);
525
576
  }
526
- const resourceTypeName = segments[resourceTypeIndex];
527
- const typeSegments = [resourceTypeName];
528
- // Build the instance path: all segments up to and including the resource type,
529
- // plus the instance variable
530
- const instanceSegments = segments.slice(0, resourceTypeIndex + 1);
531
- // For list operations (no instance variable in path), derive the variable name
532
- // from the resource model's @key property
533
- if (resourceTypeIndex + 1 < segments.length &&
534
- isVariableSegment(segments[resourceTypeIndex + 1])) {
535
- instanceSegments.push(segments[resourceTypeIndex + 1]);
536
- }
537
- else if (kind === "list" && resourceModel) {
538
- // Derive instance path variable name from the resource model's @key property
539
- let keyPropName;
540
- for (const [, prop] of resourceModel.properties) {
541
- const keyName = getKeyName(program, prop);
542
- if (keyName !== undefined) {
543
- keyPropName = keyName;
544
- break;
545
- }
546
- }
547
- if (keyPropName) {
548
- instanceSegments.push(`{${keyPropName}}`);
577
+ return { provider, types };
578
+ }
579
+ function getBestListOperationTarget(operation, resources) {
580
+ let best;
581
+ let bestDistance = Number.POSITIVE_INFINITY;
582
+ for (const resource of resources) {
583
+ if (!isListOperationPrefixMatch(operation, resource))
584
+ continue;
585
+ const distance = getListMatchDistance(operation, resource);
586
+ if (distance < bestDistance) {
587
+ best = resource;
588
+ bestDistance = distance;
549
589
  }
550
- else {
551
- instanceSegments.push("{name}");
590
+ }
591
+ if (best !== undefined)
592
+ return best;
593
+ // TODO: https://github.com/Azure/typespec-azure/issues/5080
594
+ // Define the complete rule for associating list operations with detected resources.
595
+ // Some ARM resources expose list operations at scopes different from the resource identity,
596
+ // e.g. a resource-group-scoped resource can have subscription- or tenant-level list operations.
597
+ // Direct prefix matching handles list-by-parent paths; concrete provider/type equality handles
598
+ // cross-scope list paths without letting list operations create resource identities.
599
+ for (const resource of resources) {
600
+ if (isListOperationResourceTypeMatch(operation, resource))
601
+ return resource;
602
+ }
603
+ return undefined;
604
+ }
605
+ function isActionOperationMatch(operation, resource) {
606
+ const operationPath = normalizePathForResourceIdentity(operation.httpOperation.path);
607
+ const instancePath = normalizePathForResourceIdentity(resource.resourceInstancePath);
608
+ return operationPath.startsWith(`${instancePath}/`);
609
+ }
610
+ function tryAddOperationToResolvedResource(candidate, target) {
611
+ const { armOperation, resourceInfo } = candidate;
612
+ if (isInstanceLifecycleOperation(armOperation.kind)) {
613
+ if (resourceInfo !== undefined && isResourceIdentityMatch(resourceInfo, target)) {
614
+ tryAddLifecycleOperation(target.resourceType, armOperation, target);
552
615
  }
616
+ return;
553
617
  }
554
- else {
555
- instanceSegments.push("{name}");
618
+ if (armOperation.kind === "action" && isActionOperationMatch(armOperation, target)) {
619
+ tryAddLifecycleOperation(target.resourceType, armOperation, target);
620
+ return;
621
+ }
622
+ if (armOperation.kind === "other") {
623
+ addAssociatedOperation(armOperation, target);
556
624
  }
557
- return {
558
- resourceType: {
559
- provider: provider,
560
- types: typeSegments,
561
- },
562
- resourceInstancePath: `/${instanceSegments.join("/")}`,
563
- };
564
625
  }
565
626
  function tryAddLifecycleOperation(resourceType, sourceOperation, targetResource) {
566
627
  const opType = sourceOperation.kind;
@@ -628,6 +689,22 @@ export function isResourceOperationMatch(source, target) {
628
689
  }
629
690
  return true;
630
691
  }
692
+ function isResourceIdentityMatch(source, target) {
693
+ if (source.resourceName &&
694
+ target.resourceName &&
695
+ source.resourceName.toLowerCase() !== target.resourceName.toLowerCase())
696
+ return false;
697
+ if (source.resourceType.provider.toLowerCase() !== target.resourceType.provider.toLowerCase())
698
+ return false;
699
+ if (source.resourceType.types.length !== target.resourceType.types.length)
700
+ return false;
701
+ for (let i = 0; i < source.resourceType.types.length; i++) {
702
+ if (source.resourceType.types[i].toLowerCase() !== target.resourceType.types[i].toLowerCase())
703
+ return false;
704
+ }
705
+ return (normalizePathForResourceIdentity(source.resourceInstancePath) ===
706
+ normalizePathForResourceIdentity(target.resourceInstancePath));
707
+ }
631
708
  export function getUnassociatedOperations(program) {
632
709
  return getAllOperations(program)
633
710
  .map((op) => getResourceOperation(program, op))
@@ -694,63 +771,43 @@ function addUniqueOperation(operation, operations) {
694
771
  }
695
772
  export function resolveArmResourceOperations(program, resourceType) {
696
773
  const resolvedOperations = new Set();
697
- const operations = getArmResourceOperationList(program, resourceType);
698
- for (const operation of operations) {
699
- const armOperation = getResourceOperation(program, operation.operation);
700
- if (armOperation === undefined)
774
+ const candidates = [...getArmResourceOperationList(program, resourceType)]
775
+ .map((operation) => resolveArmResourceOperationCandidate(program, resourceType, operation))
776
+ .filter((operation) => operation !== undefined);
777
+ for (const { armOperation, resourceInfo, resourceNameIsExplicit } of candidates) {
778
+ if (!isResourceIdentityOperation(armOperation.kind))
701
779
  continue;
702
- armOperation.kind = operation.kind;
703
- armOperation.resourceModelName = operation.resource?.name ?? resourceType.name;
704
- const resourceInfo = getResourceInfo(program, armOperation, operation.resource ?? resourceType);
705
780
  if (resourceInfo === undefined)
706
781
  continue;
707
- armOperation.name = operation.name;
708
- armOperation.resourceKind = operation.resourceKind;
709
- const resourceNameIsExplicit = operation.resourceName !== undefined;
710
- resourceInfo.resourceName =
711
- operation.resourceName ??
712
- getResourceNameForOperation(program, armOperation, resourceInfo.resourceInstancePath) ??
713
- armOperation.resourceModelName;
714
- resourceInfo.resourceNameIsExplicit = resourceNameIsExplicit;
715
- armOperation.resourceName = resourceInfo.resourceName;
716
782
  let matched = false;
717
- // Check if we already have an operation for this resource
718
783
  for (const resolvedOp of resolvedOperations) {
719
- if (isResourceOperationMatch(resourceInfo, resolvedOp)) {
784
+ if (isResourceIdentityMatch(resourceInfo, resolvedOp)) {
720
785
  matched = true;
721
- if (tryAddLifecycleOperation(resourceInfo.resourceType, armOperation, resolvedOp)) {
722
- continue;
723
- }
724
- addAssociatedOperation(armOperation, resolvedOp);
786
+ tryAddLifecycleOperation(resourceInfo.resourceType, armOperation, resolvedOp);
725
787
  continue;
726
788
  }
727
789
  }
728
790
  if (matched)
729
791
  continue;
730
- // If we don't have an operation for this resource, create a new one
731
- const newResource = {
732
- resourceType: resourceInfo.resourceType,
733
- resourceInstancePath: resourceInfo.resourceInstancePath,
734
- resourceName: resourceInfo.resourceName,
735
- resourceNameIsExplicit: resourceNameIsExplicit,
736
- operations: {
737
- lifecycle: {
738
- read: undefined,
739
- createOrUpdate: undefined,
740
- update: undefined,
741
- delete: undefined,
742
- checkExistence: undefined,
743
- },
744
- actions: [],
745
- lists: [],
746
- },
747
- associatedOperations: [],
748
- };
749
- if (!tryAddLifecycleOperation(resourceInfo.resourceType, armOperation, newResource)) {
750
- addAssociatedOperation(armOperation, newResource);
751
- }
792
+ const newResource = createResolvedResourceOperations(resourceInfo, resourceNameIsExplicit);
793
+ tryAddLifecycleOperation(resourceInfo.resourceType, armOperation, newResource);
752
794
  resolvedOperations.add(newResource);
753
795
  }
796
+ for (const candidate of candidates) {
797
+ if (isResourceIdentityOperation(candidate.armOperation.kind))
798
+ continue;
799
+ if (candidate.armOperation.kind === "list") {
800
+ const target = getBestListOperationTarget(candidate.armOperation, resolvedOperations);
801
+ if (target !== undefined) {
802
+ tryAddLifecycleOperation(target.resourceType, candidate.armOperation, target);
803
+ }
804
+ // TODO: Define how non-prefix list paths should map to detected resource identities.
805
+ continue;
806
+ }
807
+ for (const resolvedOp of resolvedOperations) {
808
+ tryAddOperationToResolvedResource(candidate, resolvedOp);
809
+ }
810
+ }
754
811
  return [...resolvedOperations.values()].toSorted((a, b) => {
755
812
  // Sort by provider, type, then instance path
756
813
  if (a.resourceType.types.length < b.resourceType.types.length)
@@ -770,6 +827,51 @@ export function resolveArmResourceOperations(program, resourceType) {
770
827
  return 0;
771
828
  });
772
829
  }
830
+ function resolveArmResourceOperationCandidate(program, resourceType, operation) {
831
+ const armOperation = getResourceOperation(program, operation.operation);
832
+ if (armOperation === undefined)
833
+ return undefined;
834
+ armOperation.kind = operation.kind;
835
+ armOperation.resourceModelName = operation.resource?.name ?? resourceType.name;
836
+ const resourceInfo = getResourceInfo(armOperation);
837
+ if (resourceInfo === undefined && isInstanceLifecycleOperation(armOperation.kind))
838
+ return undefined;
839
+ armOperation.name = operation.name;
840
+ armOperation.resourceKind = operation.resourceKind;
841
+ const resourceNameIsExplicit = operation.resourceName !== undefined;
842
+ if (resourceInfo !== undefined) {
843
+ resourceInfo.resourceName =
844
+ operation.resourceName ??
845
+ getResourceNameForOperation(program, armOperation, resourceInfo.resourceInstancePath) ??
846
+ armOperation.resourceModelName;
847
+ resourceInfo.resourceNameIsExplicit = resourceNameIsExplicit;
848
+ armOperation.resourceName = resourceInfo.resourceName;
849
+ }
850
+ else {
851
+ armOperation.resourceName = operation.resourceName ?? armOperation.resourceModelName;
852
+ }
853
+ return { armOperation, resourceInfo, resourceNameIsExplicit };
854
+ }
855
+ function createResolvedResourceOperations(resourceInfo, resourceNameIsExplicit) {
856
+ return {
857
+ resourceType: resourceInfo.resourceType,
858
+ resourceInstancePath: resourceInfo.resourceInstancePath,
859
+ resourceName: resourceInfo.resourceName,
860
+ resourceNameIsExplicit: resourceNameIsExplicit,
861
+ operations: {
862
+ lifecycle: {
863
+ read: undefined,
864
+ createOrUpdate: undefined,
865
+ update: undefined,
866
+ delete: undefined,
867
+ checkExistence: undefined,
868
+ },
869
+ actions: [],
870
+ lists: [],
871
+ },
872
+ associatedOperations: [],
873
+ };
874
+ }
773
875
  export { getArmResource } from "./private.decorators.js";
774
876
  export function getArmResourceInfo(program, resourceType) {
775
877
  const resourceInfo = getArmResource(program, resourceType);
@@ -1074,6 +1176,9 @@ export function resolveResourceBaseType(type) {
1074
1176
  }
1075
1177
  export const [getResourceFeature, setResourceFeature] = useStateMap(ArmStateKeys.armFeature);
1076
1178
  export const [getResourceFeatureSet, setResourceFeatureSet] = useStateMap(ArmStateKeys.armFeatureSet);
1179
+ /**
1180
+ * Gets the enum configured by `@featureFiles`, or `undefined` when feature files are not configured.
1181
+ */
1077
1182
  export const [getFeatureFileSet, setFeatureFileSet] = useStateMap(ArmStateKeys.armFeatureFileSet);
1078
1183
  export const [getResourceFeatureOptions, setResourceFeatureOptions] = useStateMap(ArmStateKeys.armFeatureOptions);
1079
1184
  const commonFeatureOptions = {
@@ -1207,7 +1312,7 @@ export const $featureOptions = (context, entity, options) => {
1207
1312
  // New Azure.ResourceManager namespace decorators
1208
1313
  export const $featureFile = $feature;
1209
1314
  export const $featureFiles = (context, entity, features) => {
1210
- setFeatureFileSet(context.program, entity, true);
1315
+ setFeatureFileSet(context.program, entity, features);
1211
1316
  $features(context, entity, features);
1212
1317
  };
1213
1318
  export const $featureFileOptions = $featureOptions;