@wickermoney/plugin-sdk 0.4.1 → 0.5.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.
Files changed (83) hide show
  1. package/README.md +124 -8
  2. package/dist/index.d.ts +11 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +10 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/manifest/PERMISSIONS.d.ts +3 -0
  7. package/dist/manifest/PERMISSIONS.d.ts.map +1 -1
  8. package/dist/manifest/PERMISSIONS.js +3 -0
  9. package/dist/manifest/PERMISSIONS.js.map +1 -1
  10. package/dist/manifest/checkRemoteEntry.d.ts +2 -1
  11. package/dist/manifest/checkRemoteEntry.d.ts.map +1 -1
  12. package/dist/manifest/checkRemoteEntry.js +2 -1
  13. package/dist/manifest/checkRemoteEntry.js.map +1 -1
  14. package/dist/manifest/pluginManifestSchema.d.ts.map +1 -1
  15. package/dist/manifest/pluginManifestSchema.js +12 -1
  16. package/dist/manifest/pluginManifestSchema.js.map +1 -1
  17. package/dist/manifest/tableGrantSchema.d.ts +6 -1
  18. package/dist/manifest/tableGrantSchema.d.ts.map +1 -1
  19. package/dist/manifest/tableGrantSchema.js +6 -1
  20. package/dist/manifest/tableGrantSchema.js.map +1 -1
  21. package/dist/money/index.d.ts +4 -0
  22. package/dist/money/index.d.ts.map +1 -1
  23. package/dist/money/index.js.map +1 -1
  24. package/dist/recurrence/calendar.d.ts +30 -2
  25. package/dist/recurrence/calendar.d.ts.map +1 -1
  26. package/dist/recurrence/calendar.js +42 -3
  27. package/dist/recurrence/calendar.js.map +1 -1
  28. package/dist/recurrence/index.d.ts +8 -0
  29. package/dist/recurrence/index.d.ts.map +1 -1
  30. package/dist/recurrence/index.js +8 -0
  31. package/dist/recurrence/index.js.map +1 -1
  32. package/dist/runtime.d.ts +22 -3
  33. package/dist/runtime.d.ts.map +1 -1
  34. package/dist/runtime.js.map +1 -1
  35. package/dist/server/ConditionForMatching.d.ts +18 -0
  36. package/dist/server/ConditionForMatching.d.ts.map +1 -0
  37. package/dist/server/ConditionForMatching.js +2 -0
  38. package/dist/server/ConditionForMatching.js.map +1 -0
  39. package/dist/server/PluginRouteError.d.ts +27 -0
  40. package/dist/server/PluginRouteError.d.ts.map +1 -0
  41. package/dist/server/PluginRouteError.js +32 -0
  42. package/dist/server/PluginRouteError.js.map +1 -0
  43. package/dist/server/PluginRouteIssue.d.ts +8 -0
  44. package/dist/server/PluginRouteIssue.d.ts.map +1 -0
  45. package/dist/server/PluginRouteIssue.js +2 -0
  46. package/dist/server/PluginRouteIssue.js.map +1 -0
  47. package/dist/server/Query.d.ts +11 -0
  48. package/dist/server/Query.d.ts.map +1 -0
  49. package/dist/server/Query.js +2 -0
  50. package/dist/server/Query.js.map +1 -0
  51. package/dist/server/RegisterRoute.d.ts +19 -0
  52. package/dist/server/RegisterRoute.d.ts.map +1 -0
  53. package/dist/server/RegisterRoute.js +2 -0
  54. package/dist/server/RegisterRoute.js.map +1 -0
  55. package/dist/server/RouteContext.d.ts +12 -0
  56. package/dist/server/RouteContext.d.ts.map +1 -0
  57. package/dist/server/RouteContext.js +2 -0
  58. package/dist/server/RouteContext.js.map +1 -0
  59. package/dist/server/RouteMethod.d.ts +3 -0
  60. package/dist/server/RouteMethod.d.ts.map +1 -0
  61. package/dist/server/RouteMethod.js +2 -0
  62. package/dist/server/RouteMethod.js.map +1 -0
  63. package/dist/server/RuleForMatching.d.ts +16 -0
  64. package/dist/server/RuleForMatching.d.ts.map +1 -0
  65. package/dist/server/RuleForMatching.js +2 -0
  66. package/dist/server/RuleForMatching.js.map +1 -0
  67. package/dist/server/RuleSubject.d.ts +10 -0
  68. package/dist/server/RuleSubject.d.ts.map +1 -0
  69. package/dist/server/RuleSubject.js +2 -0
  70. package/dist/server/RuleSubject.js.map +1 -0
  71. package/dist/server/RunAsPlugin.d.ts +9 -0
  72. package/dist/server/RunAsPlugin.d.ts.map +1 -0
  73. package/dist/server/RunAsPlugin.js +2 -0
  74. package/dist/server/RunAsPlugin.js.map +1 -0
  75. package/dist/server/index.d.ts +30 -0
  76. package/dist/server/index.d.ts.map +1 -0
  77. package/dist/server/index.js +3 -0
  78. package/dist/server/index.js.map +1 -0
  79. package/dist/server/isUuid.d.ts +18 -0
  80. package/dist/server/isUuid.d.ts.map +1 -0
  81. package/dist/server/isUuid.js +26 -0
  82. package/dist/server/isUuid.js.map +1 -0
  83. package/package.json +5 -1
package/README.md CHANGED
@@ -28,14 +28,49 @@ plugin as a Module Federation singleton.
28
28
  | Import | Use it for | Contents |
29
29
  |---|---|---|
30
30
  | `@wickermoney/plugin-sdk/runtime` | Plugin UI code (browser) | Types for the React components a plugin exports (`PluginWidgetProps`, `PluginPageProps`, `PluginContext`, ...), and `adoptPluginStyles` |
31
- | `@wickermoney/plugin-sdk/recurrence` | Anything (browser or Node) | Recurring-item date maths and projections: `occurrences`, `nextOccurrence`, `scheduledOccurrences`, `nextScheduledOccurrence`, `nextPayday`, `monthlyEquivalent`, `dailyBalances`, `flowTotals`, with per-occurrence overrides (skip, move, change the legs) |
31
+ | `@wickermoney/plugin-sdk/recurrence` | Anything (browser or Node) | Recurring-item date maths and projections: `occurrences`, `nextOccurrence`, `scheduledOccurrences`, `nextScheduledOccurrence`, `nextPayday`, `monthlyEquivalent`, `dailyBalances`, `flowTotals`, the calendar helpers `addDays` and `addMonths`, with per-occurrence overrides (skip, move, change the legs) |
32
32
  | `@wickermoney/plugin-sdk/money` | Anything (browser or Node) | Exact money arithmetic on decimal strings: `addMoney`, `sumMoney`, `compareMoney`, `equalMoney`, `moneyToUnits`, `divideUnits`, ... |
33
+ | `@wickermoney/plugin-sdk/server` | Bundled plugins' server code, and the host (Node) | The server-side contract: `RouteContext`, `RegisterRoute`, `Query`, `RunAsPlugin`, `PluginRouteError`, `isUuid`, and the category-rule types `RuleForMatching` and `RuleSubject` |
33
34
  | `@wickermoney/plugin-sdk` | Hosts, tooling, tests (Node) | Everything above, plus the Zod manifest schemas, `parseManifest`, dashboard-range helpers and constants |
34
35
 
35
- Import from `/runtime` (and `/money` or `/recurrence` if you need them) in plugin UI code.
36
+ Import from `/runtime` (and `/money` or `/recurrence` if you need them) in plugin UI code,
37
+ and from `/server` in a bundled plugin's server code.
36
38
  The package root re-exports the Zod manifest schemas, which add about 85 kB to
37
39
  a plugin bundle that never uses them.
38
40
 
41
+ ## Stability
42
+
43
+ Every entry point has a tier. The tier is also written in each entry point's
44
+ module documentation (`@stable` or `@experimental`).
45
+
46
+ | Import | Tier | What it is for | Who uses it today |
47
+ |---|---|---|---|
48
+ | `@wickermoney/plugin-sdk` (root: manifest, dashboard range) | stable | Manifest schema and `parseManifest`, `SDK_MAJOR_VERSION`, remote-entry checks, and the dashboard range helpers | The API and the web app (manifest, range); the Insights and Spending Trends plugins (`monthsInRange`); several plugins import the `PluginContext` and props types from here |
49
+ | `@wickermoney/plugin-sdk/runtime` | stable | The props and context the host hands a plugin's React components, plus `adoptPluginStyles` | The web app and all six bundled UI plugins |
50
+ | `@wickermoney/plugin-sdk/money` | stable | Exact money arithmetic on decimal strings | The web app, the Budgets, Insights and Spending Trends plugins, and the API's tests |
51
+ | `@wickermoney/plugin-sdk/server` | stable | The server-side contract between the host and a bundled plugin's `register` function | The API, Budgets and Import CSV |
52
+ | `@wickermoney/plugin-sdk/recurrence` | experimental | Recurring-item date maths and projections, and the `addDays` and `addMonths` calendar helpers | The API and the web app; Budgets uses `addDays`. No plugin uses the projections yet |
53
+
54
+ The root also re-exports the `/recurrence`, `/money` and `/server` exports. An
55
+ export keeps the tier of the entry point it comes from, however it is
56
+ imported, so `occurrences` is experimental even when imported from the root.
57
+
58
+ What the tiers promise:
59
+
60
+ - **Stable.** A breaking change (a removed or renamed export, a changed
61
+ signature or type, a changed return value or error) is made only with a
62
+ `BREAKING CHANGE:` footer on the commit, an entry under **Breaking** in the
63
+ [CHANGELOG](../../CHANGELOG.md), and a migration note saying what to write
64
+ instead. Additions are not breaking.
65
+ - **Experimental.** May change in any pre-1.0 minor release, including
66
+ removals and renamed or reshaped types. Changes are still recorded in the
67
+ CHANGELOG, but no migration note is promised. Re-check it on each upgrade.
68
+
69
+ Both tiers are covered by the same rule as the rest of the package: until
70
+ `SDK_MAJOR_VERSION` is frozen at 1, the whole contract can still move between
71
+ minor releases. The tiers say how much notice to expect and which parts are
72
+ settled.
73
+
39
74
  ## Recurring items
40
75
 
41
76
  `/recurrence` is pure and dependency-free: calendar dates in and out as
@@ -76,6 +111,21 @@ scheduledOccurrences(bills, '2026-03-01', '2026-06-01')
76
111
  // [{ nominalDate: '2026-04-30', date: '2026-05-01', legs }, { nominalDate: '2026-05-31', ... }]
77
112
  ```
78
113
 
114
+ The calendar helpers work on the same `YYYY-MM-DD` strings, with no time zone
115
+ involved. `addMonths` clamps to the end of a short month, and each call clamps
116
+ on its own, so add the total to the original date rather than stepping.
117
+
118
+ ```ts
119
+ import { addDays, addMonths } from '@wickermoney/plugin-sdk/recurrence'
120
+
121
+ addDays('2026-12-31', 1) // '2027-01-01'
122
+ addMonths('2026-08-31', 6) // '2027-02-28' ('2028-02-29' in a leap year)
123
+ addMonths('2026-03-31', -1) // '2026-02-28'
124
+ ```
125
+
126
+ Both throw `RangeError` for anything that is not a real calendar date or not
127
+ a whole number.
128
+
79
129
  ## Money
80
130
 
81
131
  Money is `numeric(19,4)` in the database and a decimal string in TypeScript,
@@ -147,9 +197,13 @@ const result = parseManifest({
147
197
  if ('error' in result) throw new Error(result.error)
148
198
  ```
149
199
 
150
- `requiredTables` is enforced by PostgreSQL, not only by the app. Each plugin
151
- runs under its own database role, which is granted exactly the tables its
152
- manifest lists. A query against any other table is refused.
200
+ `requiredTables` is enforced by PostgreSQL for a plugin's **server-side** code.
201
+ Each bundled plugin's server code runs under its own database role, which is
202
+ granted exactly the tables its manifest lists. A query against any other table
203
+ is refused.
204
+
205
+ It is **not** enforced against your plugin's UI code. See
206
+ [Trust model](#trust-model) below.
153
207
 
154
208
  ### Widget
155
209
 
@@ -157,8 +211,9 @@ manifest lists. A query against any other table is refused.
157
211
  import type { PluginWidgetProps } from '@wickermoney/plugin-sdk/runtime'
158
212
 
159
213
  export default function RunwayWidget({ ctx, size, range }: PluginWidgetProps) {
160
- // ctx.api is scoped to your plugin and the tables your manifest grants;
161
- // the host attaches credentials, so the plugin never sees a token.
214
+ // ctx.api is scoped to your plugin and the tables your manifest grants
215
+ // (a convenience that catches mistakes early, not a sandbox); the host
216
+ // attaches credentials, so well-behaved plugin code never handles a token.
162
217
  // Paths are relative to the API root; don't prefix /api/v1 yourself.
163
218
  // ...
164
219
  return <p>{ctx.formatMoney('1234.5600')}</p>
@@ -187,11 +242,72 @@ Money crosses the contract as a **decimal string**, never a JavaScript
187
242
  This is not a style sandbox. Scope your selectors under a class your plugin
188
243
  owns.
189
244
 
245
+ ## Trust model
246
+
247
+ UI plugins (widgets and pages loaded over Module Federation) run **fully
248
+ trusted, in the host application's origin**. They share the page, its memory and
249
+ the signed-in user's session with the host. The host's scoped client, the
250
+ `x-wickermoney-plugin` header and the manifest check in `ctx.api` are
251
+ developer feedback, not a security boundary: UI code that wants to can call any
252
+ `/api/v1/*` route as the user, including routes outside its `requiredTables`.
253
+
254
+ What is enforced against plugin code is the per-plugin PostgreSQL role, and only
255
+ for server-side code (`contributes.endpoints`, bundled plugins only).
256
+
257
+ So today:
258
+
259
+ - Third-party plugin install is not supported. Treat every UI plugin as code
260
+ with full access to the user's data, and only run plugins you wrote or have
261
+ reviewed.
262
+ - Operators should keep `PLUGIN_REMOTE_ORIGINS` empty unless they fully trust
263
+ every origin listed.
264
+ - Declare `requiredTables` honestly anyway. It is what the database enforces
265
+ for your server code, and the contract a future isolation model will rely on.
266
+
190
267
  ## Server-side code
191
268
 
192
269
  Only bundled plugins may contribute server endpoints (`contributes.endpoints`).
193
270
  The host has no sandbox for third-party server code yet. Third-party plugins are
194
- UI-only and use core endpoints through `ctx.api`.
271
+ UI-only and use core endpoints through `ctx.api`. Bundled plugins are trusted
272
+ as much as the API itself; the one thing that is enforced for them is the
273
+ database: every query runs under the plugin's own PostgreSQL role.
274
+
275
+ `/server` is the contract between the host and a bundled plugin's `register`
276
+ function. It is dependency-free (no Zod) and has no runtime cost beyond two
277
+ small values.
278
+
279
+ ```ts
280
+ import {
281
+ PluginRouteError, isUuid,
282
+ type RegisterRoute, type RunAsPlugin,
283
+ } from '@wickermoney/plugin-sdk/server'
284
+
285
+ export function registerRoutes(deps: { route: RegisterRoute; runAsPlugin: RunAsPlugin }): void {
286
+ deps.route('GET', '/things/:id', async ({ userId, params }) => {
287
+ if (!isUuid(params['id'])) throw new PluginRouteError('id must be a thing id.', 400, 'bad_id')
288
+ return deps.runAsPlugin(userId, (q) => q`SELECT id, name FROM things WHERE id = ${params['id']}`)
289
+ })
290
+ }
291
+ ```
292
+
293
+ - **`PluginRouteError(message, statusCode, code, issues?)`** is how a handler
294
+ refuses a request the person can fix. The host answers with that status and
295
+ code and shows `message`, so it must be safe to display. `issues` is a list
296
+ of `{ path, message }` so a form can show each problem by its field. Any
297
+ other thrown error is a bug: it is logged and answered with a generic 500.
298
+ The host recognises an error by its `statusCode` and `code`, so a subclass
299
+ (to add defaults or helpers) works too.
300
+ - **`isUuid(value)`** is the one UUID rule. It accepts the canonical
301
+ hyphenated form in either case with a valid RFC 9562 version (1 to 8) and
302
+ variant, plus the nil and max UUIDs. It refuses braces, `urn:uuid:`, missing
303
+ hyphens and anything that is not a string. Every id PostgreSQL generates
304
+ passes. Check ids with it before they reach a `uuid` column, which would
305
+ otherwise fail as a 500.
306
+ - **`RouteContext`**, **`RegisterRoute`**, **`Query`** and **`RunAsPlugin`**
307
+ are the request input, the route registrar, the tagged-template query runner
308
+ and the transaction wrapper the host provides.
309
+ - **`RuleForMatching`**, **`ConditionForMatching`** and **`RuleSubject`**
310
+ describe the category rules the host loads and matches on a plugin's behalf.
195
311
 
196
312
  ## Related
197
313
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @module
2
3
  * Public surface of the plugin SDK: the contract both the host and every
3
4
  * plugin implement.
4
5
  *
@@ -6,6 +7,13 @@
6
7
  * server; the runtime exports are React types for browser-side plugin code.
7
8
  * The two groups are kept apart so a Node process can import the manifest
8
9
  * exports without pulling in React.
10
+ *
11
+ * Stability: the manifest, runtime, range, money and server exports are
12
+ * `@stable`. The recurrence exports re-exported here are `@experimental`,
13
+ * exactly as they are from `@wickermoney/plugin-sdk/recurrence`: an export
14
+ * keeps the tier of the entry point it comes from, however it is imported.
15
+ *
16
+ * @stable
9
17
  */
10
18
  export { CORE_TABLES, checkRemoteEntry, remoteEntrySchema, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseManifest, pageContributionSchema, pluginManifestSchema, tableGrantSchema, widgetContributionSchema, } from './manifest/index.js';
11
19
  export type { CoreTableName, ManifestParseResult, PageContribution, Permission, PluginManifest, TableGrant, WidgetContribution, WidgetSize, WidgetSlot, } from './manifest/index.js';
@@ -13,8 +21,10 @@ export { adoptPluginStyles } from './runtime.js';
13
21
  export type { PluginApi, PluginContext, PluginModule, PluginPage, PluginPageProps, PluginSession, PluginWidget, PluginWidgetProps, } from './runtime.js';
14
22
  export { RANGE_KEYS, DEFAULT_RANGE_KEY, isRangeKey, rangeLabel, resolveRange, monthsInRange, } from './range.js';
15
23
  export type { DashboardRange, RangeKey } from './range.js';
16
- export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
24
+ export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, addDays, addMonths, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
17
25
  export type { DailyBalance, FlowTotals, OccurrenceOverride, RecurrenceFrequency, RecurrenceSchedule, RecurringItem, RecurringLeg, ScheduledOccurrence, } from './recurrence/index.js';
18
26
  export { MONEY_SCALE, MONEY_UNIT, ZERO_MONEY, absMoney, addMoney, compareMoney, divideUnits, editableMoney, equalMoney, isNegativeMoney, isZeroMoney, moneyToUnits, negateMoney, normalizeMoney, subtractMoney, sumMoney, unitsToMoney, } from './money/index.js';
19
27
  export type { Money } from './money/index.js';
28
+ export { PluginRouteError, isUuid } from './server/index.js';
29
+ export type { ConditionForMatching, PluginRouteIssue, Query, RegisterRoute, RouteContext, RouteMethod, RuleForMatching, RuleSubject, RunAsPlugin, } from './server/index.js';
20
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GACnF,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,cAAc,EA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,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GACnF,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1D,OAAO,EACL,wBAAwB,EAAE,sBAAsB,EAChD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,uBAAuB,EACrH,WAAW,EAAE,oBAAoB,GAClC,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EACpG,YAAY,EAAE,mBAAmB,GAClC,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EACzF,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAC9F,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC5D,YAAY,EACV,oBAAoB,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EACxG,WAAW,EAAE,WAAW,GACzB,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @module
2
3
  * Public surface of the plugin SDK: the contract both the host and every
3
4
  * plugin implement.
4
5
  *
@@ -6,10 +7,18 @@
6
7
  * server; the runtime exports are React types for browser-side plugin code.
7
8
  * The two groups are kept apart so a Node process can import the manifest
8
9
  * exports without pulling in React.
10
+ *
11
+ * Stability: the manifest, runtime, range, money and server exports are
12
+ * `@stable`. The recurrence exports re-exported here are `@experimental`,
13
+ * exactly as they are from `@wickermoney/plugin-sdk/recurrence`: an export
14
+ * keeps the tier of the entry point it comes from, however it is imported.
15
+ *
16
+ * @stable
9
17
  */
10
18
  export { CORE_TABLES, checkRemoteEntry, remoteEntrySchema, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseManifest, pageContributionSchema, pluginManifestSchema, tableGrantSchema, widgetContributionSchema, } from './manifest/index.js';
11
19
  export { adoptPluginStyles } from './runtime.js';
12
20
  export { RANGE_KEYS, DEFAULT_RANGE_KEY, isRangeKey, rangeLabel, resolveRange, monthsInRange, } from './range.js';
13
- export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
21
+ export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, addDays, addMonths, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
14
22
  export { MONEY_SCALE, MONEY_UNIT, ZERO_MONEY, absMoney, addMoney, compareMoney, divideUnits, editableMoney, equalMoney, isNegativeMoney, isZeroMoney, moneyToUnits, negateMoney, normalizeMoney, subtractMoney, sumMoney, unitsToMoney, } from './money/index.js';
23
+ export { PluginRouteError, isUuid } from './server/index.js';
15
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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AAYhD,OAAO,EACL,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GACnF,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,wBAAwB,EAAE,sBAAsB,EAChD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,uBAAuB,EACrH,WAAW,EAAE,oBAAoB,GAClC,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EACzF,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAC9F,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Capabilities beyond table access that a plugin may ask the host for.
3
3
  *
4
+ * These are declarations only. Nothing in the host enforces them yet, so a
5
+ * plugin that omits one is not prevented from doing the thing it names.
6
+ *
4
7
  * - `network:outbound` - make outgoing network requests.
5
8
  * - `schedule:daily` - run work once a day.
6
9
  * - `notify` - send the user notifications.
@@ -1 +1 @@
1
- {"version":3,"file":"PERMISSIONS.d.ts","sourceRoot":"","sources":["../../src/manifest/PERMISSIONS.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,2DAA4D,CAAA"}
1
+ {"version":3,"file":"PERMISSIONS.d.ts","sourceRoot":"","sources":["../../src/manifest/PERMISSIONS.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,2DAA4D,CAAA"}
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Capabilities beyond table access that a plugin may ask the host for.
3
3
  *
4
+ * These are declarations only. Nothing in the host enforces them yet, so a
5
+ * plugin that omits one is not prevented from doing the thing it names.
6
+ *
4
7
  * - `network:outbound` - make outgoing network requests.
5
8
  * - `schedule:daily` - run work once a day.
6
9
  * - `notify` - send the user notifications.
@@ -1 +1 @@
1
- {"version":3,"file":"PERMISSIONS.js","sourceRoot":"","sources":["../../src/manifest/PERMISSIONS.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,CAAU,CAAA"}
1
+ {"version":3,"file":"PERMISSIONS.js","sourceRoot":"","sources":["../../src/manifest/PERMISSIONS.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,CAAU,CAAA"}
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * A same-origin path is always allowed: it is served by the host itself. An
5
5
  * `https:` URL is allowed only when its origin is in `allowedOrigins`, which is
6
- * empty by default (same-origin only).
6
+ * empty by default (same-origin only). An allowlisted origin is fully trusted:
7
+ * its code runs in the host's origin with the user's full API access.
7
8
  *
8
9
  * Run by the host when a manifest is registered, after `parseManifest` has
9
10
  * checked the entry's shape.
@@ -1 +1 @@
1
- {"version":3,"file":"checkRemoteEntry.d.ts","sourceRoot":"","sources":["../../src/manifest/checkRemoteEntry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,SAAS,MAAM,EAAO,GACrC,MAAM,GAAG,SAAS,CAUpB"}
1
+ {"version":3,"file":"checkRemoteEntry.d.ts","sourceRoot":"","sources":["../../src/manifest/checkRemoteEntry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,SAAS,MAAM,EAAO,GACrC,MAAM,GAAG,SAAS,CAUpB"}
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * A same-origin path is always allowed: it is served by the host itself. An
5
5
  * `https:` URL is allowed only when its origin is in `allowedOrigins`, which is
6
- * empty by default (same-origin only).
6
+ * empty by default (same-origin only). An allowlisted origin is fully trusted:
7
+ * its code runs in the host's origin with the user's full API access.
7
8
  *
8
9
  * Run by the host when a manifest is registered, after `parseManifest` has
9
10
  * checked the entry's shape.
@@ -1 +1 @@
1
- {"version":3,"file":"checkRemoteEntry.js","sourceRoot":"","sources":["../../src/manifest/checkRemoteEntry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmB,EACnB,iBAAoC,EAAE;IAEtC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACjD,IAAI,MAAc,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAA;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,gBAAgB,WAAW,sBAAsB,CAAA;IAC1D,CAAC;IACD,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACrD,OAAO,uBAAuB,MAAM,gEAAgE,CAAA;AACtG,CAAC"}
1
+ {"version":3,"file":"checkRemoteEntry.js","sourceRoot":"","sources":["../../src/manifest/checkRemoteEntry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmB,EACnB,iBAAoC,EAAE;IAEtC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACjD,IAAI,MAAc,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAA;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,gBAAgB,WAAW,sBAAsB,CAAA;IAC1D,CAAC;IACD,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACrD,OAAO,uBAAuB,MAAM,gEAAgE,CAAA;AACtG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pluginManifestSchema.d.ts","sourceRoot":"","sources":["../../src/manifest/pluginManifestSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoD/B,CAAA"}
1
+ {"version":3,"file":"pluginManifestSchema.d.ts","sourceRoot":"","sources":["../../src/manifest/pluginManifestSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+D/B,CAAA"}
@@ -23,7 +23,14 @@ export const pluginManifestSchema = z.object({
23
23
  author: z.string().default(''),
24
24
  /** Major version of the SDK the plugin was built against. */
25
25
  sdkVersion: z.number().int().nonnegative(),
26
- /** Core tables the plugin needs, each with the access level requested. Defaults to none. */
26
+ /**
27
+ * Core tables the plugin needs, each with the access level requested.
28
+ * Defaults to none.
29
+ *
30
+ * Enforced by a per-plugin PostgreSQL role for the plugin's server-side code.
31
+ * It is a declaration and early feedback, not an enforced boundary, for the
32
+ * plugin's UI code, which runs fully trusted in the host origin.
33
+ */
27
34
  requiredTables: z.array(tableGrantSchema).default([]),
28
35
  /** Capabilities beyond table access the plugin asks for. Defaults to none. */
29
36
  permissions: z.array(z.enum(PERMISSIONS)).default([]),
@@ -31,6 +38,10 @@ export const pluginManifestSchema = z.object({
31
38
  * URL of the Module Federation entry: a same-origin `/plugins/<folder>/...`
32
39
  * path, or an `https:` URL whose origin the host has allowlisted.
33
40
  *
41
+ * Whatever is loaded from here runs with full trust in the host's origin.
42
+ * Third-party plugin install is not supported yet; do not allowlist an
43
+ * origin you do not fully trust.
44
+ *
34
45
  * The entry must be an ES module: the host registers every remote with
35
46
  * `type: 'module'` and loads it with a dynamic `import()`, never a classic
36
47
  * script tag.
@@ -1 +1 @@
1
- {"version":3,"file":"pluginManifestSchema.js","sourceRoot":"","sources":["../../src/manifest/pluginManifestSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,sFAAsF;IACtF,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,4BAA4B,EAAE,mDAAmD,CAAC;IACvG,kCAAkC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,oCAAoC;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,8EAA8E;IAC9E,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACnC,yDAAyD;IACzD,MAAM,EAAE,CAAC,CAAC,MAA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,EAAE,CAAC;QAClD,kDAAkD;QAClD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD;;;;;WAKG;QACH,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QACrC;;;;;;;;WAQG;QACH,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;KACtC,CAAC;SACD,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;CAC3E,CAAC,CAAA"}
@@ -1,5 +1,10 @@
1
1
  import { z } from 'zod';
2
- /** Validates one entry of a manifest's `requiredTables`: a core table and the access level requested on it. */
2
+ /**
3
+ * Validates one entry of a manifest's `requiredTables`: a core table and the access level requested on it.
4
+ *
5
+ * The grant becomes a database privilege for the plugin's server-side code. It
6
+ * does not restrict the plugin's UI code, which runs fully trusted in the host origin.
7
+ */
3
8
  export declare const tableGrantSchema: z.ZodObject<{
4
9
  table: z.ZodEnum<{
5
10
  accounts: "accounts";
@@ -1 +1 @@
1
- {"version":3,"file":"tableGrantSchema.d.ts","sourceRoot":"","sources":["../../src/manifest/tableGrantSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAK3B,CAAA"}
1
+ {"version":3,"file":"tableGrantSchema.d.ts","sourceRoot":"","sources":["../../src/manifest/tableGrantSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAK3B,CAAA"}
@@ -1,6 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { CORE_TABLES } from './CORE_TABLES.js';
3
- /** Validates one entry of a manifest's `requiredTables`: a core table and the access level requested on it. */
3
+ /**
4
+ * Validates one entry of a manifest's `requiredTables`: a core table and the access level requested on it.
5
+ *
6
+ * The grant becomes a database privilege for the plugin's server-side code. It
7
+ * does not restrict the plugin's UI code, which runs fully trusted in the host origin.
8
+ */
4
9
  export const tableGrantSchema = z.object({
5
10
  /** The core table the plugin wants to reach. */
6
11
  table: z.enum(CORE_TABLES),
@@ -1 +1 @@
1
- {"version":3,"file":"tableGrantSchema.js","sourceRoot":"","sources":["../../src/manifest/tableGrantSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,+GAA+G;AAC/G,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,gDAAgD;IAChD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAC1B,+FAA+F;IAC/F,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC,CAAA"}
1
+ {"version":3,"file":"tableGrantSchema.js","sourceRoot":"","sources":["../../src/manifest/tableGrantSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,gDAAgD;IAChD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAC1B,+FAA+F;IAC/F,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC,CAAA"}
@@ -22,6 +22,10 @@
22
22
  *
23
23
  * Pure and dependency-free, so it is safe in the browser and in Node. For
24
24
  * showing an amount to a person, use the host's `ctx.formatMoney`.
25
+ *
26
+ * Stability: `@stable`. Plugins, the API and the web app all use it.
27
+ *
28
+ * @stable
25
29
  */
26
30
  export type { Money } from './Money.js';
27
31
  export { MONEY_SCALE } from './MONEY_SCALE.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/money/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/money/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/money/index.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC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A;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @module
3
- * Calendar-date arithmetic on `YYYY-MM-DD` strings. Internal to the SDK.
3
+ * Calendar-date arithmetic on `YYYY-MM-DD` strings. `addDays` and `addMonths` are
4
+ * public (re-exported from the `./recurrence` entry point); the rest is internal to the SDK.
4
5
  *
5
6
  * Dates here are calendar days, not instants: there is no time of day and no
6
7
  * time zone, so nothing can shift a day across midnight or a DST change. The
@@ -63,11 +64,38 @@ export declare function daysInMonth(year: number, month: number): number;
63
64
  *
64
65
  * @param year - Starting year.
65
66
  * @param month - Starting month, 1-12.
66
- * @param months - Whole months to add; may be zero.
67
+ * @param months - Whole months to add; may be zero or negative.
67
68
  * @param day - The wanted day of month, 1-31.
68
69
  * @returns The clamped date as `YYYY-MM-DD`.
69
70
  */
70
71
  export declare function clampedMonthDate(year: number, month: number, months: number, day: number): string;
72
+ /**
73
+ * Adds whole days to a calendar date.
74
+ *
75
+ * Works on day numbers, never on local time, so no time zone or daylight
76
+ * saving change can move the result.
77
+ *
78
+ * @param date - `YYYY-MM-DD`.
79
+ * @param days - Whole days to add; may be zero or negative.
80
+ * @returns The resulting date, `YYYY-MM-DD`.
81
+ * @throws {RangeError} If `date` is not a real calendar date or `days` is not an integer.
82
+ */
83
+ export declare function addDays(date: string, days: number): string;
84
+ /**
85
+ * Adds whole calendar months to a date. A day past the end of the target
86
+ * month is clamped to that month's last day: Aug 31 plus 6 months is Feb 28,
87
+ * or Feb 29 in a leap year.
88
+ *
89
+ * Each call clamps on its own. Adding months one at a time is not the same as
90
+ * adding them together (Jan 31 + 1 + 1 is Mar 28, Jan 31 + 2 is Mar 31), so
91
+ * add the total to the original date.
92
+ *
93
+ * @param date - `YYYY-MM-DD`.
94
+ * @param months - Whole months to add; may be zero or negative.
95
+ * @returns The resulting date, `YYYY-MM-DD`.
96
+ * @throws {RangeError} If `date` is not a real calendar date or `months` is not an integer.
97
+ */
98
+ export declare function addMonths(date: string, months: number): string;
71
99
  /**
72
100
  * Whole months from one year/month to another (`to - from`), ignoring days.
73
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/recurrence/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAUrG;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;;;;;;;;GASG;A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AE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI9D;AAMD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1G"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @module
3
- * Calendar-date arithmetic on `YYYY-MM-DD` strings. Internal to the SDK.
3
+ * Calendar-date arithmetic on `YYYY-MM-DD` strings. `addDays` and `addMonths` are
4
+ * public (re-exported from the `./recurrence` entry point); the rest is internal to the SDK.
4
5
  *
5
6
  * Dates here are calendar days, not instants: there is no time of day and no
6
7
  * time zone, so nothing can shift a day across midnight or a DST change. The
@@ -83,16 +84,54 @@ export function daysInMonth(year, month) {
83
84
  *
84
85
  * @param year - Starting year.
85
86
  * @param month - Starting month, 1-12.
86
- * @param months - Whole months to add; may be zero.
87
+ * @param months - Whole months to add; may be zero or negative.
87
88
  * @param day - The wanted day of month, 1-31.
88
89
  * @returns The clamped date as `YYYY-MM-DD`.
89
90
  */
90
91
  export function clampedMonthDate(year, month, months, day) {
91
92
  const absolute = year * 12 + (month - 1) + months;
92
93
  const y = Math.floor(absolute / 12);
93
- const m = (absolute % 12) + 1;
94
+ const m = (((absolute % 12) + 12) % 12) + 1;
94
95
  return formatDate(y, m, Math.min(day, daysInMonth(y, m)));
95
96
  }
97
+ /**
98
+ * Adds whole days to a calendar date.
99
+ *
100
+ * Works on day numbers, never on local time, so no time zone or daylight
101
+ * saving change can move the result.
102
+ *
103
+ * @param date - `YYYY-MM-DD`.
104
+ * @param days - Whole days to add; may be zero or negative.
105
+ * @returns The resulting date, `YYYY-MM-DD`.
106
+ * @throws {RangeError} If `date` is not a real calendar date or `days` is not an integer.
107
+ */
108
+ export function addDays(date, days) {
109
+ requireInteger(days, 'days');
110
+ return fromDayNumber(toDayNumber(date) + days);
111
+ }
112
+ /**
113
+ * Adds whole calendar months to a date. A day past the end of the target
114
+ * month is clamped to that month's last day: Aug 31 plus 6 months is Feb 28,
115
+ * or Feb 29 in a leap year.
116
+ *
117
+ * Each call clamps on its own. Adding months one at a time is not the same as
118
+ * adding them together (Jan 31 + 1 + 1 is Mar 28, Jan 31 + 2 is Mar 31), so
119
+ * add the total to the original date.
120
+ *
121
+ * @param date - `YYYY-MM-DD`.
122
+ * @param months - Whole months to add; may be zero or negative.
123
+ * @returns The resulting date, `YYYY-MM-DD`.
124
+ * @throws {RangeError} If `date` is not a real calendar date or `months` is not an integer.
125
+ */
126
+ export function addMonths(date, months) {
127
+ requireInteger(months, 'months');
128
+ const { year, month, day } = parseDate(date);
129
+ return clampedMonthDate(year, month, months, day);
130
+ }
131
+ function requireInteger(value, label) {
132
+ if (!Number.isInteger(value))
133
+ throw new RangeError(`Invalid ${label}: ${String(value)} (expected a whole number)`);
134
+ }
96
135
  /**
97
136
  * Whole months from one year/month to another (`to - from`), ignoring days.
98
137
  *
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/recurrence/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,QAAQ,GAAG,2BAA2B,CAAA;AAC5C,MAAM,UAAU,GAAG,UAAU,CAAA;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,KAAK,GAAG,MAAM;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,UAAU,CAAC,WAAW,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;IACpG,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,C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AE,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,IAAY;IAChD,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;AAChD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,MAAc;IACpD,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAC5C,OAAO,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,WAAW,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;AACpH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,SAAiB,EAAE,MAAc,EAAE,OAAe;IAChG,OAAO,CAAC,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAC,CAAA;AAC9D,CAAC"}
@@ -9,10 +9,18 @@
9
9
  * zone. The caller works out the user's today once, in their zone, and passes
10
10
  * it in. Ranges are half-open (`from` inclusive, `to` exclusive), like
11
11
  * `DashboardRange`.
12
+ *
13
+ * Stability: `@experimental`. Only the host consumes the projections today
14
+ * (the API and the web app), and the item and schedule shapes mirror the
15
+ * host's recurring-item rows. They may change in any pre-1.0 minor release
16
+ * until a plugin needs them and the shape is settled.
17
+ *
18
+ * @experimental
12
19
  */
13
20
  export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES } from './types.js';
14
21
  export type { DailyBalance, FlowTotals, OccurrenceOverride, RecurrenceFrequency, RecurrenceSchedule, RecurringItem, RecurringLeg, ScheduledOccurrence, } from './types.js';
15
22
  export { nextOccurrence, occurrences } from './schedule.js';
16
23
  export { nextScheduledOccurrence, scheduledOccurrences } from './scheduled.js';
17
24
  export { dailyBalances, flowTotals, monthlyEquivalent, nextPayday, } from './projection.js';
25
+ export { addDays, addMonths } from './calendar.js';
18
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recurrence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAC7E,YAAY,EACV,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EACpG,YAAY,EAAE,mBAAmB,GAClC,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EACL,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,GACzD,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recurrence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAC7E,YAAY,EACV,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EACpG,YAAY,EAAE,mBAAmB,GAClC,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EACL,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,GACzD,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
@@ -9,9 +9,17 @@
9
9
  * zone. The caller works out the user's today once, in their zone, and passes
10
10
  * it in. Ranges are half-open (`from` inclusive, `to` exclusive), like
11
11
  * `DashboardRange`.
12
+ *
13
+ * Stability: `@experimental`. Only the host consumes the projections today
14
+ * (the API and the web app), and the item and schedule shapes mirror the
15
+ * host's recurring-item rows. They may change in any pre-1.0 minor release
16
+ * until a plugin needs them and the shape is settled.
17
+ *
18
+ * @experimental
12
19
  */
13
20
  export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES } from './types.js';
14
21
  export { nextOccurrence, occurrences } from './schedule.js';
15
22
  export { nextScheduledOccurrence, scheduledOccurrences } from './scheduled.js';
16
23
  export { dailyBalances, flowTotals, monthlyEquivalent, nextPayday, } from './projection.js';
24
+ export { addDays, addMonths } from './calendar.js';
17
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recurrence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAK7E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EACL,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,GACzD,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recurrence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAK7E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EACL,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,GACzD,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,16 @@
1
+ /**
2
+ * @module
3
+ * The browser-side half of the plugin contract: the props and context the
4
+ * host hands a plugin's React components, the shape of a plugin's federated
5
+ * module, and {@link adoptPluginStyles}.
6
+ *
7
+ * Types plus one small helper, so importing this costs a plugin bundle almost
8
+ * nothing. It needs `react` 19 as a type dependency only.
9
+ *
10
+ * Stability: `@stable`. Every bundled UI plugin builds against it.
11
+ *
12
+ * @stable
13
+ */
1
14
  import type { ComponentType } from 'react';
2
15
  import type { WidgetSize } from './manifest/index.js';
3
16
  import type { DashboardRange } from './range.js';
@@ -14,9 +27,15 @@ export interface PluginSession {
14
27
  * Scoped HTTP client handed to a plugin.
15
28
  *
16
29
  * Requests are relative to the plugin's own namespace (`/api/v1/p/<id>/`) for
17
- * plugin endpoints, or to core read endpoints the manifest's `requiredTables`
18
- * permits. The host attaches credentials — a plugin never sees the access
19
- * token, so it cannot exfiltrate one or call the API as the user elsewhere.
30
+ * plugin endpoints, or to core endpoints the manifest's `requiredTables`
31
+ * covers. The host attaches credentials, so well-behaved plugin code never
32
+ * handles the access token.
33
+ *
34
+ * This client is a convenience and a statement of intent, not a sandbox. A UI
35
+ * plugin runs fully trusted in the host's origin and could bypass it with
36
+ * `fetch`. The grants it checks are enforced by the database for server-side
37
+ * plugin code only, not for calls a UI plugin makes through here or around
38
+ * here. Do not install a UI plugin you would not give your whole session to.
20
39
  */
21
40
  export interface PluginApi {
22
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACpD;;;;;;;OAOG;IACH,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACpE;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACnE;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACrD;AAED;;;;GAIG;AACH,M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IAC3C,MAAM,EAAE,GAAG,6BAA6B,QAAQ,EAAE,CAAA;IAClD,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,IAAI;QAAE,OAAM;IAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC7C,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;IACb,KAAK,CAAC,WAAW,GAAG,GAAG,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC"}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAgJA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,GAAW;IAC7D,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAM;IAC3C,MAAM,EAAE,GAAG,6BAA6B,QAAQ,EAAE,CAAA;IAClD,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,IAAI;QAAE,OAAM;IAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC7C,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;IACb,KAAK,CAAC,WAAW,GAAG,GAAG,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The columns the host's category rule engine needs to test one condition.
3
+ *
4
+ * A rule carries an array of AND-ed conditions. Text and amount fields are
5
+ * mutually exclusive per `condition_type`, mirroring the check constraint on
6
+ * the rule-conditions table. Field names are snake_case to match the row shape
7
+ * the host's query returns.
8
+ */
9
+ export interface ConditionForMatching {
10
+ readonly condition_type: 'merchant_exact' | 'merchant_contains' | 'description_contains' | 'amount_exact' | 'amount_range';
11
+ readonly text_value: string | null;
12
+ readonly is_case_sensitive: boolean;
13
+ readonly direction: 'in' | 'out' | null;
14
+ readonly amount_value: string | null;
15
+ readonly amount_min: string | null;
16
+ readonly amount_max: string | null;
17
+ }
18
+ //# sourceMappingURL=ConditionForMatching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionForMatching.d.ts","sourceRoot":"","sources":["../../src/server/ConditionForMatching.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,cAAc,EACnB,gBAAgB,GAAG,mBAAmB,GAAG,sBAAsB,GAC/D,cAAc,GAAG,cAAc,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAA;IACnC,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAA;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ConditionForMatching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionForMatching.js","sourceRoot":"","sources":["../../src/server/ConditionForMatching.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { PluginRouteIssue } from './PluginRouteIssue.js';
2
+ /**
3
+ * An error a route handler raises on purpose, for a request the user can
4
+ * correct or retry.
5
+ *
6
+ * The host answers with `statusCode` and `code` and shows `message` to the
7
+ * person, so `message` must be safe to display. Anything a handler throws that
8
+ * is not recognisably one of these is treated as a bug: it is logged and
9
+ * answered with a generic 500.
10
+ *
11
+ * The host recognises the shape (`statusCode` and `code`), not only the
12
+ * class, so an error from a copy of this class bundled into a plugin still
13
+ * works. A plugin may subclass it to add defaults or helpers.
14
+ */
15
+ export declare class PluginRouteError extends Error {
16
+ readonly statusCode: number;
17
+ readonly code: string;
18
+ readonly issues?: readonly PluginRouteIssue[] | undefined;
19
+ /**
20
+ * @param message - Human-readable explanation, safe to show to the user.
21
+ * @param statusCode - HTTP status the host responds with.
22
+ * @param code - Stable machine-readable identifier for clients.
23
+ * @param issues - Field-level detail, so a form can show each problem by its field.
24
+ */
25
+ constructor(message: string, statusCode: number, code: string, issues?: readonly PluginRouteIssue[] | undefined);
26
+ }
27
+ //# sourceMappingURL=PluginRouteError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRouteError.d.ts","sourceRoot":"","sources":["../../src/server/PluginRouteError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IASvC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,gBAAgB,EAAE;IAV/C;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACN,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,SAAS,gBAAgB,EAAE,YAAA;CAKhD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * An error a route handler raises on purpose, for a request the user can
3
+ * correct or retry.
4
+ *
5
+ * The host answers with `statusCode` and `code` and shows `message` to the
6
+ * person, so `message` must be safe to display. Anything a handler throws that
7
+ * is not recognisably one of these is treated as a bug: it is logged and
8
+ * answered with a generic 500.
9
+ *
10
+ * The host recognises the shape (`statusCode` and `code`), not only the
11
+ * class, so an error from a copy of this class bundled into a plugin still
12
+ * works. A plugin may subclass it to add defaults or helpers.
13
+ */
14
+ export class PluginRouteError extends Error {
15
+ statusCode;
16
+ code;
17
+ issues;
18
+ /**
19
+ * @param message - Human-readable explanation, safe to show to the user.
20
+ * @param statusCode - HTTP status the host responds with.
21
+ * @param code - Stable machine-readable identifier for clients.
22
+ * @param issues - Field-level detail, so a form can show each problem by its field.
23
+ */
24
+ constructor(message, statusCode, code, issues) {
25
+ super(message);
26
+ this.statusCode = statusCode;
27
+ this.code = code;
28
+ this.issues = issues;
29
+ this.name = new.target.name;
30
+ }
31
+ }
32
+ //# sourceMappingURL=PluginRouteError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRouteError.js","sourceRoot":"","sources":["../../src/server/PluginRouteError.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAS9B;IACA;IACA;IAVX;;;;;OAKG;IACH,YACE,OAAe,EACN,UAAkB,EAClB,IAAY,EACZ,MAAoC;QAE7C,KAAK,CAAC,OAAO,CAAC,CAAA;QAJL,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAA8B;QAG7C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;IAC7B,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /** One problem with a request, tied to the body field it is about. */
2
+ export interface PluginRouteIssue {
3
+ /** The field, as the request body spells it; empty for the request as a whole. */
4
+ readonly path: readonly (string | number)[];
5
+ /** A sentence about that field that does not repeat its name. */
6
+ readonly message: string;
7
+ }
8
+ //# sourceMappingURL=PluginRouteIssue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRouteIssue.d.ts","sourceRoot":"","sources":["../../src/server/PluginRouteIssue.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC3C,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PluginRouteIssue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRouteIssue.js","sourceRoot":"","sources":["../../src/server/PluginRouteIssue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A parameterised query runner bound to the plugin's database role.
3
+ *
4
+ * Usable only as a tagged template, so values are always sent as bound
5
+ * parameters and nothing is ever interpolated into the SQL text.
6
+ *
7
+ * @typeParam T - The row shape each result row is typed as.
8
+ * @returns The result rows.
9
+ */
10
+ export type Query = <T = Record<string, unknown>>(strings: TemplateStringsArray, ...values: unknown[]) => Promise<T[]>;
11
+ //# sourceMappingURL=Query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../src/server/Query.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9C,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,OAAO,EAAE,KACjB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../src/server/Query.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import type { RouteContext } from './RouteContext.js';
2
+ import type { RouteMethod } from './RouteMethod.js';
3
+ /**
4
+ * Registers one route for a plugin.
5
+ *
6
+ * The host mounts it under `/api/v1/p/<pluginId>`, after authentication and
7
+ * the enabled-plugin check, so `path` is relative to the plugin's base. A
8
+ * handler's return value is sent as the JSON response; an error it throws is
9
+ * answered according to `PluginRouteError`.
10
+ *
11
+ * @param method - The HTTP method.
12
+ * @param path - The path relative to the plugin's base, such as `/batches/:id/revert`.
13
+ * @param handler - Handles one request.
14
+ * @param options - `bodyLimit` raises the request-body limit, in bytes, for this route only.
15
+ */
16
+ export type RegisterRoute = (method: RouteMethod, path: string, handler: (ctx: RouteContext) => Promise<unknown>, options?: {
17
+ readonly bodyLimit?: number;
18
+ }) => void;
19
+ //# sourceMappingURL=RegisterRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterRoute.d.ts","sourceRoot":"","sources":["../../src/server/RegisterRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,EAChD,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,IAAI,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RegisterRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterRoute.js","sourceRoot":"","sources":["../../src/server/RegisterRoute.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ /** The per-request input a route handler receives from the host. */
2
+ export interface RouteContext {
3
+ /** The authenticated user the request runs as, taken from the verified token, never from the plugin. */
4
+ readonly userId: string;
5
+ /** The parsed JSON body, unvalidated. */
6
+ readonly body: unknown;
7
+ /** Path parameters, such as `id` in `/batches/:id/revert`. */
8
+ readonly params: Record<string, string>;
9
+ /** Query-string parameters; a parameter that was not sent is `undefined`. */
10
+ readonly query: Record<string, string | undefined>;
11
+ }
12
+ //# sourceMappingURL=RouteContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteContext.d.ts","sourceRoot":"","sources":["../../src/server/RouteContext.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,wGAAwG;IACxG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACnD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RouteContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteContext.js","sourceRoot":"","sources":["../../src/server/RouteContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** The HTTP methods a plugin route can be registered for. */
2
+ export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
3
+ //# sourceMappingURL=RouteMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteMethod.d.ts","sourceRoot":"","sources":["../../src/server/RouteMethod.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RouteMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteMethod.js","sourceRoot":"","sources":["../../src/server/RouteMethod.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { ConditionForMatching } from './ConditionForMatching.js';
2
+ /**
3
+ * One category rule as the host's rule engine consumes it.
4
+ *
5
+ * Field names are snake_case to match the host's row shape rather than the
6
+ * SDK's usual camelCase. A plugin does not normally read these fields: a value
7
+ * flows unchanged from the host's `getRulesForMatching` into its
8
+ * `resolveCategory`, so the type only describes what arrives at runtime.
9
+ */
10
+ export interface RuleForMatching {
11
+ /** The category assigned when every condition matches. */
12
+ readonly category_id: string;
13
+ /** Conditions that must all match for the rule to apply. */
14
+ readonly conditions: readonly ConditionForMatching[];
15
+ }
16
+ //# sourceMappingURL=RuleForMatching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleForMatching.d.ts","sourceRoot":"","sources":["../../src/server/RuleForMatching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAA;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RuleForMatching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleForMatching.js","sourceRoot":"","sources":["../../src/server/RuleForMatching.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /** The transaction fields the host's rule engine evaluates a rule's conditions against. */
2
+ export interface RuleSubject {
3
+ /** Merchant text. */
4
+ readonly merchant: string;
5
+ /** Free-text notes or description, if any. */
6
+ readonly notes?: string | null;
7
+ /** Signed decimal string as stored on the ledger; negative is money out. */
8
+ readonly amount: string;
9
+ }
10
+ //# sourceMappingURL=RuleSubject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleSubject.d.ts","sourceRoot":"","sources":["../../src/server/RuleSubject.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RuleSubject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleSubject.js","sourceRoot":"","sources":["../../src/server/RuleSubject.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { Query } from './Query.js';
2
+ /**
3
+ * Runs `fn` in one transaction as the given user, under this plugin's database role.
4
+ *
5
+ * The host supplies it; the plugin never sees a connection string or the
6
+ * application's own database handle.
7
+ */
8
+ export type RunAsPlugin = <T>(userId: string, fn: (q: Query) => Promise<T>) => Promise<T>;
9
+ //# sourceMappingURL=RunAsPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunAsPlugin.d.ts","sourceRoot":"","sources":["../../src/server/RunAsPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RunAsPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunAsPlugin.js","sourceRoot":"","sources":["../../src/server/RunAsPlugin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @module
3
+ * The server-side half of the plugin contract: what a bundled plugin's
4
+ * `register` function is handed by the host, and what it may throw back.
5
+ *
6
+ * Only bundled plugins may contribute server endpoints today; the host has no
7
+ * sandbox for third-party server code. This entry point exists so the host and
8
+ * every bundled plugin build against one definition instead of a private copy
9
+ * each.
10
+ *
11
+ * Pure types plus two small values ({@link PluginRouteError}, {@link isUuid});
12
+ * dependency-free (no Zod), safe to import from Node.
13
+ *
14
+ * Stability: `@stable`. The host and every bundled plugin with server code
15
+ * build against it.
16
+ *
17
+ * @stable
18
+ */
19
+ export type { ConditionForMatching } from './ConditionForMatching.js';
20
+ export { isUuid } from './isUuid.js';
21
+ export { PluginRouteError } from './PluginRouteError.js';
22
+ export type { PluginRouteIssue } from './PluginRouteIssue.js';
23
+ export type { Query } from './Query.js';
24
+ export type { RegisterRoute } from './RegisterRoute.js';
25
+ export type { RouteContext } from './RouteContext.js';
26
+ export type { RouteMethod } from './RouteMethod.js';
27
+ export type { RuleForMatching } from './RuleForMatching.js';
28
+ export type { RuleSubject } from './RuleSubject.js';
29
+ export type { RunAsPlugin } from './RunAsPlugin.js';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { isUuid } from './isUuid.js';
2
+ export { PluginRouteError } from './PluginRouteError.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Tests whether a value is a UUID string, before it is sent to PostgreSQL.
3
+ *
4
+ * A malformed id that reached a `uuid` column would fail with an invalid-text
5
+ * error and surface as a 500; checking first lets a handler answer 400.
6
+ *
7
+ * The rule is strict: the canonical hyphenated form only, in either case, with
8
+ * a valid RFC 9562 version and variant (the nil and max UUIDs are allowed).
9
+ * Every id PostgreSQL generates (`uuid_generate_v4()`, `gen_random_uuid()`,
10
+ * version 7) passes. PostgreSQL itself would also accept braces, no hyphens
11
+ * and arbitrary hex digits; those are refused here, so an id has one spelling
12
+ * and one meaning.
13
+ *
14
+ * @param value - Anything, usually unvalidated request input.
15
+ * @returns `true` when `value` is a string in that form, narrowing it to `string`.
16
+ */
17
+ export declare function isUuid(value: unknown): value is string;
18
+ //# sourceMappingURL=isUuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUuid.d.ts","sourceRoot":"","sources":["../../src/server/isUuid.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEtD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * RFC 9562 UUID in its canonical 8-4-4-4-12 form: a version of 1 to 8 and a
3
+ * variant of 8, 9, a or b, plus the nil and max UUIDs. Either case. This is
4
+ * the rule Zod 4's `z.uuid()` applies, which the API uses for `:id` params.
5
+ */
6
+ const UUID_PATTERN = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
7
+ /**
8
+ * Tests whether a value is a UUID string, before it is sent to PostgreSQL.
9
+ *
10
+ * A malformed id that reached a `uuid` column would fail with an invalid-text
11
+ * error and surface as a 500; checking first lets a handler answer 400.
12
+ *
13
+ * The rule is strict: the canonical hyphenated form only, in either case, with
14
+ * a valid RFC 9562 version and variant (the nil and max UUIDs are allowed).
15
+ * Every id PostgreSQL generates (`uuid_generate_v4()`, `gen_random_uuid()`,
16
+ * version 7) passes. PostgreSQL itself would also accept braces, no hyphens
17
+ * and arbitrary hex digits; those are refused here, so an id has one spelling
18
+ * and one meaning.
19
+ *
20
+ * @param value - Anything, usually unvalidated request input.
21
+ * @returns `true` when `value` is a string in that form, narrowing it to `string`.
22
+ */
23
+ export function isUuid(value) {
24
+ return typeof value === 'string' && UUID_PATTERN.test(value);
25
+ }
26
+ //# sourceMappingURL=isUuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUuid.js","sourceRoot":"","sources":["../../src/server/isUuid.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,YAAY,GAChB,0JAA0J,CAAA;AAE5J;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wickermoney/plugin-sdk",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,6 +30,10 @@
30
30
  "./money": {
31
31
  "types": "./dist/money/index.d.ts",
32
32
  "default": "./dist/money/index.js"
33
+ },
34
+ "./server": {
35
+ "types": "./dist/server/index.d.ts",
36
+ "default": "./dist/server/index.js"
33
37
  }
34
38
  },
35
39
  "files": [