Cookie Consent by FreePrivacyPolicy.com TIBET
TIBET Logo

TIBET

URIs

URLs & URNs


Wins

  • Leverage W3C standards to refer to local and remote resources.
  • Read/write data using a wide variety of standardized path languages.
  • Locally bind, cache, snapshot, rollback, refresh, or sync with ease.
  • Customize handling of different resources by location or MIME.
  • Reduce conceptual complexity by using well-known URI semantics.

Contents

Concepts

Cookbook

reference

Code

Concepts

Introduction

The TP.uri.URI type and its subtypes are central to development with TIBET.

Everything in TIBET can be referenced via a URI, from the data you work with on a remote server to the data cached in the client to the elements in your UI. Access to these objects is provided by leveraging the features of the TP.uri.URI type and its subtypes.

In TIBET a URI instance isn't just a parsed string, it's a fully-featured object you can configure with respect to caching, updating, undo/redo, and a number of other "data management" features. You can configure based on patterns or configure individual URIs to meet your requirements.

URIs, thanks to TIBET's support for XPointer, also provide the foundation for querying into your data using powerful query languages including JSONPath, XPath, and TIBET paths.

When you query a TIBET URL you will automatically receive back an instance of one of TIBET's Content Types specific to the data being accessed. These content types let you manage your data in an encapsulated fashion, ensuring you don't have hard-coded paths throughout your code and allowing you to write whatever function methods your data might require.

Thanks to the combination of URI-based data management, custom content types, and powerful query and slicing syntax you can use Data Binding to bind data with little or no code.

Best of all, most of your work with URIs happens transparently, you just need to be familiar with the syntax of URLs, URNs, and query paths to use TIBET's data features.

TIBET URIs

A URI, or uniform resource identifier, is the top-most concept the W3 standard defines with respect to resource identification.

In TIBET, the TP.uri.URI type represents a top-level URI. TP.uri.URI is actually what TIBET calls an abstract type in that you can't create a concrete instance of that type, you can only create instances of the non-abstract subtypes of TP.uri.URI.

The primary subtypes of TP.uri.URI are TP.uri.URL and TP.uri.URN, which represent uniform resource locators and uniform resource names respectively.

TIBET's URI construct call and its shortcut TP.uc are implemented such that you never need to worry about using a specific constructor for a subtype, you can invoke TP.uri.URI.construct or TP.uc and you will receive the proper concrete subtype instance in return:

//  Returns the proper subtype based on load scheme and URI text.
url = TP.uc('~/tibet.json');

In the example above if you're running over HTTP you'll get back a TP.uri.HTTPURL instance. If, however, you were running off the file system you would receive an instance of TP.uri.FileURL. TIBET automatically adjusts the subtype based on load context and the URI text itself.

As mentioned earlier, often you don't need to interact with TP.uri.URI or its subtypes directly. You mention them in your application markup and TIBET automatically manages the data for you.

A leading tidle (~) indicates a 'virtual URI' in TIBET. Virtual URIs are a way to map abstract locations to concrete locations during the execution of an app. See the section on Virtual URIs for more information. To get the current resolved value for the virtual URI, use getLocation():

url = TP.uc('~/tibet.json');
url.getLocation();           //  ->  http://localhost:1407/tibet.json

In the 'hello world!' example below we:

  • fetch the content of ~/tibet.json (via an unseen TP.uri.HTTPURL).
  • assign it to a TP.uri.TIBETURN with the name urn:tibet:tibet_json.
  • query it via a JSONPath built from $.project + name to get 'hello'.

<hello:app id="app">

<http:service href="~/tibet.json" name="urn:tibet:tibet_json"
    on:attach="UIActivate"/>

<div bind:scope="urn:tibet:tibet_json">
    <div bind:scope="$.project">
        <xctrls:button on:click="ClickMe">
        <xctrls:label>[[name]] world!</xctrls:label>
        <xctrls:hint>Click me ;)</xctrls:hint>
        </xctrls:button>
    </div>
</div>

</hello:app>

Accessing data, naming it for easy reference, and querying it, all without a single line of JavaScript or any direct interaction with a TP.uri.URI instance.

TIBET URLs

TP.uri.URL is the root for most common URIs including those for the http: and file: schemes most web developers are familiar with.

Most of the time when you're working with a data source you're working with an instance of some concrete TP.uri.URL subtype such as TP.uri.HTTPURL or TP.uri.FileURL.

To get a sense of functionality for a TP.uri.HTTPURL let's look at the output of the tibet reflect command line tool for that type:

$ tibet reflect TP.uri.HTTPURL

# Loading TIBET platform at 2021-04-29T01:04:15.486Z
# TIBET reflection suite loaded and active in 6309ms

# Type: TP.uri.HTTPURL
# Supertypes: TP.uri.URL TP.uri.URI TP.lang.Object TP.lang.RootObject Object

# TP.uri.HTTPURL
TP.uri.HTTPURL.Inst
TP.uri.HTTPURL.Type
TP.uri.HTTPURL.localName
TP.uri.HTTPURL.nsPrefix
TP.uri.HTTPURL.nsRoot

# TP.uri.HTTPURL.Type
TP.uri.HTTPURL.Type.SCHEME
TP.uri.HTTPURL.Type.mode
TP.uri.HTTPURL.Type.supportedModes

# TP.uri.HTTPURL.Inst
TP.uri.HTTPURL.Inst.hostname
TP.uri.HTTPURL.Inst.httpConnect
TP.uri.HTTPURL.Inst.httpDelete
TP.uri.HTTPURL.Inst.httpGet
TP.uri.HTTPURL.Inst.httpHead
TP.uri.HTTPURL.Inst.httpOptions
TP.uri.HTTPURL.Inst.httpPatch
TP.uri.HTTPURL.Inst.httpPost
TP.uri.HTTPURL.Inst.httpPut
TP.uri.HTTPURL.Inst.httpTrace
TP.uri.HTTPURL.Inst.location
TP.uri.HTTPURL.Inst.password
TP.uri.HTTPURL.Inst.port
TP.uri.HTTPURL.Inst.query
TP.uri.HTTPURL.Inst.queryDict
TP.uri.HTTPURL.Inst.user

./public/TIBET-INF/tibet/src/tibet/kernel/TIBETURITypes.js

As the tibet reflect output shows the HTTPURL type has methods supporting each of the HTTP verbs as well as a few other utility functions. It also inherits a significant amount of functionality from TP.uri.URI which is not shown above.

TIBET URNs

TP.uri.URN (urn:*) is the typical URI type for "named objects" such as types in the TIBET system or other objects for which a public name is needed. Instances of TP.uri.URN are typically instances of an NID-specific subtype so that each subtype can process the namespace specific string (NSS) portion in a namespace-specific fashion. TP.uri.TIBETURN is the most common TP.uri.URN subtype.

TP.uri.TIBETURN (urn:tibet:*) is a TIBET-specific URL type which provides extensions to the general URI addressing model. Most URNs in TIBET use a namespace ID (NID) of tibet so they start off with urn:tibet: followed by the actual name string.

TIBET URNs serve a particularly powerful role in TIBET development since they make it easy to name any piece of data and get a handle back to it using that name from anywhere in TIBET (TIBET URIs are uniqued. Any reference to the same path returns the same instance).

Any time you alter the data in an TIBET URN it signals that change to any observers. The result is that TIBET URNs work like "value holders" which are an essential element of building true MVC and MVVM front-ends. This is clearly visible when binding to a shared URN.

URI Caching

TIBET's URI types each have the ability to manage a cache for their data so that bandwidth can be managed efficiently. The focal point for caching is the URI instance itself, which also manages header and content data for all access to that instance's target resource. URI caching for things like client-side templates and common lookup code tables is a typical use case.

It is easy to ask a URI if it has been loaded with its resource:

url = TP.uc('~/tibet.json');
url.isLoaded();                 //  <- false
url.getContent();               //  returns JSONContent object
url.isLoaded();                 //  <- true

It is also easy to ask a URI if it has been 'dirtied' (i.e. mutated) by your application:

url.isDirty();                 //  <- false
url.setContent(null);
url.isDirty();                 //  <- true

Finally, it is possible to have the URL 'refetch' its original content and overwrite whatever data is its content:

url.getContent();                       //  returns JSONContent object
url.getContent().get('data');           //  returns null
url.getContent(TP.hc('refresh', true)); //  returns JSONContent object
url.getContent().get('data');           //  returns JSON data

URI "Xtensions"

URI-related standards like XPointer are also supported by the appropriate URI subtypes. These standards provide additional ways to help you modularize your application for better maintainability and performance. By leveraging XPointer, you can slice content from template files or access portions of a REST response with ease.

There are 3 types of paths that can be used with TIBET's implementation of XPointer schemes: JSON Paths (#jpath()), XPaths (#xpath()), and a TIBET-specific path syntax (#tibet()) that allows easy access to objects. These are used in conjunction with the different types of paths.

url = TP.uc('~/tibet.json#jpath($.project)')
url.getContent();          //  returns JSON data

For more information on how TIBET Paths work, see the TIBET Paths documentation, which shows how to use TIBET Paths both within a URI via XPointer and outside of URIs.

Virtual URIs

As mentioned above, TIBET has a concept of 'virtual URIs'. These allow for dynamic resolution and targeting of objects in "browser space".

Virtual URIs are URIs with a leading tilde ('~') prefix which resolve to a concrete value at run time using the built in configuration system. For instance, a path of ~lib_xsl will use the value in the configuration system named path.lib_xsl.

So, rather than hard coding either absolute paths starting with 'http://', 'https://', etc. into your application or relative paths that could change as the application evolves, simply use virtual URIs. When TIBET encounters a leading tilde (~) in a path, it will look up that path in TIBET 'cfg' system under the path. key.

This is how we resolve the path to our 'application root':

TP.sys.getcfg('path.app_root');     //  ->  'http://localhost:1407'
TP.uc('~app_root').getLocation();   //  ->  'http://localhost:1407'

These URIs can be resolved recursively. For instance, the application's 'build' directory is defined to have a value of ~app/build and registered under the path.app_build entry in the cfg system.

This then allows us to use ~app_build in our URIs and the system recusively looks up and builds the final location:

TP.uc('~app_build').getLocation();  //  ->  'http://localhost:1407/build'

Note that the underlying 'URI primitives' capability of TIBET, in addition to standard URI 'slicing and dicing' operations, also support virtual URIs.

There are a number of 'built-in' shortcuts that can be used with virtual URIs:

~       The application root (a shorthand for '~app_root')
~app    The application root
~lib    The TIBET library root

See the Virtual URI Paths for a full list of paths at the time of this writing.

You can also register your own paths for use in virtual URIs:

//  Note the reference to '~app' here using TIBET's recursive path resolution
TP.sys.setcfg('path.my_path', '~app/mygui');
TP.uc('~my_path').getLocation();  //  ->  'http://localhost:1407/mygui

Synchronous vs Asynchronous

Obviously, URIs need to handle resources that can be fetched synchronously or asynchronously. So far, we've seen fetching content from a URI using the getContent() method. This method always treats the URI as if it already has the content. For example, a vCard for the currently active user is found by accessing the URN with getContent() that TIBET sets up for that purpose.

//  getNativeNode() 'unwraps' the content into a native DOM node
TP.uc('urn:tibet:userinfo').getContent().getNativeNode();

This works well when the URI content is always guaranteed to be there. But what happens when that's not true, when the content must be fetched from a server?

We didn't have to concern ourselves with this when we were loading the tibet.json file because it was already loaded by TIBET. And, in fact, depending on the URI type that the getContent() message is sent to, it will synchronously fetch the content if it is not already loaded.

However this synchronous technique is frowned upon, especially when it involves remote servers. A much better way is for you to load the data asynchronously.

We do this by using TP.uri.URI's getResource() method rather than the getContent() call. It allows us to fetch content asynchronously. The return value from the getResource() call is not actually the result - it is an instance of TP.sig.Response (a special form of a TIBET signal). In fact getContent() is just an alias for getResource().get('result'). But for asynchronous calls, we don't want the result immediately - we want to wait until the server returns with our content.

There are two ways to fulfill a URI's content asynchronously: using the standard JavaScript Promise mechanism and using the signal system in TIBET for even more control.

Using Promises

To use a Promise to fetch a URI's content in TIBET, simply chain a .then() onto the end of the getResource() call. This is because TP.sig.Response objects are what JavaScript calls a 'thenable':

uri = TP.uc('~app/robots.txt');     //  A file that hasn't already been loaded
uri.getResource().then(
    function(aResult) {
        console.log('we got: ', aResult.get('data'));
    },
    function(anErr) {
        console.log('sorry, no dice:, anErr.stack);
    });

OR

uri = TP.uc('~app/robots.txt');

try {
    aResult = await uri.getResource();
    console.log('we got: ', aResult.get('data'));
} catch (e) {
    console.log('sorry, no dice:, e.stack);
}

Using TIBET Signals

Sometimes we want more control over fetching a URI's content than a simple Promise chain provides. TIBET's signaling system provides complete control over the URI fulfillment process in an object that can be assigned and passed.

To use the full power of the TIBET signaling system to fetch, we use TIBET's powerful inheritance system to construct a reusable type of TP.sig.Request:

TP.sig.HTTPRequest.defineSubtype('APP.MyApp.MyRequest');

APP.MyApp.MyRequest.Inst.defineHandler('RequestSucceeded', function(aResponse) {
    console.log('Success!', aResponse);
});

APP.MyApp.MyRequest.Inst.defineHandler('RequestFailed', function(aResponse) {
    console.log('Failure: ', aResponse);
});

APP.MyApp.MyRequest.Inst.defineHandler('RequestCompleted', function(aResponse) {
    console.log('Completed: ', aResponse);
});

req = APP.MyApp.MyRequest.construct();

uri.getResource(req);

Accessing Mapped Data Services

Certain data services have been mapped into TIBET with their own URI 'scheme' for easy access. These include:

Local Storage

The localdb:// URL type gives access to the browser's built-in local storage. Note that accessing localdb: URLs is synchronous by default (since the data source is accessed synchronously).

url = TP.uc('localdb://local_test/author_info');
url.setResource(TP.hc('firstName', 'November', 'lastName', 'Jones'));
url.save(TP.hc('method', TP.HTTP_PUT));

url.getContent();   //  -> {"firstName":"November", "lastName", "Jones"}

PouchDB Storage

PouchDB is a JavaScript-based NoSQL database that loads into a web browser and provides a CouchDB-like API and semantics over the browser's built-in IndexedDB functionality. By default, PouchDB is bundled into TIBET. It can be easily accessed using the pouchdb:// URL scheme. Note that accessing pouchdb: URLs is asynchronous by default (since the data source is accessed asynchronously):

url = TP.uc('pouchdb://pouch_test/author_info');
url.setResource(TP.hc('firstName', 'November', 'lastName', 'Jones'));
await url.save(TP.hc('method', TP.HTTP_PUT));

await url.getContent();   //  -> {"firstName":"November", "lastName", "Jones"}

Cookies

The 'cookie://' URL type gives access to the browser's built-in local storage. Note that accessing cookie: URLs is synchronous by default (since the data source is accessed synchronously).

This will make one entry in the browser's cookie storage under cookieTestKey which has an Object of which author_info is a key in that record.

url = TP.uc('cookie:///cookieTestKey');
url.setResource('cookieTestVal');
url.save();

url.getContent();   //  -> "cookieTestVal"

Accessing Globally Registered Objects

In addition to providing references to data in various parts of the system, you can also access a whole variety of objects using URIs in TIBET. This is done with either TIBET URNs, which we discussed above or using a special kind of TIBET URL, the tibet:// scheme.

The tibet:// scheme is very powerful and can be used to access just about anything in a running TIBET application.

The tibet:// URL scheme has the general form of:

tibet:[node @domain:port]/[resource]/[canvas]/[uri | path]

The first and second parts are used for remote access to another TIBET application and are currently disabled.

The third part is a 'canvas specifier'. In TIBET, because we could be dealing with multiple windows, there is a notion of a 'current canvas' as represented by the internal TIBET variable UICANVAS.

The fourth part is either a 'uri', an embedded URI to a resource or a 'path', a common URL path to a resource.

Since the fourth part represents an embedded URI or a defaulted URI (if a path is specified), anything in a running TIBET application that can be accessed via another URI representation can be accessed via a tibet:// URL. In fact, TIBET URNs are really just a shorthand form of tibet:// URLs:

urn:tibet:TP    ->      tibet://urn:tibet:TP

If the fourth part of a tibet:// URL is an embedded URI, a portion of the resource pointed to by the URI can be referenced by use of an XPointer. TIBET has built-in support for multiple XPointer 'schemes' such as:

//  Standard XPointer schemes
#<barename>
#xpointer(...)
#element(...)

//  TIBET extended schemes
#xpath1(...)
#css(...)

These can be used to address objects in the current UICANVAS DOM or in DOMs running in other windows.

Accessing DOM & Window objects

Access the current top-level window

TP.uc('tibet://top').getContent();

Access the #document node in the current top-level window

TP.uc('tibet://top/#document').getContent();

Access the element with an id of '#app' in the document of the current top-level window

TP.uc('tibet://top/#app').getContent().getNativeNode();

Access a top-level window that is not the current top-level window via its name

TP.uc('tibet://window_0').getContent();

Access the #document node in a top-level window that is not the current top-level window

TP.uc('tibet://window_0/#document').getContent();

Access the raw element with an id of '#app' in the document of a top-level window that is not the current top-level window

TP.uc('tibet://window_0/#app').getContent().getNativeNode();

Access the window that is the current UI canvas

TP.uc('tibet://UICANVAS/').getContent();
TP.uc('tibet://uicanvas/').getContent();

Access the #document node of the window that is the current UI canvas

TP.uc('tibet://UICANVAS/#document').getContent();
TP.uc('tibet://uicanvas/#document').getContent();

Access the #document node of the window that is the current UI canvas

TP.uc('#document').getContent();

Access the raw element with an id of 'top_background' in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas#top_background').getContent().getNativeNode();

Access the raw element with an id of 'top_background' in the document of the window that is the current UI canvas

TP.uc('#top_background').getContent().getNativeNode();

Access the raw 'id' attribute node on the raw element with an id of '#top_background' element in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas/#top_background@id').getContent.getNativeNode();

Access the raw 'id' attribute node on the raw element with an id of '#top_background' element in the document of the window that is the current UI canvas

TP.uc('#top_background@id').getContent().getNativeNode();

Access the raw element that is the second element of the first element (1-based) in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas/#element(/1/2)').getContent().getNativeNode();

Access the raw element that is the second element of the first element (1-based) in the document of the window that is the current UI canvas

TP.uc('#element(/1/2)').getContent().getNativeNode();

Access the raw element that is the first element (1-based) under the raw element with an id of 'top_background' in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas/#element(top_background/1)').getContent().getNativeNode();

Access the raw element that is the first element (1-based) under the raw element with an id of 'top_background' in the document of the window that is the current UI canvas

TP.uc('#element(top_background/1)').getContent().getNativeNode();

Access the raw element, in the default namespace, that is a 'body' element preceded by an 'html' element in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas/#xpath1(/$def:html/$def:body)').getContent().getNativeNode();

Access the raw element, in the default namespace, that is a 'body' element preceded by an 'html' element in the document of the window that is the current UI canvas

TP.uc('#xpath1(/$def:html/$def:body)').getContent().getNativeNode();

Access the raw element, in the default namespace, that is a 'body' element preceded by an 'html' element in the document of the window that is the current UI canvas

TP.uc('tibet://uicanvas#xpointer(/$def:html/$def:body)').getContent().getNativeNode();

Access the raw element, in the default namespace, that is a 'body' element preceded by an 'html' element in the document of the window that is the current UI canvas

TP.uc('#xpointer(/$def:html/$def:body)').getContent().getNativeNode();

Access the raw element that is the first child of the raw element with an id of 'top_background' in the document of the window that is the current UI canvas.

TP.uc('tibet://uicanvas/#css(#top_background > *:first-child)').getContent().getNativeNode();

Access the raw element that is the first child of the raw element with an id of 'top_background' in the document of the window that is the current UI canvas.

TP.uc('#css(#top_background > *:first-child)').getContent().getNativeNode();

Accessing other globally registered objects

tibet:// URLs and TIBET URNs can access objects in the system that have been 'globally registered':

foo = TP.ac(1, 2, 3);
TP.sys.registerObject(foo, 'FOO', true);
...
TP.uc('tibet://urn:tibet:FOO').getContent();    //  -> foo
TP.uc('urn:tibet:FOO').getContent();            //  -> foo

Accessing types, namespaces and top-level objects

tibet:// URLs and TIBET URNs can access types, namespace objects and other top-level objects in TIBET for convenience.

TIBET Types

TP.uc('tibet://urn:tibet:TP.sig.Signal').getContent();  //  -> TP.sig.Signal
TP.uc('urn:tibet:TP.sig.Signal').getContent();          //  -> TP.sig.Signal

TIBET Type Namespacess

TP.uc('tibet://urn:tibet:TP.sig').getContent();         //  -> TP.sig
TP.uc('urn:tibet:TP.sig').getContent();                 //  -> TP.sig

Global top-level objects

TP.uc('tibet://urn:tibet:TP').getContent();             //  -> TP
TP.uc('urn:tibet:TP').getContent();                     //  -> TP

Cookbook

Create A URI Instance

To create a URI instance use TP.uc or TP.uri.URI.construct:

url = TP.uc('~/tibet.json');

// or

url = TP.uri.URI.construct('~/tibet.json');

Create A URN Instance

To create a URN instance use TP.uc or TP.uri.URI.construct:

url = TP.uc('urn:tibet:foo');

// or

url = TP.uri.URI.construct('urn:tibet:foo');

Assign Data To A URN

For a URN instance the easiest thing to do is assign the data when you create the instance. (You can actually do this with any URI instance).

For example, we can set the data of urn:tibet:foo to 123 as follows:

urn = TP.uc('urn:tibet:foo', 123);
urn.getContent();
123

Or we can use 'object registration', which leverages TIBET URNs:

arrayOfStuff = TP.ac(1,2,3);
TP.sys.registerObject(arrayOfStuff, 'MyArray');
TP.uc('urn:tibet:MyArray').getContent() === arrayOfStuff;   //  <- true

Fetch URL Data

Use the uri instance's getContent method for synchronous fetching:

url = TP.uc('~/tibet.json');
content = url.getContent();     //  <- TP.core.JSONContent
content.asString();

Use the uri instance's getResource method for asynchronous fetching:

url = TP.uc('~/tibet.json');
content = await url.getResource();     //  <- TP.core.JSONContent
content.asString();

Assign Data To A URL

Once you have a URI instance you can use setContent to put new content into it.

The one caveat here is that if you are passing "raw" content rather than a new Content instance the original Content instance will try to verify the new data is appropriate for that content type.

url = TP.uc('~/tibet.json');
url.setContent('{ "this": "is JSON content" }');
url.getContent();               //  <- TP.core.JSONContent
{
    "this": "is JSON content"
}

To set a completely different type of data we need to construct a new content instance and pass that instead:

url = TP.uc('~/tibet.json');
content = TP.core.TextContent.construct('any darn string');
url.setContent(content);
url.getContent();               // <- TP.core.TextContent
'any darn string'

Store URL Content To A Remote

Simply store the data in the URL and invoke the save() method.

The save() method can take a TP.sig.Request (or TP.core.Hash) with various specific endpoint information, such as an HTTP method or headers. It returns a TP.sig.Response (a 'thenable'), so you can await it:

//  Set the content locally in the app
url = TP.uc('~app_dat/mydata.xml');    //  <- a URL that we can write to
url.setContent('<greeting>Hi there</greeting>');

//  Now store it to the server
await url.save(TP.hc(
                    'method', TP.HTTP_PUT,
                    'headers', TP.hc('Content-Type',
                                        TP.XML_TEXT_ENCODED + '; ' +
                                        'charset=' + TP.UTF8)));

Refresh URL Content

Let's assume in the previous example we made a mistake and want to reset the URL's content to it's original state (or at least the state on the server). The getContent() method can take a TP.sig.Request (or TP.core.Hash) with refresh set to true:

url = TP.uc('~/tibet.json');
url.getContent(TP.hc('refresh', true));     // <- TP.core.JSONContent

reference

NOTE: the information here is static. Use the commands utilized to produce each list below to get current reflection data from your specific version of TIBET.

TP.uri.URI Methods

TP.uri.URI has an extensive API. The most common methods used at this level are getContent and setContent which fetch and set the content of the target resource.

Below we target the instance methods via tibet reflect:

$ tibet reflect TP.uri.URI.Inst --methods
# Loading TIBET platform at 2021-04-29T01:39:53.225Z
# TIBET reflection suite loaded and active in 6571ms

# Prototype
TP.uri.URI.Inst.addResource
TP.uri.URI.Inst.asDumpString
TP.uri.URI.Inst.asHTMLString
TP.uri.URI.Inst.asJSONSource
TP.uri.URI.Inst.asPrettyString
TP.uri.URI.Inst.asSource
TP.uri.URI.Inst.asString
TP.uri.URI.Inst.asTP_uri_URI
TP.uri.URI.Inst.asXMLString
TP.uri.URI.Inst.canReuseContentForInspector
TP.uri.URI.Inst.clearCaches
TP.uri.URI.Inst.constructRequest
TP.uri.URI.Inst.constructSubrequest
TP.uri.URI.Inst.empty
TP.uri.URI.Inst.equalTo
TP.uri.URI.Inst.expire
TP.uri.URI.Inst.getChildTypeForCanvas
TP.uri.URI.Inst.getConcreteURI
TP.uri.URI.Inst.getConfigForInspector
TP.uri.URI.Inst.getContent
TP.uri.URI.Inst.getContentForInspector
TP.uri.URI.Inst.getContentForToolbar
TP.uri.URI.Inst.getDataForInspector
TP.uri.URI.Inst.getEntryAt
TP.uri.URI.Inst.getEntryLabel
TP.uri.URI.Inst.getFragment
TP.uri.URI.Inst.getFragmentAccessPath
TP.uri.URI.Inst.getFragmentAccessPathType
TP.uri.URI.Inst.getFragmentExpr
TP.uri.URI.Inst.getFragmentParameters
TP.uri.URI.Inst.getFragmentPath
TP.uri.URI.Inst.getFragmentWeight
TP.uri.URI.Inst.getHeader
TP.uri.URI.Inst.getID
TP.uri.URI.Inst.getLastUpdateDate
TP.uri.URI.Inst.getLocalPath
TP.uri.URI.Inst.getLocation
TP.uri.URI.Inst.getMIMEType
TP.uri.URI.Inst.getMode
TP.uri.URI.Inst.getName
TP.uri.URI.Inst.getNativeObject
TP.uri.URI.Inst.getOriginalSource
TP.uri.URI.Inst.getPathPartsForInspector
TP.uri.URI.Inst.getPrimaryLocation
TP.uri.URI.Inst.getPrimaryURI
TP.uri.URI.Inst.getResource
TP.uri.URI.Inst.getRoot
TP.uri.URI.Inst.getRootAndPath
TP.uri.URI.Inst.getScheme
TP.uri.URI.Inst.getSecondaryURIs
TP.uri.URI.Inst.getSize
TP.uri.URI.Inst.getSubURIs
TP.uri.URI.Inst.getSuperURIWithResourceType
TP.uri.URI.Inst.getURI
TP.uri.URI.Inst.getValue
TP.uri.URI.Inst.getVirtualLocation
TP.uri.URI.Inst.getWebPath
TP.uri.URI.Inst.handleChangeFromANYWhenANY
TP.uri.URI.Inst.hasFragment
TP.uri.URI.Inst.init
TP.uri.URI.Inst.isDirty
TP.uri.URI.Inst.isExpired
TP.uri.URI.Inst.isHTTPBased
TP.uri.URI.Inst.isLoaded
TP.uri.URI.Inst.isPrimaryURI
TP.uri.URI.Inst.refreshFromRemoteResource
TP.uri.URI.Inst.register
TP.uri.URI.Inst.remap
TP.uri.URI.Inst.resourcesAreAlike
TP.uri.URI.Inst.rewrite
TP.uri.URI.Inst.rewriteRequestMode
TP.uri.URI.Inst.setContent
TP.uri.URI.Inst.setLastUpdateDate
TP.uri.URI.Inst.setResource
TP.uri.URI.Inst.setResourcePortion
TP.uri.URI.Inst.setResourceToResultOf
TP.uri.URI.Inst.setValue
TP.uri.URI.Inst.shouldSignalChange
TP.uri.URI.Inst.stubResourceContent
TP.uri.URI.Inst.transform
TP.uri.URI.Inst.unregister
TP.uri.URI.Inst.updateHeaders

./public/TIBET-INF/tibet/src/tibet/kernel/TIBETURITypes.js

Copy and paste a line from the output above onto tibet reflect to view its comment.

Here we look at the comment for the getContent method:

$ tibet reflect TP.uri.URI.Inst.getContent
# Loading TIBET platform at 2019-07-23T02:25:16.428Z
# TIBET reflection suite loaded and active in 6057ms

TP.uri.URI.Inst.getContent

function getContent(aRequest)

/**
 * @method getContent
 * @summary Returns the URI's resource, forcing any fetch to be
 *     synchronous. If you need async access use getResource.
 * @returns {Object} The immediate value of the receiver's resource
 *     result.
 */

./public/TIBET-INF/tibet/src/tibet/kernel/TIBETURITypes.js

Note all tibet reflect output includes the source file used for the data.

List Virtual URI Paths

The full list of virtual URIs is effectively found via the tibet config path command:

"~": "/Users/ss/temporary/hello",
"~app": "~/public",
"~lib": "/Users/ss/temporary/hello/node_modules/tibet",
"path.app": "~app_root",
"path.app_bin": "~app/bin",
"path.app_boot": "~app_inf/boot",
"path.app_build": "~app/build",
"path.app_cache": "~app_tmp/cache",
"path.app_cfg": "~app_inf/cfg",
"path.app_change": "~app_src/changes",
"path.app_cmd": "~/cmd",
"path.app_dat": "~app_inf/dat",
"path.app_deps": "~app/deps",
"path.app_dna": "~app_inf/dna",
"path.app_etc": "~app/etc",
"path.app_fonts": "~app/fonts",
"path.app_inf": "~app/TIBET-INF",
"path.app_keyrings": "~app_dat/keyrings.xml",
"path.app_lib": "~app/lib",
"path.app_log": "~/logs",
"path.app_media": "~app/media",
"path.app_npm": "~/node_modules",
"path.app_schema": "~app/schema",
"path.app_src": "~app/src",
"path.app_styles": "~app/styles",
"path.app_tags": "~app_src/tags",
"path.app_test": "~app/test",
"path.app_tmp": "~app_inf/tmp",
"path.app_tsh": "~app_inf/tsh",
"path.app_vcards": "~app_dat/vcards.xml",
"path.app_xhtml": "~app/xhtml",
"path.app_xml": "~app_inf/xml",
"path.app_xmlbase": "~app_xhtml",
"path.app_xsl": "~app_inf/xsl",
"path.blank_page": "~lib_xhtml/blank.xhtml",
"path.boot_fonts": "~app_boot/fonts",
"path.boot_media": "~app_boot/media",
"path.boot_styles": "~app_boot/styles",
"path.boot_xhtml": "~app_boot/xhtml",
"path.couchapp": "~/couch/tws",
"path.ide_root": "~lib_src/tibet/tools/lama",
"path.ide_src": "~ide_root/src",
"path.iframe_page": "~app_boot/xhtml/blank.xhtml",
"path.lib": "~lib_root",
"path.lib_bin": "~lib/bin",
"path.lib_boot": "~tibet_src/boot",
"path.lib_build": "~lib_lib/src",
"path.lib_cfg": "~lib_lib/cfg",
"path.lib_cmd": "~lib/cmd",
"path.lib_dat": "~lib_lib/dat",
"path.lib_demo": "~lib/demo",
"path.lib_deps": "~lib/deps",
"path.lib_dna": "~lib/dna",
"path.lib_etc": "~lib/etc",
"path.lib_fonts": "~lib_lib/fonts",
"path.lib_inf": "~lib/TIBET-INF",
"path.lib_keyrings": "~lib_dat/keyrings.xml",
"path.lib_lib": "~lib/lib",
"path.lib_media": "~lib_lib/media",
"path.lib_npm": "~lib/node_modules",
"path.lib_schema": "~lib_lib/schema",
"path.lib_src": "~lib/src",
"path.lib_styles": "~lib_lib/styles",
"path.lib_test": "~lib/test",
"path.lib_tsh": "~lib_lib/tsh",
"path.lib_vcards": "~lib_dat/vcards.xml",
"path.lib_version_latest": "https://coderats.llc/tibet/latest.js",
"path.lib_xhtml": "~lib_lib/xhtml",
"path.lib_xml": "~lib_lib/xml",
"path.lib_xsl": "~lib_lib/xsl",
"path.npm_dir": "node_modules",
"path.npm_file": "package.json",
"path.release_version_target": "~lib/src/tibet/kernel/TIBETVersion.js",
"path.release_version_template": "~lib/src/tibet/kernel/TIBETVersionTemplate.js",
"path.lama_screen_0": "~boot_xhtml/home.xhtml",
"path.tds_couch_defs": "~/couch/app",
"path.tds_file": "~/tds.json",
"path.tds_plugins": "~/plugins",
"path.tds_processors": "~tds_plugins/processors",
"path.tds_task_defs": "~/couch/tws",
"path.tds_tasks": "~tds_plugins/tasks",
"path.tds_templates": "~tds_tasks/templates",
"path.tibet": "~lib_root",
"path.tibet_file": "~app/tibet.json",
"path.tibet_inf": "TIBET-INF",
"path.tibet_lib": "tibet",
"path.tibet_src": "~lib_src/tibet",
"path.tws": "~/couch/tws",
"path.uiboot_page": "~app_boot/xhtml/UIBOOT.xhtml",
"path.uiroot_page": "~app_boot/xhtml/UIROOT.xhtml",
"path.user_file": "~/users.json",
"path.xctrls_src": "~lib_src/xctrls",
"path.xpath_parser": "~lib_deps/xpath-tpi.js",
"path.xslt_boilerplate": "~lib_src/tsh/xsl/tsh_template_template.xsl"

Code

The OO layer implementation for the core URI types is found in:

~lib/src/tibet/kernel/TIBETURITypes.js

Primitives specific to working with URIs can be found in:

  • ~lib/src/tibet/kernel/TIBETURIPrimitivesPre.js
  • ~lib/src/tibet/kernel/TIBETURIPrimitivesBase.js
  • ~lib/src/tibet/kernel/TIBETURIPrimitivesPlatform.js
  • ~lib/src/tibet/kernel/TIBETURIPrimitivesPost.js

See TIBET Content Types for content-related code references.