Skip to content

Commit 5c37d6d

Browse files
committed
fix: fix boolean false values
1 parent 2bfb2aa commit 5c37d6d

File tree

16 files changed

+109
-75
lines changed

16 files changed

+109
-75
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
The Runnable repo is a monorepo using pnpm workspaces. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/).
66

7-
To develop and test:
7+
To develop:
88

99
1. Run `pnpm install` in the root folder
10+
2. `cd packages/runnable-app`. `pnpm run dev` to run the server in watch mode.
11+
3. In another tab, `cd examples/nestjs-with-sdk`. `pnpm run start` to run the client in watch mode.
1012

11-
2. `cd packages/runnable-app`. `pnpm run dev` to build sources in watch mode
13+
To test:
1214

13-
3. Run
15+
1. Run
1416
- `pnpm run test` to run tests

examples/nestjs-with-sdk/src/actions.provider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export const ActionsProvider: FactoryProvider<RunnableWorkflows> = {
138138
getValue: (r) => r,
139139
}),
140140
checkbox: io.input.boolean({ label: 'Checkbox' }),
141+
checkboxOn: io.input.boolean({ label: 'Checkbox (default on)', defaultValue: true }),
141142
color: io.input.color({ label: 'Color' }),
142143
multiCheckbox: io.multiSelect.checkbox({
143144
label: 'Multi Checkbox',
@@ -150,9 +151,11 @@ export const ActionsProvider: FactoryProvider<RunnableWorkflows> = {
150151

151152
const data2 = await io.hstack(
152153
io.vstack(io.input.text({ label: 'Text', optional: true }), io.input.number({ label: 'Number' })),
153-
io.input.boolean({ label: 'Checkbox' })
154+
io.input.boolean({ label: 'Another Checkbox' })
154155
);
155156

157+
const data3 = await io.input.boolean({ label: 'A 3rd Checkbox' });
158+
156159
const response = await io.hstack(
157160
io.message.info({
158161
title: 'Data 1',
@@ -162,9 +165,13 @@ export const ActionsProvider: FactoryProvider<RunnableWorkflows> = {
162165
title: 'Data 2',
163166
message: JSON.stringify(data2, null, 2),
164167
}),
168+
io.message.info({
169+
title: 'Data 3',
170+
message: JSON.stringify(data3, null, 2),
171+
}),
165172
io.input.boolean({ label: 'Should continue', defaultValue: true })
166173
);
167-
const shouldContinue = response[2];
174+
const shouldContinue = response[3];
168175
if (!shouldContinue) {
169176
return;
170177
}

examples/nestjs/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { installRunnable } from '@runnablejs/express';
22
import { NestFactory } from '@nestjs/core';
3+
import { Logger } from '@nestjs/common';
34
import { AppModule } from './app.module';
45

56
async function bootstrap() {
@@ -11,8 +12,8 @@ async function bootstrap() {
1112
installRunnable(app.getHttpServer()._events.request, actions, context);
1213

1314
await app.listen(process.env.PORT || 3007);
14-
// eslint-disable-next-line no-console
15-
console.log(`Application is running on: ${await app.getUrl()}/admin`);
15+
const logger = app.get(Logger);
16+
logger.log(`Application is running on: ${await app.getUrl()}/admin`);
1617
}
1718

1819
bootstrap();

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
"description": "Build internal apps with ease",
77
"scripts": {
88
"preinstall": "npx only-allow pnpm",
9-
"build": "FORCE_COLOR=1 turbo run build",
109
"ci": "pnpm install && pnpm typecheck && pnpm lint && pnpm build && pnpm test",
11-
"dev": "FORCE_COLOR=1 turbo --parallel run dev",
10+
"build": "FORCE_COLOR=1 turbo run build",
11+
"dev": "FORCE_COLOR=1 turbo run dev",
12+
"test": "FORCE_COLOR=1 turbo run test",
13+
"typecheck": " FORCE_COLOR=1 turbo run typecheck",
1214
"docs:build": "vitepress build docs",
1315
"docs:dev": "vitepress dev docs",
1416
"docs:serve": "vitepress serve docs",
1517
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
16-
"lint:fix": "pnpm lint --fix",
18+
"lint:fix": "eslint . --fix",
1719
"lint": "eslint .",
18-
"release": "bumpp package.json packages/*/package.json --commit --push --tag && pnpm -r publish --access public",
19-
"test": "FORCE_COLOR=1 turbo run test",
20-
"typecheck": " pnpm -r --parallel run typecheck"
20+
"release": "bumpp package.json packages/*/package.json --commit --push --tag && pnpm -r publish --access public"
2121
},
2222
"devDependencies": {
2323
"@rollup/plugin-alias": "^5.0.0",

packages/runnable-api/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { components } from './schema';
33

44
export type WorkflowResponse = components['responses']['WorkflowResponse']['content']['application/json'];
55
export type WorkflowPrompt = components['schemas']['WorkflowPrompt'];
6+
export type WorkflowPromptFormField = components['schemas']['WorkflowPromptFormField'];
67
export type TableCellValue = components['schemas']['TableCell'];
78
export type Breadcrumb = components['schemas']['Breadcrumb'];
89
export type Option = components['schemas']['Option'];

packages/runnable-app/app/models/auth.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (env.RUNNABLE_AUTH_PROVIDER_FORM) {
1717
const password = form.get('password');
1818
if (context?.auth?.form === undefined) throw new Error('Cannot login using email and password');
1919
if (typeof email !== 'string' || typeof password !== 'string') throw new Error('Invalid email or password');
20-
const user = await context?.auth?.form?.verifyLogin({ email, password });
20+
const user = await context.auth.form.verifyLogin({ email, password });
2121
return user;
2222
}),
2323
'form'

packages/runnable-app/app/routes/($basename).actions._index.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { Heading, HStack, Stack, Tag, Text, VStack, Wrap, WrapItem } from '@chakra-ui/react';
1+
import { FormControl, FormLabel, Heading, HStack, Select, Stack, Tag, Text, VStack, Wrap, WrapItem } from '@chakra-ui/react';
22
import { Link, useLoaderData, useLocation } from '@remix-run/react';
33
import type { LoaderFunction, MetaFunction } from '@remix-run/server-runtime';
44
import { json } from '@remix-run/server-runtime';
55
import { parseNamespacedId, WorkflowType } from '@runnablejs/api';
6+
import { useState } from 'react';
67
import { Iconify } from '../components/icons/Iconify';
78
import { Page } from '../components/layout/Page';
89
import { getUrl } from '../utils/routes';
910
import { groupBy } from '../utils/objects';
11+
import { uniq } from '../utils/array';
1012

1113
type LoaderData = {
1214
actions: WorkflowType[];
@@ -23,19 +25,46 @@ export const meta: MetaFunction<LoaderData> = () => {
2325
};
2426
};
2527

28+
const defaultNamespace = 'All';
29+
2630
export default function ActionsIndexPage() {
2731
const { actions } = useLoaderData<LoaderData>();
2832

29-
const categories = groupBy(actions, (action) => action.category || 'Other');
30-
// sort, but 'Other' comes last
33+
// Namespace filter
34+
const [selectedNamespace, setSelectedNamespace] = useState<string>(defaultNamespace);
35+
const namespaces = uniq(actions.map((action) => parseNamespacedId(action.id)[0]).filter(Boolean)).sort();
36+
37+
// Filter actions by namespace
38+
const filteredActions = selectedNamespace === defaultNamespace ? actions : actions.filter((action) => parseNamespacedId(action.id)[0] === selectedNamespace);
39+
40+
// Categorize actions
41+
const categories = groupBy(filteredActions, (action) => action.category);
3142
const sortedCategories = Object.entries(categories).sort(([a], [b]) => {
32-
if (a === 'Other') return 1;
33-
if (b === 'Other') return -1;
3443
return a.localeCompare(b);
3544
});
3645

46+
3747
return (
3848
<Page title="Actions" animationKey={useLocation().pathname}>
49+
<FormControl width={350} mb={10}>
50+
<FormLabel>Namespace</FormLabel>
51+
<Select
52+
size='md'
53+
bg='white'
54+
value={selectedNamespace}
55+
onChange={(evt) => {
56+
setSelectedNamespace(evt.target.value)
57+
}}
58+
>
59+
<option value={defaultNamespace}>All</option>
60+
{namespaces.map((ns) => (
61+
<option key={ns} value={ns}>
62+
{ns}
63+
</option>
64+
))}
65+
</Select>
66+
</FormControl>
67+
3968
<Stack direction="column" spacing={10}>
4069
{sortedCategories.map(([category, actionGroup]) => (
4170
<Stack key={category} direction="column">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function uniq<T>(array: T[]): T[] {
2+
return [...new Set(array)];
3+
}

packages/runnable-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
],
1313
"scripts": {
1414
"build": "remix build",
15-
"dev": "RUNNABLE_BASE_URL='/' remix dev",
15+
"watch": "remix watch",
16+
"dev": "run-p dev:server watch",
1617
"dev:server": "tsx server/server.ts",
1718
"build:server": "esbuild --platform=node --format=cjs ./server/server.ts --outdir=build --bundle",
1819
"start:server": "cross-env RUNNABLE_BASE_URL='/' NODE_ENV=production node ./build/server.js",
1920
"prepublishOnly": "pnpm build",
2021
"format": "prettier --write .",
21-
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
22+
"lint": "TIMING=1 eslint . --fix",
2223
"test": "jest --passWithNoTests",
2324
"typecheck": "tsc --noEmit",
2425
"types": "tsc -p tsconfig.types.json",

packages/runnable-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build:watch": "rollup -c --watch --watch.include=src/**",
1414
"prepublishOnly": "pnpm build",
1515
"format": "prettier --write .",
16-
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
16+
"lint": "TIMING=1 eslint . --fix",
1717
"test": "jest --passWithNoTests",
1818
"typecheck": "tsc --noEmit",
1919
"typecheck:watch": "tsc --noEmit --watch",

0 commit comments

Comments
 (0)