Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-nights-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@forgerock/davinci-client': patch
---

update type misalignments and fallback to `continue` state when there is no state given
11 changes: 8 additions & 3 deletions packages/davinci-client/src/lib/client.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
import type { InitFlow, Updater, Validator } from './client.types.js';
import { returnValidator } from './collector.utils.js';
import { authorize } from './davinci.utils.js';
import { NodeStates, StartNode } from '../types.js';

/**
* Create a client function that returns a set of methods
Expand Down Expand Up @@ -125,13 +126,17 @@ export async function davinci<ActionType extends ActionTypes = ActionTypes>({
* @param {DaVinciRequest} args - the arguments to pass to the next
* @returns {Promise} - a promise that resolves to the next node
*/
next: async (args?: DaVinciRequest) => {
next: async (args?: DaVinciRequest): Promise<NodeStates> => {
const nodeCheck = nodeSlice.selectSlice(store.getState());
if (nodeCheck.status === 'start') {
return {
...nodeCheck,
error: 'Please use `start` before calling `next`',
};
error: {
status: 'error',
type: 'state_error',
message: 'Please use `start` before calling `next`',
},
} satisfies StartNode;
}

await store.dispatch(davinciApi.endpoints.next.initiate(args));
Expand Down
2 changes: 1 addition & 1 deletion packages/davinci-client/src/lib/node.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const nodeSlice = createSlice({
id: action.payload.data.id,
interactionId: action.payload.data.interactionId,
interactionToken: action.payload.data.interactionToken,
eventName: action.payload.data.eventName,
eventName: action.payload.data.eventName || 'continue',
status: CONTINUE_STATUS,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/davinci-client/src/lib/node.types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('Node Types', () => {
};

expectTypeOf<StartNode>().toHaveProperty('cache').toBeNull();
expectTypeOf<StartNode>().toHaveProperty('error').toBeNull();
expectTypeOf<StartNode>().toHaveProperty('error').toBeNullable();
expectTypeOf<StartNode>().toHaveProperty('status').toEqualTypeOf<'start'>();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/davinci-client/src/lib/node.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface StartNode {
client: {
status: 'start';
};
error: null;
error: DaVinciError | null;
server: {
status: 'start';
};
Expand Down
3 changes: 2 additions & 1 deletion packages/davinci-client/src/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
SubmitCollector,
} from './types.js';
import type * as Types from './types.js';
import { DaVinciError } from './lib/node.types.js';

describe('Type exports', () => {
it('should validate all types are exported', () => {
Expand All @@ -44,7 +45,7 @@ describe('Type exports', () => {
type ExpectedStartNode = {
cache: null;
client: { status: 'start' };
error: null;
error: DaVinciError | null;
server: { status: 'start' };
status: 'start';
};
Expand Down
2 changes: 1 addition & 1 deletion packages/davinci-client/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"noImplicitOverride": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"skipLibCheck": false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm unsure about the importance of this change, its probably worth us having it anyways because if theres a bug in an RTK version we are using we probably want to catch it here in our code before publishing.

this setting just checks the library types also

"sourceMap": true,
"lib": ["es2022", "dom", "dom.iterable"]
},
Expand Down
16 changes: 3 additions & 13 deletions tools/release/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Effect, Stream, Console } from 'effect';
import { Command } from '@effect/platform';

export const buildPackages = Command.make('pnpm', 'build').pipe(
Command.lines,
Command.string,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formats output better than lines

Stream.tap((line) => Console.log(`Build: ${line}`)),
Stream.runDrain,
);
Expand Down Expand Up @@ -33,17 +33,7 @@ export const runChangesetsSnapshot = Command.make(
'version',
'--snapshot',
'beta',
).pipe(
Command.lines,
Stream.tap((line) => Console.log(`Changesets: ${line}`)),
Stream.runDrain, // Consume the stream and wait for completion
Effect.tapBoth({
onFailure: (error) =>
Effect.fail(Console.error(`Changesets snapshot command failed: ${error}`)),
onSuccess: () => Console.log('Changesets snapshot completed successfully.'),
}),
Effect.asVoid,
);
).pipe(Command.exitCode);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we get a 1 exit code we fail.


// Effect to start local registry (run in background)
export const startLocalRegistry = Command.make('pnpm', 'nx', 'local-registry').pipe(
Expand All @@ -66,7 +56,7 @@ export const publishPackages = Command.make(
'--registry=http://localhost:4873',
'--no-git-checks',
).pipe(
Command.lines,
Command.string,
Stream.tap((line) => Console.log(`Publish: ${line}`)),
Stream.runDrain,
Effect.tapBoth({
Expand Down
14 changes: 9 additions & 5 deletions tools/release/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ const program = Effect.gen(function* () {
yield* Console.log('Git status OK (no staged files found).');
yield* checkForChangesets;

yield* Console.log('Running Changesets snapshot version...');
const exitCode = yield* runChangesetsSnapshot;

if (exitCode.valueOf() == 1) {
return yield* Effect.fail('Failed to version all snapshots');
}

yield* Console.log('Building packages');
yield* buildPackages;

yield* Console.log('Running Changesets snapshot version...');
yield* runChangesetsSnapshot;

yield* Console.log('Starting Verdaccio');
yield* startLocalRegistry;
yield* Console.log('Waiting for local registry to initialize... (5 seconds)');
yield* Effect.sleep('5 seconds');
yield* Console.log('Waiting for local registry to initialize... (10 seconds)');
yield* Effect.sleep('10 seconds');

yield* Console.log('Publishing packages to local registry...');
yield* publishPackages;
Expand Down
Loading