ankka 0.6.4 → 0.7.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 +2 -0
- package/dist/testkit/index.d.ts +1 -1
- package/dist/testkit/index.js +1 -1
- package/dist/testkit/integration.d.ts +7 -1
- package/dist/testkit/integration.js +15 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ankka for TypeScript
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/ankka)
|
|
4
|
+
|
|
3
5
|
The ankka SDK for services written in TypeScript on Node.js. A service is a process that the ankka
|
|
4
6
|
runtime hosts as a sidecar: the sidecar owns everything durable and distributed, and the process owns
|
|
5
7
|
the decisions. This package speaks the sidecar protocol so your code never does.
|
package/dist/testkit/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { EventSourcedTestKit, EndpointTestKit, Response, type RequestOptions, type Materialised } from "./unit.ts";
|
|
2
2
|
export { KeyValueTestKit, WorkflowTestKit, ViewTestKit, ConsumerTestKit, TimedActionTestKit, AgentTestKit, ScriptedModel, type WorkflowProgress, type ModelResponse, type ModelCall, } from "./kinds.ts";
|
|
3
|
-
export { AnkkaTestKit, type AnkkaTestKitOptions, type HttpResponse, type Http, type Beside } from "./integration.ts";
|
|
3
|
+
export { AnkkaTestKit, PUBLISHED_SIDECAR, sidecarImage, type AnkkaTestKitOptions, type HttpResponse, type Http, type Beside } from "./integration.ts";
|
package/dist/testkit/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// `testcontainers` and `@testcontainers/postgresql`, are loaded only when `AnkkaTestKit.start` runs.
|
|
4
4
|
export { EventSourcedTestKit, EndpointTestKit, Response } from "./unit.js";
|
|
5
5
|
export { KeyValueTestKit, WorkflowTestKit, ViewTestKit, ConsumerTestKit, TimedActionTestKit, AgentTestKit, ScriptedModel, } from "./kinds.js";
|
|
6
|
-
export { AnkkaTestKit } from "./integration.js";
|
|
6
|
+
export { AnkkaTestKit, PUBLISHED_SIDECAR, sidecarImage } from "./integration.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentClient } from "../client.ts";
|
|
2
2
|
import type { ServiceBuilder } from "../service.ts";
|
|
3
3
|
export interface AnkkaTestKitOptions {
|
|
4
|
-
/** The sidecar image;
|
|
4
|
+
/** The sidecar image; `sidecarImage()` by default. */
|
|
5
5
|
readonly image?: string;
|
|
6
6
|
/** Environment for the sidecar container: `ANKKA_MODEL_SCRIPT` scripts its model. */
|
|
7
7
|
readonly env?: Readonly<Record<string, string>>;
|
|
@@ -37,6 +37,12 @@ export interface Beside {
|
|
|
37
37
|
logs(): Promise<string>;
|
|
38
38
|
stop(): Promise<void>;
|
|
39
39
|
}
|
|
40
|
+
export declare const PUBLISHED_SIDECAR = "ghcr.io/thinkmorestupidless/ankka-sidecar";
|
|
41
|
+
/**
|
|
42
|
+
* The sidecar the testkit starts when it is not told: see the top of this file. A release publishes the SDK
|
|
43
|
+
* and the sidecar under one version, so a released SDK's own version names the sidecar it was tested with.
|
|
44
|
+
*/
|
|
45
|
+
export declare function sidecarImage(version?: string): string;
|
|
40
46
|
export declare class AnkkaTestKit {
|
|
41
47
|
#private;
|
|
42
48
|
/** The component client every handler in `service` uses, pointed at the sidecar's mapped callback port. */
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
// is how a test proves durability rather than caching.
|
|
8
8
|
//
|
|
9
9
|
// Needs Docker, and `testcontainers` with `@testcontainers/postgresql` installed (optional peers of this
|
|
10
|
-
// package). The image is `$ANKKA_SIDECAR_IMAGE`
|
|
10
|
+
// package). The image is `$ANKKA_SIDECAR_IMAGE` when that is set. Otherwise a released SDK uses the sidecar
|
|
11
|
+
// published with it, `ghcr.io/thinkmorestupidless/ankka-sidecar:<this SDK's version>` — public, so Docker
|
|
12
|
+
// pulls it on first use — and an unreleased one (version `0.0.0`, a checkout of the ankka repository) uses
|
|
13
|
+
// `ankka-sidecar:latest`, the image `sbt sidecar/Docker/publishLocal` builds.
|
|
11
14
|
import { execFileSync } from "node:child_process";
|
|
12
15
|
import { chmodSync, mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
13
16
|
import { tmpdir } from "node:os";
|
|
14
17
|
import { join } from "node:path";
|
|
18
|
+
import { VERSION } from "../version.js";
|
|
15
19
|
const POSTGRES_IMAGE = "postgres:17-alpine";
|
|
16
20
|
const HTTP_PORT = 9000;
|
|
17
21
|
const CALLBACK_PORT = 9011;
|
|
@@ -79,8 +83,16 @@ export class Http {
|
|
|
79
83
|
.map((line) => JSON.parse(line.slice(5).trim()));
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
export const PUBLISHED_SIDECAR = "ghcr.io/thinkmorestupidless/ankka-sidecar";
|
|
87
|
+
/**
|
|
88
|
+
* The sidecar the testkit starts when it is not told: see the top of this file. A release publishes the SDK
|
|
89
|
+
* and the sidecar under one version, so a released SDK's own version names the sidecar it was tested with.
|
|
90
|
+
*/
|
|
91
|
+
export function sidecarImage(version = VERSION) {
|
|
92
|
+
const explicit = process.env.ANKKA_SIDECAR_IMAGE;
|
|
93
|
+
if (explicit)
|
|
94
|
+
return explicit;
|
|
95
|
+
return version === "0.0.0" ? "ankka-sidecar:latest" : `${PUBLISHED_SIDECAR}:${version}`;
|
|
84
96
|
}
|
|
85
97
|
/** The DDL as files, from `/opt/docker/ddl` in the sidecar image, without running the image. */
|
|
86
98
|
function copyDdl(image, into) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Written by scripts/proto.ts from package.json; do not edit. 0.0.0 in the tree, the tag's version in a release.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.7.1";
|
package/package.json
CHANGED