Compare commits
1 Commits
AUT-804
...
decode-htm
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bb945e1bb8 |
@@ -46,6 +46,7 @@
|
|||||||
"graphql-shield": "^7.5.0",
|
"graphql-shield": "^7.5.0",
|
||||||
"graphql-tools": "^8.2.0",
|
"graphql-tools": "^8.2.0",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
|
"he": "^1.2.0",
|
||||||
"http-errors": "~1.6.3",
|
"http-errors": "~1.6.3",
|
||||||
"http-proxy-agent": "^7.0.0",
|
"http-proxy-agent": "^7.0.0",
|
||||||
"https-proxy-agent": "^7.0.1",
|
"https-proxy-agent": "^7.0.1",
|
||||||
|
@@ -1,116 +0,0 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
|
||||||
|
|
||||||
export default defineAction({
|
|
||||||
name: 'Create Cloud Firestore document',
|
|
||||||
key: 'createCloudFirestoreDocument',
|
|
||||||
description: 'Creates a new document 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',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Convert Numerics',
|
|
||||||
key: 'convertNumerics',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
"If any value represents a valid numerical value, whether it's an integer or a floating-point number, this field directs the database to store it as a numeric data type instead of a string.",
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Yes', value: true },
|
|
||||||
{ label: 'No', value: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Document ID',
|
|
||||||
key: 'documentId',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
'The document ID to use for this document. If not specified, an ID will be assigned.',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Document Data',
|
|
||||||
key: 'documentData',
|
|
||||||
type: 'dynamic',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
label: 'Key',
|
|
||||||
key: 'key',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Value',
|
|
||||||
key: 'value',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const projectId = $.auth.data.projectId;
|
|
||||||
const { collectionId, documentId, documentData, convertNumerics } =
|
|
||||||
$.step.parameters;
|
|
||||||
|
|
||||||
const documentDataObject = documentData.reduce((result, entry) => {
|
|
||||||
const key = entry.key?.toLowerCase();
|
|
||||||
const value = entry.value;
|
|
||||||
const isNumber = !isNaN(parseFloat(value));
|
|
||||||
|
|
||||||
if (key && value) {
|
|
||||||
const formattedValue =
|
|
||||||
convertNumerics && isNumber
|
|
||||||
? { integerValue: parseFloat(value) }
|
|
||||||
: { stringValue: value };
|
|
||||||
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
[key]: formattedValue,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const body = {
|
|
||||||
fields: documentDataObject,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await $.http.post(
|
|
||||||
`/v1/projects/${projectId}/databases/(default)/documents/${collectionId}?documentId=${documentId}`,
|
|
||||||
body,
|
|
||||||
{
|
|
||||||
additionalProperties: {
|
|
||||||
setFirestoreBaseUrl: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$.setActionItem({
|
|
||||||
raw: data,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,100 +0,0 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
|
||||||
|
|
||||||
export default defineAction({
|
|
||||||
name: 'Create Firebase Realtime Database Record',
|
|
||||||
key: 'createFirebaseRealtimeDatabaseRecord',
|
|
||||||
description: 'Creates a child object within your Firebase Realtime Database.',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
label: 'Path',
|
|
||||||
key: 'path',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description:
|
|
||||||
"Indicate the path to the key of the object where the child objects to be queried are located, for example, 'foo/bar/here'.",
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Convert Numerics',
|
|
||||||
key: 'convertNumerics',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
"If any value represents a valid numerical value, whether it's an integer or a floating-point number, this field directs the database to store it as a numeric data type instead of a string.",
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Yes', value: true },
|
|
||||||
{ label: 'No', value: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'New ID',
|
|
||||||
key: 'newId',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
'The key to use for this object, or leave it blank for Firebase to create one automatically.',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Data',
|
|
||||||
key: 'childData',
|
|
||||||
type: 'dynamic',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
label: 'Key',
|
|
||||||
key: 'key',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Value',
|
|
||||||
key: 'value',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
let path = $.step.parameters.path;
|
|
||||||
const { convertNumerics, newId, childData } = $.step.parameters;
|
|
||||||
|
|
||||||
if (newId) {
|
|
||||||
path = `${path}/${newId}.json`;
|
|
||||||
} else {
|
|
||||||
path = `${path}.json`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedChildObjectData = childData.reduce((result, entry) => {
|
|
||||||
const key = entry?.key;
|
|
||||||
const value = entry?.value;
|
|
||||||
const isNumber = !isNaN(parseFloat(value));
|
|
||||||
|
|
||||||
if (isNumber && convertNumerics) {
|
|
||||||
result[key] = parseFloat(value);
|
|
||||||
} else {
|
|
||||||
result[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const body = formattedChildObjectData;
|
|
||||||
|
|
||||||
const { data } = await $.http.post(path, body, {
|
|
||||||
additionalProperties: {
|
|
||||||
setFirestoreBaseUrl: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
$.setActionItem({
|
|
||||||
raw: data,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,53 +0,0 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
|
||||||
|
|
||||||
export default defineAction({
|
|
||||||
name: 'Find Cloud Firestore document',
|
|
||||||
key: 'findCloudFirestoreDocument',
|
|
||||||
description: 'Finds a document within a collection.',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
label: 'Collection',
|
|
||||||
key: 'collectionId',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: true,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listFirestoreCollections',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Document ID',
|
|
||||||
key: 'documentId',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const projectId = $.auth.data.projectId;
|
|
||||||
const { collectionId, documentId } = $.step.parameters;
|
|
||||||
|
|
||||||
const { data } = await $.http.get(
|
|
||||||
`/v1/projects/${projectId}/databases/(default)/documents/${collectionId}/${documentId}`,
|
|
||||||
{
|
|
||||||
additionalProperties: {
|
|
||||||
setFirestoreBaseUrl: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$.setActionItem({
|
|
||||||
raw: data,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,32 +0,0 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
|
||||||
|
|
||||||
export default defineAction({
|
|
||||||
name: 'Find Firebase Realtime Database Record',
|
|
||||||
key: 'findFirebaseRealtimeDatabaseRecord',
|
|
||||||
description: 'Finds a child object in Firebase Realtime Database.',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
label: 'Path',
|
|
||||||
key: 'path',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description:
|
|
||||||
"Indicate the path to the key of the object where the child objects to be queried are located, for example, 'foo/bar/here'.",
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const { path } = $.step.parameters;
|
|
||||||
|
|
||||||
const { data } = await $.http.get(`${path}.json`, {
|
|
||||||
additionalProperties: {
|
|
||||||
setFirestoreBaseUrl: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
$.setActionItem({
|
|
||||||
raw: data,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,11 +0,0 @@
|
|||||||
import createCloudFirestoreDocument from './create-cloud-firestore-document/index.js';
|
|
||||||
import createFirebaseRealtimeDatabaseRecord from './create-firebase-realtime-database-record/index.js';
|
|
||||||
import findCloudFirestoreDocument from './find-cloud-firestore-document/index.js';
|
|
||||||
import findFirebaseRealtimeDatabaseRecord from './find-firebase-realtime-database-record/index.js';
|
|
||||||
|
|
||||||
export default [
|
|
||||||
createCloudFirestoreDocument,
|
|
||||||
createFirebaseRealtimeDatabaseRecord,
|
|
||||||
findCloudFirestoreDocument,
|
|
||||||
findFirebaseRealtimeDatabaseRecord,
|
|
||||||
];
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 21 KiB |
@@ -1,23 +0,0 @@
|
|||||||
import { URLSearchParams } from 'url';
|
|
||||||
import authScope from '../common/auth-scope.js';
|
|
||||||
|
|
||||||
export default async function generateAuthUrl($) {
|
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
|
||||||
(field) => field.key == 'oAuthRedirectUrl'
|
|
||||||
);
|
|
||||||
const redirectUri = oauthRedirectUrlField.value;
|
|
||||||
const searchParams = new URLSearchParams({
|
|
||||||
client_id: $.auth.data.clientId,
|
|
||||||
redirect_uri: redirectUri,
|
|
||||||
prompt: 'select_account',
|
|
||||||
scope: authScope.join(' '),
|
|
||||||
response_type: 'code',
|
|
||||||
access_type: 'offline',
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = `https://accounts.google.com/o/oauth2/v2/auth?${searchParams.toString()}`;
|
|
||||||
|
|
||||||
await $.auth.set({
|
|
||||||
url,
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
import generateAuthUrl from './generate-auth-url.js';
|
|
||||||
import verifyCredentials from './verify-credentials.js';
|
|
||||||
import refreshToken from './refresh-token.js';
|
|
||||||
import isStillVerified from './is-still-verified.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
key: 'oAuthRedirectUrl',
|
|
||||||
label: 'OAuth Redirect URL',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
readOnly: true,
|
|
||||||
value: '{WEB_APP_URL}/app/firebase/connections/add',
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
|
||||||
clickToCopy: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'clientId',
|
|
||||||
label: 'Client ID',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description: null,
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'clientSecret',
|
|
||||||
label: 'Client Secret',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description: null,
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'projectId',
|
|
||||||
label: 'Project ID',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description: 'The project id of your Firebase project',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'realtimeDatabaseId',
|
|
||||||
label: 'Realtime Database Domain',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'If you want to use Realtime Database, please provide the domain of your Realtime Database (https://{{domain}}.firebaseio.com)',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
generateAuthUrl,
|
|
||||||
verifyCredentials,
|
|
||||||
isStillVerified,
|
|
||||||
refreshToken,
|
|
||||||
};
|
|
@@ -1,8 +0,0 @@
|
|||||||
import getCurrentUser from '../common/get-current-user.js';
|
|
||||||
|
|
||||||
const isStillVerified = async ($) => {
|
|
||||||
const currentUser = await getCurrentUser($);
|
|
||||||
return !!currentUser.resourceName;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default isStillVerified;
|
|
@@ -1,31 +0,0 @@
|
|||||||
import { URLSearchParams } from 'node:url';
|
|
||||||
|
|
||||||
import authScope from '../common/auth-scope.js';
|
|
||||||
|
|
||||||
const refreshToken = async ($) => {
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
client_id: $.auth.data.clientId,
|
|
||||||
client_secret: $.auth.data.clientSecret,
|
|
||||||
grant_type: 'refresh_token',
|
|
||||||
refresh_token: $.auth.data.refreshToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data } = await $.http.post(
|
|
||||||
'https://oauth2.googleapis.com/token',
|
|
||||||
params.toString(),
|
|
||||||
{
|
|
||||||
additionalProperties: {
|
|
||||||
skipAddingAuthHeader: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await $.auth.set({
|
|
||||||
accessToken: data.access_token,
|
|
||||||
expiresIn: data.expires_in,
|
|
||||||
scope: authScope.join(' '),
|
|
||||||
tokenType: data.token_type,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default refreshToken;
|
|
@@ -1,50 +0,0 @@
|
|||||||
import getCurrentUser from '../common/get-current-user.js';
|
|
||||||
|
|
||||||
const verifyCredentials = async ($) => {
|
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
|
||||||
(field) => field.key == 'oAuthRedirectUrl'
|
|
||||||
);
|
|
||||||
const redirectUri = oauthRedirectUrlField.value;
|
|
||||||
const { data } = await $.http.post(
|
|
||||||
`https://oauth2.googleapis.com/token`,
|
|
||||||
{
|
|
||||||
client_id: $.auth.data.clientId,
|
|
||||||
client_secret: $.auth.data.clientSecret,
|
|
||||||
code: $.auth.data.code,
|
|
||||||
grant_type: 'authorization_code',
|
|
||||||
redirect_uri: redirectUri,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
additionalProperties: {
|
|
||||||
skipAddingAuthHeader: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await $.auth.set({
|
|
||||||
accessToken: data.access_token,
|
|
||||||
tokenType: data.token_type,
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentUser = await getCurrentUser($);
|
|
||||||
|
|
||||||
const { displayName } = currentUser.names.find(
|
|
||||||
(name) => name.metadata.primary
|
|
||||||
);
|
|
||||||
const { value: email } = currentUser.emailAddresses.find(
|
|
||||||
(emailAddress) => emailAddress.metadata.primary
|
|
||||||
);
|
|
||||||
|
|
||||||
await $.auth.set({
|
|
||||||
clientId: $.auth.data.clientId,
|
|
||||||
clientSecret: $.auth.data.clientSecret,
|
|
||||||
scope: $.auth.data.scope,
|
|
||||||
idToken: data.id_token,
|
|
||||||
expiresIn: data.expires_in,
|
|
||||||
refreshToken: data.refresh_token,
|
|
||||||
resourceName: currentUser.resourceName,
|
|
||||||
screenName: `${displayName} - ${email}`,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default verifyCredentials;
|
|
@@ -1,9 +0,0 @@
|
|||||||
const addAuthHeader = ($, requestConfig) => {
|
|
||||||
if ($.auth.data?.accessToken) {
|
|
||||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestConfig;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default addAuthHeader;
|
|
@@ -1,9 +0,0 @@
|
|||||||
const authScope = [
|
|
||||||
'https://www.googleapis.com/auth/datastore',
|
|
||||||
'https://www.googleapis.com/auth/firebase.database',
|
|
||||||
'https://www.googleapis.com/auth/datastore',
|
|
||||||
'https://www.googleapis.com/auth/userinfo.email',
|
|
||||||
'https://www.googleapis.com/auth/userinfo.profile',
|
|
||||||
];
|
|
||||||
|
|
||||||
export default authScope;
|
|
@@ -1,13 +0,0 @@
|
|||||||
const getCurrentUser = async ($) => {
|
|
||||||
const { data: currentUser } = await $.http.get(
|
|
||||||
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses',
|
|
||||||
{
|
|
||||||
additionalProperties: {
|
|
||||||
skipAddingAuthHeader: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return currentUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default getCurrentUser;
|
|
@@ -1,16 +0,0 @@
|
|||||||
const setBaseUrl = ($, requestConfig) => {
|
|
||||||
const realtimeDatabaseId = $.auth.data.realtimeDatabaseId;
|
|
||||||
|
|
||||||
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
|
|
||||||
return requestConfig;
|
|
||||||
|
|
||||||
if (requestConfig.additionalProperties?.setFirestoreBaseUrl) {
|
|
||||||
requestConfig.baseURL = 'https://firestore.googleapis.com';
|
|
||||||
} else {
|
|
||||||
requestConfig.baseURL = `https://${realtimeDatabaseId}.firebaseio.com`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestConfig;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default setBaseUrl;
|
|
@@ -1,3 +0,0 @@
|
|||||||
import listFirestoreCollections from './list-firestore-collections/index.js';
|
|
||||||
|
|
||||||
export default [listFirestoreCollections];
|
|
@@ -1,32 +0,0 @@
|
|||||||
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;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,23 +0,0 @@
|
|||||||
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';
|
|
||||||
import actions from './actions/index.js';
|
|
||||||
|
|
||||||
export default defineApp({
|
|
||||||
name: 'Firebase',
|
|
||||||
key: 'firebase',
|
|
||||||
baseUrl: 'https://firebase.google.com',
|
|
||||||
apiBaseUrl: '',
|
|
||||||
iconUrl: '{BASE_URL}/apps/firebase/assets/favicon.svg',
|
|
||||||
authDocUrl: 'https://automatisch.io/docs/apps/firebase/connection',
|
|
||||||
primaryColor: 'FFA000',
|
|
||||||
supportsConnections: true,
|
|
||||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
|
||||||
auth,
|
|
||||||
triggers,
|
|
||||||
dynamicData,
|
|
||||||
actions,
|
|
||||||
});
|
|
@@ -1,7 +0,0 @@
|
|||||||
import newChildObjectInFirebaseRealtimeDatabase from './new-child-object-in-a-firebase-realtime-database/index.js';
|
|
||||||
import newDocumentsWithinFirestoreCollection from './new-documents-within-firestore-collection/index.js';
|
|
||||||
|
|
||||||
export default [
|
|
||||||
newChildObjectInFirebaseRealtimeDatabase,
|
|
||||||
newDocumentsWithinFirestoreCollection,
|
|
||||||
];
|
|
@@ -1,75 +0,0 @@
|
|||||||
import Crypto from 'crypto';
|
|
||||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
|
||||||
|
|
||||||
export default defineTrigger({
|
|
||||||
name: 'New child object in a firebase realtime database',
|
|
||||||
key: 'newChildObjectInFirebaseRealtimeDatabase',
|
|
||||||
pollInterval: 15,
|
|
||||||
description:
|
|
||||||
'Triggers when a new child object is generated within a specific path.',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
label: 'Path',
|
|
||||||
key: 'path',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description:
|
|
||||||
"Indicate the path to the key of the object where the child objects to be queried are located, for example, 'foo/bar/here.json'.",
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Order',
|
|
||||||
key: 'order',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
'The key or path of the child that should be utilized for comparing objects/records. If unspecified, the order of $key is used.',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Location of newest objects',
|
|
||||||
key: 'locationOfNewestObjects',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description:
|
|
||||||
'Specifies whether the new 100 records are positioned at the "top" or the "bottom" of the ordering. If left unspecified, the assumption is that the bottom/last result represents the "newest objects" (limitToLast).',
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Top of results', value: 'limitToFirst' },
|
|
||||||
{ label: 'Bottom of results', value: 'limitToLast' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const { path, order, locationOfNewestObjects } = $.step.parameters;
|
|
||||||
|
|
||||||
const params = {};
|
|
||||||
|
|
||||||
if (order) {
|
|
||||||
params.orderBy = `"${order}"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locationOfNewestObjects) {
|
|
||||||
params[`${locationOfNewestObjects}`] = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await $.http.get(path, {
|
|
||||||
params,
|
|
||||||
additionalProperties: {
|
|
||||||
setFirestoreBaseUrl: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.pushTriggerItem({
|
|
||||||
raw: data,
|
|
||||||
meta: {
|
|
||||||
internalId: Crypto.randomUUID(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,66 +0,0 @@
|
|||||||
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);
|
|
||||||
},
|
|
||||||
});
|
|
@@ -2,6 +2,7 @@ import defineAction from '../../../../helpers/define-action.js';
|
|||||||
|
|
||||||
import base64ToString from './transformers/base64-to-string.js';
|
import base64ToString from './transformers/base64-to-string.js';
|
||||||
import capitalize from './transformers/capitalize.js';
|
import capitalize from './transformers/capitalize.js';
|
||||||
|
import decodeHtmlEntities from './transformers/decode-html-entities.js';
|
||||||
import extractEmailAddress from './transformers/extract-email-address.js';
|
import extractEmailAddress from './transformers/extract-email-address.js';
|
||||||
import extractNumber from './transformers/extract-number.js';
|
import extractNumber from './transformers/extract-number.js';
|
||||||
import htmlToMarkdown from './transformers/html-to-markdown.js';
|
import htmlToMarkdown from './transformers/html-to-markdown.js';
|
||||||
@@ -16,6 +17,7 @@ import useDefaultValue from './transformers/use-default-value.js';
|
|||||||
const transformers = {
|
const transformers = {
|
||||||
base64ToString,
|
base64ToString,
|
||||||
capitalize,
|
capitalize,
|
||||||
|
decodeHtmlEntities,
|
||||||
extractEmailAddress,
|
extractEmailAddress,
|
||||||
extractNumber,
|
extractNumber,
|
||||||
htmlToMarkdown,
|
htmlToMarkdown,
|
||||||
@@ -43,6 +45,7 @@ export default defineAction({
|
|||||||
options: [
|
options: [
|
||||||
{ label: 'Base64 to String', value: 'base64ToString' },
|
{ label: 'Base64 to String', value: 'base64ToString' },
|
||||||
{ label: 'Capitalize', value: 'capitalize' },
|
{ label: 'Capitalize', value: 'capitalize' },
|
||||||
|
{ label: 'Decode HTML Entities', value: 'decodeHtmlEntities' },
|
||||||
{ label: 'Convert HTML to Markdown', value: 'htmlToMarkdown' },
|
{ label: 'Convert HTML to Markdown', value: 'htmlToMarkdown' },
|
||||||
{ label: 'Convert Markdown to HTML', value: 'markdownToHtml' },
|
{ label: 'Convert Markdown to HTML', value: 'markdownToHtml' },
|
||||||
{ label: 'Extract Email Address', value: 'extractEmailAddress' },
|
{ label: 'Extract Email Address', value: 'extractEmailAddress' },
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
import he from 'he';
|
||||||
|
|
||||||
|
const decodeHtmlEntities = ($) => {
|
||||||
|
const input = $.step.parameters.input;
|
||||||
|
return he.decode(input);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default decodeHtmlEntities;
|
@@ -1,5 +1,6 @@
|
|||||||
import base64ToString from './text/base64-to-string.js';
|
import base64ToString from './text/base64-to-string.js';
|
||||||
import capitalize from './text/capitalize.js';
|
import capitalize from './text/capitalize.js';
|
||||||
|
import decodeHtmlEntities from './text/decode-html-entities.js';
|
||||||
import extractEmailAddress from './text/extract-email-address.js';
|
import extractEmailAddress from './text/extract-email-address.js';
|
||||||
import extractNumber from './text/extract-number.js';
|
import extractNumber from './text/extract-number.js';
|
||||||
import htmlToMarkdown from './text/html-to-markdown.js';
|
import htmlToMarkdown from './text/html-to-markdown.js';
|
||||||
@@ -19,6 +20,7 @@ import formatDateTime from './date-time/format-date-time.js';
|
|||||||
const options = {
|
const options = {
|
||||||
base64ToString,
|
base64ToString,
|
||||||
capitalize,
|
capitalize,
|
||||||
|
decodeHtmlEntities,
|
||||||
extractEmailAddress,
|
extractEmailAddress,
|
||||||
extractNumber,
|
extractNumber,
|
||||||
htmlToMarkdown,
|
htmlToMarkdown,
|
||||||
|
@@ -0,0 +1,12 @@
|
|||||||
|
const decodeHtmlEntities = [
|
||||||
|
{
|
||||||
|
label: 'Input',
|
||||||
|
key: 'input',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'Text that will be decoded.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default decodeHtmlEntities;
|
@@ -95,16 +95,6 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/filter/connection' },
|
{ text: 'Connection', link: '/apps/filter/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
text: 'Firebase',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [
|
|
||||||
{ text: 'Actions', link: '/apps/firebase/actions' },
|
|
||||||
{ text: 'Triggers', link: '/apps/firebase/triggers' },
|
|
||||||
{ text: 'Connection', link: '/apps/firebase/connection' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: 'Flickr',
|
text: 'Flickr',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
favicon: /favicons/firebase.svg
|
|
||||||
items:
|
|
||||||
- name: Create Cloud Firestore document
|
|
||||||
desc: Creates a new document within a Cloud Firestore collection.
|
|
||||||
- name: Create Firebase Realtime Database Record
|
|
||||||
desc: Creates a child object within your Firebase Realtime Database.
|
|
||||||
- name: Find Cloud Firestore document
|
|
||||||
desc: Finds a document within a collection.
|
|
||||||
- name: Find Firebase Realtime Database Record
|
|
||||||
desc: Finds a child object in Firebase Realtime Database.
|
|
||||||
---
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import CustomListing from '../../components/CustomListing.vue'
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<CustomListing />
|
|
@@ -1,31 +0,0 @@
|
|||||||
# Firebase
|
|
||||||
|
|
||||||
:::info
|
|
||||||
This page explains the steps you need to follow to set up the Firebase
|
|
||||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
|
||||||
:::
|
|
||||||
|
|
||||||
1. Go to the [Google Cloud Console](https://console.cloud.google.com) to create a project.
|
|
||||||
2. Click on the project drop-down menu at the top of the page, and click on the **New Project** button.
|
|
||||||
3. Enter a name for your project and click on the **Create** button.
|
|
||||||
4. Go to [API Library](https://console.cloud.google.com/apis/library) in Google Cloud console.
|
|
||||||
5. Search for **Cloud Firestore API** in the search bar and click on it.
|
|
||||||
6. Click on the **Enable** button to enable the API.
|
|
||||||
7. Repeat steps 5 and 6 for the **Firebase Realtime Database API and People API**
|
|
||||||
8. Go to [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) in Google Cloud console.
|
|
||||||
9. Select **External** here for starting your app in testing mode at first. Click on the **Create** button.
|
|
||||||
10. Fill **App Name**, **User Support Email**, and **Developer Contact Information**. Click on the **Save and Continue** button.
|
|
||||||
11. Skip adding or removing scopes and click on the **Save and Continue** button.
|
|
||||||
12. Click on the **Add Users** button and add a test email because only test users can access the app while publishing status is set to "Testing".
|
|
||||||
13. Click on the **Save and Continue** button and now you have configured the consent screen.
|
|
||||||
14. Go to [Credentials](https://console.cloud.google.com/apis/credentials) in Google Cloud console.
|
|
||||||
15. Click on the **Create Credentials** button and select the **OAuth client ID** option.
|
|
||||||
16. Select the application type as **Web application** and fill the **Name** field.
|
|
||||||
17. Copy **OAuth Redirect URL** from Automatisch to **Authorized redirect URIs** field, and click on the **Create** button.
|
|
||||||
18. Copy the **Your Client ID** value from the following popup to the `Client ID` field on Automatisch.
|
|
||||||
19. Copy the **Your Client Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
|
||||||
20. Login to your [Firebase account](https://firebase.google.com/) and go to your project (please create a new project if you don't already have one).
|
|
||||||
21. Click on the gear icon next to **Project Overview** and go to **Project settings**.
|
|
||||||
22. Copy the **Project ID** value to the `Project ID` field on Automatisch.
|
|
||||||
23. Click **Submit** button on Automatisch.
|
|
||||||
24. Congrats! Start using your new Firebase connection within the flows.
|
|
@@ -1,14 +0,0 @@
|
|||||||
---
|
|
||||||
favicon: /favicons/firebase.svg
|
|
||||||
items:
|
|
||||||
- name: New child object in a firebase realtime database
|
|
||||||
desc: Triggers when a new child object is generated within a specific path.
|
|
||||||
- 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,7 +9,6 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Discord](/apps/discord/actions)
|
- [Discord](/apps/discord/actions)
|
||||||
- [Dropbox](/apps/dropbox/actions)
|
- [Dropbox](/apps/dropbox/actions)
|
||||||
- [Filter](/apps/filter/actions)
|
- [Filter](/apps/filter/actions)
|
||||||
- [Firebase](/apps/firebase/triggers)
|
|
||||||
- [Flickr](/apps/flickr/triggers)
|
- [Flickr](/apps/flickr/triggers)
|
||||||
- [Formatter](/apps/formatter/actions)
|
- [Formatter](/apps/formatter/actions)
|
||||||
- [Ghost](/apps/ghost/triggers)
|
- [Ghost](/apps/ghost/triggers)
|
||||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 21 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 21 KiB |
@@ -8973,11 +8973,16 @@ has@^1.0.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
function-bind "^1.1.1"
|
function-bind "^1.1.1"
|
||||||
|
|
||||||
he@1.2.0, he@^1.2.0:
|
he@1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
|
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
|
||||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||||
|
|
||||||
|
he@^1.2.0:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||||
|
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||||
|
|
||||||
hexoid@^1.0.0:
|
hexoid@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
|
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
|
||||||
|
Reference in New Issue
Block a user