@assembly-js/app-foundation 0.0.32 → 0.0.33
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/dist/next.js
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
|
+
// Dev-invariant wrapper for generated apps' Next config. Each app's
|
|
2
|
+
// next.config.ts is platform-owned boilerplate — `export default
|
|
3
|
+
// withAssemblyDev(appConfig)` — so the preview invariants live here in the
|
|
4
|
+
// versioned package instead of as config keys the build agent must know to
|
|
5
|
+
// preserve when it edits its own app.config.ts.
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
// Read non-root surface paths from the app manifest so location-prefix.ts can
|
|
9
|
+
// discover them at runtime instead of relying on the hardcoded /c and /n defaults.
|
|
10
|
+
function readSurfacePrefixes() {
|
|
11
|
+
try {
|
|
12
|
+
const manifestPath = path.join(process.cwd(), '.assembly', 'app.json');
|
|
13
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
14
|
+
const prefixes = Object.values(manifest.surfaces ?? {})
|
|
15
|
+
.map((s) => s.path)
|
|
16
|
+
.filter((p) => typeof p === 'string' && p !== '/');
|
|
17
|
+
return prefixes.length > 0 ? JSON.stringify(prefixes) : undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
1
23
|
export function withAssemblyDev(config = {}) {
|
|
24
|
+
// Inject manifest-derived surface prefixes into the client bundle so
|
|
25
|
+
// location-prefix.ts honours whatever paths the app declares.
|
|
26
|
+
const surfacePrefixesJson = readSurfacePrefixes();
|
|
27
|
+
const baseConfig = surfacePrefixesJson
|
|
28
|
+
? {
|
|
29
|
+
...config,
|
|
30
|
+
env: {
|
|
31
|
+
...config.env,
|
|
32
|
+
NEXT_PUBLIC_ASSEMBLY_SURFACE_PREFIXES: surfacePrefixesJson,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
: config;
|
|
2
36
|
// Production builds (deploys) have no dev server, no HMR socket, and no
|
|
3
|
-
// sandbox host — the
|
|
37
|
+
// sandbox host — only the env injection above applies there.
|
|
4
38
|
if (process.env.NODE_ENV === 'production')
|
|
5
|
-
return
|
|
39
|
+
return baseConfig;
|
|
6
40
|
const sandboxHost = process.env.SANDBOX_HOST;
|
|
7
41
|
const allowedDevOrigins = sandboxHost
|
|
8
|
-
? [...new Set([sandboxHost, ...(
|
|
9
|
-
:
|
|
42
|
+
? [...new Set([sandboxHost, ...(baseConfig.allowedDevOrigins ?? [])])]
|
|
43
|
+
: baseConfig.allowedDevOrigins;
|
|
10
44
|
// A dev WebSocket that never connects would otherwise hang hydration forever
|
|
11
45
|
// on Next 16.3+. Debug data falls back to the flight stream, so
|
|
12
46
|
// nothing user-visible is lost. Cast because this package type-checks against
|
|
13
47
|
// its Next 15 devDependency, which predates the flag; runtimes that predate
|
|
14
48
|
// it ignore the unknown key.
|
|
15
49
|
const experimental = {
|
|
16
|
-
...
|
|
50
|
+
...baseConfig.experimental,
|
|
17
51
|
reactDebugChannel: false,
|
|
18
52
|
};
|
|
19
53
|
return {
|
|
20
|
-
...
|
|
54
|
+
...baseConfig,
|
|
21
55
|
...(allowedDevOrigins ? { allowedDevOrigins } : {}),
|
|
22
|
-
devIndicators:
|
|
56
|
+
devIndicators: baseConfig.devIndicators ?? false,
|
|
23
57
|
experimental,
|
|
24
58
|
};
|
|
25
59
|
}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ If you are unsure, default to **internal-only**. Do not add a client surface unl
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
- `internal` is **required** — every Vibe app must have a dashboard surface. `client` is optional; omit it for internal-only apps. `notification` is optional; declare it
|
|
28
|
+
- `internal` is **required** — every Vibe app must have a dashboard surface. `client` is optional; omit it for internal-only apps. `notification` is optional; declare it when opening a notification should land on a specific record (see below).
|
|
29
29
|
- `path` is the route within your app for that surface. Must start with `/`. Use `/` for the surface's root; use distinct sub-paths if both surfaces share one Next.js app.
|
|
30
30
|
- Generate the corresponding routes in your app code. E.g. if you declare `client.path = "/c"`, you must have a `/c` page in the app.
|
|
31
31
|
|
|
@@ -58,7 +58,7 @@ The app's API contract (automation triggers/actions, webhook events) is NOT an `
|
|
|
58
58
|
|
|
59
59
|
## The `notification` surface
|
|
60
60
|
|
|
61
|
-
When
|
|
61
|
+
When a notification should open a specific record, declare a `notification` surface. That path is what the Notification Center embeds; it is not a button the app renders.
|
|
62
62
|
|
|
63
63
|
```json
|
|
64
64
|
{
|
|
@@ -71,10 +71,10 @@ When an app sends notifications with `ctaParams`, the Notification Center needs
|
|
|
71
71
|
|
|
72
72
|
When `notification` is declared:
|
|
73
73
|
- The build pipeline sets `notificationUrl` on the marketplace app to `<deployURL>/n`.
|
|
74
|
-
-
|
|
74
|
+
- Opening the notification embeds that URL in the Notification Center detail panel, with the token and `ctaParams` as search params. If `notificationUrl` is empty, the panel has no iframe: it shows the body and an "Open {app name}" button that opens the app's main view, and non-reserved `ctaParams` are forwarded as search params on that view.
|
|
75
75
|
- Your `/n` page shows its context-specific content from the `ctaParams` in the URL. Those always arrive; `notificationId` from the token payload is best-effort under the session-exchange flow, so never gate the record render on it.
|
|
76
76
|
|
|
77
|
-
**Declare the `notification` surface
|
|
77
|
+
**Declare the `notification` surface, and pass `ctaParams` that identify the record, whenever a notification should open that record.** A send with neither is only correct when the destination is the app's main view. See the `assembly-notifications` skill.
|
|
78
78
|
|
|
79
79
|
## Examples
|
|
80
80
|
|
|
@@ -29,7 +29,9 @@ The audience changes the experience and the code:
|
|
|
29
29
|
|
|
30
30
|
## Notification surfaces
|
|
31
31
|
|
|
32
|
-
A surface is the embedded view the Notification Center renders when an internal user opens a notification. It's a route (conventionally `/n`) that reads
|
|
32
|
+
A surface is the embedded view the Notification Center renders when an internal user opens a notification. It's a route (conventionally `/n`) that reads your `ctaParams` off the URL and renders the record they name.
|
|
33
|
+
|
|
34
|
+
Declare the surface, and pass `ctaParams` that identify the record, whenever opening the notification should land on that record (one retainer, one submission, one task). Without the surface the Center shows the title and body, plus a platform button labeled "Open {app name}" that opens the app's main view. Non-reserved `ctaParams` are forwarded as search params on that main view. Skip the surface only when that main view is the right destination.
|
|
33
35
|
|
|
34
36
|
Surfaces are internal-only. Clients don't render one, but `ctaParams` still travel with the notification and become URL search params on an email CTA click — that's how a client landing from an email gets enough context.
|
|
35
37
|
|
|
@@ -142,7 +144,7 @@ export async function GET() {
|
|
|
142
144
|
- `senderType` — read-side only. Automatically populated from `senderId` (client, internal user, or company). You do not set it on create.
|
|
143
145
|
- `deliveryTargets.inProduct` — include to make the notification appear in the Notification Center (for internal users) or trigger the badge (for clients). Requires `title`. `body` and `ctaParams` are optional. Omit entirely for email-only notifications.
|
|
144
146
|
- `deliveryTargets.email` — include to send an email. `subject`, `header`, and `title` (CTA button label) are required, plus one body: `htmlBody` for formatted content (see below) or `body` for plain text. Either `inProduct` or `email` must be present; both is also valid.
|
|
145
|
-
- `ctaParams` — a plain object of string key/value pairs that become URL search params when the user engages with the notification. Pass as an object — never `JSON.stringify()`. **Values must be strings** — stringify numbers and booleans yourself (e.g., `{ count: '3' }`, not `{ count: 3 }`). Nested objects aren't supported. Used by both the email CTA and the Notification Center surface.
|
|
147
|
+
- `ctaParams` — a plain object of string key/value pairs that become URL search params when the user engages with the notification. Pass as an object — never `JSON.stringify()`. **Values must be strings** — stringify numbers and booleans yourself (e.g., `{ count: '3' }`, not `{ count: 3 }`). Nested objects aren't supported. Used by both the email CTA and the Notification Center surface. A notification about one record always includes the id that selects it (`{ retainerId: retainer.id }`). Title and body text do not.
|
|
146
148
|
<!-- feature:notification-settings -->
|
|
147
149
|
- `notificationSettingId` — the id of one of the app's declared notification settings (see "Per-user notification settings" below). Pass it on **every** send of a declared category so internal users' Product/Email toggles apply. Omit it for sends with no declared setting.
|
|
148
150
|
<!-- /feature:notification-settings -->
|