#Hello team!

1 messages · Page 1 of 1 (latest)

worthy glade
#

Hello @floral night , can you try it this way?

const permify = require("@permify/permify-node");

const {StringArrayValue} = require("@permify/permify-node/dist/src/grpc/generated/base");
const {Any} = require("@permify/permify-node/dist/src/grpc/generated/google/protobuf/any");

const test = () => {
    try {
        let client = permify.grpc.newClient({
            endpoint: "localhost:3478",
            cert: null
        })

        const stringArrayValue = StringArrayValue.fromJSON({ data: ['ai_docs', 'actions'] });

        const value = Any.fromJSON({
            typeUrl: 'type.googleapis.com/base.v1.StringArrayValue',
            value: StringArrayValue.encode(stringArrayValue).finish()
        });
        
        client.data
            .write({
                tenantId: tenantId,
                metadata: {
                    schemaVersion: schemaVersion,
                },
                tuples: [
                    {
                        entity: {
                            type: "role",
                            id: "admin",
                        },
                        relation: "assignee",
                        subject: {
                            type: "user",
                            id: "1",
                        },
                    },
                    {
                        entity: {
                            type: "role",
                            id: "member",
                        },
                        relation: "assignee",
                        subject: {
                            type: "user",
                            id: "1",
                        },
                    },
                    {
                        entity: {
                            type: "recipe",
                            id: "+",
                        },
                        relation: "viewer_all",
                        subject: {
                            type: "role",
                            id: "admin",
                            relation: "assignee",
                        },
                    },
                    {
                        entity: {
                            type: "recipe",
                            id: "+",
                        },
                        relation: "viewer_owned",
                        subject: {
                            type: "role",
                            id: "member",
                            relation: "assignee",
                        },
                    },
                ],
                attributes: [
                    {
                        entity: {
                            type: "bake",
                            id: "docs+",
                        },
                        attribute: "usecases",
                        value: value,
                    },
                ],
            })
            .then((response) => {
                console.log(response);
            });
    } catch (err) {
        console.log('err', err)
    }
}