Skip to content
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

feat: Exposed Rules APIs from firebase-admin/security-rules entry point #1156

Merged
merged 1 commit into from
Feb 5, 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
55 changes: 21 additions & 34 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,43 +736,30 @@ export namespace remoteConfig {
export const SDK_VERSION: string;

// @public
export function securityRules(app?: app.App): securityRules.SecurityRules;
export function securityRules(app?: App): securityRules.SecurityRules;

// @public (undocumented)
export namespace securityRules {
export interface Ruleset extends RulesetMetadata {
// (undocumented)
readonly source: RulesFile[];
}
export interface RulesetMetadata {
readonly createTime: string;
readonly name: string;
}
export interface RulesetMetadataList {
readonly nextPageToken?: string;
readonly rulesets: RulesetMetadata[];
}
export interface RulesFile {
// (undocumented)
readonly content: string;
// (undocumented)
readonly name: string;
}
export interface SecurityRules {
// (undocumented)
app: app.App;
createRuleset(file: RulesFile): Promise<Ruleset>;
createRulesFileFromSource(name: string, source: string | Buffer): RulesFile;
deleteRuleset(name: string): Promise<void>;
getFirestoreRuleset(): Promise<Ruleset>;
getRuleset(name: string): Promise<Ruleset>;
getStorageRuleset(bucket?: string): Promise<Ruleset>;
listRulesetMetadata(pageSize?: number, nextPageToken?: string): Promise<RulesetMetadataList>;
releaseFirestoreRuleset(ruleset: string | RulesetMetadata): Promise<void>;
releaseFirestoreRulesetFromSource(source: string | Buffer): Promise<Ruleset>;
releaseStorageRuleset(ruleset: string | RulesetMetadata, bucket?: string): Promise<void>;
releaseStorageRulesetFromSource(source: string | Buffer, bucket?: string): Promise<Ruleset>;
}
// Warning: (ae-forgotten-export) The symbol "Ruleset" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type Ruleset = Ruleset;
// Warning: (ae-forgotten-export) The symbol "RulesetMetadata" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type RulesetMetadata = RulesetMetadata;
// Warning: (ae-forgotten-export) The symbol "RulesetMetadataList" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type RulesetMetadataList = RulesetMetadataList;
// Warning: (ae-forgotten-export) The symbol "RulesFile" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type RulesFile = RulesFile;
// Warning: (ae-forgotten-export) The symbol "SecurityRules" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type SecurityRules = SecurityRules;
}

// @public (undocumented)
Expand Down
83 changes: 83 additions & 0 deletions etc/firebase-admin.security-rules.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## API Report File for "firebase-admin.security-rules"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { Agent } from 'http';

// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function getSecurityRules(app?: App): SecurityRules;

// @public
export class Ruleset {
// (undocumented)
readonly createTime: string;
// (undocumented)
readonly name: string;
// (undocumented)
readonly source: RulesFile[];
}

// @public
export interface RulesetMetadata {
readonly createTime: string;
readonly name: string;
}

// @public (undocumented)
export class RulesetMetadataList {
// (undocumented)
readonly nextPageToken?: string;
// (undocumented)
readonly rulesets: RulesetMetadata[];
}

// @public
export interface RulesFile {
// (undocumented)
readonly content: string;
// (undocumented)
readonly name: string;
}

// @public
export class SecurityRules {
// (undocumented)
readonly app: App;
createRuleset(file: RulesFile): Promise<Ruleset>;
createRulesFileFromSource(name: string, source: string | Buffer): RulesFile;
deleteRuleset(name: string): Promise<void>;
getFirestoreRuleset(): Promise<Ruleset>;
getRuleset(name: string): Promise<Ruleset>;
getStorageRuleset(bucket?: string): Promise<Ruleset>;
listRulesetMetadata(pageSize?: number, nextPageToken?: string): Promise<RulesetMetadataList>;
releaseFirestoreRuleset(ruleset: string | RulesetMetadata): Promise<void>;
releaseFirestoreRulesetFromSource(source: string | Buffer): Promise<Ruleset>;
releaseStorageRuleset(ruleset: string | RulesetMetadata, bucket?: string): Promise<void>;
releaseStorageRulesetFromSource(source: string | Buffer, bucket?: string): Promise<Ruleset>;
}

// @public
export function securityRules(app?: App): securityRules.SecurityRules;

// @public (undocumented)
export namespace securityRules {
// (undocumented)
export type Ruleset = Ruleset;
// (undocumented)
export type RulesetMetadata = RulesetMetadata;
// (undocumented)
export type RulesetMetadataList = RulesetMetadataList;
// (undocumented)
export type RulesFile = RulesFile;
// (undocumented)
export type SecurityRules = SecurityRules;
}


// (No @packageDocumentation comment for this package)

```
1 change: 1 addition & 0 deletions generate-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const entryPoints = {
'firebase-admin/firestore': './lib/firestore/index.d.ts',
'firebase-admin/instance-id': './lib/instance-id/index.d.ts',
'firebase-admin/messaging': './lib/messaging/index.d.ts',
'firebase-admin/security-rules': './lib/security-rules/index.d.ts',
'firebase-admin/remote-config': './lib/remote-config/index.d.ts',
};

Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ gulp.task('compile', function() {
'lib/firestore/*.d.ts',
'lib/instance-id/*.d.ts',
'lib/messaging/*.d.ts',
'lib/security-rules/*.d.ts',
'lib/remote-config/*.d.ts',
'!lib/utils/index.d.ts',
];
Expand Down
9 changes: 3 additions & 6 deletions src/app/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { Database } from '../database/index';
import { Firestore } from '../firestore/index';
import { InstanceId } from '../instance-id/index';
import { ProjectManagement } from '../project-management/project-management';
import { SecurityRules } from '../security-rules/security-rules';
import { SecurityRules } from '../security-rules/index';
import { RemoteConfig } from '../remote-config/index';

/**
Expand Down Expand Up @@ -356,11 +356,8 @@ export class FirebaseApp implements app.App {
* @return The SecurityRules service instance of this app.
*/
public securityRules(): SecurityRules {
return this.ensureService_('security-rules', () => {
const securityRulesService: typeof SecurityRules =
require('../security-rules/security-rules').SecurityRules;
return new securityRulesService(this);
});
const fn = require('../security-rules/index').getSecurityRules;
return fn(this);
}

/**
Expand Down
Loading