Skip to content

Commit

Permalink
fix: add version number to the flow model
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Jan 10, 2025
1 parent 9c269d9 commit 3cd8d0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/dull-buckets-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@frigade/js": patch
"@frigade/react": patch
---

Adds version number to the `Flow` model
6 changes: 5 additions & 1 deletion packages/js-api/src/core/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class Flow extends Fetchable {
* The Flow's ID.
*/
public id: string
/**
* The version of the Flow.
*/
public version: number
/**
* The Flow's component ID.
*/
Expand Down Expand Up @@ -125,7 +129,7 @@ export class Flow extends Fetchable {
this.subtitle = statefulFlow?.data?.subtitle
this.type = statefulFlow?.data?.type
this.props = statefulFlow?.data?.props ?? {}

this.version = statefulFlow?.version
this.isCompleted = statefulFlow.$state.completed
this.isStarted = statefulFlow.$state.started
this.isSkipped = statefulFlow.$state.skipped
Expand Down
1 change: 1 addition & 0 deletions packages/js-api/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export interface StatefulFlow {
flowSlug: string
flowName: string
flowType: FlowType
version: number
/**
* Contains the raw data of the Flow as defined in the YAML config as well as the user's state of each step.
*/
Expand Down
4 changes: 4 additions & 0 deletions packages/js-api/test/frigade.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('Basic Checklist integration test', () => {
expect(step.id).toBeDefined()
expect(step.title).toBeDefined()
})
expect(flow.version).toBeDefined()
})

test('read and set flow state', async () => {
Expand All @@ -67,6 +68,7 @@ describe('Basic Checklist integration test', () => {
flowSlug: 'some-flow',
flowName: 'Some flow',
flowType: FlowType.CHECKLIST,
version: 1,
data: {
steps: [
{
Expand Down Expand Up @@ -125,6 +127,7 @@ describe('Basic Checklist integration test', () => {
[madeUpFlowId]: {
flowSlug: 'some-flow',
flowName: 'Some flow',
version: 1,
flowType: FlowType.CHECKLIST,
data: {
steps: [
Expand Down Expand Up @@ -180,6 +183,7 @@ describe('Basic Checklist integration test', () => {
[madeUpFlowId]: {
flowSlug: 'some-flow',
flowName: 'Some flow',
version: 1,
flowType: FlowType.CHECKLIST,
data: {
steps: [
Expand Down

0 comments on commit 3cd8d0b

Please sign in to comment.