create-substrat 0.15.3 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-substrat",
3
- "version": "0.15.3",
3
+ "version": "0.16.0",
4
4
  "description": "Scaffold a Substrat vertical — `npm create substrat <dir>`.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/project-files.js CHANGED
@@ -30,12 +30,12 @@ import { DEV_SERVERS } from './dev-servers.js';
30
30
  // The runtime packages release together off one version line (the changesets `fixed`
31
31
  // group), so one constant is right for all of them. Engines do NOT share a line —
32
32
  // each versions on its own, so one pin per engine, deliberately.
33
- const SUBSTRAT = '^0.190.1';
34
- const ENGINE_WORKORDER = '^0.13.15';
35
- const ENGINE_INVOICING = '^0.11.74';
33
+ const SUBSTRAT = '^0.191.0';
34
+ const ENGINE_WORKORDER = '^0.13.16';
35
+ const ENGINE_INVOICING = '^0.11.75';
36
36
  const BOUNDARY_LINT = '^0.9.1';
37
- const DEV_ISSUER = '^0.4.3';
38
- const ATTACHMENT_EXTRACTORS = '^0.2.51';
37
+ const DEV_ISSUER = '^0.5.0';
38
+ const ATTACHMENT_EXTRACTORS = '^0.2.52';
39
39
 
40
40
  export const TSCONFIG = `${JSON.stringify(
41
41
  {
@@ -9,14 +9,16 @@ import { HTTPException } from 'hono/http-exception';
9
9
  import { platformActorId } from '@substrat-run/contracts';
10
10
  import { ulid, type ScopeStub } from '@substrat-run/kernel';
11
11
  import { devMailOutbox } from '@substrat-run/adapter-sqlite';
12
- import { devLogin } from '@substrat-run/dev-issuer';
12
+ import Database from 'better-sqlite3';
13
+ import { devLogin, devMemberInvites } from '@substrat-run/dev-issuer';
13
14
  import { buildBikeShopHost, linkDevPersonas, seedBikeShop, type BikeShopWorld } from './seed.js';
14
15
  import { DEV_PROVIDER } from './personas.js';
15
16
  import { mountApi } from './routes.js';
16
17
 
17
18
  // ============================================================================
18
- // The DEV entrypoint. It owns exactly four things — a SQLite host on disk, the
19
- // relying-party login, where queued mail goes, and the port — and then mounts `routes.ts`, the same
19
+ // The DEV entrypoint. It owns exactly five things — a SQLite host on disk, the
20
+ // relying-party login, where queued mail goes, where member invites are kept, and the port — and
21
+ // then mounts `routes.ts`, the same
20
22
  // route table `worker.ts` mounts. There is no business logic here and no route
21
23
  // here either: a route added to this file would exist in dev and 404 in
22
24
  // production, which is the one failure this split exists to prevent.
@@ -59,6 +61,21 @@ const staffActor = platformActorId.parse(ulid());
59
61
  const outbox = devMailOutbox(host, { dataDir, actor: staffActor });
60
62
  await outbox.drain();
61
63
 
64
+ // ── MEMBER INVITES ──────────────────────────────────────────────────────────
65
+ // A person a member invite names gets in by the address the issuer verified, as they do hosted:
66
+ // the first time they sign in, `login` finds the invite and links them to the invited account,
67
+ // with its role. The invites are kept in `.data/members.sqlite`. A vertical whose people invite
68
+ // each other mounts the routes below, naming the same operations worker.ts names in `workerDoor`.
69
+ // The dev issuer signs in only the people in src/personas.ts. If your people invite each other, add
70
+ // one persona and leave it out of `homes` in seed.ts, so nothing links it; invite it at the `email`
71
+ // its persona carries, and it gets in as it would hosted. This shop has none, as it invites nobody.
72
+ const members = devMemberInvites({
73
+ db: new Database(join(dataDir, 'members.sqlite')),
74
+ host,
75
+ actor: staffActor,
76
+ provider: DEV_PROVIDER,
77
+ });
78
+
62
79
  /**
63
80
  * The relying party — login, callback, logout, plus `sub` → principal through the
64
81
  * identity directory. The persona's tenant and scope come out of the link the seed
@@ -79,6 +96,7 @@ const login = devLogin({
79
96
  actor: staffActor,
80
97
  provider: DEV_PROVIDER,
81
98
  issuer: process.env.OIDC_ISSUER ?? `http://localhost:${ISSUER_PORT}`,
99
+ admit: members.admit,
82
100
  });
83
101
 
84
102
  const app = new Hono();
@@ -107,6 +125,20 @@ async function stub(c: Context): Promise<ScopeStub> {
107
125
  });
108
126
  }
109
127
 
128
+ // `POST /api/member-invites` and its withdrawal, for a vertical that invites its people:
129
+ //
130
+ // members.mount(app, {
131
+ // login,
132
+ // scope: stub,
133
+ // invites: {
134
+ // roles: ['mechanic', 'front-desk'],
135
+ // send: (scope, i) => scope.invoke('shop/invite-member', { principal: i.principal, email: i.email, roleKey: i.roleKey }),
136
+ // cancel: (scope, i) => scope.invoke('shop/cancel-invite', { principal: i.principal }),
137
+ // },
138
+ // });
139
+ //
140
+ // This shop invites nobody: its people are added by staff.
141
+
110
142
  // Everything else — including `/api/invoke` and the shared error envelope.
111
143
  mountApi(app, stub);
112
144
 
@@ -14,8 +14,8 @@
14
14
  * Sign-in is `workerDoor`'s, from @substrat-run/vertical-host: the issuer the dashboard delivers
15
15
  * for this instance, the tenant's identity directory (the `AUTH` store), and the owner seat the
16
16
  * first person takes. There is no credential store here and no dev header: a request names no
17
- * caller, the session does. Member invites are yours to add: who may invite is your own rule, so
18
- * mount `mountInviteRoutes` from @substrat-run/vertical-auth with your admin gate.
17
+ * caller, the session does. Member invites go through the door too: name your invite operations
18
+ * in `workerDoor({ invites })` (below).
19
19
  */
20
20
  import { Hono } from 'hono';
21
21
  import type { Context } from 'hono';
@@ -142,7 +142,21 @@ function hostFor(env: Env): CloudflareScopeHost {
142
142
  *
143
143
  * join: (scope, who) => scope.invoke('shop/join', { displayName: who.display }),
144
144
  *
145
- * This shop has neither: its people are added by staff, and its portal shape is a customer's.
145
+ * A person a member invite names is let in by the address their issuer verified, with no link: the
146
+ * first time they sign in they are bound to the invited account, with its role, and then joined. A
147
+ * vertical whose people invite each other names its invite operations here, and the door mounts
148
+ * `POST /api/member-invites` and `POST /api/member-invites/:principal/withdraw` for its screens:
149
+ *
150
+ * invites: {
151
+ * roles: ['mechanic', 'front-desk'],
152
+ * send: (scope, i) => scope.invoke('shop/invite-member', { principal: i.principal, email: i.email, roleKey: i.roleKey }),
153
+ * cancel: (scope, i) => scope.invoke('shop/cancel-invite', { principal: i.principal }),
154
+ * },
155
+ *
156
+ * `send` checks who may invite, records the invite for the screens and queues the mail ("sign in
157
+ * with this address"); it must not grant anything to `i.principal`. server.ts names the same three.
158
+ *
159
+ * This shop has none of these: its people are added by staff, and its portal shape is a customer's.
146
160
  */
147
161
  const door = workerDoor<Env>({
148
162
  directory: (env, node) => env.AUTH.get(env.AUTH.idFromName(node.tenantId)),