@jskit-ai/agent-docs 0.1.256 → 0.1.258

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.
Files changed (230) hide show
  1. package/guide/agent/app-extras/assistant-conversation.md +88 -35
  2. package/guide/agent/app-extras/assistant.md +28 -28
  3. package/guide/agent/app-setup/authentication.md +36 -17
  4. package/guide/agent/app-setup/database-layer.md +116 -17
  5. package/guide/agent/app-setup/existing-application-migration.md +29 -25
  6. package/guide/agent/app-setup/multi-homing.md +94 -48
  7. package/guide/agent/app-setup/run-an-accounts-hub.md +6 -4
  8. package/guide/agent/framework/client-features.md +496 -0
  9. package/guide/agent/framework/crud-operations.md +5 -5
  10. package/guide/agent/framework/translation.md +4 -3
  11. package/guide/agent/framework/typed-features.md +1104 -0
  12. package/guide/agent/framework/ui-operations.md +2 -2
  13. package/guide/agent/index.md +6 -1
  14. package/package.json +1 -1
  15. package/patterns/feature-package/PATTERN.md +104 -10
  16. package/patterns/feature-package/example/booking-engine/package.json +9 -4
  17. package/patterns/feature-package/example/booking-engine/src/server/BookingEngineFeature.js +24 -0
  18. package/patterns/feature-package/example/booking-engine/src/server/bookingAvailability.js +10 -0
  19. package/patterns/feature-package/example/booking-engine/src/server/bookingEngine.js +29 -0
  20. package/patterns/feature-package/example/booking-engine/src/server/bookingEngineActions.js +26 -0
  21. package/patterns/feature-package/example/booking-engine/src/server/inputSchemas.js +1 -2
  22. package/patterns/feature-package/example/booking-engine/src/server/types.js +12 -0
  23. package/patterns/feature-package/example/variations/AvailabilityEngineFeature.js +19 -0
  24. package/patterns/feature-package/example/variations/InvoiceRollupFeature.js +23 -0
  25. package/patterns/feature-package/example/variations/availabilityEngineActions.js +26 -0
  26. package/patterns/feature-package/example/variations/customKnexRepository.js +32 -26
  27. package/patterns/feature-package/example/variations/invoiceRollupActions.js +26 -0
  28. package/patterns/feature-package/example/variations/orchestratorService.js +24 -19
  29. package/patterns/feature-package/example/variations/types.js +7 -0
  30. package/patterns/minimal-foundation/PATTERN.md +30 -1
  31. package/patterns/minimal-foundation/example/AGENTS.md +14 -0
  32. package/patterns/minimal-foundation/example/bin/develop.js +10 -5
  33. package/patterns/minimal-foundation/example/eslint.config.mjs +21 -2
  34. package/patterns/minimal-foundation/example/package.json +5 -4
  35. package/patterns/minimal-foundation/example/playwright.config.mjs +1 -1
  36. package/patterns/minimal-foundation/example/server/lib/envFile.js +19 -0
  37. package/patterns/minimal-foundation/example/server/lib/loggerOptions.js +15 -0
  38. package/patterns/minimal-foundation/example/server/lib/runtimeEnv.js +17 -17
  39. package/patterns/minimal-foundation/example/server.js +32 -29
  40. package/patterns/minimal-foundation/example/tests/server/smoke.test.js +2 -1
  41. package/patterns/shell-foundation/PATTERN.md +29 -0
  42. package/patterns/shell-foundation/example/AGENTS.md +14 -0
  43. package/patterns/shell-foundation/example/bin/develop.js +10 -5
  44. package/patterns/shell-foundation/example/eslint.config.mjs +21 -2
  45. package/patterns/shell-foundation/example/package.json +6 -5
  46. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  47. package/patterns/shell-foundation/example/packages/main/src/client/providers/MainClientProvider.js +1 -0
  48. package/patterns/shell-foundation/example/playwright.config.mjs +1 -1
  49. package/patterns/shell-foundation/example/server/lib/envFile.js +19 -0
  50. package/patterns/shell-foundation/example/server/lib/loggerOptions.js +15 -0
  51. package/patterns/shell-foundation/example/server/lib/runtimeEnv.js +17 -17
  52. package/patterns/shell-foundation/example/server.js +32 -29
  53. package/patterns/shell-foundation/example/tests/server/smoke.test.js +2 -1
  54. package/reference/autogen/KERNEL_MAP.md +14 -8
  55. package/reference/autogen/PATTERN_INDEX.md +37 -37
  56. package/reference/autogen/README.md +2 -0
  57. package/reference/autogen/packages/agent-docs.md +70 -26
  58. package/reference/autogen/packages/agent-runtime.md +129 -0
  59. package/reference/autogen/packages/agent.md +149 -0
  60. package/reference/autogen/packages/architecture-inspector.md +97 -44
  61. package/reference/autogen/packages/assistant-core.md +786 -292
  62. package/reference/autogen/packages/assistant-runtime.md +182 -57
  63. package/reference/autogen/packages/assistant-voice-sherpa.md +4 -0
  64. package/reference/autogen/packages/assistant-voice.md +54 -8
  65. package/reference/autogen/packages/auth-core.md +44 -13
  66. package/reference/autogen/packages/auth-provider-local-core.md +86 -34
  67. package/reference/autogen/packages/auth-provider-local-db-core.md +1 -2
  68. package/reference/autogen/packages/auth-provider-oidc-core.md +10 -4
  69. package/reference/autogen/packages/auth-provider-supabase-core.md +52 -66
  70. package/reference/autogen/packages/auth-web.md +19 -11
  71. package/reference/autogen/packages/connectors-catalog.md +71 -43
  72. package/reference/autogen/packages/connectors-core.md +42 -4
  73. package/reference/autogen/packages/console-core.md +27 -14
  74. package/reference/autogen/packages/crud-core.md +178 -170
  75. package/reference/autogen/packages/database-runtime-mysql.md +0 -2
  76. package/reference/autogen/packages/database-runtime-postgres.md +0 -2
  77. package/reference/autogen/packages/database-runtime.md +39 -10
  78. package/reference/autogen/packages/http-runtime.md +79 -57
  79. package/reference/autogen/packages/json-rest-api-core.md +11 -8
  80. package/reference/autogen/packages/kernel.md +144 -83
  81. package/reference/autogen/packages/oidc-issuer-core.md +49 -20
  82. package/reference/autogen/packages/payments-core.md +20 -3
  83. package/reference/autogen/packages/realtime.md +47 -22
  84. package/reference/autogen/packages/resource-core.md +1 -1
  85. package/reference/autogen/packages/resource-crud-core.md +64 -26
  86. package/reference/autogen/packages/rewarded-core.md +47 -36
  87. package/reference/autogen/packages/shell-web.md +7 -10
  88. package/reference/autogen/packages/storage-runtime.md +6 -2
  89. package/reference/autogen/packages/uploads-runtime.md +10 -2
  90. package/reference/autogen/packages/users-core.md +73 -71
  91. package/reference/autogen/packages/workspaces-core.md +121 -106
  92. package/reference/autogen/packages/workspaces-web.md +1 -2
  93. package/reference/autogen/tooling/config-eslint.md +302 -0
  94. package/reference/autogen/tooling/jskit-catalog.md +28 -18
  95. package/reference/autogen/tooling/jskit-release.md +35 -20
  96. package/reference/autogen/tooling/testUtils.md +3 -1
  97. package/skills/jskit/SKILL.md +3 -2
  98. package/skills/jskit/references/app-operations.md +1 -1
  99. package/skills/jskit/references/client-features.md +491 -0
  100. package/skills/jskit/references/crud-form-actions.md +1 -1
  101. package/skills/jskit/references/crud-operations.md +7 -7
  102. package/skills/jskit/references/existing-application-migration.md +31 -27
  103. package/skills/jskit/references/heuristics/INDEX.md +5 -1
  104. package/skills/jskit/references/heuristics/child-cruds.md +1 -1
  105. package/skills/jskit/references/heuristics/client-features.md +66 -0
  106. package/skills/jskit/references/heuristics/client-requests.md +1 -1
  107. package/skills/jskit/references/heuristics/crud-authoring.md +12 -2
  108. package/skills/jskit/references/heuristics/crud-links.md +1 -1
  109. package/skills/jskit/references/heuristics/crud-repository-mapping.md +3 -3
  110. package/skills/jskit/references/heuristics/filters.md +1 -1
  111. package/skills/jskit/references/heuristics/live-actions.md +1 -1
  112. package/skills/jskit/references/heuristics/page-redirects.md +1 -1
  113. package/skills/jskit/references/heuristics/page-scaffolding.md +1 -1
  114. package/skills/jskit/references/heuristics/placements.md +1 -1
  115. package/skills/jskit/references/heuristics/row-policies.md +1 -1
  116. package/skills/jskit/references/heuristics/server-search.md +1 -1
  117. package/skills/jskit/references/heuristics/surfaces.md +1 -1
  118. package/skills/jskit/references/heuristics/typed-features.md +100 -0
  119. package/skills/jskit/references/heuristics/ui-contract.md +1 -1
  120. package/skills/jskit/references/heuristics/ui-testing.md +4 -4
  121. package/skills/jskit/references/material-3.md +2 -2
  122. package/skills/jskit/references/multi-homing.md +96 -50
  123. package/skills/jskit/references/pattern-index.md +37 -37
  124. package/skills/jskit/references/patterns/app/minimal-foundation/PATTERN.md +30 -1
  125. package/skills/jskit/references/patterns/app/minimal-foundation/example/AGENTS.md +14 -0
  126. package/skills/jskit/references/patterns/app/minimal-foundation/example/bin/develop.js +10 -5
  127. package/skills/jskit/references/patterns/app/minimal-foundation/example/eslint.config.mjs +21 -2
  128. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +5 -4
  129. package/skills/jskit/references/patterns/app/minimal-foundation/example/playwright.config.mjs +1 -1
  130. package/skills/jskit/references/patterns/app/minimal-foundation/example/server/lib/envFile.js +19 -0
  131. package/skills/jskit/references/patterns/app/minimal-foundation/example/server/lib/loggerOptions.js +15 -0
  132. package/skills/jskit/references/patterns/app/minimal-foundation/example/server/lib/runtimeEnv.js +17 -17
  133. package/skills/jskit/references/patterns/app/minimal-foundation/example/server.js +32 -29
  134. package/skills/jskit/references/patterns/app/minimal-foundation/example/tests/server/smoke.test.js +2 -1
  135. package/skills/jskit/references/patterns/app/shell-foundation/PATTERN.md +29 -0
  136. package/skills/jskit/references/patterns/app/shell-foundation/example/AGENTS.md +14 -0
  137. package/skills/jskit/references/patterns/app/shell-foundation/example/bin/develop.js +10 -5
  138. package/skills/jskit/references/patterns/app/shell-foundation/example/eslint.config.mjs +21 -2
  139. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +6 -5
  140. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  141. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/src/client/providers/MainClientProvider.js +1 -0
  142. package/skills/jskit/references/patterns/app/shell-foundation/example/playwright.config.mjs +1 -1
  143. package/skills/jskit/references/patterns/app/shell-foundation/example/server/lib/envFile.js +19 -0
  144. package/skills/jskit/references/patterns/app/shell-foundation/example/server/lib/loggerOptions.js +15 -0
  145. package/skills/jskit/references/patterns/app/shell-foundation/example/server/lib/runtimeEnv.js +17 -17
  146. package/skills/jskit/references/patterns/app/shell-foundation/example/server.js +32 -29
  147. package/skills/jskit/references/patterns/app/shell-foundation/example/tests/server/smoke.test.js +2 -1
  148. package/skills/jskit/references/patterns/assistant/assistant-surface/example/src/ApplicationAiFeature.js +4 -2
  149. package/skills/jskit/references/patterns/auth/accounts-hub/PATTERN.md +2 -1
  150. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +2 -2
  151. package/skills/jskit/references/patterns/auth/accounts-hub/example/server/hubPaths.js +9 -3
  152. package/skills/jskit/references/patterns/auth/auth-surface/PATTERN.md +25 -12
  153. package/skills/jskit/references/patterns/auth/auth-surface/example/tools/preview-identity +7 -1
  154. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  155. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  156. package/skills/jskit/references/patterns/connectors/ai-connections/PATTERN.md +16 -1
  157. package/skills/jskit/references/patterns/connectors/ai-connections/example/ai-model.js +12 -3
  158. package/skills/jskit/references/patterns/connectors/ai-connections/example/perplexity-answer.js +15 -4
  159. package/skills/jskit/references/patterns/connectors/api-key-connection/PATTERN.md +9 -1
  160. package/skills/jskit/references/patterns/connectors/api-key-connection/example/connections.js +5 -2
  161. package/skills/jskit/references/patterns/connectors/aws-storage-queries/PATTERN.md +13 -3
  162. package/skills/jskit/references/patterns/connectors/aws-storage-queries/example/s3-transfer.js +14 -3
  163. package/skills/jskit/references/patterns/connectors/calendar-cli/PATTERN.md +8 -0
  164. package/skills/jskit/references/patterns/connectors/calendar-cli/example/knexfile.js +1 -1
  165. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +4 -4
  166. package/skills/jskit/references/patterns/connectors/calendar-cli/example/scripts/calendar.js +8 -4
  167. package/skills/jskit/references/patterns/connectors/event-delivery/PATTERN.md +1 -1
  168. package/skills/jskit/references/patterns/connectors/firebase-messaging/PATTERN.md +10 -0
  169. package/skills/jskit/references/patterns/connectors/firebase-messaging/example/server/notifications.js +8 -0
  170. package/skills/jskit/references/patterns/connectors/google-ads-search/PATTERN.md +18 -7
  171. package/skills/jskit/references/patterns/connectors/google-ads-search/example/ads-setup.js +13 -5
  172. package/skills/jskit/references/patterns/connectors/oauth-connection/PATTERN.md +1 -1
  173. package/skills/jskit/references/patterns/connectors/paddle-catalogue/PATTERN.md +11 -2
  174. package/skills/jskit/references/patterns/connectors/paddle-catalogue/example/create-products.js +5 -2
  175. package/skills/jskit/references/patterns/connectors/public-image/PATTERN.md +10 -1
  176. package/skills/jskit/references/patterns/connectors/public-image/example/logo-url.js +4 -1
  177. package/skills/jskit/references/patterns/connectors/redshift-queries/PATTERN.md +1 -1
  178. package/skills/jskit/references/patterns/connectors/source-scanning/PATTERN.md +13 -2
  179. package/skills/jskit/references/patterns/connectors/source-scanning/example/source-scanner.js +9 -0
  180. package/skills/jskit/references/patterns/crud/json-api-resource-package/PATTERN.md +102 -23
  181. package/skills/jskit/references/patterns/crud/json-api-resource-package/example/packages/books/package.json +3 -2
  182. package/skills/jskit/references/patterns/crud/json-api-resource-package/example/packages/books/src/server/types.js +5 -0
  183. package/skills/jskit/references/patterns/crud/resource-contract/PATTERN.md +54 -1
  184. package/skills/jskit/references/patterns/database/mysql-application/PATTERN.md +16 -5
  185. package/skills/jskit/references/patterns/database/mysql-application/example/knexfile.js +2 -2
  186. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +1 -1
  187. package/skills/jskit/references/patterns/database/mysql-application/example/scripts/prepare-database.js +1 -1
  188. package/skills/jskit/references/patterns/database/postgres-application/PATTERN.md +16 -5
  189. package/skills/jskit/references/patterns/database/postgres-application/example/knexfile.js +2 -2
  190. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +1 -1
  191. package/skills/jskit/references/patterns/database/postgres-application/example/scripts/prepare-database.js +1 -1
  192. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  193. package/skills/jskit/references/patterns/rewards/google-rewarded/example/GoogleRewardedDeliveryProvider.js +1 -1
  194. package/skills/jskit/references/patterns/rewards/google-rewarded/example/googlePublisherTag.js +5 -11
  195. package/skills/jskit/references/patterns/server/feature-package/PATTERN.md +104 -10
  196. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +9 -4
  197. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/BookingEngineFeature.js +24 -0
  198. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/bookingAvailability.js +10 -0
  199. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/bookingEngine.js +29 -0
  200. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/bookingEngineActions.js +26 -0
  201. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/inputSchemas.js +1 -2
  202. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/types.js +12 -0
  203. package/skills/jskit/references/patterns/server/feature-package/example/variations/AvailabilityEngineFeature.js +19 -0
  204. package/skills/jskit/references/patterns/server/feature-package/example/variations/InvoiceRollupFeature.js +23 -0
  205. package/skills/jskit/references/patterns/server/feature-package/example/variations/availabilityEngineActions.js +26 -0
  206. package/skills/jskit/references/patterns/server/feature-package/example/variations/customKnexRepository.js +32 -26
  207. package/skills/jskit/references/patterns/server/feature-package/example/variations/invoiceRollupActions.js +26 -0
  208. package/skills/jskit/references/patterns/server/feature-package/example/variations/orchestratorService.js +24 -19
  209. package/skills/jskit/references/patterns/server/feature-package/example/variations/types.js +7 -0
  210. package/skills/jskit/references/patterns/users/user-administration-server/PATTERN.md +16 -1
  211. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -2
  212. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/src/server/types.js +5 -0
  213. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +4 -3
  214. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/src/server/UsersWorkspaceFeature.js +2 -9
  215. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/src/server/types.js +5 -0
  216. package/skills/jskit/references/patterns/workspaces/workspace-server/PATTERN.md +42 -17
  217. package/skills/jskit/references/patterns/workspaces/workspace-server/example/packages/main/src/server/WorkspaceInvitationsFeature.js +27 -0
  218. package/skills/jskit/references/patterns/workspaces/workspace-server/example/packages/main/src/server/email/workspaceInviteEmail.js +11 -10
  219. package/skills/jskit/references/patterns/workspaces/workspace-server/example/packages/main/src/server/email/workspaceInviteMailer.js +27 -0
  220. package/skills/jskit/references/translation.md +5 -4
  221. package/skills/jskit/references/typed-features.md +1099 -0
  222. package/skills/jskit/references/ui-operations.md +3 -3
  223. package/patterns/feature-package/example/booking-engine/src/server/BookingEngineProvider.js +0 -33
  224. package/patterns/feature-package/example/booking-engine/src/server/actions.js +0 -24
  225. package/patterns/feature-package/example/variations/AvailabilityEngineProvider.js +0 -31
  226. package/patterns/feature-package/example/variations/InvoiceRollupProvider.js +0 -36
  227. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/BookingEngineProvider.js +0 -33
  228. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/src/server/actions.js +0 -24
  229. package/skills/jskit/references/patterns/server/feature-package/example/variations/AvailabilityEngineProvider.js +0 -31
  230. package/skills/jskit/references/patterns/server/feature-package/example/variations/InvoiceRollupProvider.js +0 -36
@@ -24,8 +24,8 @@ Choose workspace creation policy, roles, invitation policy, expiry, email copy,
24
24
  member permissions, personal-workspace behavior, and surface access rules.
25
25
 
26
26
  In `workspaces` mode, `tenancyPolicy.workspace.autoProvision: true` gives every
27
- user a personal workspace in addition to shared ones; the server config function
28
- `personalWorkspaceName(user)` names it. `workspaceSettings.defaults` sets
27
+ user a personal workspace in addition to shared ones; the optional
28
+ `workspaces.personal-workspace-name` capability, a function of the user, names it. `workspaceSettings.defaults` sets
29
29
  `invitesEnabled` and the colours (`lightPrimaryColor`, `darkPrimaryColor` and
30
30
  the other palette fields) that new workspaces start with.
31
31
 
@@ -63,16 +63,16 @@ catalogue entries. Updating labels requires no database migration.
63
63
 
64
64
  ## Transactional invitation participation
65
65
 
66
- Through `workspaces.core`, register one callback during feature setup with
67
- `workspaces.services.pendingInvitations.registerAcceptanceParticipant(fn)`.
68
- The built-in `workspace.invite.redeem` action invokes
69
- `fn({ invite, user }, { trx, context })` after validating the recipient, state and
70
- expiry and activating membership in the uncommitted transaction. Forward `trx`
71
- to every application owner and propagate failures. JSKIT marks accepted and
72
- commits after the callback succeeds. Keep external effects out of the callback.
73
- Registration rejects non-functions, duplicates and calls after acceptance/refusal
74
- begins. Allow ordinary invitations; reject stale, revoked, conflicting or
75
- unexpectedly missing application associations.
66
+ Provide one function as the optional `workspaces.invite-acceptance-participant`
67
+ capability, from a small application feature that requires only what its writes
68
+ need (it cannot require `workspaces.core`, which receives it). The built-in
69
+ `workspace.invite.redeem` action invokes `fn({ invite, user }, { trx, context })`
70
+ after validating the recipient, state and expiry and activating membership in the
71
+ uncommitted transaction. Forward `trx` to every application owner and propagate
72
+ failures. JSKIT marks accepted and commits after the function succeeds. Keep
73
+ external effects out of it. Without the capability, acceptance activates the
74
+ membership only. Allow ordinary invitations; reject stale, revoked, conflicting
75
+ or unexpectedly missing application associations.
76
76
 
77
77
  Use `members.prepareInvite(workspace, actor,
78
78
  payload, { trx, context })` in `repositories.workspaceInvites.withTransaction`
@@ -91,8 +91,8 @@ exception, or the normalized mailer result. Persistence is unchanged by delivery
91
91
  failure. A provider may accept a message before failing; the application owns
92
92
  receipts and retries. Keep tokens/URLs out of logs and use controlled mailers in tests.
93
93
 
94
- `createInvite`, acceptance and refusal now own managed transactions and reject
95
- borrowed `options.trx`. Use preparation followed by delivery after commit for
94
+ `createInvite`, acceptance and refusal own their managed transactions and
95
+ reject a borrowed `options.trx`. Use preparation followed by delivery after commit for
96
96
  transactional creation; put related acceptance writes in the participant. Revocation may join
97
97
  a managed transaction. Raw Knex/savepoint transactions cannot own resource
98
98
  writes. Invitation mutations lock workspace then invitation rows, revalidate
@@ -115,9 +115,34 @@ authorization, identity/training linking, scope eligibility and required audit.
115
115
 
116
116
  ## Example files
117
117
 
118
- `example/config/roles.js` is a concrete role catalogue.
119
- `example/packages/main/src/server/email/workspaceInviteEmail.js` demonstrates an
120
- app-owned invitation renderer. Compose both through normal application config.
118
+ `example/config/roles.js` is a concrete role catalogue, set as the
119
+ application's `roleCatalog` config.
120
+
121
+ The invitation email comes from two optional `workspaces.core` capabilities,
122
+ which one small application feature provides:
123
+ `example/packages/main/src/server/WorkspaceInvitationsFeature.js`.
124
+
125
+ ```js
126
+ provides: {
127
+ inviteEmailTemplate: "workspaces.invite-email-template",
128
+ inviteMailer: "workspaces.invite-mailer"
129
+ },
130
+ setup({ env }) {
131
+ return {
132
+ inviteEmailTemplate: renderWorkspaceInviteEmail,
133
+ inviteMailer: createWorkspaceInviteMailer({ env })
134
+ };
135
+ }
136
+ ```
137
+
138
+ - `email/workspaceInviteEmail.js` is the renderer, a
139
+ `WorkspaceInviteEmailTemplate` returning `{ subject, text, html }`.
140
+ - `email/workspaceInviteMailer.js` is the mailer, a `WorkspaceInviteMailer`
141
+ whose `sendWorkspaceInvite` sends the rendered message over SMTP.
142
+
143
+ Without a renderer, workspaces-core uses its built-in email; without a mailer,
144
+ invitations are created and their delivery reports `mailer_unconfigured`. The
145
+ feature must not require `workspaces.core`, which receives both.
121
146
 
122
147
  ## Variation points
123
148
 
@@ -0,0 +1,27 @@
1
+ import { defineFeature } from "@jskit-ai/kernel/server/features";
2
+ import { renderWorkspaceInviteEmail } from "./email/workspaceInviteEmail.js";
3
+ import { createWorkspaceInviteMailer } from "./email/workspaceInviteMailer.js";
4
+
5
+ /**
6
+ * The application's invitation email: the renderer and the mailer that sends
7
+ * it, each filling one of workspaces-core's optional tokens.
8
+ */
9
+ const WorkspaceInvitationsFeature = defineFeature({
10
+ id: "main.workspace-invitations",
11
+ requires: {
12
+ env: "runtime.env"
13
+ },
14
+ provides: {
15
+ inviteEmailTemplate: "workspaces.invite-email-template",
16
+ inviteMailer: "workspaces.invite-mailer"
17
+ },
18
+ /** @param {{ env: import("@jskit-ai/kernel/server/types").RuntimeEnv }} capabilities */
19
+ setup({ env }) {
20
+ return {
21
+ inviteEmailTemplate: renderWorkspaceInviteEmail,
22
+ inviteMailer: createWorkspaceInviteMailer({ env })
23
+ };
24
+ }
25
+ });
26
+
27
+ export { WorkspaceInvitationsFeature };
@@ -1,13 +1,14 @@
1
- function renderWorkspaceInviteEmail({
2
- inviteUrl = "",
3
- workspace = {},
4
- inviter = null,
5
- roleSid = "member",
6
- expiresAt = ""
7
- } = {}) {
8
- const workspaceName = String(workspace?.name || workspace?.slug || "the workspace").trim() || "the workspace";
9
- const inviterName = String(inviter?.displayName || inviter?.email || "").trim();
10
- const roleName = String(roleSid || "member").trim() || "member";
1
+ /**
2
+ * The application's invitation email, provided as
3
+ * `workspaces.invite-email-template`. workspaces-core passes every field; the
4
+ * inviter is null when no one is signed in, and `roleLabel` is present only
5
+ * when the role catalogue names the role.
6
+ * @type {import("@jskit-ai/workspaces-core/server/types").WorkspaceInviteEmailTemplate}
7
+ */
8
+ function renderWorkspaceInviteEmail({ inviteUrl, workspace, inviter, roleSid, roleLabel, expiresAt }) {
9
+ const workspaceName = workspace.name || workspace.slug;
10
+ const inviterName = inviter?.displayName || inviter?.email || "";
11
+ const roleName = roleLabel || roleSid;
11
12
  const intro = inviterName
12
13
  ? `${inviterName} invited you to join ${workspaceName} as ${roleName}.`
13
14
  : `You have been invited to join ${workspaceName} as ${roleName}.`;
@@ -0,0 +1,27 @@
1
+ import nodemailer from "nodemailer";
2
+
3
+ /**
4
+ * The application's `workspaces.invite-mailer`: sends each rendered
5
+ * invitation through the SMTP server `SMTP_URL` names, from `MAIL_FROM`.
6
+ * @param {object} dependencies
7
+ * @param {import("@jskit-ai/kernel/server/types").RuntimeEnv} dependencies.env
8
+ * @returns {import("@jskit-ai/workspaces-core/server/types").WorkspaceInviteMailer}
9
+ */
10
+ function createWorkspaceInviteMailer({ env }) {
11
+ const transport = nodemailer.createTransport(env.SMTP_URL);
12
+
13
+ async function sendWorkspaceInvite({ email, message }) {
14
+ const sent = await transport.sendMail({
15
+ from: env.MAIL_FROM,
16
+ to: email,
17
+ subject: message.subject,
18
+ text: message.text,
19
+ ...(message.html ? { html: message.html } : {})
20
+ });
21
+ return { status: "sent", providerMessageId: sent.messageId };
22
+ }
23
+
24
+ return Object.freeze({ sendWorkspaceInvite });
25
+ }
26
+
27
+ export { createWorkspaceInviteMailer };
@@ -1,4 +1,4 @@
1
- <!-- Generated from `packages/agent-docs/site/guide/framework/translation.md` by `npm run agent-docs:build`. -->
1
+ <!-- Generated from `packages/agent-docs/site/guide/framework/translation.md`. -->
2
2
 
3
3
  # Translating a JSKIT app
4
4
 
@@ -140,9 +140,10 @@ the English `message`:
140
140
  `messageParams` for the exact sentence.
141
141
 
142
142
  The client translates a code only when the English the server sent is JSKIT's
143
- English for that code. An app's own sentence under a shared code (for example
144
- `throw new NotFoundError("Contact not found.")`) is shown exactly as written, and
145
- so is any text whose code has no catalog entry.
143
+ English for that code. An app's own sentence under JSKIT's shared code is shown
144
+ exactly as written, and so is any text whose code has no catalog entry. That is
145
+ why each refusal an app throws
146
+ [carries its own code](typed-features.md#refusals-carry-their-own-code).
146
147
 
147
148
  App code that shows errors uses the same helper JSKIT's components use:
148
149