Improved sjs-3 API

2018-01-09

This is a developers post.

The API of the sjs-3 interpreter was improved with the following.

os.TYPESAFE

The os.TYPESAFE placement flag was added for moving, copying, creating files. This allows you to programmatically access the same typesafe file placement functionality present on the drag-and-drop frontend.

The os.TYPESAFE flag enforces that a file can only be placed in a typesafe fashion, where typesafe means conforming the file’s .Accept rules.

If the bucket is provided, and placement would not be typesafe, the operation will fail.

If the bucket is not provided, Boomla will find the first typesafe bucket and use it. If no bucket is safe, the operation will fail.

Docs: os.TYPESAFE.

os.TYPESAFE_IF_POSSIBLE

Similarly, the os.TYPESAFE_IF_POSSIBLE placement flag was also added.

It’s like os.TYPESAFE, but it will proceed anyway instead of failing, when a typesafe bucket is not available.

Docs: os.TYPESAFE_IF_POSSIBLE.

File.inline(), Collection.inline()

Now you can call f.inline() directly, instead of calling os.inline(f).

Same goes for collection.inline(), instead of os.inline(collection).

Docs: File.inline().
Docs: Collection.inline().

File.new()

The last argument, the bucket, is now optional.

Now you can call

f.new(os.APPEND, "name")

instead of

f.new(os.APPEND, "name", 0)

Docs: File.new().

File.move()

The last 2 arguments are now optional. You can use the following 3 forms:

f.move(os.APPEND, target)
f.move(os.APPEND, target, "name")
f.move(os.APPEND, target, "name", 0)

Docs: File.move().

File.copy()

Similarly, the last 2 arguments are now optional. You can use the following 3 forms:

f.copy(os.APPEND, target)
f.copy(os.APPEND, target, "name")
f.copy(os.APPEND, target, "name", 0)


Cheers,

you can follow me on Twitter