Skip to content

Commit eca3bde

Browse files
authored
Merge 12179a1 into 87c200b
2 parents 87c200b + 12179a1 commit eca3bde

File tree

9 files changed

+31
-26
lines changed

9 files changed

+31
-26
lines changed

.changeset/empty-nights-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@forgerock/davinci-client': patch
3+
---
4+
5+
update type misalignments and fallback to `continue` state when there is no state given

packages/davinci-client/src/lib/client.store.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
import type { InitFlow, Updater, Validator } from './client.types.js';
3434
import { returnValidator } from './collector.utils.js';
3535
import { authorize } from './davinci.utils.js';
36+
import { NodeStates, StartNode } from '../types.js';
3637

3738
/**
3839
* Create a client function that returns a set of methods
@@ -126,13 +127,17 @@ export async function davinci<ActionType extends ActionTypes = ActionTypes>({
126127
* @param {DaVinciRequest} args - the arguments to pass to the next
127128
* @returns {Promise} - a promise that resolves to the next node
128129
*/
129-
next: async (args?: DaVinciRequest) => {
130+
next: async (args?: DaVinciRequest): Promise<NodeStates> => {
130131
const nodeCheck = nodeSlice.selectSlice(store.getState());
131132
if (nodeCheck.status === 'start') {
132133
return {
133134
...nodeCheck,
134-
error: 'Please use `start` before calling `next`',
135-
};
135+
error: {
136+
status: 'error',
137+
type: 'state_error',
138+
message: 'Please use `start` before calling `next`',
139+
},
140+
} satisfies StartNode;
136141
}
137142

138143
await store.dispatch(davinciApi.endpoints.next.initiate(args));

packages/davinci-client/src/lib/node.slice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export const nodeSlice = createSlice({
210210
id: action.payload.data.id,
211211
interactionId: action.payload.data.interactionId,
212212
interactionToken: action.payload.data.interactionToken,
213-
eventName: action.payload.data.eventName,
213+
eventName: action.payload.data.eventName || 'continue',
214214
status: CONTINUE_STATUS,
215215
};
216216

packages/davinci-client/src/lib/node.types.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('Node Types', () => {
176176
};
177177

178178
expectTypeOf<StartNode>().toHaveProperty('cache').toBeNull();
179-
expectTypeOf<StartNode>().toHaveProperty('error').toBeNull();
179+
expectTypeOf<StartNode>().toHaveProperty('error').toBeNullable();
180180
expectTypeOf<StartNode>().toHaveProperty('status').toEqualTypeOf<'start'>();
181181
});
182182

packages/davinci-client/src/lib/node.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export interface StartNode {
124124
client: {
125125
status: 'start';
126126
};
127-
error: null;
127+
error: DaVinciError | null;
128128
server: {
129129
status: 'start';
130130
};

packages/davinci-client/src/types.test-d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
SubmitCollector,
2323
} from './types.js';
2424
import type * as Types from './types.js';
25+
import { DaVinciError } from './lib/node.types.js';
2526

2627
describe('Type exports', () => {
2728
it('should validate all types are exported', () => {
@@ -44,7 +45,7 @@ describe('Type exports', () => {
4445
type ExpectedStartNode = {
4546
cache: null;
4647
client: { status: 'start' };
47-
error: null;
48+
error: DaVinciError | null;
4849
server: { status: 'start' };
4950
status: 'start';
5051
};

packages/davinci-client/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"noImplicitOverride": true,
1414
"declaration": true,
1515
"declarationMap": true,
16-
"skipLibCheck": true,
16+
"skipLibCheck": false,
1717
"sourceMap": true,
1818
"lib": ["es2022", "dom", "dom.iterable"]
1919
},

tools/release/commands/commands.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Effect, Stream, Console } from 'effect';
22
import { Command } from '@effect/platform';
33

44
export const buildPackages = Command.make('pnpm', 'build').pipe(
5-
Command.lines,
5+
Command.string,
66
Stream.tap((line) => Console.log(`Build: ${line}`)),
77
Stream.runDrain,
88
);
@@ -33,17 +33,7 @@ export const runChangesetsSnapshot = Command.make(
3333
'version',
3434
'--snapshot',
3535
'beta',
36-
).pipe(
37-
Command.lines,
38-
Stream.tap((line) => Console.log(`Changesets: ${line}`)),
39-
Stream.runDrain, // Consume the stream and wait for completion
40-
Effect.tapBoth({
41-
onFailure: (error) =>
42-
Effect.fail(Console.error(`Changesets snapshot command failed: ${error}`)),
43-
onSuccess: () => Console.log('Changesets snapshot completed successfully.'),
44-
}),
45-
Effect.asVoid,
46-
);
36+
).pipe(Command.exitCode);
4737

4838
// Effect to start local registry (run in background)
4939
export const startLocalRegistry = Command.make('pnpm', 'nx', 'local-registry').pipe(
@@ -66,7 +56,7 @@ export const publishPackages = Command.make(
6656
'--registry=http://localhost:4873',
6757
'--no-git-checks',
6858
).pipe(
69-
Command.lines,
59+
Command.string,
7060
Stream.tap((line) => Console.log(`Publish: ${line}`)),
7161
Stream.runDrain,
7262
Effect.tapBoth({

tools/release/release.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ const program = Effect.gen(function* () {
5050
yield* Console.log('Git status OK (no staged files found).');
5151
yield* checkForChangesets;
5252

53+
yield* Console.log('Running Changesets snapshot version...');
54+
const exitCode = yield* runChangesetsSnapshot;
55+
56+
if (exitCode.valueOf() == 1) {
57+
return yield* Effect.fail('Failed to version all snapshots');
58+
}
59+
5360
yield* Console.log('Building packages');
5461
yield* buildPackages;
5562

56-
yield* Console.log('Running Changesets snapshot version...');
57-
yield* runChangesetsSnapshot;
58-
5963
yield* Console.log('Starting Verdaccio');
6064
yield* startLocalRegistry;
61-
yield* Console.log('Waiting for local registry to initialize... (5 seconds)');
62-
yield* Effect.sleep('5 seconds');
65+
yield* Console.log('Waiting for local registry to initialize... (10 seconds)');
66+
yield* Effect.sleep('10 seconds');
6367

6468
yield* Console.log('Publishing packages to local registry...');
6569
yield* publishPackages;

0 commit comments

Comments
 (0)