diff --git a/firestore-bigquery-export/scripts/gen-schema-view/src/index.ts b/firestore-bigquery-export/scripts/gen-schema-view/src/index.ts index 81c382be1..40bc3fbcc 100644 --- a/firestore-bigquery-export/scripts/gen-schema-view/src/index.ts +++ b/firestore-bigquery-export/scripts/gen-schema-view/src/index.ts @@ -19,7 +19,7 @@ import firebase = require("firebase-admin"); import { FirestoreBigQuerySchemaViewFactory, FirestoreSchema } from "./schema"; import { readSchemas } from "./schema-loader-utils"; -import { parseConfig } from "./config"; +import { parseConfig, CliConfig } from "./config"; import { generateSchemaFilesWithGemini } from "./schema/genkit"; export async function run(): Promise { @@ -72,12 +72,32 @@ export async function run(): Promise { } if (process.env.NODE_ENV !== "test") { - run() + let config: CliConfig | null = null; + + parseConfig() + .then((parsedConfig) => { + config = parsedConfig; + return run(); + }) .then((result) => { console.log("done."); process.exit(); }) .catch((error) => { + if (config) { + const errorMessage = error.message || error.errors?.[0]?.message; + if ( + errorMessage?.includes("ProjectId must be non-empty") || + errorMessage?.includes("Cannot parse as CloudRegion") + ) { + const improvedMessage = `The BigQuery Project ID '${config.bigQueryProjectId}' is not valid. Please verify that the project ID is correct and that you have access to it.`; + error.message = improvedMessage; + if (error.errors?.[0]) { + error.errors[0].message = improvedMessage; + } + } + } + console.log(JSON.stringify(error)); console.error(error.message); process.exit(); diff --git a/storage-resize-images/CHANGELOG.md b/storage-resize-images/CHANGELOG.md index 0e7d219ff..f12933d6b 100644 --- a/storage-resize-images/CHANGELOG.md +++ b/storage-resize-images/CHANGELOG.md @@ -1,3 +1,8 @@ +## Version 0.3.1 + +fix - add missing recordStartEvent call (#2546) +feat - add new onStartResize event + ## Version 0.3.0 fix! - remove backfill, due to architectural flaws. diff --git a/storage-resize-images/extension.yaml b/storage-resize-images/extension.yaml index 69d3fec20..ea4fb4212 100644 --- a/storage-resize-images/extension.yaml +++ b/storage-resize-images/extension.yaml @@ -13,7 +13,7 @@ # limitations under the License. name: storage-resize-images -version: 0.3.0 +version: 0.3.1 specVersion: v1beta displayName: Resize Images @@ -426,6 +426,12 @@ events: description: Occurs when the function is settled. Provides no customized data other than the context. + + - type: firebase.extensions.storage-resize-images.v1.onStartResize + description: + Occurs when an image resize operation completes successfully. This event + is only triggered when shouldResize returns true and the resize operation + succeeds. # Lifecycle events disabled - backfill feature commented out # lifecycleEvents: # onInstall: diff --git a/storage-resize-images/functions/src/events.ts b/storage-resize-images/functions/src/events.ts index f3168b4dc..6b548d766 100644 --- a/storage-resize-images/functions/src/events.ts +++ b/storage-resize-images/functions/src/events.ts @@ -60,3 +60,19 @@ export const recordCompletionEvent = async (data: string | object) => { data, }); }; + +export const recordStartResizeEvent = async ({ + subject, + data, +}: { + subject: string; + data: string | object; +}) => { + if (!eventChannel) return; + + return eventChannel.publish({ + type: getEventType("onStartResize"), + subject, + data, + }); +}; diff --git a/storage-resize-images/functions/src/index.ts b/storage-resize-images/functions/src/index.ts index 5cb7034f5..6a4a380cb 100644 --- a/storage-resize-images/functions/src/index.ts +++ b/storage-resize-images/functions/src/index.ts @@ -59,6 +59,11 @@ const generateResizedImageHandler = async ( return; } + await events.recordStartResizeEvent({ + subject: object.name, + data: { input: object }, + }); + const bucket = admin.storage().bucket(object.bucket); const filePath = object.name; // File path in the bucket. const parsedPath = path.parse(filePath); @@ -149,6 +154,7 @@ const generateResizedImageHandler = async ( export const generateResizedImage = functions.storage .object() .onFinalize(async (object, context) => { + await events.recordStartEvent(object); await generateResizedImageHandler(object); await events.recordCompletionEvent({ context }); });