Forum Documentation Showcase Pricing Learn more

[New Plugin] UNIX Converter

Could be :slight_smile:

By the way, have you managed to make any server-side plugin to work consistent?

I struggle to understand if I am doing something wrong or the NPM dependencies thing does not actually work with Bubble…

Server-side instantiation still takes a couple of seconds for the first time. My SSA plugin suite is way better than it was, but I’ve not finished it as I’ve been working on Calendar Grid Pro (in release), some pretty-AMAZING additions to Cal Grid Pro (Time Grid accessory) and a new thing that’s just to kill a really stupid thread here in the forums (guess what it does). Oddly, though I have no interest in client-side plugs, those last three are all… Client-side plugins.

Fate… so cruel.

I see.

Yeah, I saw the grid plugin, look useful and quick!

Could I ask for some help with SSA?

In the “modules” box I put:


{
    "dependencies": {
        "NAME OF PACKAGE (from NPM)": "latest"
    }
}

And the the I have in the code section:


function(properties, context) { 

    var someVar = require('SOMETHING');
     
    XXX.someMehtodThatCameFromNPM ( function (zzz, yyy) {      
                var m = yyy;
    });
    return {
        KEY_NAME: yyy
    }
      
}

This sort of thing does not work :frowning: I either get error of “KEY_NAME is not defined” or “KEY_NAME: null”

Any advice would be appreciated greatly!

This is potentially pretty worriesome. Of course because of @mishav but let’s assume he is alive and well. :slight_smile:

His toolbox plugin is so widely used now, I wonder if it needs to be integrated as an ‘official’ bubble plugin. If something happens with the plugin (maybe a problem when bubble releases a new version and is in conflict with Toolbox) who is there to solve the problem now?

I think too many people rely on that plugin to not make sure its covered…

3 Likes

Hey @funwtp, a dependency looks like this:

^^^ name of package : version to fetch

And then in your code, the require statement is just whatever the package needs (consult documentation):

Note that, apparently, you do not have to build the dependencies part anymore. Just having require statements is supposed to autofetch and load the latest package. (I’ve not tested this though.)

1 Like

Uhmm…It pings devices?

1 Like

BTW, @funwtp: If you’re still getting your feet wet with writing out valid JSON (e.g., the list of dependencies is JSON), tools like https://jsonlint.com/ are very handy.

Hey @vincent56 - while it would suck if @mishav’s been eaten by a dingo or something, the Toolbox plug, since it is open source, is right there out in the open.

(And, actually, it’s remarkably simple – but very very clever. At the end of the day, Run JavaScript just executes eval() on the code that’s typed into the Run Javascript action. It’s the whole concept that’s the amazing thing about the Toolbox plugins. The JavaScript to Bubble element is a touch more complicated than Run JavaScript, but again the brilliance of it is the concept, not the rather simple code itself.

The Server Script server-side action is kind of mind-bending and the most “complex”… but it’s just 14 lines of code and once you read it it’s like… “Oh, duh. Cool… but, duh.” Though there’s an amazingly clever thing in terms of its output – it shows how you can get an app-specific data type back from the SSA, which is something that’s not described anywhere else, AFAIK.)

I often forget that it’s open source and that you can just go examine or fork the plugin. D’oh!

The JSON part seems to be fine.

It it more that Bubble doesn’t seem to actually run the “required” function, in other words, I get expected result only 2 out of 5 runs :frowning:

You’re talking about this:

Are your forgetting to define your returned values? Here’s snip of a minimal Server Side Action:

You can go look at the code here. It does basically nothing, but you see how an SSA works:

If the issue you’re having is not-that-simple, it could be there’s a bug/problem with generating the deployment package.

I note that I was just looking at one of my SSAs and that Bubble was saying “deployment package out of date”. And, while there was no issue with my dependencies, Bubble could not successfully rebuild the deployment package. I had to UNCLICK “uses node modules”, RE-CLICK it and then paste my dependencies back in for the error to resolve.

Here’s that SSA – it’s fairly simple, but shows use of require, definition of return values, and use how you define dependencies:

1 Like

All keys are defined.

Thanks for the detailed overview.

Let me try to “unclick” methods. Perhaps Bubbles is struggling a bit.

One thing I noted, FYI, server side actions (even simple ones) take at least 20 seconds to run. This basically may time out any workflow (including the API ones). What I learnt is that if a API workflow is run on a list, all of them must be completed must be completed within 3 minutes, otherwise the whole thing times out.

I don’t know how to put this to Bubble but it kinda undermines any data driven app. Leaving alone the processing speed, the reliability of actually completing processing is not great either.

They shouldn’t take that long. Is the “slow SSA bug” back? It shouldn’t be.

Note: there are things you can do (wrong) with typecasting that will slow down your SSAs.

Note 2: Make sure you understand how to retrieve lists from Bubble and put that junk at the very start of your function (get the data from the properties object before attempting to operate on it or you can waste a lot of time doing parts of your function over and over until the data fully loads.)

1 Like

Not to dilute this topic further, yes, it’s open source but it is still that plugin. So in the case something would happen that affects it, it would still require someone from the community to fork it, fix it and publish. It would mean a lot of apps would have to switch plugins and that has consequences.

The fact that it is actually so ‘simple’ would be another argument for it to become part of Bubble’s ecosystem directly rather than a plugin…

1 Like

Are you suggesting to take over the UNIX Time plugin or the whole JS Toolbox?

the unix plugin is based on an api that was never meant to be used like that, but there are other ways to get unix times (corrected for timezone) so no. Also not meaning to ‘take over’ toolbox. I guess what I’m saying is that toolbox should be a part of bubble natively

1 Like

I made a quick video about how to do this. Doesn’t take long! I posted it over here:

1 Like

@vincent56 @keith @deliriousmiles

Have you seen this? I have just discovered…

19%20am

2 Likes

Hey @funwtp: Yes, I have, but it’s easy to forget about, isn’t it!? I certainly didn’t think of it when I saw your earlier answer about this (derp).

It’s the equivalent of doing .getTime() on a JavaScript date. I’m not sure when that was introduced (the original thread here is pretty old, so could be that wasn’t available when this thread started).

Also, I guess it’s a better approach than your recent suggestion here.

Anyway, if you did the following in Bubble:

Current Date/Time:extract UNIX timestamp (ms)

And, at the exact same moment in time did the following in JavaScript:

new Date().getTime()

The values would be the same number of milliseconds.

Aside: .getTime() is critical to how we can most performantly sort dates in JavaScript. I do things like this in several places in Calendar Grid Pro, for example:

some_array_of_dates.sort(function(a,b){return a.getTime() - b.getTime()})

^^^ this causes some_array_of_dates to be sorted from earliest moment-in-time (some_array_of_dates[0]) to latest moment-in-time (some_array_of_dates[last_element]).

1 Like

If you dont care about users in different timezones it’s good enough indeed.

1 Like

I discovered this right after posting, such a great feature.

1 Like