@intersystems-community/ascot 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/dist/index.d.ts +16 -12
- package/dist/index.js +65 -9
- package/dist/index.js.map +1 -1
- package/generated/ascot.js +17864 -16480
- package/generated/interfaces/iris-ascot-common.d.ts +19 -1
- package/generated/interfaces/iris-ascot-exported.d.ts +2 -2
- package/generated/interfaces/iris-ascot-imported.d.ts +24 -6
- package/lib/ascot.core.wasm +0 -0
- package/lib/ascot.core2.wasm +0 -0
- package/lib/ascot.core3.wasm +0 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -40,13 +40,13 @@ await ws.hover("file:///T.cls", { line: 5, character: 7 }); // the `x` being wri
|
|
|
40
40
|
// "```objectscript\n%DataType = 1\n```"
|
|
41
41
|
````
|
|
42
42
|
|
|
43
|
-
To provide declarations for documents that aren't in the workspace, extend `
|
|
43
|
+
To provide declarations for documents that aren't in the workspace, extend `IrisContext`,
|
|
44
44
|
override the lookups you can answer, and pass an instance:
|
|
45
45
|
|
|
46
46
|
```ts
|
|
47
|
-
import {
|
|
47
|
+
import { IrisContext, type ClassInfo } from "@intersystems-community/ascot";
|
|
48
48
|
|
|
49
|
-
class MyIris extends
|
|
49
|
+
class MyIris extends IrisContext {
|
|
50
50
|
override async getCls(cls: string): Promise<ClassInfo | undefined> {
|
|
51
51
|
return undefined; // look `cls` up, e.g. over IRIS's REST API
|
|
52
52
|
}
|
|
@@ -55,6 +55,22 @@ class MyIris extends IrisConnection {
|
|
|
55
55
|
const connected = await createWorkspace(new MyIris());
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
Or extend `Atelier` with the two Atelier REST API requests, `query` (the rows of
|
|
59
|
+
`/action/query` as a JSON array) and `getDoc` (the text of `/doc/{name}`), and let ascot make
|
|
60
|
+
the lookups itself:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { Atelier } from "@intersystems-community/ascot";
|
|
64
|
+
|
|
65
|
+
class MyAtelier extends Atelier {
|
|
66
|
+
override async getDoc(name: string): Promise<string | undefined> {
|
|
67
|
+
return undefined; // GET /doc/{name}, e.g. with your own credentials and session
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const connected = await createWorkspace(new MyAtelier());
|
|
72
|
+
```
|
|
73
|
+
|
|
58
74
|
`createWorkspace` takes an optional second argument, a `Style` applied to every document:
|
|
59
75
|
|
|
60
76
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Root } from "../generated/ascot.js" with { "resolution-mode": "import" };
|
|
2
|
-
import type { ClassInfo,
|
|
2
|
+
import type { ClassInfo, RoutineInfo, Source, Style } from "../generated/interfaces/iris-ascot-common.js" with { "resolution-mode": "import"
|
|
3
3
|
};
|
|
4
4
|
export type * from "../generated/interfaces/iris-ascot-common.js";
|
|
5
5
|
type RawWorkspace = InstanceType<Root["exported"]["Workspace"]>;
|
|
@@ -8,19 +8,23 @@ type RawWorkspace = InstanceType<Root["exported"]["Workspace"]>;
|
|
|
8
8
|
export type Workspace = {
|
|
9
9
|
[K in keyof RawWorkspace]: RawWorkspace[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : RawWorkspace[K];
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/** What ascot asks about code outside the workspace. A failed lookup throws; ascot then takes
|
|
12
|
+
* what it looked for on trust and says why. */
|
|
13
|
+
export declare class IrisContext {
|
|
12
14
|
/** A class's own members and metadata. */
|
|
13
15
|
getCls(_cls: string): Promise<ClassInfo | undefined>;
|
|
14
16
|
/** The text of `name.inc`. */
|
|
15
|
-
getInc(_name: string): Promise<
|
|
16
|
-
/** The
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
getInc(_name: string): Promise<Source | undefined>;
|
|
18
|
+
/** The labels of routine `name`, `undefined` if there is no such routine. */
|
|
19
|
+
getRtn(_name: string): Promise<RoutineInfo | undefined>;
|
|
20
|
+
}
|
|
21
|
+
/** The two Atelier REST API requests, for ascot to make `IrisContext`'s lookups with. A failed
|
|
22
|
+
* request throws, like a failed lookup. */
|
|
23
|
+
export declare class Atelier {
|
|
24
|
+
/** The rows of `/action/query` as a JSON array, each an object keyed by column name. */
|
|
25
|
+
query(_sql: string, _params: string[]): Promise<string>;
|
|
26
|
+
/** The text of `/doc/{name}`, `undefined` if there is no such document. */
|
|
27
|
+
getDoc(_name: string): Promise<string | undefined>;
|
|
24
28
|
}
|
|
25
29
|
/** A workspace whose calls run one at a time, resolving what it doesn't contain through `iris`. */
|
|
26
|
-
export declare function createWorkspace(iris?:
|
|
30
|
+
export declare function createWorkspace(iris?: IrisContext | Atelier, style?: Style): Promise<Workspace>;
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.Atelier = exports.IrisContext = void 0;
|
|
37
37
|
exports.createWorkspace = createWorkspace;
|
|
38
38
|
const fs = __importStar(require("node:fs"));
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
|
-
|
|
40
|
+
/** What ascot asks about code outside the workspace. A failed lookup throws; ascot then takes
|
|
41
|
+
* what it looked for on trust and says why. */
|
|
42
|
+
class IrisContext {
|
|
41
43
|
/** A class's own members and metadata. */
|
|
42
44
|
async getCls(_cls) {
|
|
43
45
|
return undefined;
|
|
@@ -46,16 +48,28 @@ class IrisConnection {
|
|
|
46
48
|
async getInc(_name) {
|
|
47
49
|
return undefined;
|
|
48
50
|
}
|
|
49
|
-
/** The
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return { tag: "some", val: undefined };
|
|
51
|
+
/** The labels of routine `name`, `undefined` if there is no such routine. */
|
|
52
|
+
async getRtn(_name) {
|
|
53
|
+
return { labels: undefined, uri: undefined };
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
exports.
|
|
56
|
+
exports.IrisContext = IrisContext;
|
|
57
|
+
/** The two Atelier REST API requests, for ascot to make `IrisContext`'s lookups with. A failed
|
|
58
|
+
* request throws, like a failed lookup. */
|
|
59
|
+
class Atelier {
|
|
60
|
+
/** The rows of `/action/query` as a JSON array, each an object keyed by column name. */
|
|
61
|
+
async query(_sql, _params) {
|
|
62
|
+
throw new Error("no IRIS connection");
|
|
63
|
+
}
|
|
64
|
+
/** The text of `/doc/{name}`, `undefined` if there is no such document. */
|
|
65
|
+
async getDoc(_name) {
|
|
66
|
+
throw new Error("no IRIS connection");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Atelier = Atelier;
|
|
56
70
|
const wasm = import("../generated/ascot.js").then(({ instantiate }) => instantiate((name) => new WebAssembly.Module(fs.readFileSync(path.resolve(__dirname, "../lib", name))), {
|
|
57
71
|
"iris:ascot/common": {},
|
|
58
|
-
"iris:ascot/imported": {
|
|
72
|
+
"iris:ascot/imported": { IrisContext, Atelier },
|
|
59
73
|
}));
|
|
60
74
|
wasm.catch(() => { }); // reported by createWorkspace instead
|
|
61
75
|
// jco's jspi glue allows only one in-flight suspended call per component instance --
|
|
@@ -87,6 +101,48 @@ function serialize(instance) {
|
|
|
87
101
|
/** A workspace whose calls run one at a time, resolving what it doesn't contain through `iris`. */
|
|
88
102
|
async function createWorkspace(iris, style) {
|
|
89
103
|
const root = await wasm;
|
|
90
|
-
|
|
104
|
+
const env = iris instanceof Atelier
|
|
105
|
+
? { tag: "atelier", val: new FailingAtelier(iris) }
|
|
106
|
+
: iris && { tag: "context", val: new FailingContext(iris) };
|
|
107
|
+
return serialize(new root.exported.Workspace(env, style));
|
|
108
|
+
}
|
|
109
|
+
// jco rethrows a thrown `Error` to the caller, and hands ascot only a thrown `{ payload }` as the
|
|
110
|
+
// failure; so what the host throws becomes one.
|
|
111
|
+
class FailingContext extends IrisContext {
|
|
112
|
+
inner;
|
|
113
|
+
constructor(inner) {
|
|
114
|
+
super();
|
|
115
|
+
this.inner = inner;
|
|
116
|
+
}
|
|
117
|
+
getCls(cls) {
|
|
118
|
+
return payload(() => this.inner.getCls(cls));
|
|
119
|
+
}
|
|
120
|
+
getInc(name) {
|
|
121
|
+
return payload(() => this.inner.getInc(name));
|
|
122
|
+
}
|
|
123
|
+
getRtn(name) {
|
|
124
|
+
return payload(() => this.inner.getRtn(name));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class FailingAtelier extends Atelier {
|
|
128
|
+
inner;
|
|
129
|
+
constructor(inner) {
|
|
130
|
+
super();
|
|
131
|
+
this.inner = inner;
|
|
132
|
+
}
|
|
133
|
+
query(sql, params) {
|
|
134
|
+
return payload(() => this.inner.query(sql, params));
|
|
135
|
+
}
|
|
136
|
+
getDoc(name) {
|
|
137
|
+
return payload(() => this.inner.getDoc(name));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function payload(request) {
|
|
141
|
+
try {
|
|
142
|
+
return await request();
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
throw { payload: e instanceof Error ? e.message : String(e) };
|
|
146
|
+
}
|
|
91
147
|
}
|
|
92
148
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,s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