diff --git a/components/firebase_admin_sdk/actions/get-document/get-document.mjs b/components/firebase_admin_sdk/actions/get-document/get-document.mjs new file mode 100644 index 0000000000000..8b066123c762b --- /dev/null +++ b/components/firebase_admin_sdk/actions/get-document/get-document.mjs @@ -0,0 +1,66 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "firebase_admin_sdk-get-document", + name: "Get Document", + description: "Retrieves a document from a Firestore collection. [See the documentation](https://firebase.google.com/docs/firestore/query-data/get-data#get_a_document)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + collection: { + propDefinition: [ + common.props.firebase, + "collection", + (c) => ({ + region: c.databaseRegion, + }), + ], + }, + document: { + propDefinition: [ + common.props.firebase, + "document", + (c) => ({ + collection: c.collection, + region: c.databaseRegion, + }), + ], + }, + }, + methods: { + ...common.methods, + async getResponse() { + const docRef = this.firebase.getDocument({ + collection: this.collection, + document: this.document, + }); + const snapshot = await docRef.get(); + + if (!snapshot.exists) { + return { + exists: false, + id: this.document, + }; + } + + return { + exists: true, + id: snapshot.id, + data: snapshot.data(), + createTime: snapshot.createTime?.toDate(), + updateTime: snapshot.updateTime?.toDate(), + readTime: snapshot.readTime?.toDate(), + ref: snapshot.ref.path, + }; + }, + emitSummary($, response) { + if (!response.exists) { + $.export("$summary", `Document ${this.document} not found in collection ${this.collection}`); + return; + } + $.export("$summary", `Successfully retrieved document ${this.document} from collection ${this.collection}`); + }, + }, +}; diff --git a/components/firebase_admin_sdk/package.json b/components/firebase_admin_sdk/package.json index b82cfd4d18ade..25981f6c845fc 100644 --- a/components/firebase_admin_sdk/package.json +++ b/components/firebase_admin_sdk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/firebase_admin_sdk", - "version": "0.0.10", + "version": "0.1.0", "description": "Pipedream Firebase Admin SDK Components", "main": "firebase_admin_sdk.app.mjs", "keywords": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c257e350a5fb5..3cb3a6c726e45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8656,8 +8656,7 @@ importers: components/notiff: {} - components/notiff_io: - specifiers: {} + components/notiff_io: {} components/notion: dependencies: @@ -12000,8 +11999,7 @@ importers: components/smartengage: {} - components/smartlead: - specifiers: {} + components/smartlead: {} components/smartproxy: {} @@ -34522,8 +34520,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: