-
Notifications
You must be signed in to change notification settings - Fork 212
Parse Firebase extensions from code #1590
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
267ceeb
Parse Firebase extensions out of code
d48abf0
removing peer dep
e6bbcd3
fixed tests
e84745c
fixed more tests
97d8ce3
more testing fixes
19e320c
added extsdks for tests
f075590
fixed lint
65f4218
added changelog
b71ae6d
more lint
84f073c
added PR number to changelog
1a45154
make extensions optional
a56adbd
fixing nits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Future Extensions support (#1590) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for backfill@0.0.2 | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for Local extension. | ||
* https://github.com/firebase/firebase-tools/issues/new/choose | ||
* | ||
* GENERATED FILE. DO NOT EDIT. | ||
*/ | ||
export type DoBackfillParam = "True" | "False"; | ||
export type LocationParam = | ||
| "us-central1" | ||
| "us-east1" | ||
| "us-east4" | ||
| "europe-west1" | ||
| "europe-west2" | ||
| "europe-west3" | ||
| "asia-east2" | ||
| "asia-northeast1"; | ||
/** | ||
* Parameters for backfill@0.0.2 extension | ||
*/ | ||
export interface BackfillParams { | ||
/** | ||
* Do a backfill | ||
*/ | ||
DO_BACKFILL: DoBackfillParam; | ||
/** | ||
* Cloud Functions location | ||
*/ | ||
LOCATION: LocationParam; | ||
} | ||
export declare function backfill(instanceId: string, params: BackfillParams): Backfill; | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester | ||
* A tester for the TaskQueue/LCE/RuntimeStatus project | ||
*/ | ||
export declare class Backfill { | ||
private instanceId; | ||
private params; | ||
readonly FIREBASE_EXTENSION_LOCAL_PATH = | ||
"./functions/generated/extensions/local/backfill/0.0.2/src"; | ||
constructor(instanceId: string, params: BackfillParams); | ||
getInstanceId(): string; | ||
getParams(): BackfillParams; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for extensions-try-backfill3@0.0.2 | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for Local extension. | ||
* https://github.com/firebase/firebase-tools/issues/new/choose | ||
* | ||
* GENERATED FILE. DO NOT EDIT. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.backfill = exports.backfill = void 0; | ||
function backfill(instanceId, params) { | ||
return new Backfill(instanceId, params); | ||
} | ||
exports.backfill = backfill; | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester | ||
* A tester for the TaskQueue/LCE/RuntimeStatus project | ||
*/ | ||
class Backfill { | ||
constructor(instanceId, params) { | ||
this.instanceId = instanceId; | ||
this.params = params; | ||
this.FIREBASE_EXTENSION_LOCAL_PATH = "./functions/generated/extensions/local/backfill/0.0.2/src"; | ||
} | ||
getInstanceId() { return this.instanceId; } | ||
getParams() { return this.params; } | ||
} | ||
exports.Backfill = Backfill; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@firebase-extensions/local-backfill-sdk", | ||
"main": "./index.js" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/** | ||
* Translate Text in Firestore SDK for firestore-translate-text@0.1.18 | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for firestore-translate-text@0.1.18" | ||
* https://github.com/firebase/firebase-tools/issues/new/choose | ||
* | ||
* GENERATED FILE. DO NOT EDIT. | ||
*/ | ||
import { CloudEvent } from "../../../../v2"; | ||
import { EventarcTriggerOptions } from "../../../../v2/eventarc"; | ||
export type EventCallback<T> = (event: CloudEvent<T>) => unknown | Promise<unknown>; | ||
export type SimpleEventarcTriggerOptions = Omit< | ||
EventarcTriggerOptions, | ||
"eventType" | "channel" | "region" | ||
>; | ||
export type EventArcRegionType = "us-central1" | "us-west1" | "europe-west4" | "asia-northeast1"; | ||
export type SystemFunctionVpcConnectorEgressSettingsParam = | ||
| "VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED" | ||
| "PRIVATE_RANGES_ONLY" | ||
| "ALL_TRAFFIC"; | ||
export type SystemFunctionIngressSettingsParam = | ||
| "ALLOW_ALL" | ||
| "ALLOW_INTERNAL_ONLY" | ||
| "ALLOW_INTERNAL_AND_GCLB"; | ||
export type SystemFunctionLocationParam = | ||
| "us-central1" | ||
| "us-east1" | ||
| "us-east4" | ||
| "us-west1" | ||
| "us-west2" | ||
| "us-west3" | ||
| "us-west4" | ||
| "europe-central2" | ||
| "europe-west1" | ||
| "europe-west2" | ||
| "europe-west3" | ||
| "europe-west6" | ||
| "asia-east1" | ||
| "asia-east2" | ||
| "asia-northeast1" | ||
| "asia-northeast2" | ||
| "asia-northeast3" | ||
| "asia-south1" | ||
| "asia-southeast1" | ||
| "asia-southeast2" | ||
| "northamerica-northeast1" | ||
| "southamerica-east1" | ||
| "australia-southeast1"; | ||
export type SystemFunctionMemoryParam = "128" | "256" | "512" | "1024" | "2048" | "4096" | "8192"; | ||
/** | ||
* Parameters for firestore-translate-text@0.1.18 extension | ||
*/ | ||
export interface FirestoreTranslateTextParams { | ||
/** | ||
* Target languages for translations, as a comma-separated list | ||
*/ | ||
LANGUAGES: string; | ||
/** | ||
* Collection path | ||
*/ | ||
COLLECTION_PATH: string; | ||
/** | ||
* Input field name | ||
*/ | ||
INPUT_FIELD_NAME: string; | ||
/** | ||
* Translations output field name | ||
*/ | ||
OUTPUT_FIELD_NAME: string; | ||
/** | ||
* Languages field name | ||
*/ | ||
LANGUAGES_FIELD_NAME?: string; | ||
/** | ||
* Event Arc Region | ||
*/ | ||
_EVENT_ARC_REGION?: EventArcRegionType; | ||
/** | ||
* Function timeout seconds | ||
*/ | ||
_FUNCTION_TIMEOUT_SECONDS?: string; | ||
/** | ||
* VPC Connector | ||
*/ | ||
_FUNCTION_VPC_CONNECTOR?: string; | ||
/** | ||
* VPC Connector Egress settings | ||
*/ | ||
_FUNCTION_VPC_CONNECTOR_EGRESS_SETTINGS?: SystemFunctionVpcConnectorEgressSettingsParam; | ||
/** | ||
* Minimum function instances | ||
*/ | ||
_FUNCTION_MIN_INSTANCES?: string; | ||
/** | ||
* Maximum function instances | ||
*/ | ||
_FUNCTION_MAX_INSTANCES?: string; | ||
/** | ||
* Function ingress settings | ||
*/ | ||
_FUNCTION_INGRESS_SETTINGS?: SystemFunctionIngressSettingsParam; | ||
/** | ||
* Function labels | ||
*/ | ||
_FUNCTION_LABELS?: string; | ||
/** | ||
* KMS key name | ||
*/ | ||
_FUNCTION_KMS_KEY_NAME?: string; | ||
/** | ||
* Docker repository | ||
*/ | ||
_FUNCTION_DOCKER_REPOSITORY?: string; | ||
/** | ||
* Cloud Functions location | ||
*/ | ||
_FUNCTION_LOCATION: SystemFunctionLocationParam; | ||
/** | ||
* Function memory | ||
*/ | ||
_FUNCTION_MEMORY?: SystemFunctionMemoryParam; | ||
} | ||
export declare function firestoreTranslateText( | ||
instanceId: string, | ||
params: FirestoreTranslateTextParams | ||
): FirestoreTranslateText; | ||
/** | ||
* Translate Text in Firestore | ||
* Translates strings written to a Cloud Firestore collection into multiple languages (uses Cloud Translation API). | ||
*/ | ||
export declare class FirestoreTranslateText { | ||
private instanceId; | ||
private params; | ||
events: string[]; | ||
readonly FIREBASE_EXTENSION_REFERENCE = "firebase/firestore-translate-text@0.1.18"; | ||
readonly EXTENSION_VERSION = "0.1.18"; | ||
constructor(instanceId: string, params: FirestoreTranslateTextParams); | ||
getInstanceId(): string; | ||
getParams(): FirestoreTranslateTextParams; | ||
/** | ||
* Occurs when a trigger has been called within the Extension, and will include data such as the context of the trigger request. | ||
*/ | ||
onStart<T = unknown>( | ||
callback: EventCallback<T>, | ||
options?: SimpleEventarcTriggerOptions | ||
): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>; | ||
/** | ||
* Occurs when image resizing completes successfully. The event will contain further details about specific formats and sizes. | ||
*/ | ||
onSuccess<T = unknown>( | ||
callback: EventCallback<T>, | ||
options?: SimpleEventarcTriggerOptions | ||
): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>; | ||
/** | ||
* Occurs when an issue has been experienced in the Extension. This will include any error data that has been included within the Error Exception. | ||
*/ | ||
onError<T = unknown>( | ||
callback: EventCallback<T>, | ||
options?: SimpleEventarcTriggerOptions | ||
): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>; | ||
/** | ||
* Occurs when the function is settled. Provides no customized data other than the context. | ||
*/ | ||
onCompletion<T = unknown>( | ||
callback: EventCallback<T>, | ||
options?: SimpleEventarcTriggerOptions | ||
): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use strict"; | ||
/** | ||
* Translate Text in Firestore SDK for firestore-translate-text@0.1.18 | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for firestore-translate-text@0.1.18" | ||
* https://github.com/firebase/firebase-tools/issues/new/choose | ||
* | ||
* GENERATED FILE. DO NOT EDIT. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FirestoreTranslateText = exports.firestoreTranslateText = void 0; | ||
const eventarc_1 = require("firebase-functions/v2/eventarc"); | ||
function firestoreTranslateText(instanceId, params) { | ||
return new FirestoreTranslateText(instanceId, params); | ||
} | ||
exports.firestoreTranslateText = firestoreTranslateText; | ||
/** | ||
* Translate Text in Firestore | ||
* Translates strings written to a Cloud Firestore collection into multiple languages (uses Cloud Translation API). | ||
*/ | ||
class FirestoreTranslateText { | ||
constructor(instanceId, params) { | ||
this.instanceId = instanceId; | ||
this.params = params; | ||
this.events = []; | ||
this.FIREBASE_EXTENSION_REFERENCE = "firebase/firestore-translate-text@0.1.18"; | ||
this.EXTENSION_VERSION = "0.1.18"; | ||
} | ||
getInstanceId() { return this.instanceId; } | ||
getParams() { return this.params; } | ||
/** | ||
* Occurs when a trigger has been called within the Extension, and will include data such as the context of the trigger request. | ||
*/ | ||
onStart(callback, options) { | ||
this.events.push("firebase.extensions.firestore-translate-text.v1.onStart"); | ||
return (0, eventarc_1.onCustomEventPublished)(Object.assign(Object.assign({}, options), { "eventType": "firebase.extensions.firestore-translate-text.v1.onStart", "channel": `projects/locations/${this.params._EVENT_ARC_REGION}/channels/firebase`, "region": `${this.params._EVENT_ARC_REGION}` }), callback); | ||
} | ||
/** | ||
* Occurs when image resizing completes successfully. The event will contain further details about specific formats and sizes. | ||
*/ | ||
onSuccess(callback, options) { | ||
this.events.push("firebase.extensions.firestore-translate-text.v1.onSuccess"); | ||
return (0, eventarc_1.onCustomEventPublished)(Object.assign(Object.assign({}, options), { "eventType": "firebase.extensions.firestore-translate-text.v1.onSuccess", "channel": `projects/locations/${this.params._EVENT_ARC_REGION}/channels/firebase`, "region": `${this.params._EVENT_ARC_REGION}` }), callback); | ||
} | ||
/** | ||
* Occurs when an issue has been experienced in the Extension. This will include any error data that has been included within the Error Exception. | ||
*/ | ||
onError(callback, options) { | ||
this.events.push("firebase.extensions.firestore-translate-text.v1.onError"); | ||
return (0, eventarc_1.onCustomEventPublished)(Object.assign(Object.assign({}, options), { "eventType": "firebase.extensions.firestore-translate-text.v1.onError", "channel": `projects/locations/${this.params._EVENT_ARC_REGION}/channels/firebase`, "region": `${this.params._EVENT_ARC_REGION}` }), callback); | ||
} | ||
/** | ||
* Occurs when the function is settled. Provides no customized data other than the context. | ||
*/ | ||
onCompletion(callback, options) { | ||
this.events.push("firebase.extensions.firestore-translate-text.v1.onCompletion"); | ||
return (0, eventarc_1.onCustomEventPublished)(Object.assign(Object.assign({}, options), { "eventType": "firebase.extensions.firestore-translate-text.v1.onCompletion", "channel": `projects/locations/${this.params._EVENT_ARC_REGION}/channels/firebase`, "region": `${this.params._EVENT_ARC_REGION}` }), callback); | ||
} | ||
} | ||
exports.FirestoreTranslateText = FirestoreTranslateText; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@firebase-extensions/firebase-firestore-translate-text-sdk", | ||
"main": "./index.js" | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of adding extensions "functions" as a test case on every single set up, can we instead separate out extensions test cases as unique ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's the same if-else code chunk being tested... I don't want someone to "forget" to run half the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anybody runs this test individually but instead runs it via this test script.
I think it'd be cleaner to separate out extension use case - I see it as a specialized use case and isn't representative of most CF3 users set up.