Overview
Atscript OData turns the $metadata of an OData v2 or v4 service into typed Atscript models, and serves the service to Atscript UI the way an Atscript DB backend is served. Tables, filters, value-help pickers and forms then work against the service you already run.
It works with services of SAP S/4HANA®, SAP Gateway®, the ABAP® RESTful Application Programming Model (RAP) and the SAP Cloud Application Programming Model® (SAP CAP), and with any other OData v2 or v4 service.
Preview release
The packages are a preview (0.0.x): their APIs may still change between releases.
What it does, and what it leaves to others
Atscript OData owns the OData side:
- reading
$metadata(v2 and v4) into one version-neutral service model; - generating
.asmodels from it: entity sets, keys, labels, relations, value helps, texts, fixed values, version tokens (ETags); - reading the live
$metadataat runtime and running on it, the generated types included; - translating Atscript DB queries and writes into OData requests, and the answers back;
- the transport: CSRF tokens, ETags, sessions, paging links, error bodies.
It does not render anything, and it does not run a database. Screens come from Atscript UI; the server, when you have one, is Moost with the controllers of Atscript DB.
Two hosts, one core
┌─ @atscript/odata-client ──────────────── browser ──────┐
$metadata ─► @atscript/odata (models, query, codec, transport) ├─► Atscript UI
└─ @atscript/db-odata ─► @atscript/moost-odata ─ server ─┘| Package | Runs in | Role |
|---|---|---|
@atscript/odata | browser, Node | The core: metadata parser, generator and build plugin, query engine, transport, CLI |
@atscript/odata-client | browser | A client Atscript UI uses like the Client of @atscript/db-client, talking OData |
@atscript/db-odata | Node | An Atscript DB adapter: each entity set becomes a table |
@atscript/moost-odata | Node | Base classes for the Moost controllers you declare, operations, credentials, sessions |
Both hosts share the core, so they build the same requests and agree on what a service can do. Their limits differ only where the host is the reason (see Limitations).
Which host to choose
The browser client talks to the service directly. There is no server of yours in between.
A Moost server of your own serves each entity set through Atscript DB's REST controllers. The browser sees a plain Atscript DB backend and never talks to the service.
| You need | Browser client | Server |
|---|---|---|
| The fastest start, no server | yes | no |
| The service reachable from the browser (same origin, or a proxy) | required | not needed |
| The end user's own login at the service (single sign-on cookies) | the browser's own | no: the service sees a technical user |
| One technical account for every caller | no | yes |
| Your own authorization, scopes, hooks on reads and writes | no | yes, as on any Atscript DB controller |
| OData entity sets next to tables of your own database | yes, other URLs go to your server | yes, one server |
| The service's host, credentials and texts kept away from the browser | no | yes |
Start with the browser client when the service is reachable from your origin and the users already have a session with it. Choose a Moost server when you need your own authorization, a technical user, server-side hooks, or a stable API in front of the service: the server signs in its own users, and calls the service with credentials of its own. Both read the same generated models, and the screens do not change when you move from one to the other: only the URL of each entity set does.
See it live
Same screens, two data paths: the page of the browser app talks OData to the service, the page of the Moost server app talks REST to its own server. Code: src/odata.ts; src/server/space.ts and src/ui/api.ts.
The 80% path
Generate the models once, register the service, connect, and point a table at it:
// src/main.ts (browser client)
import { createODataClientFactory } from "@atscript/odata-client";
import { setDefaultClientFactory } from "@atscript/ui";
import { createApp } from "vue";
import App from "./App.vue";
import * as sales from "./odata/sales.as";
import { model } from "./odata/sales.model.gen";
const odata = createODataClientFactory({
services: [{ baseUrl: "/sap/opu/odata/sap/ZDEMO_ORDERS_SRV", model, types: sales }],
});
setDefaultClientFactory(odata);
odata.connect().then(() => createApp(App).mount("#app"), showStartError);<AsTableRoot url="/odata/sales/OrderSet" :types="cellTypes">
<AsTable />
</AsTableRoot>The Quick Start walks through it, and through the same screen behind a Moost server.
What each page covers
Getting started
- Installation: the packages of each setup, and the toolchain.
- Quick Start: from
$metadatato a table and a form, in the browser and behind a Moost server. - Demo Apps: two apps over one OData v4 service, one per host, with a walkthrough of each repo.
- AI Agent Skill: the skill that walks a coding agent through the same path.
Models
- Generating Models:
atscript-odata fetch, the build plugin and its options, what is generated, and what is listed as not expressed. - Live Metadata: the live
$metadataat runtime, the language, the browser on a changed service, the Moost server's drift report, and the limits. - Value Helps: value lists, value-help services, fills, texts, columns and dropdowns.
- Relations: navigations as relations,
$withas$expand.
Hosts
- Browser Client: the client factory, connecting, runtime mode, sessions and locale.
- Moost Server: the space, connecting before
app.init(), declaring the controllers, value-help targets, your own base class. - Type Safety: what the compiler checks when you pass the generated types and handles, per host, typed screen configs, and what it does not check.
- Credentials and Sessions: the server's technical user, the strategies, and the sessions the space keeps.
Reading and writing
- Writes and Concurrency: what a write sends, version tokens, CSRF.
- Operations: function imports and actions on a Moost server (the generated bases) and in the browser (db actions of the sets,
odata.call), and what happens when the service changes them. - Aggregation: grouped reads as
$apply. - Errors: what each host throws or answers, and why.
Reference
- Dialects and Vendors: the
sapandstandardpresets, and how a service is recognized. - Limitations: what is not supported, by design or not yet.
Conventions used across these pages
- Typed at build time, live at runtime. The saved
$metadatagives the models and the TypeScript types; at runtime the hosts read the live$metadataand run on it, and the generated classes become the live declarations. See Live Metadata. - Service name. The name you give a service in the plugin (
sales). It is written into every generated type as@db.space, the name a Moost server registers the service's space under (provideDbSpace(space, "sales")); the hosts take it from the model module, and it is the URL segment of the browser client. - An SAP service is one whose
$metadatacame from SAP Gateway or RAP. The core recognizes it by itself and picks thesapdialect for it; SAP CAP and every other service getstandard. See Dialects and Vendors. - Version token. An entity set with optimistic concurrency gets a field
__etagin its type that carries the entity's ETag. It is never sent to the service as data. - Fail closed. What OData or the service cannot do is refused with a clear error before any request, and left out of
/metawhere/metacan say so. Nothing is emulated in silence. - Examples use a synthetic Gateway v2 service
ZDEMO_ORDERS_SRVwith the entity setsOrderSet,OrderItemSetandCustomerSet, generated as the interfacesOrder,OrderItemandCustomerofsrc/odata/sales.as.