@positronic/template-new-project 0.0.15 → 0.0.16
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/index.js
CHANGED
|
@@ -53,9 +53,9 @@ module.exports = {
|
|
|
53
53
|
],
|
|
54
54
|
setup: async ctx => {
|
|
55
55
|
const devRootPath = process.env.POSITRONIC_LOCAL_PATH;
|
|
56
|
-
let coreVersion = '^0.0.
|
|
57
|
-
let cloudflareVersion = '^0.0.
|
|
58
|
-
let clientVercelVersion = '^0.0.
|
|
56
|
+
let coreVersion = '^0.0.16';
|
|
57
|
+
let cloudflareVersion = '^0.0.16';
|
|
58
|
+
let clientVercelVersion = '^0.0.16';
|
|
59
59
|
|
|
60
60
|
// Map backend selection to package names
|
|
61
61
|
const backendPackageMap = {
|
package/package.json
CHANGED
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "@positronic/cloudflare";
|
|
10
10
|
// Import the generated manifest - NOTE the .js extension for runtime compatibility
|
|
11
11
|
// @ts-expect-error - _manifest.js is generated during template processing
|
|
12
|
-
import {
|
|
12
|
+
import { manifest as brainManifest } from "./_manifest.js";
|
|
13
13
|
import { runner } from "./runner.js";
|
|
14
14
|
// Configure the manifest to use the statically generated list
|
|
15
15
|
const manifest = new PositronicManifest({
|
|
16
|
-
|
|
16
|
+
manifest: brainManifest,
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
setManifest(manifest);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ObjectGenerator } from '@positronic/core';
|
|
2
2
|
import type { BrainEvent } from '@positronic/core';
|
|
3
3
|
import { BRAIN_EVENTS, applyPatches } from '@positronic/core';
|
|
4
|
+
import { jest } from '@jest/globals';
|
|
4
5
|
|
|
5
6
|
export interface MockClient extends ObjectGenerator {
|
|
6
7
|
mockResponses: (...responses: any[]) => void;
|
|
@@ -38,26 +39,37 @@ export interface BrainTestResult<TState> {
|
|
|
38
39
|
events: BrainEvent<any>[];
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export async function runBrainTest<
|
|
42
|
+
export async function runBrainTest<
|
|
43
|
+
TOptions extends object = object,
|
|
44
|
+
TState extends object = object,
|
|
45
|
+
TServices extends object = object
|
|
46
|
+
>(
|
|
42
47
|
brain: any,
|
|
43
|
-
|
|
48
|
+
params?: {
|
|
44
49
|
client?: ObjectGenerator;
|
|
45
50
|
initialState?: Partial<TState>;
|
|
46
51
|
resources?: any;
|
|
52
|
+
options?: TOptions;
|
|
53
|
+
services?: TServices;
|
|
47
54
|
}
|
|
48
55
|
): Promise<BrainTestResult<TState>> {
|
|
49
56
|
const events: BrainEvent<any>[] = [];
|
|
50
|
-
let finalState: any =
|
|
57
|
+
let finalState: any = params?.initialState || {};
|
|
51
58
|
let error: Error | null = null;
|
|
52
59
|
let completed = false;
|
|
53
60
|
|
|
54
61
|
try {
|
|
55
62
|
const runOptions = {
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
client: params?.client,
|
|
64
|
+
initialState: params?.initialState,
|
|
65
|
+
resources: params?.resources,
|
|
66
|
+
options: params?.options,
|
|
58
67
|
};
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
// If brain has services, we need to apply them first
|
|
70
|
+
const brainToRun = params?.services ? brain.withServices(params.services) : brain;
|
|
71
|
+
|
|
72
|
+
for await (const event of brainToRun.run(runOptions)) {
|
|
61
73
|
events.push(event);
|
|
62
74
|
|
|
63
75
|
if (event.type === BRAIN_EVENTS.STEP_COMPLETE) {
|