refactor(types): adopt official beta Graph types for container-type control-plane contracts - #36
Merged
Conversation
…ontrol-plane contracts
Replace the remaining hand-maintained control-plane (container-type) Microsoft
Graph interfaces with types derived from the official
@microsoft/microsoft-graph-types-beta package (the SPE container-type APIs are
/beta). This is a types-only refactor: no runtime, behavior, or wire-format
change. The beta package is a dev-only, types-only .d.ts dependency that
compiles away to zero runtime JS.
graph-client.ts:
- RawContainerType now derives from the official FileStorageContainerType
(Pick of the scalar wire fields + intersected local normalize extras;
every field stays optional so normalizeContainerType({}) still type-checks).
- The four local { value: T[] } envelope interfaces collapse onto the shared
generic GraphCollection<T>.
types.ts:
- ContainerTypePermission derives from the official beta permission resource
(roles kept NonNullable; grantedToV2.user narrowed to keep userPrincipalName).
- ContainerTypeRegistrationRecord / ContainerTypeRegistration derive from the
official FileStorageContainerTypeRegistration.
- ApplicationPermissionGrant derives appId from the official
FileStorageContainerTypeAppPermissionGrant; the two permission arrays stay
string[] (not the official enum) so the registration-PUT
`satisfies ApplicationPermissionGrant` still compiles and .length/.join reads
stay non-null.
Intentional local narrowings are preserved via intersection (BillingClassification
union, string[] permission arrays, narrowed grantedToV2.user). Pins
@microsoft/microsoft-graph-types-beta at 0.44.0-preview (exact; 0.x) as a
devDependency. Local pipeline green: lint, typecheck, build, and 682 passed /
3 skipped tests (unchanged from baseline). Ref: PR #3 review.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… unused Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Gregory Joseph (gnjoseph)
merged commit Jul 9, 2026
1694346
into
feat/spe-mcp-server
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch C — official beta Graph types for the container-type control plane
Types-only refactor in the Graph-SDK type-adoption series (follows the Batch A POC and Batch B). Replaces the remaining hand-maintained control-plane (container-type) Microsoft Graph interfaces with types derived from the official
@microsoft/microsoft-graph-types-betapackage. The SPE container-type control-plane APIs (/storage/fileStorage/containerTypes*) are/beta, so the official types come from the beta package (Batch A/B used the stable@microsoft/microsoft-graph-typesfor the content plane).No runtime, behavior, or wire-format change — only type annotations and generic arguments change.
Local type → official beta type
Pick)RawContainerType(graph-client.ts)FileStorageContainerTypeid,name,owningAppId,createdDateTime,expirationDateTime,etagcontainerTypeId?,displayName?,azureSubscriptionId?;billingClassification?kept as localBillingClassificationunion. All optional sonormalizeContainerType({})still type-checks.ContainerTypePermission(types.ts)Permission(beta)roles=NonNullable<Permission["roles"]>idrolesun-nullabled (officialNullableOption<string[]>);grantedToV2.userkept as narrowed local shape to retainuserPrincipalName(officialidentityomits it).ContainerTypeRegistrationRecord(types.ts)FileStorageContainerTypeRegistrationid,owningAppId,registeredDateTimebillingClassification?(local union) +applicationPermissionGrants?: ApplicationPermissionGrant[](our non-null-element array).ContainerTypeRegistration(types.ts)FileStorageContainerTypeRegistration(transitively)applicationPermissionGrantsapplicationPermissionGrants(see note).ApplicationPermissionGrant(types.ts)FileStorageContainerTypeAppPermissionGrantappId=Required<Pick<…>>delegatedPermissions/applicationPermissionskeptstring[](not the official enum) + required (see note).graph-client.ts)GraphCollection<T>ListContainerTypesResponse,ApplicationPermissionGrantsResponse,ContainerTypeRegistrationsListResponse,ContainerTypePermissionsResponsecollapse ontoGraphCollection<T>.Exact beta type names (verified in
node_modules/@microsoft/microsoft-graph-types-beta/microsoft-graph.d.ts)FileStorageContainerType(extendsEntity;id/name/owningAppId/createdDateTime/expirationDateTime/etag/billingClassification, …). Note: it does not exposedisplayNameor apermissionsnav prop in this version.FileStorageContainerTypeRegistration(extendsEntity;applicationPermissionGrants?: NullableOption<FileStorageContainerTypeAppPermissionGrant[]>,owningAppId,registeredDateTime, …).FileStorageContainerTypeAppPermissionGrant(appId?;applicationPermissions?/delegatedPermissions?: NullableOption<FileStorageContainerTypeAppPermission[]>).Permission(beta;roles?: NullableOption<string[]>,grantedToV2?: NullableOption<SharePointIdentitySet>) — the container-type…/permissionsresource is the generic Graphpermission.Entity(id?: string),NullableOption<T> = T | null,FileStorageContainerBillingClassification = "standard" | "trial" | "directToCustomer" | "unknownFutureValue".Derive pattern + null handling
Required<T>strips?but not| null; beta fields are frequentlyNullableOption<T>. Fields we dereference/pass non-null are wrapped inNonNullable<…>(ContainerTypePermission.roles). Fields read null-tolerantly (??,===) keep the official shape.billingClassificationstays the localBillingClassificationunion;grantedToV2.userstays the narrowed local shape; grant permission arrays staystring[].Why the beta package is exact-pinned / types-only / dev-only
microsoft-graph.d.ts(nomain, zero JS). Confirmed theimport typeerases to zero references indist(thegraph-types-betaliteral appears 0× in compiled output).devDependencies; never imported at runtime.LICENSEis MIT (matches the stable types package already in the tree). Resolves from the public npm registry.0.44.0-preview, no caret): it is a0.xpre-release, so a caret would allow minor drift — pin for reproducibility (mirrors the existing@microsoft/microsoft-graph-types2.43.1exact pin).Left partially hand-maintained (deliberate — no bad mapping forced)
ApplicationPermissionGrant.delegatedPermissions/applicationPermissions: the official grant types these asNullableOption<FileStorageContainerTypeAppPermission[]>(a string-literal enum, nullable). The server builds/sends them asstring[]and asserts the registration-PUT body withsatisfies ApplicationPermissionGrant; deriving the enum would break thatsatisfiesand the non-null.length/.joinreads. SoappIdderives from the official type (required) while the two arrays stay ourstring[]narrowing.ContainerTypeRegistration: its sole field is the narrowed non-nullapplicationPermissionGrantsoverride, so it derives fromFileStorageContainerTypeRegistrationonly transitively (throughApplicationPermissionGrant); forcing aPick/NullableOptionon the single field would add noise without value.Discipline / scope
DESIRED_GRAPH_RESOURCE_ACCESS,registerContainerType, thelistContainerTypesstaleness writer) are not altered — only the type argument onlistContainerTypes'sgraphRequestBeta<…>call changed.satisfies ApplicationPermissionGrantstill compiles.Test evidence (local pipeline, all green)
npm run lint→ cleannpm run typecheck(tsc --noEmit) → cleannpm run build(tsc) → cleannpm test→ Tests 682 passed | 3 skipped (685) — unchanged from baseline.Ref: PR #3 review.