Skip to content

Commit e6bbcd3

Browse files
author
Ingrid Fielker
committed
fixed tests
1 parent d48abf0 commit e6bbcd3

File tree

15 files changed

+511
-15
lines changed

15 files changed

+511
-15
lines changed

spec/fixtures/extsdk/local/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for [email protected]
3+
*
4+
* When filing bugs or feature requests please specify:
5+
* "Extensions SDK v1.0.0 for Local extension.
6+
* https://github.com/firebase/firebase-tools/issues/new/choose
7+
*
8+
* GENERATED FILE. DO NOT EDIT.
9+
*/
10+
export type DoBackfillParam = "True" | "False";
11+
export type LocationParam = "us-central1" | "us-east1" | "us-east4" | "europe-west1" | "europe-west2" | "europe-west3" | "asia-east2" | "asia-northeast1";
12+
/**
13+
* Parameters for [email protected] extension
14+
*/
15+
export interface BackfillParams {
16+
/**
17+
* Do a backfill
18+
*/
19+
DO_BACKFILL: DoBackfillParam;
20+
/**
21+
* Cloud Functions location
22+
*/
23+
LOCATION: LocationParam;
24+
}
25+
export declare function backfill(instanceId: string, params: BackfillParams): Backfill;
26+
/**
27+
* TaskQueue/LifecycleEvent/RuntimeStatus Tester
28+
* A tester for the TaskQueue/LCE/RuntimeStatus project
29+
*/
30+
export declare class Backfill {
31+
private instanceId;
32+
private params;
33+
readonly FIREBASE_EXTENSION_LOCAL_PATH = "./functions/generated/extensions/local/backfill/0.0.2/src";
34+
constructor(instanceId: string, params: BackfillParams);
35+
getInstanceId(): string;
36+
getParams(): BackfillParams;
37+
}

spec/fixtures/extsdk/local/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use strict";
2+
/**
3+
* TaskQueue/LifecycleEvent/RuntimeStatus Tester SDK for [email protected]
4+
*
5+
* When filing bugs or feature requests please specify:
6+
* "Extensions SDK v1.0.0 for Local extension.
7+
* https://github.com/firebase/firebase-tools/issues/new/choose
8+
*
9+
* GENERATED FILE. DO NOT EDIT.
10+
*/
11+
Object.defineProperty(exports, "__esModule", { value: true });
12+
exports.backfill = exports.backfill = void 0;
13+
function backfill(instanceId, params) {
14+
return new Backfill(instanceId, params);
15+
}
16+
exports.backfill = backfill;
17+
/**
18+
* TaskQueue/LifecycleEvent/RuntimeStatus Tester
19+
* A tester for the TaskQueue/LCE/RuntimeStatus project
20+
*/
21+
class Backfill {
22+
constructor(instanceId, params) {
23+
this.instanceId = instanceId;
24+
this.params = params;
25+
this.FIREBASE_EXTENSION_LOCAL_PATH = "./functions/generated/extensions/local/backfill/0.0.2/src";
26+
}
27+
getInstanceId() { return this.instanceId; }
28+
getParams() { return this.params; }
29+
}
30+
exports.Backfill = Backfill;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@firebase-extensions/local-backfill-sdk",
3+
"main": "./index.js"
4+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* Translate Text in Firestore SDK for [email protected]
3+
*
4+
* When filing bugs or feature requests please specify:
5+
* "Extensions SDK v1.0.0 for [email protected]"
6+
* https://github.com/firebase/firebase-tools/issues/new/choose
7+
*
8+
* GENERATED FILE. DO NOT EDIT.
9+
*/
10+
import { CloudEvent } from "../../../../v2";
11+
import { EventarcTriggerOptions } from "../../../../v2/eventarc";
12+
export type EventCallback<T> = (event: CloudEvent<T>) => unknown | Promise<unknown>;
13+
export type SimpleEventarcTriggerOptions = Omit<EventarcTriggerOptions, 'eventType' | 'channel' | 'region'>;
14+
export type EventArcRegionType = "us-central1" | "us-west1" | "europe-west4" | "asia-northeast1";
15+
export type SystemFunctionVpcConnectorEgressSettingsParam = "VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED" | "PRIVATE_RANGES_ONLY" | "ALL_TRAFFIC";
16+
export type SystemFunctionIngressSettingsParam = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERNAL_AND_GCLB";
17+
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";
18+
export type SystemFunctionMemoryParam = "128" | "256" | "512" | "1024" | "2048" | "4096" | "8192";
19+
/**
20+
* Parameters for [email protected] extension
21+
*/
22+
export interface FirestoreTranslateTextParams {
23+
/**
24+
* Target languages for translations, as a comma-separated list
25+
*/
26+
LANGUAGES: string;
27+
/**
28+
* Collection path
29+
*/
30+
COLLECTION_PATH: string;
31+
/**
32+
* Input field name
33+
*/
34+
INPUT_FIELD_NAME: string;
35+
/**
36+
* Translations output field name
37+
*/
38+
OUTPUT_FIELD_NAME: string;
39+
/**
40+
* Languages field name
41+
*/
42+
LANGUAGES_FIELD_NAME?: string;
43+
/**
44+
* Event Arc Region
45+
*/
46+
_EVENT_ARC_REGION?: EventArcRegionType;
47+
/**
48+
* Function timeout seconds
49+
*/
50+
_FUNCTION_TIMEOUT_SECONDS?: string;
51+
/**
52+
* VPC Connector
53+
*/
54+
_FUNCTION_VPC_CONNECTOR?: string;
55+
/**
56+
* VPC Connector Egress settings
57+
*/
58+
_FUNCTION_VPC_CONNECTOR_EGRESS_SETTINGS?: SystemFunctionVpcConnectorEgressSettingsParam;
59+
/**
60+
* Minimum function instances
61+
*/
62+
_FUNCTION_MIN_INSTANCES?: string;
63+
/**
64+
* Maximum function instances
65+
*/
66+
_FUNCTION_MAX_INSTANCES?: string;
67+
/**
68+
* Function ingress settings
69+
*/
70+
_FUNCTION_INGRESS_SETTINGS?: SystemFunctionIngressSettingsParam;
71+
/**
72+
* Function labels
73+
*/
74+
_FUNCTION_LABELS?: string;
75+
/**
76+
* KMS key name
77+
*/
78+
_FUNCTION_KMS_KEY_NAME?: string;
79+
/**
80+
* Docker repository
81+
*/
82+
_FUNCTION_DOCKER_REPOSITORY?: string;
83+
/**
84+
* Cloud Functions location
85+
*/
86+
_FUNCTION_LOCATION: SystemFunctionLocationParam;
87+
/**
88+
* Function memory
89+
*/
90+
_FUNCTION_MEMORY?: SystemFunctionMemoryParam;
91+
}
92+
export declare function firestoreTranslateText(instanceId: string, params: FirestoreTranslateTextParams): FirestoreTranslateText;
93+
/**
94+
* Translate Text in Firestore
95+
* Translates strings written to a Cloud Firestore collection into multiple languages (uses Cloud Translation API).
96+
*/
97+
export declare class FirestoreTranslateText {
98+
private instanceId;
99+
private params;
100+
events: string[];
101+
readonly FIREBASE_EXTENSION_REFERENCE = "firebase/[email protected]";
102+
readonly EXTENSION_VERSION = "0.1.18";
103+
constructor(instanceId: string, params: FirestoreTranslateTextParams);
104+
getInstanceId(): string;
105+
getParams(): FirestoreTranslateTextParams;
106+
/**
107+
* Occurs when a trigger has been called within the Extension, and will include data such as the context of the trigger request.
108+
*/
109+
onStart<T = unknown>(callback: EventCallback<T>, options?: SimpleEventarcTriggerOptions): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>;
110+
/**
111+
* Occurs when image resizing completes successfully. The event will contain further details about specific formats and sizes.
112+
*/
113+
onSuccess<T = unknown>(callback: EventCallback<T>, options?: SimpleEventarcTriggerOptions): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>;
114+
/**
115+
* Occurs when an issue has been experienced in the Extension. This will include any error data that has been included within the Error Exception.
116+
*/
117+
onError<T = unknown>(callback: EventCallback<T>, options?: SimpleEventarcTriggerOptions): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>;
118+
/**
119+
* Occurs when the function is settled. Provides no customized data other than the context.
120+
*/
121+
onCompletion<T = unknown>(callback: EventCallback<T>, options?: SimpleEventarcTriggerOptions): import("firebase-functions/v2").CloudFunction<CloudEvent<T>>;
122+
}
123+
//# sourceMappingURL=index.d.ts.map
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"use strict";
2+
/**
3+
* Translate Text in Firestore SDK for [email protected]
4+
*
5+
* When filing bugs or feature requests please specify:
6+
* "Extensions SDK v1.0.0 for [email protected]"
7+
* https://github.com/firebase/firebase-tools/issues/new/choose
8+
*
9+
* GENERATED FILE. DO NOT EDIT.
10+
*/
11+
Object.defineProperty(exports, "__esModule", { value: true });
12+
exports.FirestoreTranslateText = exports.firestoreTranslateText = void 0;
13+
const eventarc_1 = require("../../../../src/v2/providers/eventarc");
14+
function firestoreTranslateText(instanceId, params) {
15+
return new FirestoreTranslateText(instanceId, params);
16+
}
17+
exports.firestoreTranslateText = firestoreTranslateText;
18+
/**
19+
* Translate Text in Firestore
20+
* Translates strings written to a Cloud Firestore collection into multiple languages (uses Cloud Translation API).
21+
*/
22+
class FirestoreTranslateText {
23+
constructor(instanceId, params) {
24+
this.instanceId = instanceId;
25+
this.params = params;
26+
this.events = [];
27+
this.FIREBASE_EXTENSION_REFERENCE = "firebase/[email protected]";
28+
this.EXTENSION_VERSION = "0.1.18";
29+
}
30+
getInstanceId() { return this.instanceId; }
31+
getParams() { return this.params; }
32+
/**
33+
* Occurs when a trigger has been called within the Extension, and will include data such as the context of the trigger request.
34+
*/
35+
onStart(callback, options) {
36+
this.events.push("firebase.extensions.firestore-translate-text.v1.onStart");
37+
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);
38+
}
39+
/**
40+
* Occurs when image resizing completes successfully. The event will contain further details about specific formats and sizes.
41+
*/
42+
onSuccess(callback, options) {
43+
this.events.push("firebase.extensions.firestore-translate-text.v1.onSuccess");
44+
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);
45+
}
46+
/**
47+
* Occurs when an issue has been experienced in the Extension. This will include any error data that has been included within the Error Exception.
48+
*/
49+
onError(callback, options) {
50+
this.events.push("firebase.extensions.firestore-translate-text.v1.onError");
51+
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);
52+
}
53+
/**
54+
* Occurs when the function is settled. Provides no customized data other than the context.
55+
*/
56+
onCompletion(callback, options) {
57+
this.events.push("firebase.extensions.firestore-translate-text.v1.onCompletion");
58+
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);
59+
}
60+
}
61+
exports.FirestoreTranslateText = FirestoreTranslateText;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@firebase-extensions/firebase-firestore-translate-text-sdk",
3+
"main": "./index.js"
4+
}

spec/fixtures/sources/commonjs-grouped/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const functions = require("../../../../src/v1");
22
const functionsv2 = require("../../../../src/v2");
3+
const firestoreTranslateText = require("../../extsdk/translate").firestoreTranslateText;
4+
const backfill = require("../../extsdk/local").backfill;
5+
36

47
exports.v1http = functions.https.onRequest((req, resp) => {
58
resp.status(200).send("PASS");
@@ -17,4 +20,28 @@ exports.v2callable = functionsv2.https.onCall(() => {
1720
return "PASS";
1821
});
1922

23+
// A Firebase extension by ref
24+
const extRef1 = firestoreTranslateText("extRef1", {
25+
"COLLECTION_PATH": "collection1",
26+
"INPUT_FIELD_NAME": "input1",
27+
"LANGUAGES": "de,es",
28+
"OUTPUT_FIELD_NAME": "translated",
29+
"_EVENT_ARC_REGION": "us-central1",
30+
"_FUNCTION_LOCATION": "us-central1",
31+
});
32+
exports.extRef1 = extRef1;
33+
34+
// A Firebase function defined by extension event
35+
const ttOnStart = extRef1.onStart((event) => {
36+
console.log("onStart got event: " + JSON.stringify(event, null, 2));
37+
});
38+
exports.ttOnStart = ttOnStart;
39+
40+
// A Firebase extension by localPath
41+
const extLocal2 = backfill("extLocal2", {
42+
DO_BACKFILL: "False",
43+
LOCATION: "us-central1",
44+
});
45+
exports.extLocal2 = extLocal2;
46+
2047
exports.g1 = require("./g1");

spec/fixtures/sources/commonjs-main/functions.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const functions = require("../../../../src/v1");
22
const functionsv2 = require("../../../../src/v2");
3+
const firestoreTranslateText = require("../../extsdk/translate").firestoreTranslateText;
4+
const backfill = require("../../extsdk/local").backfill;
35

46
exports.v1http = functions.https.onRequest((req, resp) => {
57
resp.status(200).send("PASS");
@@ -16,3 +18,27 @@ exports.v2http = functionsv2.https.onRequest((req, resp) => {
1618
exports.v2callable = functionsv2.https.onCall(() => {
1719
return "PASS";
1820
});
21+
22+
// A Firebase extension by ref
23+
const extRef1 = firestoreTranslateText("extRef1", {
24+
"COLLECTION_PATH": "collection1",
25+
"INPUT_FIELD_NAME": "input1",
26+
"LANGUAGES": "de,es",
27+
"OUTPUT_FIELD_NAME": "translated",
28+
"_EVENT_ARC_REGION": "us-central1",
29+
"_FUNCTION_LOCATION": "us-central1",
30+
});
31+
exports.extRef1 = extRef1;
32+
33+
// A Firebase function defined by extension event
34+
const ttOnStart = extRef1.onStart((event) => {
35+
console.log("onStart got event: " + JSON.stringify(event, null, 2));
36+
});
37+
exports.ttOnStart = ttOnStart;
38+
39+
// A Firebase extension by localPath
40+
const extLocal2 = backfill("extLocal2", {
41+
DO_BACKFILL: "False",
42+
LOCATION: "us-central1",
43+
});
44+
exports.extLocal2 = extLocal2;

spec/fixtures/sources/commonjs-parametrized-fields/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const functions = require("../../../../src/v1/index");
22
const functionsv2 = require("../../../../src/v2/index");
3+
const firestoreTranslateText = require("../../extsdk/translate").firestoreTranslateText;
4+
const backfill = require("../../extsdk/local").backfill;
35
const params = require("../../../../src/params");
46
params.clearParams();
57

@@ -28,3 +30,27 @@ exports.v2http = functionsv2.https.onRequest({
2830
}, (req, resp) => {
2931
resp.status(200).send("Hello world!");
3032
});
33+
34+
// A Firebase extension by ref
35+
const extRef1 = firestoreTranslateText("extRef1", {
36+
"COLLECTION_PATH": "collection1",
37+
"INPUT_FIELD_NAME": "input1",
38+
"LANGUAGES": "de,es",
39+
"OUTPUT_FIELD_NAME": "translated",
40+
"_EVENT_ARC_REGION": "us-central1",
41+
"_FUNCTION_LOCATION": "us-central1",
42+
});
43+
exports.extRef1 = extRef1;
44+
45+
// A Firebase function defined by extension event
46+
const ttOnStart = extRef1.onStart((event) => {
47+
console.log("onStart got event: " + JSON.stringify(event, null, 2));
48+
});
49+
exports.ttOnStart = ttOnStart;
50+
51+
// A Firebase extension by localPath
52+
const extLocal2 = backfill("extLocal2", {
53+
DO_BACKFILL: "False",
54+
LOCATION: "us-central1",
55+
});
56+
exports.extLocal2 = extLocal2;

0 commit comments

Comments
 (0)