@iblai/mcp 1.0.0 → 1.1.3
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/README.md +95 -142
- package/dist/index.js +129 -97
- package/dist/index.js.map +1 -1
- package/dist/prompts/create-playwright-test.d.ts +2 -0
- package/dist/prompts/create-playwright-test.d.ts.map +1 -0
- package/dist/prompts/create-playwright-test.js +99 -0
- package/dist/prompts/create-playwright-test.js.map +1 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +4 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/setup-e2e-testing.d.ts +2 -0
- package/dist/prompts/setup-e2e-testing.d.ts.map +1 -0
- package/dist/prompts/setup-e2e-testing.js +162 -0
- package/dist/prompts/setup-e2e-testing.js.map +1 -0
- package/dist/prompts/setup-new-app.d.ts +2 -0
- package/dist/prompts/setup-new-app.d.ts.map +1 -0
- package/dist/prompts/setup-new-app.js +226 -0
- package/dist/prompts/setup-new-app.js.map +1 -0
- package/dist/resources/data-layer.js +14 -14
- package/dist/resources/guides-layout.js +5 -5
- package/dist/resources/guides-playwright.d.ts +8 -0
- package/dist/resources/guides-playwright.d.ts.map +1 -0
- package/dist/resources/guides-playwright.js +235 -0
- package/dist/resources/guides-playwright.js.map +1 -0
- package/dist/resources/guides-rbac.js +2 -2
- package/dist/resources/guides-theme.js +4 -4
- package/dist/resources/index.d.ts +3 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +5 -1
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/packages-overview.d.ts.map +1 -1
- package/dist/resources/packages-overview.js +12 -6
- package/dist/resources/packages-overview.js.map +1 -1
- package/dist/resources/packages-playwright.d.ts +8 -0
- package/dist/resources/packages-playwright.d.ts.map +1 -0
- package/dist/resources/packages-playwright.js +161 -0
- package/dist/resources/packages-playwright.js.map +1 -0
- package/dist/resources/web-containers.d.ts.map +1 -1
- package/dist/resources/web-containers.js +82 -22
- package/dist/resources/web-containers.js.map +1 -1
- package/dist/resources/web-utils.d.ts.map +1 -1
- package/dist/resources/web-utils.js +46 -9
- package/dist/resources/web-utils.js.map +1 -1
- package/dist/tools/api-query-info.d.ts.map +1 -1
- package/dist/tools/api-query-info.js +248 -238
- package/dist/tools/api-query-info.js.map +1 -1
- package/dist/tools/component-info.d.ts.map +1 -1
- package/dist/tools/component-info.js +945 -469
- package/dist/tools/component-info.js.map +1 -1
- package/dist/tools/hook-info.d.ts.map +1 -1
- package/dist/tools/hook-info.js +229 -98
- package/dist/tools/hook-info.js.map +1 -1
- package/dist/tools/index.d.ts +15 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/page-template.js +8 -8
- package/dist/tools/page-template.js.map +1 -1
- package/dist/tools/playwright-helper-info.d.ts +16 -0
- package/dist/tools/playwright-helper-info.d.ts.map +1 -0
- package/dist/tools/playwright-helper-info.js +849 -0
- package/dist/tools/playwright-helper-info.js.map +1 -0
- package/dist/tools/provider-setup.js +4 -4
- package/dist/tools/provider-setup.js.map +1 -1
- package/package.json +19 -6
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export function generateCreateTestPrompt(feature, appType) {
|
|
2
|
+
const hostVar = appType === 'mentor' ? 'MENTOR_NEXTJS_HOST' : appType === 'skills' ? 'SKILLS_HOST' : 'APP_HOST';
|
|
3
|
+
return `Write a Playwright E2E test for the "${feature}" feature in an IBL.ai ${appType} app.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
### Imports
|
|
8
|
+
|
|
9
|
+
\`\`\`typescript
|
|
10
|
+
// Core Playwright (always import test/expect from here)
|
|
11
|
+
import { test, expect, Page } from '@playwright/test';
|
|
12
|
+
|
|
13
|
+
// SDK utilities (import helpers from here)
|
|
14
|
+
import {
|
|
15
|
+
logger,
|
|
16
|
+
safeWaitForURL,
|
|
17
|
+
waitForPageReady,
|
|
18
|
+
reliableClick,
|
|
19
|
+
reliableFill,
|
|
20
|
+
waitForDialogReady,
|
|
21
|
+
closeWithEsc,
|
|
22
|
+
expectNoAccessibilityViolations,
|
|
23
|
+
} from '@iblai/iblai-js/playwright';
|
|
24
|
+
|
|
25
|
+
// App-specific env vars
|
|
26
|
+
import { ${hostVar} } from '../utils';
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
### Test Structure
|
|
30
|
+
|
|
31
|
+
\`\`\`typescript
|
|
32
|
+
test.describe('${feature}', () => {
|
|
33
|
+
test.beforeEach(async ({ page }) => {
|
|
34
|
+
await page.goto(${hostVar});
|
|
35
|
+
await waitForPageReady(page);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('should ...', async ({ page }) => {
|
|
39
|
+
// Use logger for debugging
|
|
40
|
+
logger.info('Starting test step');
|
|
41
|
+
|
|
42
|
+
// Use reliableClick for buttons (retries on detached/hidden elements)
|
|
43
|
+
await reliableClick(page, page.getByRole('button', { name: 'Action' }));
|
|
44
|
+
|
|
45
|
+
// Use reliableFill for inputs (clears, fills, verifies value)
|
|
46
|
+
await reliableFill(page, page.getByLabel('Name'), 'Test Value');
|
|
47
|
+
|
|
48
|
+
// Use safeWaitForURL for navigation (handles browser quirks)
|
|
49
|
+
await safeWaitForURL(page, (url) => url.pathname.includes('/target'));
|
|
50
|
+
|
|
51
|
+
// Standard Playwright assertions
|
|
52
|
+
await expect(page.getByText('Expected')).toBeVisible();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
\`\`\`
|
|
56
|
+
|
|
57
|
+
### Available Helpers
|
|
58
|
+
|
|
59
|
+
**Navigation:**
|
|
60
|
+
- \`safeWaitForURL(page, urlMatcher, options?)\` — Browser-safe URL waiting
|
|
61
|
+
- \`waitForPageLoad(page)\` — Full page load (load + DOM + networkidle)
|
|
62
|
+
- \`isFirefox(page)\` — Check if Firefox (for browser-specific logic)
|
|
63
|
+
|
|
64
|
+
**Page Interaction:**
|
|
65
|
+
- \`waitForPageReady(page, timeout?)\` — Wait for document.readyState complete
|
|
66
|
+
- \`reliableClick(page, locator, timeout?, maxRetries?)\` — Click with retry
|
|
67
|
+
- \`reliableFill(page, locator, value, timeout?, maxRetries?)\` — Fill with retry
|
|
68
|
+
- \`waitForElementStable(page, locator, timeout?)\` — Wait for element stability
|
|
69
|
+
- \`waitForDialogReady(page, dialogLocator, timeout?)\` — Wait for dialog
|
|
70
|
+
- \`selectDateFromCalendar(page, dialogLocator, targetDate, timeout?)\` — Date picker
|
|
71
|
+
- \`closeWithEsc(page)\` — Press Escape to close modals
|
|
72
|
+
|
|
73
|
+
**Assertions:**
|
|
74
|
+
- \`expectNoAccessibilityViolations(page)\` — Full page axe-core audit
|
|
75
|
+
- \`expectNoAccessibilityViolationsOnDialogs(page, rules?, exclude?)\` — Dialog a11y
|
|
76
|
+
|
|
77
|
+
**Auth:**
|
|
78
|
+
- \`loginWithEmailAndPassword(page, username, password, hostUrl)\` — Login flow
|
|
79
|
+
- \`signUpWithEmailAndPassword(page, authHost, postSignUpUrl, credentials?)\` — Sign up
|
|
80
|
+
|
|
81
|
+
**Utilities:**
|
|
82
|
+
- \`logger\` — Winston logger (info locally, silent in CI)
|
|
83
|
+
- \`retry(action, errorMessage, retryCount?)\` — Generic retry
|
|
84
|
+
- \`checkAdminStatus(page)\` — Check admin from localStorage
|
|
85
|
+
|
|
86
|
+
### Best Practices
|
|
87
|
+
|
|
88
|
+
1. **Use \`safeWaitForURL\` instead of \`page.waitForURL\`** — handles Firefox NS_BINDING_ABORTED errors
|
|
89
|
+
2. **Use \`reliableClick\`/\`reliableFill\`** — handles detached elements and race conditions
|
|
90
|
+
3. **Use \`waitForPageReady\` after navigation** — ensures page is interactive
|
|
91
|
+
4. **Use \`logger.info()\` for debugging** — visible locally, suppressed in CI
|
|
92
|
+
5. **Use \`data-testid\` attributes** for element selection when role-based selectors are unreliable
|
|
93
|
+
6. **Set timeouts generously** — use \`test.setTimeout()\` for slow operations
|
|
94
|
+
7. **Use \`test.describe\` blocks** to group related tests
|
|
95
|
+
8. **Add accessibility tests** with \`expectNoAccessibilityViolations\`
|
|
96
|
+
|
|
97
|
+
Now write the test for "${feature}". Include appropriate beforeEach setup, multiple test cases covering happy path and edge cases, and use the SDK helpers where appropriate.`;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=create-playwright-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-playwright-test.js","sourceRoot":"","sources":["../../src/prompts/create-playwright-test.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,OAAe;IACvE,MAAM,OAAO,GACX,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC;IAElG,OAAO,wCAAwC,OAAO,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;WAuB9E,OAAO;;;;;;iBAMD,OAAO;;sBAEF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA+DH,OAAO,6IAA6I,CAAC;AAC/K,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-e2e-testing.d.ts","sourceRoot":"","sources":["../../src/prompts/setup-e2e-testing.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAoKhF"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export function generateE2ESetupPrompt(appType, appName) {
|
|
2
|
+
const name = appName || appType;
|
|
3
|
+
const hostVar = appType === 'mentor'
|
|
4
|
+
? 'MENTOR_NEXTJS_HOST'
|
|
5
|
+
: appType === 'skills'
|
|
6
|
+
? 'SKILLS_HOST'
|
|
7
|
+
: appType === 'auth'
|
|
8
|
+
? 'AUTH_HOST'
|
|
9
|
+
: 'APP_HOST';
|
|
10
|
+
const platformName = appType === 'mentor' ? 'mentornextjs' : appType === 'skills' ? 'skills' : name;
|
|
11
|
+
return `Set up Playwright E2E testing for an IBL.ai ${appType} app called "${name}" using @iblai/iblai-js/playwright.
|
|
12
|
+
|
|
13
|
+
## What to create
|
|
14
|
+
|
|
15
|
+
### 1. e2e/playwright.config.ts
|
|
16
|
+
|
|
17
|
+
\`\`\`typescript
|
|
18
|
+
import { createPlaywrightConfig } from '@iblai/iblai-js/playwright';
|
|
19
|
+
import dotenv from 'dotenv';
|
|
20
|
+
import path from 'path';
|
|
21
|
+
|
|
22
|
+
dotenv.config({ path: path.resolve(__dirname, '.env.development') });
|
|
23
|
+
|
|
24
|
+
export default createPlaywrightConfig({
|
|
25
|
+
platforms: [
|
|
26
|
+
{
|
|
27
|
+
name: '${platformName}',
|
|
28
|
+
dependencies: ['setup'],
|
|
29
|
+
otherTestMatch: ['**${platformName}/*/*.spec.ts'],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
This generates per-browser auth setup projects (setup-chrome, setup-firefox, setup-safari, setup-edge) and test projects for each platform/browser combination. CI mode: retries=3, workers=1, headless, trace=retain-on-failure.
|
|
36
|
+
|
|
37
|
+
### 2. e2e/auth.setup.ts
|
|
38
|
+
|
|
39
|
+
\`\`\`typescript
|
|
40
|
+
import { test as setup, createAuthSetup } from '@iblai/iblai-js/playwright';
|
|
41
|
+
|
|
42
|
+
setup(
|
|
43
|
+
'authenticate',
|
|
44
|
+
createAuthSetup({
|
|
45
|
+
hostUrl: process.env.${hostVar} || '',
|
|
46
|
+
authHost: process.env.AUTH_HOST || '',
|
|
47
|
+
appName: '${appType}',
|
|
48
|
+
postLoginUrlMatcher: (url) =>
|
|
49
|
+
url.href.includes('/platform/') || url.href.includes('/home'),
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
Authenticates once per browser and saves storage state to \`playwright/.auth/user-{browser}.json\`. Supports auth flows: username_password (default), magic_link, sso, direct_sso.
|
|
55
|
+
|
|
56
|
+
### 3. e2e/custom-reporter.ts
|
|
57
|
+
|
|
58
|
+
\`\`\`typescript
|
|
59
|
+
export { CustomReporter as default } from '@iblai/iblai-js/playwright';
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
### 4. e2e/.env.development
|
|
63
|
+
|
|
64
|
+
\`\`\`
|
|
65
|
+
${hostVar}=https://${name}.example.com
|
|
66
|
+
AUTH_HOST=https://auth.example.com
|
|
67
|
+
PLAYWRIGHT_USERNAME=test@example.com
|
|
68
|
+
PLAYWRIGHT_PASSWORD=testpassword
|
|
69
|
+
AUTH_FLOW=username_password
|
|
70
|
+
AUTH_IDP=
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
### 5. e2e/tests/utils.ts
|
|
74
|
+
|
|
75
|
+
\`\`\`typescript
|
|
76
|
+
export const ${hostVar} = process.env.${hostVar} || '';
|
|
77
|
+
export const AUTH_HOST = process.env.AUTH_HOST || '';
|
|
78
|
+
\`\`\`
|
|
79
|
+
|
|
80
|
+
### 6. e2e/tests/helpers.ts
|
|
81
|
+
|
|
82
|
+
\`\`\`typescript
|
|
83
|
+
import { loginWithEmailAndPassword, logger } from '@iblai/iblai-js/playwright';
|
|
84
|
+
import { ${hostVar}, AUTH_HOST } from './utils';
|
|
85
|
+
|
|
86
|
+
export async function loginAsTestUser(page: import('@playwright/test').Page) {
|
|
87
|
+
const username = process.env.PLAYWRIGHT_USERNAME || '';
|
|
88
|
+
const password = process.env.PLAYWRIGHT_PASSWORD || '';
|
|
89
|
+
await loginWithEmailAndPassword(page, username, password, ${hostVar});
|
|
90
|
+
}
|
|
91
|
+
\`\`\`
|
|
92
|
+
|
|
93
|
+
### 7. Sample test file: e2e/tests/${platformName}/example.spec.ts
|
|
94
|
+
|
|
95
|
+
\`\`\`typescript
|
|
96
|
+
import { test, expect } from '@playwright/test';
|
|
97
|
+
import { logger, safeWaitForURL, waitForPageReady, reliableClick } from '@iblai/iblai-js/playwright';
|
|
98
|
+
import { ${hostVar} } from '../utils';
|
|
99
|
+
|
|
100
|
+
test.describe('Example Feature', () => {
|
|
101
|
+
test.beforeEach(async ({ page }) => {
|
|
102
|
+
await page.goto(${hostVar});
|
|
103
|
+
await waitForPageReady(page);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('should load the page', async ({ page }) => {
|
|
107
|
+
logger.info('Checking page loaded');
|
|
108
|
+
await expect(page.getByRole('heading')).toBeVisible();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('should navigate on click', async ({ page }) => {
|
|
112
|
+
await reliableClick(page, page.getByRole('button', { name: 'Continue' }));
|
|
113
|
+
await safeWaitForURL(page, (url) => url.pathname.includes('/next'));
|
|
114
|
+
await expect(page.getByText('Next Page')).toBeVisible();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
\`\`\`
|
|
118
|
+
|
|
119
|
+
### 8. Directory structure
|
|
120
|
+
|
|
121
|
+
\`\`\`
|
|
122
|
+
e2e/
|
|
123
|
+
├── playwright.config.ts
|
|
124
|
+
├── auth.setup.ts
|
|
125
|
+
├── custom-reporter.ts
|
|
126
|
+
├── .env.development
|
|
127
|
+
├── tests/
|
|
128
|
+
│ ├── utils.ts
|
|
129
|
+
│ ├── helpers.ts
|
|
130
|
+
│ └── ${platformName}/
|
|
131
|
+
│ └── example.spec.ts
|
|
132
|
+
└── playwright/
|
|
133
|
+
└── .auth/ # Created automatically by auth setup
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
### 9. package.json scripts
|
|
137
|
+
|
|
138
|
+
\`\`\`json
|
|
139
|
+
{
|
|
140
|
+
"test:e2e": "playwright test --config e2e/playwright.config.ts",
|
|
141
|
+
"test:e2e:ui": "playwright test --config e2e/playwright.config.ts --ui",
|
|
142
|
+
"test:e2e:headed": "cross-env HEADED=true playwright test --config e2e/playwright.config.ts"
|
|
143
|
+
}
|
|
144
|
+
\`\`\`
|
|
145
|
+
|
|
146
|
+
### 10. Dependencies to install
|
|
147
|
+
|
|
148
|
+
\`\`\`bash
|
|
149
|
+
pnpm add -D @playwright/test @axe-core/playwright dotenv cross-env
|
|
150
|
+
npx playwright install
|
|
151
|
+
\`\`\`
|
|
152
|
+
|
|
153
|
+
## Key patterns
|
|
154
|
+
|
|
155
|
+
- Import \`test\` and \`expect\` from \`@playwright/test\` directly
|
|
156
|
+
- Import utilities (\`logger\`, \`safeWaitForURL\`, \`waitForPageReady\`, \`reliableClick\`, \`reliableFill\`) from \`@iblai/iblai-js/playwright\`
|
|
157
|
+
- Use \`safeWaitForURL\` instead of \`page.waitForURL\` — it handles Firefox NS_BINDING_ABORTED and Safari navigation policy errors
|
|
158
|
+
- Use \`reliableClick\`/\`reliableFill\` for flaky UI interactions
|
|
159
|
+
- Use \`waitForPageReady\` after navigation before assertions
|
|
160
|
+
- Use \`expectNoAccessibilityViolations(page)\` for a11y testing`;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=setup-e2e-testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-e2e-testing.js","sourceRoot":"","sources":["../../src/prompts/setup-e2e-testing.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,sBAAsB,CAAC,OAAe,EAAE,OAAgB;IACtE,MAAM,IAAI,GAAG,OAAO,IAAI,OAAO,CAAC;IAChC,MAAM,OAAO,GACX,OAAO,KAAK,QAAQ;QAClB,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,OAAO,KAAK,QAAQ;YACpB,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,OAAO,KAAK,MAAM;gBAClB,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,UAAU,CAAC;IAErB,MAAM,YAAY,GAChB,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAEjF,OAAO,+CAA+C,OAAO,gBAAgB,IAAI;;;;;;;;;;;;;;;;eAgBpE,YAAY;;4BAEC,YAAY;;;;;;;;;;;;;;;;2BAgBb,OAAO;;gBAElB,OAAO;;;;;;;;;;;;;;;;;;EAkBrB,OAAO,YAAY,IAAI;;;;;;;;;;;eAWV,OAAO,kBAAkB,OAAO;;;;;;;;WAQpC,OAAO;;;;;8DAK4C,OAAO;;;;qCAIhC,YAAY;;;;;WAKtC,OAAO;;;;sBAII,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BnB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA8B2C,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-new-app.d.ts","sourceRoot":"","sources":["../../src/prompts/setup-new-app.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,EAAO,GAAG,MAAM,CAwO1F"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
export function generateSetupNewAppPrompt(appType, features = []) {
|
|
2
|
+
const hasE2E = features.includes('e2e') || features.includes('testing');
|
|
3
|
+
const hasRbac = features.includes('rbac');
|
|
4
|
+
const hasAnalytics = features.includes('analytics');
|
|
5
|
+
const hasChat = features.includes('chat');
|
|
6
|
+
const hostVar = appType === 'mentor'
|
|
7
|
+
? 'MENTOR_NEXTJS_HOST'
|
|
8
|
+
: appType === 'skills'
|
|
9
|
+
? 'SKILLS_HOST'
|
|
10
|
+
: appType === 'auth'
|
|
11
|
+
? 'AUTH_HOST'
|
|
12
|
+
: 'APP_HOST';
|
|
13
|
+
let prompt = `Set up a new IBL.ai ${appType} app using the @iblai/iblai-js SDK.
|
|
14
|
+
|
|
15
|
+
## SDK Package
|
|
16
|
+
|
|
17
|
+
The unified SDK \`@iblai/iblai-js\` provides these subpath imports:
|
|
18
|
+
|
|
19
|
+
| Subpath | Purpose |
|
|
20
|
+
|---------|---------|
|
|
21
|
+
| \`@iblai/iblai-js/data-layer\` | Redux store, RTK Query API slices, reducers |
|
|
22
|
+
| \`@iblai/iblai-js/web-containers\` | Shared React components (Radix UI, profile, SSO) |
|
|
23
|
+
| \`@iblai/iblai-js/web-containers/next\` | Next.js-specific components |
|
|
24
|
+
| \`@iblai/iblai-js/web-containers/sso\` | SSO components |
|
|
25
|
+
| \`@iblai/iblai-js/web-utils\` | Auth providers, hooks, RBAC, utilities |
|
|
26
|
+
| \`@iblai/iblai-js/playwright\` | Shared Playwright E2E test utilities |
|
|
27
|
+
|
|
28
|
+
## 1. Install Dependencies
|
|
29
|
+
|
|
30
|
+
\`\`\`bash
|
|
31
|
+
pnpm add @iblai/iblai-js @iblai/iblai-api @reduxjs/toolkit react-redux
|
|
32
|
+
\`\`\`
|
|
33
|
+
|
|
34
|
+
## 2. Store Setup
|
|
35
|
+
|
|
36
|
+
\`\`\`typescript
|
|
37
|
+
// lib/store.ts
|
|
38
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
39
|
+
import { dataLayerReducers, dataLayerMiddleware } from '@iblai/iblai-js/data-layer';
|
|
40
|
+
|
|
41
|
+
export const store = configureStore({
|
|
42
|
+
reducer: {
|
|
43
|
+
...dataLayerReducers,
|
|
44
|
+
},
|
|
45
|
+
middleware: (getDefaultMiddleware) =>
|
|
46
|
+
getDefaultMiddleware({ serializableCheck: false }).concat(dataLayerMiddleware),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
50
|
+
export type AppDispatch = typeof store.dispatch;
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
## 3. Provider Setup
|
|
54
|
+
|
|
55
|
+
\`\`\`typescript
|
|
56
|
+
// providers/store-provider.tsx
|
|
57
|
+
'use client';
|
|
58
|
+
import { Provider } from 'react-redux';
|
|
59
|
+
import { store } from '@/lib/store';
|
|
60
|
+
|
|
61
|
+
export function StoreProvider({ children }: { children: React.ReactNode }) {
|
|
62
|
+
return <Provider store={store}>{children}</Provider>;
|
|
63
|
+
}
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
\`\`\`typescript
|
|
67
|
+
// providers/app-providers.tsx
|
|
68
|
+
'use client';
|
|
69
|
+
import { AuthProvider, TenantProvider } from '@iblai/iblai-js/web-utils';
|
|
70
|
+
${hasChat ? "import { MentorProvider } from '@iblai/iblai-js/web-utils';" : ''}
|
|
71
|
+
|
|
72
|
+
export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
73
|
+
return (
|
|
74
|
+
<AuthProvider>
|
|
75
|
+
<TenantProvider>
|
|
76
|
+
${hasChat ? '<MentorProvider>' : ''}
|
|
77
|
+
{children}
|
|
78
|
+
${hasChat ? '</MentorProvider>' : ''}
|
|
79
|
+
</TenantProvider>
|
|
80
|
+
</AuthProvider>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
\`\`\`
|
|
84
|
+
|
|
85
|
+
## 4. Root Layout
|
|
86
|
+
|
|
87
|
+
\`\`\`typescript
|
|
88
|
+
// app/layout.tsx
|
|
89
|
+
import { StoreProvider } from '@/providers/store-provider';
|
|
90
|
+
import { AppProviders } from '@/providers/app-providers';
|
|
91
|
+
|
|
92
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
93
|
+
return (
|
|
94
|
+
<html lang="en">
|
|
95
|
+
<body>
|
|
96
|
+
<StoreProvider>
|
|
97
|
+
<AppProviders>
|
|
98
|
+
{children}
|
|
99
|
+
</AppProviders>
|
|
100
|
+
</StoreProvider>
|
|
101
|
+
</body>
|
|
102
|
+
</html>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
\`\`\`
|
|
106
|
+
|
|
107
|
+
## 5. Using SDK Components
|
|
108
|
+
|
|
109
|
+
\`\`\`typescript
|
|
110
|
+
import { Button, Card, Dialog } from '@iblai/iblai-js/web-containers';
|
|
111
|
+
import { Profile, NotificationDropdown } from '@iblai/iblai-js/web-containers';
|
|
112
|
+
import { useAdvancedChat, useMentorSettings } from '@iblai/iblai-js/web-utils';
|
|
113
|
+
import { useGetMentorSettingsQuery } from '@iblai/iblai-js/data-layer';
|
|
114
|
+
\`\`\``;
|
|
115
|
+
if (hasRbac) {
|
|
116
|
+
prompt += `
|
|
117
|
+
|
|
118
|
+
## 6. RBAC Setup
|
|
119
|
+
|
|
120
|
+
\`\`\`typescript
|
|
121
|
+
// lib/rbac-slice.ts
|
|
122
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
123
|
+
import { checkRbacPermission } from '@iblai/iblai-js/web-utils';
|
|
124
|
+
|
|
125
|
+
// Add rbacSlice to your store reducer
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
\`\`\`typescript
|
|
129
|
+
// Using permissions in components
|
|
130
|
+
import { WithPermissions } from '@iblai/iblai-js/web-utils';
|
|
131
|
+
|
|
132
|
+
<WithPermissions resource="mentor:settings" action="edit">
|
|
133
|
+
<SettingsPanel />
|
|
134
|
+
</WithPermissions>
|
|
135
|
+
\`\`\``;
|
|
136
|
+
}
|
|
137
|
+
if (hasAnalytics) {
|
|
138
|
+
prompt += `
|
|
139
|
+
|
|
140
|
+
## Analytics Integration
|
|
141
|
+
|
|
142
|
+
\`\`\`typescript
|
|
143
|
+
import { useGetAnalyticsOverviewQuery } from '@iblai/iblai-js/data-layer';
|
|
144
|
+
import { AnalyticsLayout } from '@iblai/iblai-js/web-containers';
|
|
145
|
+
\`\`\``;
|
|
146
|
+
}
|
|
147
|
+
if (hasE2E) {
|
|
148
|
+
prompt += `
|
|
149
|
+
|
|
150
|
+
## E2E Testing Setup
|
|
151
|
+
|
|
152
|
+
Install test dependencies:
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
pnpm add -D @playwright/test @axe-core/playwright dotenv cross-env
|
|
155
|
+
npx playwright install
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
Create the e2e directory structure:
|
|
159
|
+
|
|
160
|
+
### e2e/playwright.config.ts
|
|
161
|
+
\`\`\`typescript
|
|
162
|
+
import { createPlaywrightConfig } from '@iblai/iblai-js/playwright';
|
|
163
|
+
import dotenv from 'dotenv';
|
|
164
|
+
import path from 'path';
|
|
165
|
+
|
|
166
|
+
dotenv.config({ path: path.resolve(__dirname, '.env.development') });
|
|
167
|
+
|
|
168
|
+
export default createPlaywrightConfig({
|
|
169
|
+
platforms: [{ name: '${appType}', dependencies: ['setup'] }],
|
|
170
|
+
});
|
|
171
|
+
\`\`\`
|
|
172
|
+
|
|
173
|
+
### e2e/auth.setup.ts
|
|
174
|
+
\`\`\`typescript
|
|
175
|
+
import { test as setup, createAuthSetup } from '@iblai/iblai-js/playwright';
|
|
176
|
+
|
|
177
|
+
setup('authenticate', createAuthSetup({
|
|
178
|
+
hostUrl: process.env.${hostVar} || '',
|
|
179
|
+
authHost: process.env.AUTH_HOST || '',
|
|
180
|
+
appName: '${appType}',
|
|
181
|
+
postLoginUrlMatcher: (url) => url.href.includes('/home'),
|
|
182
|
+
}));
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
### e2e/custom-reporter.ts
|
|
186
|
+
\`\`\`typescript
|
|
187
|
+
export { CustomReporter as default } from '@iblai/iblai-js/playwright';
|
|
188
|
+
\`\`\`
|
|
189
|
+
|
|
190
|
+
### package.json scripts
|
|
191
|
+
\`\`\`json
|
|
192
|
+
{
|
|
193
|
+
"test:e2e": "playwright test --config e2e/playwright.config.ts",
|
|
194
|
+
"test:e2e:ui": "playwright test --config e2e/playwright.config.ts --ui"
|
|
195
|
+
}
|
|
196
|
+
\`\`\`
|
|
197
|
+
|
|
198
|
+
### Writing tests
|
|
199
|
+
Import \`test\`/\`expect\` from \`@playwright/test\`. Import utilities (\`logger\`, \`safeWaitForURL\`, \`waitForPageReady\`, \`reliableClick\`) from \`@iblai/iblai-js/playwright\`.`;
|
|
200
|
+
}
|
|
201
|
+
prompt += `
|
|
202
|
+
|
|
203
|
+
## Next.js Configuration
|
|
204
|
+
|
|
205
|
+
The SDK ships pre-compiled. Do NOT add @iblai/iblai-js to transpilePackages.
|
|
206
|
+
|
|
207
|
+
\`\`\`typescript
|
|
208
|
+
// next.config.ts
|
|
209
|
+
const nextConfig = {
|
|
210
|
+
// No transpilePackages needed for @iblai/iblai-js
|
|
211
|
+
};
|
|
212
|
+
export default nextConfig;
|
|
213
|
+
\`\`\`
|
|
214
|
+
|
|
215
|
+
## Tailwind CSS Setup (v4)
|
|
216
|
+
|
|
217
|
+
\`\`\`css
|
|
218
|
+
/* app/globals.css */
|
|
219
|
+
@import "tailwindcss";
|
|
220
|
+
@source "../node_modules/@iblai/iblai-js/dist/web-containers/**/*.js";
|
|
221
|
+
\`\`\`
|
|
222
|
+
|
|
223
|
+
This scans the SDK's compiled components so Tailwind generates the correct utility classes.`;
|
|
224
|
+
return prompt;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=setup-new-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-new-app.js","sourceRoot":"","sources":["../../src/prompts/setup-new-app.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,yBAAyB,CAAC,OAAe,EAAE,WAAqB,EAAE;IAChF,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE1C,MAAM,OAAO,GACX,OAAO,KAAK,QAAQ;QAClB,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,OAAO,KAAK,QAAQ;YACpB,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,OAAO,KAAK,MAAM;gBAClB,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,UAAU,CAAC;IAErB,IAAI,MAAM,GAAG,uBAAuB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyD3C,OAAO,CAAC,CAAC,CAAC,6DAA6D,CAAC,CAAC,CAAC,EAAE;;;;;;UAMpE,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;;UAEjC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCrC,CAAC;IAEN,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAI;;;;;;;;;;;;;;;;;;;OAmBP,CAAC;IACN,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,IAAI;;;;;;;OAOP,CAAC;IACN,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;yBAqBW,OAAO;;;;;;;;;yBASP,OAAO;;cAElB,OAAO;;;;;;;;;;;;;;;;;;;sLAmBiK,CAAC;IACrL,CAAC;IAED,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;4FAsBgF,CAAC;IAE3F,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,7 +3,7 @@ export const dataLayer = {
|
|
|
3
3
|
name: 'Data Layer Package',
|
|
4
4
|
description: 'Redux store and RTK Query APIs',
|
|
5
5
|
mimeType: 'text/markdown',
|
|
6
|
-
content: `# @iblai/data-layer
|
|
6
|
+
content: `# @iblai/iblai-js/data-layer
|
|
7
7
|
|
|
8
8
|
Redux Toolkit state management with RTK Query for API interactions.
|
|
9
9
|
|
|
@@ -11,9 +11,9 @@ Redux Toolkit state management with RTK Query for API interactions.
|
|
|
11
11
|
|
|
12
12
|
\`\`\`typescript
|
|
13
13
|
import { configureStore } from '@reduxjs/toolkit';
|
|
14
|
-
import { mentorReducer, mentorMiddleware } from '@iblai/data-layer';
|
|
14
|
+
import { mentorReducer, mentorMiddleware } from '@iblai/iblai-js/data-layer';
|
|
15
15
|
// or
|
|
16
|
-
import { skillsReducer, skillsMiddleware } from '@iblai/data-layer';
|
|
16
|
+
import { skillsReducer, skillsMiddleware } from '@iblai/iblai-js/data-layer';
|
|
17
17
|
|
|
18
18
|
export const store = configureStore({
|
|
19
19
|
reducer: {
|
|
@@ -41,8 +41,8 @@ import {
|
|
|
41
41
|
useEditMentorMutation,
|
|
42
42
|
useDeleteMentorMutation,
|
|
43
43
|
useForkMentorMutation,
|
|
44
|
-
|
|
45
|
-
} from '@iblai/data-layer';
|
|
44
|
+
useEditMentorAndRefreshListMutation,
|
|
45
|
+
} from '@iblai/iblai-js/data-layer';
|
|
46
46
|
|
|
47
47
|
// Get all mentors for a tenant
|
|
48
48
|
const { data: mentors } = useGetMentorsQuery({ org: tenantKey });
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
useGetUserMetadataQuery,
|
|
62
62
|
useUpdateUserMetadataMutation,
|
|
63
63
|
useUpdateUserAccountMutation,
|
|
64
|
-
} from '@iblai/data-layer';
|
|
64
|
+
} from '@iblai/iblai-js/data-layer';
|
|
65
65
|
|
|
66
66
|
const { data: user } = useGetUserMetadataQuery({
|
|
67
67
|
params: { username },
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
useGetPlatformUserGroupDetailsQuery,
|
|
77
77
|
useInviteUserMutation,
|
|
78
78
|
useUpdatePlatformUserRoleWithPoliciesMutation,
|
|
79
|
-
} from '@iblai/data-layer';
|
|
79
|
+
} from '@iblai/iblai-js/data-layer';
|
|
80
80
|
|
|
81
81
|
// Get users with pagination
|
|
82
82
|
const { data: users } = useGetPlatformUsersQuery({
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
useGetTenantMetadataQuery,
|
|
93
93
|
useUpdateTenantMetadataMutation,
|
|
94
94
|
useGetUserTenantsQuery,
|
|
95
|
-
} from '@iblai/data-layer';
|
|
95
|
+
} from '@iblai/iblai-js/data-layer';
|
|
96
96
|
|
|
97
97
|
const { data: metadata } = useGetTenantMetadataQuery({ org: tenantKey });
|
|
98
98
|
\`\`\`
|
|
@@ -103,7 +103,7 @@ import {
|
|
|
103
103
|
useGetPinnedMessagesQuery,
|
|
104
104
|
useGetRecentMessageQuery,
|
|
105
105
|
useUpdateMessageFeedbackMutation,
|
|
106
|
-
} from '@iblai/data-layer';
|
|
106
|
+
} from '@iblai/iblai-js/data-layer';
|
|
107
107
|
\`\`\`
|
|
108
108
|
|
|
109
109
|
### Skills & Catalog
|
|
@@ -113,7 +113,7 @@ import {
|
|
|
113
113
|
useGetDesiredSkillsQuery,
|
|
114
114
|
useGetCatalogSearchQuery,
|
|
115
115
|
useGetPersonalizedSearchQuery,
|
|
116
|
-
} from '@iblai/data-layer';
|
|
116
|
+
} from '@iblai/iblai-js/data-layer';
|
|
117
117
|
\`\`\`
|
|
118
118
|
|
|
119
119
|
### MCP (Model Context Protocol)
|
|
@@ -123,7 +123,7 @@ import {
|
|
|
123
123
|
useCreateMCPServerMutation,
|
|
124
124
|
useGetConnectedServicesQuery,
|
|
125
125
|
useStartOAuthFlowMutation,
|
|
126
|
-
} from '@iblai/data-layer';
|
|
126
|
+
} from '@iblai/iblai-js/data-layer';
|
|
127
127
|
\`\`\`
|
|
128
128
|
|
|
129
129
|
### Analytics
|
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
useGetAnalyticsOverviewQuery,
|
|
133
133
|
useGetAnalyticsUsersQuery,
|
|
134
134
|
useGetAnalyticsReportsQuery,
|
|
135
|
-
} from '@iblai/data-layer';
|
|
135
|
+
} from '@iblai/iblai-js/data-layer';
|
|
136
136
|
\`\`\`
|
|
137
137
|
|
|
138
138
|
## Cache Tags
|
|
@@ -154,7 +154,7 @@ dispatch(mentorApi.util.invalidateTags(['mentors']));
|
|
|
154
154
|
For conditional/on-demand data fetching:
|
|
155
155
|
|
|
156
156
|
\`\`\`typescript
|
|
157
|
-
import { useLazyGetMentorDetailsQuery } from '@iblai/data-layer';
|
|
157
|
+
import { useLazyGetMentorDetailsQuery } from '@iblai/iblai-js/data-layer';
|
|
158
158
|
|
|
159
159
|
const [trigger, { data, isLoading }] = useLazyGetMentorDetailsQuery();
|
|
160
160
|
|
|
@@ -169,7 +169,7 @@ useEffect(() => {
|
|
|
169
169
|
## Initialization
|
|
170
170
|
|
|
171
171
|
\`\`\`typescript
|
|
172
|
-
import { initializeDataLayer } from '@iblai/data-layer';
|
|
172
|
+
import { initializeDataLayer } from '@iblai/iblai-js/data-layer';
|
|
173
173
|
|
|
174
174
|
// In your app initialization
|
|
175
175
|
initializeDataLayer({
|