@assembly-js/app-foundation 0.2.6 → 0.2.7

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/CHANGELOG.md CHANGED
@@ -19,6 +19,9 @@ A patch release never changes what an app's build requires; a minor release may
19
19
  not by hand; see `changes/README.md`. CI fails a PR that changes a check script without a
20
20
  `bump: minor` change file.
21
21
 
22
+ ## 0.2.7
23
+ - [guidance] The build agent learns to call another app through its generated client and to show an empty state naming that app when the call is refused.
24
+
22
25
  ## 0.2.6
23
26
  - [fix] The app keeps connecting to a portal on a custom domain, and keeps telling the editor when it has loaded, without relying on a platform setting that is being retired. Nothing visible changes.
24
27
 
package/CLAUDE.md CHANGED
@@ -48,6 +48,9 @@ Assembly-specific gotchas live in `.claude/skills/<name>/SKILL.md`. Invoke them
48
48
  <!-- feature:deep-link-bridge-nav -->
49
49
  - `assembly-platform-links` — link platform records (client, company, invoice, contract, form, file) to their portal detail page via `linkTo()`; never hand-build a host URL. Also links between workspace apps by install id. Check the app's installed app-bridge first (see the skill) — `navigateTo` doesn't exist on older peers — and only link staff-only destinations (client, company, form, etc.) from the dashboard surface, never the client portal.
50
50
  <!-- /feature:deep-link-bridge-nav -->
51
+ <!-- feature:cross-app-apis -->
52
+ - `assembly-app-clients` — calling another workspace app through its generated client in `generated/apps/<appId>/` (`installerClient`, by verb and path), and rendering an empty state that names the app when the call is refused instead of a 500.
53
+ <!-- /feature:cross-app-apis -->
51
54
  - `assembly-ai` — AI features, including speech-to-text, via Assembly's OpenAI proxy (no API keys needed)
52
55
  - `assembly-storage` — app-private file uploads/downloads (NOT the portal Files module). The storage helpers come from `@assembly-js/app-foundation/server` — import them, don't rewrite them. POST only `{ fileName }` (a bare name) and store the key the platform returns; never build the S3 key yourself.
53
56
  - `assembly-integrations` (present only when third-party integrations are enabled for this workspace) — third-party providers (Slack, etc.) via `requiredIntegrations` + `getIntegration()`. If this skill is present, read it and `.claude/skills/assembly-integrations/providers/<slug>.md` before declaring an integration or writing any provider call — the skill lists what's connectable, the provider doc has that provider's gotchas — and read them first when provider data displays wrongly (wrong format, raw IDs). If it is absent, managed OAuth integrations are not available here; use `requiredSecrets` for any external service
@@ -454,6 +457,9 @@ Relationships:
454
457
 
455
458
  If the user names another app, read its file in `.assembly/docs/apps/` and follow the call recipe at the top of that file. If that folder is absent, the app is not callable (it may still need the Security update). Cross-app calls from pages, server actions and routes use `getInstallerAssembly()`; cron and webhooks use `getOfflineAssembly()`. Never return another app's response to a client unfiltered — scope any client data you forward. While a person is using the app, those calls use the installer client, because the platform does not yet prove which person the call is for. Once it can, use the viewer client for that person's data and keep the installer client for staff-wide reads.
456
459
  <!-- /feature:api-resources -->
460
+ <!-- feature:cross-app-apis -->
461
+ When `generated/apps/<appId>/` exists for that app, call it through the generated client instead (see the `assembly-app-clients` skill); the docs recipe is the fallback for an app with no folder there.
462
+ <!-- /feature:cross-app-apis -->
457
463
 
458
464
  ---
459
465
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assembly-js/app-foundation",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Versioned foundation helpers and build context for Assembly generated apps",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,80 @@
1
+ <!-- feature:cross-app-apis -->
2
+ ---
3
+ name: assembly-app-clients
4
+ description: Use when the app calls another workspace app and `generated/apps/<appId>/` exists for it. Covers reading the generated README and types, calling `installerClient` by verb and path, and rendering an empty state that names the app when the call is refused (app_not_found, operation_not_found, viewer_not_allowed, callee_error) instead of throwing a 500.
5
+ ---
6
+
7
+ ## Where the client lives
8
+
9
+ Each app this one may call has a folder at `generated/apps/<appId>/`, refreshed by the platform at the start of every turn:
10
+
11
+ - `README.md` — read it first. It lists every operation as a verb and a path, with a summary.
12
+ - `types.d.ts` — the request and response shapes of each operation. Read the one you need before writing the call.
13
+ - `client.ts` — exports `installerClient` and `viewerClient`.
14
+ - `openapi.json` — the contract the other files were generated from.
15
+
16
+ Never edit these files; the next refresh overwrites them. If an app has no folder here, it has published no contract: follow the call recipe in its `.assembly/docs/apps/` file instead.
17
+
18
+ ## Calling another app
19
+
20
+ Call an operation by its verb and path, exactly as the README lists it. Paths, parameters and bodies are type-checked against the contract, so a wrong path fails the type check instead of production.
21
+
22
+ ```ts
23
+ import { installerClient } from '@/generated/apps/<appId>/client';
24
+
25
+ const { data, error } = await installerClient.GET('/projects/{id}', {
26
+ params: { path: { id } },
27
+ });
28
+ ```
29
+
30
+ Call it from server code only: pages, server actions, route handlers, cron and webhooks. Never import it into a `'use client'` component.
31
+
32
+ ## Installer or viewer
33
+
34
+ Use `installerClient`. It calls as this app, so filter anything it returns to what the viewing client may see before you show it to a client.
35
+
36
+ `viewerClient` calls as the signed-in person. The platform refuses it with `viewer_not_allowed` until it can prove which person the call is for, so use `installerClient` for now.
37
+
38
+ ## When the other app cannot answer
39
+
40
+ The other app can be uninstalled, can drop an operation, or can fail on its own. None of these may crash the page. A refusal does not throw: the call returns no `data` and an `error` whose `code` says why.
41
+
42
+ | `code` | Meaning | What to render |
43
+ |---|---|---|
44
+ | `app_not_found` | The app is not installed in this workspace, or this app may not call it. | Empty state: "<App name> is not available in this workspace." |
45
+ | `operation_not_found` | The app no longer offers this operation. | Empty state: "<App name> no longer provides this." |
46
+ | `viewer_not_allowed` | The call used `viewerClient`. | Nothing at runtime: switch the call to `installerClient`. |
47
+ | `callee_error` | The other app answered with its own failure. The most common case at runtime. | Error state: "<App name> could not load this right now." |
48
+
49
+ Branch on the result and render a state that names the app:
50
+
51
+ ```tsx
52
+ import { installerClient } from '@/generated/apps/<appId>/client';
53
+
54
+ const PROVIDER_NAME = 'Projects';
55
+ const MISSING_CODES = ['app_not_found', 'operation_not_found'];
56
+
57
+ function errorCode(error: unknown): string | undefined {
58
+ if (typeof error !== 'object' || error === null || !('code' in error)) return undefined;
59
+ return typeof error.code === 'string' ? error.code : undefined;
60
+ }
61
+
62
+ export default async function ProjectsPanel() {
63
+ const { data, error } = await installerClient.GET('/projects');
64
+ if (!data) {
65
+ const code = errorCode(error);
66
+ if (code && MISSING_CODES.includes(code)) {
67
+ return <EmptyState title={`${PROVIDER_NAME} is not available in this workspace.`} />;
68
+ }
69
+ console.error('projects call failed', code ?? error);
70
+ return <EmptyState title={`${PROVIDER_NAME} could not load this right now.`} />;
71
+ }
72
+ return <ProjectList projects={data} />;
73
+ }
74
+ ```
75
+
76
+ - Only the part of the page that depends on the other app shows the empty state; render the rest as usual.
77
+ - A network failure throws instead of returning `error`. Wrap the call in `try`/`catch` where the page must still render, and show the same error state.
78
+ - In a server action, return `{ ok: false, message }` naming the app (see `assembly-action-results`) instead of throwing.
79
+ - In a route handler, answer with a non-500 status and a static message naming the app (see `assembly-route-errors`). Never forward the other app's message to a client.
80
+ <!-- /feature:cross-app-apis -->