#TS/JS docs on the web

1 messages · Page 1 of 1 (latest)

timid marlin
#

Hi.
In the site is there a page that lists the TS/JS APIs?

For example, I'm trying to find docs about '.currentWorkspace' .
If the workspace is the .dagger folder? is where I run the command?

Trying to console.log(dag.currentWorkspace() .directory(".").entries()) don't print nothing.

I can't find in the site where it is detailed all the js function.
Thanks

timid marlin
#

@tawdry night Thanks.
Is there a reason why console.log don't print nothing?
I tried to increase verbosity but I get inundated by a lot of golang output.

tawdry night
#

Also, do you have tracing enabled and so, can you share a dagger cloud trace URL?

timid marlin
#

I'm not connected to the cloud.
Let me generate a simple example.

timid marlin
#

@tawdry night I know that there is an error, but I expect the console to print something.
It's a toy example, but I'm building a file with multiple steps to test dagger and keep creating a function just to return something kinda generate friction.
And connect to the cloud just to print some lines in my view grows the friction.

tawdry night
#

I'm not an expert in the typescript SDK, but normally console() output should be visible in the logs. Can you try running with dagger --progress=logs ?

timid marlin
#

Tried with logs, plain and -v=5 and -d for debug
No console 😄

#

No worries.
I will keep testing with the available work around.
Thanks a lot for your time.
Maybe in some next release we can have some good ol' console printing.
Cheers.

tawdry night
timid marlin
#

I don't know why the load module changed time, it always took about 20ish seconds.
But same thing.
I tried with throw new Error("Something went completely wrong!");
And same behavior.

tawdry night
#

Your console() function calls your source() function directly, without passing a value for the source argument. Then you call source.entries() on a null variable -> you get the error, before getting a chance to call console.log()

#

the @argument{defaultPath: "/"} decorator is only applied when calling via the Dagger API. When you call the function directly within the typescript runtime, Dagger doesn't know about the call and therefore cannot inject the defaut value for source

#

There is actually a better API we just shipped, called the workspace API, that will solve this problem

#
import {
    dag,
    Container,
    Directory,
    Workspace,
    object,
    func,
    argument,
  } from "@dagger.io/dagger"

  @object()
  export class Frenir {
    private async source(
      ws: Workspace,
    ): Promise<string[]> {
      const cl = await ws.directory("/").entries()
      console.log("...debug separator...")
      console.log(cl)
      console.log("...debug separator...")
      process.exit()
      return cl
    }

    @func()
    async console(
      ws: Workspace,
    ): Promise<string[]> {
      return await this.source(ws)
    }
  }
#

The Workspace argument is special, if you call a function without specifying that argument, it will automatically receive the current workspace

timid marlin
#

yeah, my mistake.
One of the reason I asked for the api was to find docs about '@argument'.
And I got lost thinking that it would work on any place.
In my mind "I should getting the error because const cl = await source.entries(); is being populated by the decorator"
But in reality the code was not reaching the console.log.
My Bad.

#

On the happy path the message is flashed on console.

#

and with plain it shows