dbrwk
dbrwk
BBuildShip
Created by dbrwk on 11/18/2024 in #❓・buildship-help
In one of my production workflows expressions does not work
@nithinrdy that seems to work, thanks.
7 replies
BBuildShip
Created by jamelo#2709 on 7/14/2024 in #❓・buildship-help
Hello, how do I use npm packages in buildship, how do I install them? For example, I need to use Pu
Good for you, @Szekeres Géza . I did not found any solution and just put that idea on hold. Will check your way in the future, thanks for sharing for the community!
23 replies
BBuildShip
Created by tlawrence on 9/27/2024 in #❓・buildship-help
Installing NPM Package
@Gaurav Chadha thanks! yeah i found it, still have issue tho.
8 replies
BBuildShip
Created by jamelo#2709 on 7/14/2024 in #❓・buildship-help
Hello, how do I use npm packages in buildship, how do I install them? For example, I need to use Pu
@Gaurav Chadha when i tried ai generate jimp node this error occures: { "nodeId": "test-node-1727500902127", "nodeName": "Resize and Change Image Quality", "stage": "building node", "errorObject": { "errors": [ { "id": "", "location": { "column": 7, "file": "../../../tmp/test-node-1727500902127XXXXXXOisBbE/index.ts", "length": 4, "line": 1, "lineText": "import Jimp from 'jimp';", "namespace": "", "suggestion": "" }, "notes": [], "pluginName": "", "text": "No matching export in "../../../tmp/test-node-1727500902127XXXXXXOisBbE/node_modules/jimp/dist/esm/index.js" for import "default"" } ], "warnings": [] } }
23 replies
BBuildShip
Created by tlawrence on 9/27/2024 in #❓・buildship-help
Installing NPM Package
@Gaurav Chadha i have similar issue. i tried to import sharp from 'sharp'; and got this error: Could not load the "sharp" module using the linux-x64 runtime Possible solutions: - Ensure optional dependencies can be installed: npm install --include=optional sharp - Ensure your package manager supports multi-platform installation: See https://sharp.pixelplumbing.com/install#cross-platform - Add platform-specific dependencies: npm install --os=linux --cpu=x64 sharp - Consult the installation documentation: See https://sharp.pixelplumbing.com/install
8 replies
BBuildShip
Created by dbrwk on 7/23/2024 in #❓・buildship-help
Cant update user value in Firestore
actually, my AI Chatbot friend, resetting the node fixed the problem. And it turned out, i didnt tinker with this code (did a diffcheck to be sure) so it was some kind of a bug.
8 replies
BBuildShip
Created by dbrwk on 7/23/2024 in #❓・buildship-help
Cant update user value in Firestore
import { Firestore, DocumentReference } from '@google-cloud/firestore';

function createNestedObject(path, value) {
let obj = value;
for (let i = path.length - 1; i >= 0; i--) {
obj = { [path[i]]: obj };
}
return obj;
}

function convertDataToReferences(firestore: Firestore, data: Record<string, any>): Record<string, any> {
const convertedData: Record<string, any> = {};
for (const key in data) {
const value = data[key];
// _ref:collectionName/documentId
if (typeof value === 'string' && value.includes('/') && value.startsWith('_ref:')) {
const path = value.split('_ref:')[1];
try {
const ref = firestore.doc(path);
if (ref instanceof DocumentReference) {
convertedData[key] = ref;
} else {
convertedData[key] = value;
}
} catch (error) {
convertedData[key] = value;
}
} else if (typeof value === 'object' && value !== null) {
convertedData[key] = convertDataToReferences(firestore, value);
} else {
convertedData[key] = value;
}
}
return convertedData;
}

export default async function updateFirestoreFieldValue({
docPath,
fieldKey,
newValue,
projectId
}: NodeInputs, { logging }: NodeScriptOptions): NodeOutput {
const firestore = new Firestore(
projectId && projectId.length > 1 ? { projectId: projectId.trim() } : undefined
);

const docRef = firestore.doc(docPath);

// Convert the newValue to handle document references
const convertedNewValue = convertDataToReferences(firestore, { value: newValue }).value;

const fieldKeys = fieldKey.split('.');
const dataObject = createNestedObject(fieldKeys, convertedNewValue);

const result = await docRef.set(dataObject, { merge: true });
return result;
}
import { Firestore, DocumentReference } from '@google-cloud/firestore';

function createNestedObject(path, value) {
let obj = value;
for (let i = path.length - 1; i >= 0; i--) {
obj = { [path[i]]: obj };
}
return obj;
}

function convertDataToReferences(firestore: Firestore, data: Record<string, any>): Record<string, any> {
const convertedData: Record<string, any> = {};
for (const key in data) {
const value = data[key];
// _ref:collectionName/documentId
if (typeof value === 'string' && value.includes('/') && value.startsWith('_ref:')) {
const path = value.split('_ref:')[1];
try {
const ref = firestore.doc(path);
if (ref instanceof DocumentReference) {
convertedData[key] = ref;
} else {
convertedData[key] = value;
}
} catch (error) {
convertedData[key] = value;
}
} else if (typeof value === 'object' && value !== null) {
convertedData[key] = convertDataToReferences(firestore, value);
} else {
convertedData[key] = value;
}
}
return convertedData;
}

export default async function updateFirestoreFieldValue({
docPath,
fieldKey,
newValue,
projectId
}: NodeInputs, { logging }: NodeScriptOptions): NodeOutput {
const firestore = new Firestore(
projectId && projectId.length > 1 ? { projectId: projectId.trim() } : undefined
);

const docRef = firestore.doc(docPath);

// Convert the newValue to handle document references
const convertedNewValue = convertDataToReferences(firestore, { value: newValue }).value;

const fieldKeys = fieldKey.split('.');
const dataObject = createNestedObject(fieldKeys, convertedNewValue);

const result = await docRef.set(dataObject, { merge: true });
return result;
}
8 replies
BBuildShip
Created by dbrwk on 7/4/2024 in #❓・buildship-help
Object Validation node returns Unsupported type: timestamp error
Cool idea! Thanks! But, just for clarification. In wich node you put this? my workflow is like that: rest trigger -> object validation node -> branch node -> (is success) firestore create doc;
5 replies