Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dff1c5e387 |
3
packages/backend/src/apps/firebase/dynamic-data/index.js
Normal file
3
packages/backend/src/apps/firebase/dynamic-data/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import listFirestoreCollections from './list-firestore-collections/index.js';
|
||||
|
||||
export default [listFirestoreCollections];
|
@@ -0,0 +1,32 @@
|
||||
export default {
|
||||
name: 'List firestore collections',
|
||||
key: 'listFirestoreCollections',
|
||||
|
||||
async run($) {
|
||||
const firestoreCollections = {
|
||||
data: [],
|
||||
};
|
||||
const projectId = $.auth.data.projectId;
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`/v1/projects/${projectId}/databases/(default)/documents:listCollectionIds`,
|
||||
null,
|
||||
{
|
||||
additionalProperties: {
|
||||
setFirestoreBaseUrl: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (data.collectionIds?.length) {
|
||||
for (const collectionId of data.collectionIds) {
|
||||
firestoreCollections.data.push({
|
||||
value: collectionId,
|
||||
name: collectionId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return firestoreCollections;
|
||||
},
|
||||
};
|
@@ -2,6 +2,8 @@ import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Firebase',
|
||||
@@ -14,4 +16,6 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
});
|
||||
|
3
packages/backend/src/apps/firebase/triggers/index.js
Normal file
3
packages/backend/src/apps/firebase/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import newDocumentsWithinFirestoreCollection from './new-documents-within-firestore-collection/index.js';
|
||||
|
||||
export default [newDocumentsWithinFirestoreCollection];
|
@@ -0,0 +1,66 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New documents within a firestore collection',
|
||||
key: 'newDocumentsWithinFirestoreCollection',
|
||||
pollInterval: 15,
|
||||
description:
|
||||
'Triggers when a new document is added within a Cloud Firestore collection.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Collection',
|
||||
key: 'collectionId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listFirestoreCollections',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const projectId = $.auth.data.projectId;
|
||||
const collectionId = $.step.parameters.collectionId;
|
||||
const params = {
|
||||
pageSize: 100,
|
||||
pageToken: undefined,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(
|
||||
`/v1/projects/${projectId}/databases/(default)/documents/${collectionId}`,
|
||||
{
|
||||
params,
|
||||
additionalProperties: {
|
||||
setFirestoreBaseUrl: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (!data?.documents?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const document of data.documents) {
|
||||
const nameParts = document.name.split('/');
|
||||
const id = nameParts[nameParts.length - 1];
|
||||
$.pushTriggerItem({
|
||||
raw: document,
|
||||
meta: {
|
||||
internalId: id,
|
||||
},
|
||||
});
|
||||
}
|
||||
} while (params.pageToken);
|
||||
},
|
||||
});
|
@@ -99,7 +99,10 @@ export default defineConfig({
|
||||
text: 'Firebase',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/firebase/connection' }],
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/firebase/triggers' },
|
||||
{ text: 'Connection', link: '/apps/firebase/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Flickr',
|
||||
|
12
packages/docs/pages/apps/firebase/triggers.md
Normal file
12
packages/docs/pages/apps/firebase/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/firebase.svg
|
||||
items:
|
||||
- name: New documents within a firestore collection
|
||||
desc: Triggers when a new document is added within a Cloud Firestore collection.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -9,6 +9,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Discord](/apps/discord/actions)
|
||||
- [Dropbox](/apps/dropbox/actions)
|
||||
- [Filter](/apps/filter/actions)
|
||||
- [Firebase](/apps/firebase/triggers)
|
||||
- [Flickr](/apps/flickr/triggers)
|
||||
- [Formatter](/apps/formatter/actions)
|
||||
- [Ghost](/apps/ghost/triggers)
|
||||
|
52
packages/docs/pages/public/favicons/firestore.svg
Normal file
52
packages/docs/pages/public/favicons/firestore.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
Reference in New Issue
Block a user