@theaiplatform/miniapp-sdk 0.3.3 → 0.4.0
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 +100 -1
- package/dist/bin/tap-miniapp-test.d.ts +1 -0
- package/dist/bin/tap-miniapp-test.js +1293 -0
- package/dist/index.d.ts +24 -0
- package/dist/internal/json-schema.d.ts +10 -0
- package/dist/internal/json-schema.js +53 -0
- package/dist/rspack/index.d.ts +72 -6
- package/dist/rspack/index.js +155 -31
- package/dist/sdk.d.ts +24 -0
- package/dist/surface.d.ts +14 -0
- package/dist/testing/rstest-config.d.ts +38 -0
- package/dist/testing/rstest-config.js +59 -0
- package/dist/testing/rstest.d.ts +513 -41
- package/dist/testing/rstest.js +1642 -150
- package/dist/testing/tap.test.schema.json +361 -0
- package/dist/ui/wasm.js +2 -1
- package/dist/ui.d.ts +14 -4
- package/dist/ui.js +2 -1
- package/dist/vscode-webview.d.ts +14 -0
- package/dist/web.d.ts +24 -0
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -29,10 +29,90 @@ Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniap
|
|
|
29
29
|
- `@theaiplatform/miniapp-sdk/config`
|
|
30
30
|
- `@theaiplatform/miniapp-sdk/rspack`
|
|
31
31
|
- `@theaiplatform/miniapp-sdk/testing/rstest`
|
|
32
|
+
- `@theaiplatform/miniapp-sdk/testing/rstest-config`
|
|
33
|
+
- `@theaiplatform/miniapp-sdk/testing/tap.test.schema.json`
|
|
32
34
|
- `@theaiplatform/miniapp-sdk/config-schema.json`
|
|
33
35
|
|
|
34
36
|
## In-app E2E testing
|
|
35
37
|
|
|
38
|
+
Pin the SDK to the exact version named by `manifest.compatibility.tapSdk`.
|
|
39
|
+
Test Lab deliberately rejects ranges, tags, duplicate dependency declarations,
|
|
40
|
+
and a manifest version that differs from the executing CLI:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@theaiplatform/miniapp-sdk": "0.4.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Generate or audit the test project with the installed package binary:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm exec tap-miniapp-test list
|
|
54
|
+
pnpm exec tap-miniapp-test scaffold
|
|
55
|
+
pnpm exec tap-miniapp-test scaffold --check
|
|
56
|
+
pnpm exec tap-miniapp-test matrix
|
|
57
|
+
pnpm exec tap-miniapp-test doctor
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
All commands accept `--root`, `--manifest`, `--descriptor`, and `--json`.
|
|
61
|
+
`scaffold` creates only missing files and preserves user-owned files.
|
|
62
|
+
Its smoke test asserts the exact surface-target cell, profile, matrix entry,
|
|
63
|
+
deterministic seed, SDK/host/runner versions, and all host-attested digests
|
|
64
|
+
before exercising the universal surface remount control.
|
|
65
|
+
`migrate --dry-run` previews the deterministic schema-v1 projection;
|
|
66
|
+
`migrate` preserves the exact old document as `tap.test.v1.json` before an
|
|
67
|
+
atomic replacement. Run `doctor` in CI so missing files, unsafe paths, stale
|
|
68
|
+
versions, empty test selections, capability gaps, and surface applicability
|
|
69
|
+
branches fail before Test Lab starts a browser.
|
|
70
|
+
|
|
71
|
+
The generated `rstest.tap.config.ts` uses the public deterministic helper:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { defineTapRstestConfig } from '@theaiplatform/miniapp-sdk/testing/rstest-config';
|
|
75
|
+
|
|
76
|
+
export default defineTapRstestConfig();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
It fixes Rstest to one worker, serial execution, no retries, no isolation, a
|
|
80
|
+
Node test environment, and an error for empty suites. Safe Rstest options remain
|
|
81
|
+
composable; incompatible overrides fail at config load rather than silently
|
|
82
|
+
making a run nondeterministic.
|
|
83
|
+
|
|
84
|
+
`tap.test.json` schema v2 describes profiles separately from matrix entries.
|
|
85
|
+
Every manifest-declared surface and target needs exactly one positive matrix
|
|
86
|
+
entry. A positive entry names the capabilities it verifies:
|
|
87
|
+
|
|
88
|
+
- `action:<permission-action-id>`
|
|
89
|
+
- `effect:<effect-kind>:<resource>`
|
|
90
|
+
- `effect:<effect-kind>:*` when the manifest effect has no resources
|
|
91
|
+
|
|
92
|
+
Write denied/error matrix entries for every high-risk action and host effect.
|
|
93
|
+
Use `network.request` only for network-effect denial; use the all-denied `*`
|
|
94
|
+
scenario for non-network effects. A waiver may temporarily replace a
|
|
95
|
+
denied/error case only when it explains the gap and has a future `expiresAt`;
|
|
96
|
+
it never replaces positive capability attribution. Put surface applicability
|
|
97
|
+
in each matrix entry's `testMatch`, rather than returning or branching on
|
|
98
|
+
`tap.surfaceId` inside a test shared by multiple surfaces.
|
|
99
|
+
|
|
100
|
+
The canonical descriptor schema is published at
|
|
101
|
+
`@theaiplatform/miniapp-sdk/testing/tap.test.schema.json`. Profile environment
|
|
102
|
+
fields fix viewport, locale, IANA timezone, theme, reduced motion, and the
|
|
103
|
+
unsigned 32-bit fixture seed. Set optional `fixedNow` to a canonical UTC RFC
|
|
104
|
+
3339 instant such as `2026-01-01T00:00:00Z` when the app derives routes,
|
|
105
|
+
queries, labels, or fixture data from the wall clock. The adapter installs that
|
|
106
|
+
clock before mounting the surface, so tests never need to scrape a
|
|
107
|
+
machine-dependent date and remount. Federated surfaces that create app-owned
|
|
108
|
+
identifiers should use `context.entropy.randomUUID()`: ordinary mounts retain
|
|
109
|
+
cryptographically strong UUIDs, while Test Lab derives a frame-scoped,
|
|
110
|
+
resettable stream from this profile seed. This keeps retained remounts distinct
|
|
111
|
+
and the same test sequence reproducible without test-only globals or query
|
|
112
|
+
parameters. Artifact policy independently controls
|
|
113
|
+
trace and screenshot capture with `off`, `failure-only`, or `always`, plus an
|
|
114
|
+
optional total byte limit.
|
|
115
|
+
|
|
36
116
|
The `/testing/rstest` entry point extends Rstest's Playwright fixtures with a
|
|
37
117
|
host-provided miniapp surface and exact TAP session provenance. Tests can assert
|
|
38
118
|
both the rendered UI and the package/surface identity selected by the Test Lab:
|
|
@@ -44,6 +124,9 @@ test('mounts the miniapp surface', async ({ surface, tap }) => {
|
|
|
44
124
|
await expect(surface.locator('body')).toBeVisible();
|
|
45
125
|
expect(tap.packageId).toBe('tap_pkg_example_0001');
|
|
46
126
|
expect(tap.surfaceId).toBe('example-surface');
|
|
127
|
+
expect(tap.environment.seed).toBe(tap.seed);
|
|
128
|
+
expect(tap.environment.fixedNow).toBe('2026-01-01T00:00:00Z');
|
|
129
|
+
expect(tap.artifacts.trace).toBe('failure-only');
|
|
47
130
|
});
|
|
48
131
|
```
|
|
49
132
|
|
|
@@ -61,7 +144,23 @@ requests through host consent instead of browser `fetch`, and
|
|
|
61
144
|
secrets remain in the host vault and are injected only by the native request
|
|
62
145
|
authority.
|
|
63
146
|
|
|
64
|
-
|
|
147
|
+
Custom surface behavior can ask the exact mounted host for its current
|
|
148
|
+
descriptor-declared action decision without executing that action:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const { allowed } = await sdk.authorization.check({
|
|
152
|
+
actionId: 'example.export',
|
|
153
|
+
autonomy: 'do',
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Use this advisory check to disable or explain custom UI before the user invokes
|
|
158
|
+
it; the capability that performs the operation must still enforce authority.
|
|
159
|
+
A declared but currently denied action resolves to `{ allowed: false }`. An
|
|
160
|
+
action omitted from this exact surface's `authorization.allOf` rejects as a
|
|
161
|
+
manifest defect. The check is read-only and never executes the queried action.
|
|
162
|
+
|
|
163
|
+
## Converted VS Code webviews
|
|
65
164
|
|
|
66
165
|
The `/vscode-webview` entry point mounts a converted, static VS Code webview in
|
|
67
166
|
a sandboxed iframe while keeping platform authority in the outer federated
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|