Skip to content

Set up auth to use a separate d.ts file for docgen #5354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions common/api-review/auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export class AuthCredential {
protected constructor(
providerId: string,
signInMethod: string);
// Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
_getIdTokenResponse(_auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
// @internal (undocumented)
_getReauthenticationResolver(_auth: AuthInternal): Promise<IdTokenResponse>;
// Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
_linkToIdToken(_auth: AuthInternal, _idToken: string): Promise<IdTokenResponse>;
Expand Down Expand Up @@ -276,9 +276,6 @@ export function connectAuthEmulator(auth: Auth, url: string, options?: {
disableWarnings: boolean;
}): void;

// @public
export const cordovaPopupRedirectResolver: PopupRedirectResolver;

// @public
export function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;

Expand Down Expand Up @@ -342,7 +339,7 @@ export interface EmulatorConfig {

export { ErrorFn }

// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts
//
// @public
export class FacebookAuthProvider extends BaseOAuthProvider {
Expand Down Expand Up @@ -484,7 +481,7 @@ export type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
export class OAuthCredential extends AuthCredential {
accessToken?: string;
static fromJSON(json: string | object): OAuthCredential | null;
// Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
static _fromParams(params: OAuthCredentialParams): OAuthCredential;
Expand Down Expand Up @@ -563,7 +560,7 @@ export class PhoneAuthCredential extends AuthCredential {
_getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
// @internal (undocumented)
_linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
// Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
_makeVerificationRequest(): SignInWithPhoneNumberRequest;
Expand Down Expand Up @@ -636,9 +633,6 @@ export interface ReactNativeAsyncStorage {
setItem(key: string, value: string): Promise<void>;
}

// @public
export const reactNativeLocalPersistence: Persistence;

// @public
export function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;

Expand All @@ -657,13 +651,13 @@ export interface RecaptchaParameters {
[key: string]: any;
}

// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.d.ts
//
// @public
export class RecaptchaVerifier implements ApplicationVerifierInternal {
constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
clear(): void;
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
readonly _recaptchaLoader: ReCaptchaLoader;
Expand All @@ -677,7 +671,7 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
// @public
export function reload(user: User): Promise<void>;

// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.doc.d.ts
// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.d.ts
//
// @public
export class SAMLAuthProvider extends FederatedAuthProvider {
Expand Down
5 changes: 3 additions & 2 deletions packages/auth/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts",
// If this path ever changes, make sure to change scripts/exp/docgen.ts
// accordingly.
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
Expand Down
24 changes: 21 additions & 3 deletions scripts/exp/docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ async function generateDocs(forDevsite: boolean = false) {
const outputFolder = forDevsite ? 'docs-devsite' : 'docs-exp';
const command = forDevsite ? 'api-documenter-devsite' : 'api-documenter';

// Use a special d.ts file for auth for doc gen only.
const authApiConfigOriginal = fs.readFileSync(
`${projectRoot}/packages/auth/api-extractor.json`,
'utf8'
);
const authApiConfigModified = authApiConfigOriginal.replace(
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts"`,
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts"`
);
fs.writeFileSync(
`${projectRoot}/packages/auth/api-extractor.json`,
authApiConfigModified
);

await spawn('yarn', ['build'], {
stdio: 'inherit'
});
Expand All @@ -46,15 +60,19 @@ async function generateDocs(forDevsite: boolean = false) {
stdio: 'inherit'
});

// Restore original auth api-extractor.json contents.
fs.writeFileSync(
`${projectRoot}/packages/auth/api-extractor.json`,
authApiConfigOriginal
);

if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir);
}

// TODO: Throw error if path doesn't exist once all packages add markdown support.
const apiJsonDirectories = (
await mapWorkspaceToPackages([
`${projectRoot}/packages/*`
])
await mapWorkspaceToPackages([`${projectRoot}/packages/*`])
)
.map(path => `${path}/temp`)
.filter(path => fs.existsSync(path));
Expand Down