-
Notifications
You must be signed in to change notification settings - Fork 216
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
Changes from 9 commits
267ceeb
d48abf0
e6bbcd3
e84745c
97d8ce3
19e320c
f075590
65f4218
b71ae6d
84f073c
1a45154
a56adbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Future Extensions support | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for [email protected] | ||
* | ||
* 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 [email protected] 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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
/** | ||
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for [email protected] | ||
* | ||
* 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@firebase-extensions/local-backfill-sdk", | ||
"main": "./index.js" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/** | ||
* Translate Text in Firestore SDK for [email protected] | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for [email protected]" | ||
* 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 [email protected] 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/[email protected]"; | ||
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>>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use strict"; | ||
/** | ||
* Translate Text in Firestore SDK for [email protected] | ||
* | ||
* When filing bugs or feature requests please specify: | ||
* "Extensions SDK v1.0.0 for [email protected]" | ||
* 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/[email protected]"; | ||
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; |
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" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,17 @@ set -ex # Immediately exit on failure | |
npm run build | ||
npm link | ||
|
||
# Link local SDK to all test sources. | ||
# Link the extensions SDKs for the testing environment. | ||
(cd scripts/bin-test/extsdks/local && npm link) | ||
(cd scripts/bin-test/extsdks/translate && npm link) | ||
(cd scripts/bin-test/extsdks/translate && npm link firebase-functions) | ||
|
||
# Link SDKs to all test sources. | ||
for f in scripts/bin-test/sources/*; do | ||
if [ -d "$f" ]; then | ||
(cd "$f" && npm link firebase-functions) | ||
(cd "$f" && npm link @firebase-extensions/firebase-firestore-translate-text-sdk) | ||
(cd "$f" && npm link @firebase-extensions/local-backfill-sdk) | ||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
fi | ||
done | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.