ScriptsGuide

Import your own scripts

Write a helper once and use it everywhere. Another script of the same project and the same language imports it by its path in the project — the folders and the script name — with the import line its language already uses. No SDK call and no JSON in between: the function runs in the same process, as if it were written in the same file. Publishing freezes the library’s code with the script that imports it, so changing a helper never changes a published script by surprise.

9 min readBefore this: Writing codeOpen in Waiso
What you will learn
  • Write the import line for a project script in each language
  • Know which code an editor run and a published run use
  • Publish a script together with the libraries it needs
  • Rename or move a library without breaking its importers

A script is also a library

Nothing marks a script as a library: any script whose functions another script imports is one. When the importer runs, Waiso resolves its imports, brings every library it needs along — at its place in the project tree — and the language’s own import system does the rest. Imports can chain (A imports B, B imports C); the chain is resolved on the server, the same way for an editor run, a schedule, the API and a flow step.

The import line is ordinary code: the editor completes the project’s scripts and their functions as you type it.
LanguageImport linePath is
Pythonfrom utils.money import brl, import utils.money, from .money import brlFrom the project root, dotted; . is the importer’s own folder
TypeScript / JavaScriptimport { brl } from '../utils/money'Relative to the importer’s folder; the .ts/.js extension is optional
C / C++#include "utils/money.h"From the project root, in quotes, with .h

A helper and a script that uses it

Create a folder utils with a script money, and a folder orders with a script total, both in the same language. The library first:

utils/money.py
def brl(cents: int) -> str:
    """Format cents as Brazilian reais: 12345 -> 'R$ 123,45'."""
    return f"R$ {cents // 100},{cents % 100:02d}"

Then the script that imports it. Run total from the editor:

orders/total.py
from utils.money import brl


def main(cents: int = 12345):
    return {"total": brl(cents)}
Expected outputSuccessThe same result in all five languages
{
  "total": "R$ 123,45"
}

How names become paths

  • A path is the folders and the script name in their URL form: lowercase, spaces become - (a script My Dates in the folder Utils is utils/my-dates).
  • Python module names turn anything that is not a letter or digit into _: the same script is utils.my_dates.
  • Importing a Python script never runs its main; a library does not even need one.
  • TypeScript may import a JavaScript library; JavaScript cannot import TypeScript.
  • A C or C++ library is compiled into its importer, so it must not define main.

Drafts, publishing and updates

  • A run from the editor uses each library’s saved draft — save the library before you test its importer.
  • Publishing a script freezes the published code of every library it imports. Schedules, the API and event triggers run that frozen copy.
  • A library that was never published blocks the publish: the dialog says Publish these first. and offers Publish these first, reviewing each library before it is published.
  • When a library is published again, the editor of each script that uses it says was updated — republish to use it, with a Publish button.

Who uses a script, renames and moves

The editor’s Used by tab lists every script that imports this one, every SDK call to it, every flow step that runs it and every schedule, API endpoint and event trigger that starts it — each marked Draft or Published. More in Overview and usage.

  1. Rename or move the library

    On the Code page, rename money or move it to another folder. When other scripts import it, a dialog asks Update the scripts that import it? and lists them.

  2. Rewrite the imports

    Rename and update imports rewrites the import lines in the importers’ drafts. Their published versions keep the old copy until they are published again.

  3. Publish them together

    Publish all publishes every updated script in one go; the dialog reports any that could not be published.

Moving a whole folder works the same way: every import into it is rewritten.

Import errors

A bad import fails the run before your code starts, with one of these codes; the editor underlines the same import while you type, in the same words (see Editor intelligence).

CodeWhen
import_not_foundThe path matches no script of the project
import_languageThe script imported is in another language (JavaScript importing TypeScript included)
import_cycleThe imports go round in a circle; the message names the chain
import_too_deepThe chain of imports is deeper than 20
import_has_mainA C/C++ library defines main
import_unpublishedPublish only: a library was never published
Expected outputSuccess<code>import_cycle</code> names the whole chain
circular import: orders/total → utils/money → orders/total

Limits

  • Same project and same language only; SQL scripts never import or are imported.
  • At most 20 libraries deep in one chain.
  • Deleting a script that others use asks first and lists what breaks — see Overview and usage.