Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/npm_publish_bq_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- name: NPM install
run: npm install
- name: Publish BigQuery Schema Views
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/readmes-updated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 22
cache: "npm"
cache-dependency-path: "**/functions/package-lock.json"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ["18"]
node: ["20"]
name: node.js_${{ matrix.node }}_test
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- name: NPM install
run: SKIP_POSTINSTALL=yes npm i
- name: Prettier Lint Check
Expand Down
6 changes: 6 additions & 0 deletions firestore-shorten-urls-bitly/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.2.0

feat: use v2 firestore trigger

feat: allow non-(default) firestore instances

## Version 0.1.18

feat - move to Node.js 20 runtimes
Expand Down
2 changes: 1 addition & 1 deletion firestore-shorten-urls-bitly/POSTINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You can test out this extension right away!

1. Go to your [Cloud Firestore dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/firestore/data) in the Firebase console.
1. Go to your [Cloud Firestore dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/firestore/data) in the Firebase console. Note that, if you have configured a non-default firestore database, you may have to view it via the [Google Cloud Console](https://console.cloud.google.com/firestore/databases/${param:DATABASE}).

1. If it doesn't exist already, create a collection called `${param:COLLECTION_PATH}`.

Expand Down
10 changes: 8 additions & 2 deletions firestore-shorten-urls-bitly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan
* Short URL field name: What is the name of the field where you want to store your shortened URLs?


* Firestore Instance ID: The Firestore database to use. Use "(default)" for the default database. You can view your available Firestore databases at [https://console.cloud.google.com/firestore/databases](https://console.cloud.google.com/firestore/databases).


**Cloud Functions:**
* Firestore Instance Location: Where is the Firestore database located? You can check your current database location at [https://console.cloud.google.com/firestore/databases](https://console.cloud.google.com/firestore/databases).

* **fsurlshortener:** Listens for writes of new URLs to your specified Cloud Firestore collection, shortens the URLs, then writes the shortened form back to the same document.



**Other Resources**:

* fsurlshortener (firebaseextensions.v1beta.v2function)



Expand Down
153 changes: 145 additions & 8 deletions firestore-shorten-urls-bitly/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-shorten-urls-bitly
version: 0.1.18
version: 0.2.0
specVersion: v1beta

displayName: Shorten URLs in Firestore
Expand Down Expand Up @@ -48,16 +48,26 @@ roles:

resources:
- name: fsurlshortener
type: firebaseextensions.v1beta.function
type: firebaseextensions.v1beta.v2function
description:
Listens for writes of new URLs to your specified Cloud Firestore
collection, shortens the URLs, then writes the shortened form back to the
same document.
properties:
runtime: nodejs20
sourceDirectory: functions
buildConfig:
runtime: nodejs22
serviceConfig:
timeoutSeconds: 120
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.write
resource: projects/${param:PROJECT_ID}/databases/(default)/documents/${param:COLLECTION_PATH}/{documentId}
eventType: google.cloud.firestore.document.v1.written
triggerRegion: ${DATABASE_REGION}
eventFilters:
- attribute: database
value: ${DATABASE}
- attribute: document
value: ${COLLECTION_PATH}/{documentId}
operator: match-path-pattern

externalServices:
- name: Bitly
Expand Down Expand Up @@ -101,16 +111,143 @@ params:
default: shortUrl
required: true

- param: DATABASE
label: Firestore Instance ID
description: >
The Firestore database to use. Use "(default)" for the default database.
You can view your available Firestore databases at
[https://console.cloud.google.com/firestore/databases](https://console.cloud.google.com/firestore/databases).
example: (default)
default: (default)
required: true

- param: DATABASE_REGION
label: Firestore Instance Location
description: >
Where is the Firestore database located? You can check your current
database location at
[https://console.cloud.google.com/firestore/databases](https://console.cloud.google.com/firestore/databases).
type: select
options:
# Multi-region locations
- label: Europe (multi-regional, eur3)
value: eur3
- label: United States (multi-regional, nam5)
value: nam5
- label: Europe (multi-regional)
value: eu
- label: United States (multi-regional)
value: us

# North America
- label: Iowa (us-central1)
value: us-central1
- label: Oregon (us-west1)
value: us-west1
- label: Los Angeles (us-west2)
value: us-west2
- label: Salt Lake City (us-west3)
value: us-west3
- label: Las Vegas (us-west4)
value: us-west4
- label: South Carolina (us-east1)
value: us-east1
- label: Northern Virginia (us-east4)
value: us-east4
- label: Columbus (us-east5)
value: us-east5
- label: Dallas (us-south1)
value: us-south1
- label: Montreal (northamerica-northeast1)
value: northamerica-northeast1
- label: Toronto (northamerica-northeast2)
value: northamerica-northeast2
- label: Queretaro (northamerica-south1)
value: northamerica-south1

# South America
- label: Sao Paulo (southamerica-east1)
value: southamerica-east1
- label: Santiago (southamerica-west1)
value: southamerica-west1

# Europe
- label: Belgium (europe-west1)
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Netherlands (europe-west4)
value: europe-west4
- label: Zurich (europe-west6)
value: europe-west6
- label: Milan (europe-west8)
value: europe-west8
- label: Paris (europe-west9)
value: europe-west9
- label: Berlin (europe-west10)
value: europe-west10
- label: Turin (europe-west12)
value: europe-west12
- label: Madrid (europe-southwest1)
value: europe-southwest1
- label: Finland (europe-north1)
value: europe-north1
- label: Stockholm (europe-north2)
value: europe-north2
- label: Warsaw (europe-central2)
value: europe-central2

# Middle East
- label: Doha (me-central1)
value: me-central1
- label: Dammam (me-central2)
value: me-central2
- label: Tel Aviv (me-west1)
value: me-west1

# Asia
- label: Mumbai (asia-south1)
value: asia-south1
- label: Delhi (asia-south2)
value: asia-south2
- label: Singapore (asia-southeast1)
value: asia-southeast1
- label: Jakarta (asia-southeast2)
value: asia-southeast2
- label: Taiwan (asia-east1)
value: asia-east1
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
value: asia-northeast1
- label: Osaka (asia-northeast2)
value: asia-northeast2
- label: Seoul (asia-northeast3)
value: asia-northeast3

# Australia
- label: Sydney (australia-southeast1)
value: australia-southeast1
- label: Melbourne (australia-southeast2)
value: australia-southeast2

# Africa
- label: Johannesburg (africa-south1)
value: africa-south1
default: us
required: true
immutable: true

events:
- type: firebase.extensions.firestore-shorten-urls-bitly.v1.onStart
description:
Occurs when a trigger has been called within the Extension, and will
include data such as the context of the trigger request.

- type: firebase.extensions.firestore-shorten-urls-bitly.v1.onSuccess
description:
Occurs when image resizing completes successfully. The event will contain
further details about specific formats and sizes.
description: Occurs when URL shortening completes successfully.

- type: firebase.extensions.firestore-shorten-urls-bitly.v1.onError
description:
Expand Down
Loading
Loading