Skip to content
Open
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
4 changes: 4 additions & 0 deletions firestore-translate-text/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.1.26

fix(firestore-translate-text): removed unnecessary sanitization

## Version 0.1.25

feat - add Gemini 2.5 Flash Lite
Expand Down
2 changes: 1 addition & 1 deletion firestore-translate-text/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-translate-text
version: 0.1.25
version: 0.1.26
specVersion: v1beta

tags: [ai]
Expand Down
7 changes: 1 addition & 6 deletions firestore-translate-text/functions/src/translate/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ export class GenkitTranslator implements ITranslator {
async translate(text: string, targetLanguage: string): Promise<string> {
try {
// Sanitize input text by escaping special characters
const sanitizedText = text
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/\n/g, " ");

// Construct the prompt with strict boundaries and clear instructions
const prompt = `<translation_task>
<instructions>
Expand All @@ -131,7 +126,7 @@ export class GenkitTranslator implements ITranslator {
- Do not provide explanations or alternate translations
- Maintain the original formatting
</instructions>
<text_to_translate>${sanitizedText}</text_to_translate>
<text_to_translate>${text}</text_to_translate>
</translation_task>`;

const response = await this.client.generate({
Expand Down
5 changes: 5 additions & 0 deletions storage-resize-images/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 7 additions & 1 deletion storage-resize-images/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions storage-resize-images/functions/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
};
6 changes: 6 additions & 0 deletions storage-resize-images/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
});
Expand Down