@ekwo-ai/mcp 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ekwo-ai/mcp
2
2
 
3
3
  The [Model Context Protocol](https://modelcontextprotocol.io) server for
4
- [Ekwo OS](https://github.com/Ekwo-ai/ekwo-os). It lets an AI assistant work on
4
+ [Ekwo OS](https://github.com/Ekwo-ai/ekwo-os). It lets an AI agent work on
5
5
  the books in your own Postgres: read the ledger, raise an invoice, post it, match
6
6
  a payment, pull the VAT return or the French FEC — **as you**, under the row
7
7
  level security of your own installation.
@@ -38,7 +38,7 @@ Three things it will never do:
38
38
  accounting has always worked. `unreconcile` is the only undo here, and
39
39
  matching changes no account.
40
40
  - **Use a `service_role` key.** It would work, and that is the objection: it
41
- bypasses every policy, so the assistant would answer for companies its user
41
+ bypasses every policy, so the agent would answer for companies its user
42
42
  was never invited to. The server refuses to start with one.
43
43
 
44
44
  ## Configuration
@@ -95,7 +95,7 @@ alongside the server; the recommended route needs no driver at all.
95
95
  |---|---|
96
96
  | `SUPABASE_URL` | `https://<ref>.supabase.co` |
97
97
  | `SUPABASE_ANON_KEY` | The anon (publishable) key. A `service_role` key is refused. |
98
- | `EKWO_EMAIL` / `EKWO_PASSWORD` | The user this assistant acts as |
98
+ | `EKWO_EMAIL` / `EKWO_PASSWORD` | The user this agent acts as |
99
99
  | `EKWO_ACCESS_TOKEN` | A session already in hand, instead of the two above |
100
100
  | `EKWO_DB_URL` | A direct Postgres connection, for a self-hosted installation |
101
101
  | `EKWO_ACT_AS_USER_ID` | Required with `EKWO_DB_URL`: the `auth.users` id to act for |
@@ -123,6 +123,75 @@ The `Dockerfile` at the root of the repository builds the same server from the
123
123
  checkout; `docker run -i --rm <image>` speaks MCP over stdio, with the variables
124
124
  passed as `-e`.
125
125
 
126
+ ## Over HTTP: hosting it for others
127
+
128
+ The same server, reached by URL instead of started by a client:
129
+ `handleHttpRequest` answers the **Streamable HTTP** transport of MCP. It is
130
+ **stateless** — each request builds a server, answers in JSON and closes it,
131
+ with no session id and nothing kept — so it runs on a function platform,
132
+ behind a load balancer, or in one process. A `GET` is answered `405`: this
133
+ server never speaks first, so there is no stream to open.
134
+
135
+ What it does not do is decide who is calling. That is the host's job, and the
136
+ whole of it: the host authenticates the request its own way, then hands in
137
+ **the connection that request may use**.
138
+
139
+ ```ts
140
+ import { handleHttpRequest } from '@ekwo-ai/mcp';
141
+
142
+ export default async function (request: Request): Promise<Response> {
143
+ const who = await yourOwnAuthentication(request); // a token you issued
144
+ if (who === undefined) return new Response(null, { status: 401 });
145
+ return handleHttpRequest(request, {
146
+ supabaseUrl: who.supabaseUrl, // https://<ref>.supabase.co
147
+ anonKey: who.publishableKey, // never the service_role key
148
+ apiKey: who.ekwoKey, // or: accessToken: who.session
149
+ });
150
+ }
151
+ ```
152
+
153
+ A connection is one of two things, never both:
154
+
155
+ - **A person's access token** on the instance. Row level security decides,
156
+ exactly as for that person in a browser.
157
+ - **A key of Ekwo OS**, as `create_api_key()` issues it. It travels in the
158
+ `X-Ekwo-Api-Key` header with no `Authorization` beside it, the schema's
159
+ pre-request hook presents it (decision
160
+ [0062](../../docs/decisions/0062-a-key-reaches-the-api.md)), and the caller
161
+ is on that key's one company with that key's capabilities. A key issued
162
+ without a capability that writes gives an agent that reads.
163
+
164
+ A `service_role` key is refused in all three slots, as on stdio. For
165
+ `node:http` (or anything built on it), `handleNodeRequest(req, res,
166
+ connection, { origin })` is the same handler.
167
+
168
+ ### Putting it in front of people: authorization
169
+
170
+ A remote MCP client — Claude and the others — expects the server to follow
171
+ the [authorization part of the MCP
172
+ specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization):
173
+ OAuth 2.1 with PKCE. That belongs to the host, not to this package, and a
174
+ host that wants the clients to connect on their own serves:
175
+
176
+ 1. **`401` with `WWW-Authenticate: Bearer resource_metadata="…"`** on the MCP
177
+ endpoint when there is no valid token.
178
+ 2. **Protected resource metadata** (RFC 9728) at
179
+ `/.well-known/oauth-protected-resource`, naming the endpoint as the
180
+ `resource` and the authorization server.
181
+ 3. **Authorization server metadata** (RFC 8414) at
182
+ `/.well-known/oauth-authorization-server`, with `S256` in
183
+ `code_challenge_methods_supported`.
184
+ 4. **Dynamic client registration** (RFC 7591), or client metadata documents,
185
+ so a client registers itself.
186
+ 5. **An authorization page** where the person signs in the host's way and
187
+ chooses what the client may reach; then a token endpoint that issues short
188
+ access tokens and rotating refresh tokens.
189
+
190
+ Each access token the host issues maps to a connection — for instance to a
191
+ key of Ekwo OS the person issued on their own installation for this purpose,
192
+ held by the host encrypted and opened in memory for the one request. The
193
+ database stays the only place that decides what may be read or written.
194
+
126
195
  ## The tools
127
196
 
128
197
  Every write names its company explicitly.
package/dist/bin.js CHANGED
@@ -45,7 +45,7 @@ in claude_desktop_config.json or .mcp.json with:
45
45
 
46
46
  SUPABASE_URL https://<ref>.supabase.co
47
47
  SUPABASE_ANON_KEY the anon (publishable) key — never the service_role key
48
- EKWO_EMAIL the user this assistant acts as
48
+ EKWO_EMAIL the user this agent acts as
49
49
  EKWO_PASSWORD their password
50
50
  EKWO_ACCESS_TOKEN an access token, instead of the two above
51
51
 
@@ -0,0 +1,59 @@
1
+ /**
2
+ * What each tool reads back, written once.
3
+ *
4
+ * Two rules run through every list. A `numeric` column is asked for as
5
+ * `amount::text`, so the exact decimal arrives rather than a float; a `date`
6
+ * or a timestamp likewise, so `2026-06-15` is a string on both routes instead
7
+ * of whatever a driver decided a date object should be. Everything else —
8
+ * uuid, text, boolean, integer — crosses unchanged.
9
+ */
10
+ export declare const COMPANY: string[];
11
+ export declare const FISCAL_YEAR: string[];
12
+ export declare const ACCOUNT: string[];
13
+ export declare const JOURNAL: string[];
14
+ export declare const CONTACT: string[];
15
+ export declare const TAX: string[];
16
+ export declare const DOCUMENT: string[];
17
+ /**
18
+ * The mentions the law of a country puts on one document, from the view that
19
+ * decides which of them apply. `text_i18n` crosses as it is: a renderer picks
20
+ * the language, and the server has no business choosing one.
21
+ */
22
+ export declare const DOCUMENT_LEGAL_MENTION: string[];
23
+ /**
24
+ * What the country of a document requires of it, beside the mentions: the
25
+ * payment term the law sets, how the number is built, when the tax falls due
26
+ * and how the document is exchanged. Read from `country_defaults`, which
27
+ * holds null wherever the pack has said nothing — and null is the answer, not
28
+ * an invitation to substitute another country's.
29
+ */
30
+ export declare const COUNTRY_DOCUMENT_RULES: string[];
31
+ /**
32
+ * The header of a document, from the view that assembles it: the seller, the
33
+ * buyer, the amounts, where it is paid and what the country of the document
34
+ * requires. `document_line_items` is the lines and `document_legal_mentions`
35
+ * the sentences — three reads, and no client holding a copy of the
36
+ * letterhead.
37
+ */
38
+ export declare const DOCUMENT_HEADER: string[];
39
+ export declare const PRODUCT: string[];
40
+ export declare const DOCUMENT_LINE: string[];
41
+ export declare const ENTRY: string[];
42
+ export declare const ENTRY_LINE: string[];
43
+ export declare const BANK_ACCOUNT: string[];
44
+ export declare const BANK_TRANSACTION: string[];
45
+ export declare const PAYMENT: string[];
46
+ /**
47
+ * An invitation, without its secret. `token_hash` is deliberately absent: it
48
+ * is of no use to a client, and a list of hashes is a thing to leak rather
49
+ * than a thing to show.
50
+ */
51
+ /** What one person chose for themselves. Null everywhere is the fresh state. */
52
+ export declare const USER_PREFERENCES: string[];
53
+ export declare const INVITATION: string[];
54
+ /** A machine key, without its hash. The secret is returned once, elsewhere. */
55
+ export declare const API_KEY: string[];
56
+ export declare const INSTANCE: string[];
57
+ export declare const RECONCILIATION: string[];
58
+ export declare const AUDIT_LOG: string[];
59
+ //# sourceMappingURL=columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,OAAO,UAqCnB,CAAC;AAEF,eAAO,MAAM,WAAW,UAAoE,CAAC;AAE7F,eAAO,MAAM,OAAO,UASnB,CAAC;AAEF,eAAO,MAAM,OAAO,UAAmD,CAAC;AAExE,eAAO,MAAM,OAAO,UAYnB,CAAC;AAEF,eAAO,MAAM,GAAG,UAsBf,CAAC;AAEF,eAAO,MAAM,QAAQ,UAqBpB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAOlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,UAWlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAmE3B,CAAC;AAEF,eAAO,MAAM,OAAO,UAgBnB,CAAC;AAEF,eAAO,MAAM,aAAa,UAiBzB,CAAC;AAEF,eAAO,MAAM,KAAK,UAejB,CAAC;AAEF,eAAO,MAAM,UAAU,UAsBtB,CAAC;AAEF,eAAO,MAAM,YAAY,UAUxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAiB5B,CAAC;AAEF,eAAO,MAAM,OAAO,UAcnB,CAAC;AAEF;;;;GAIG;AACH,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAS5B,CAAC;AAEF,eAAO,MAAM,UAAU,UAYtB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,OAAO,UAWnB,CAAC;AAEF,eAAO,MAAM,QAAQ,UAQpB,CAAC;AAEF,eAAO,MAAM,cAAc,UAa1B,CAAC;AAEF,eAAO,MAAM,SAAS,UAarB,CAAC"}
@@ -0,0 +1,422 @@
1
+ /**
2
+ * What each tool reads back, written once.
3
+ *
4
+ * Two rules run through every list. A `numeric` column is asked for as
5
+ * `amount::text`, so the exact decimal arrives rather than a float; a `date`
6
+ * or a timestamp likewise, so `2026-06-15` is a string on both routes instead
7
+ * of whatever a driver decided a date object should be. Everything else —
8
+ * uuid, text, boolean, integer — crosses unchanged.
9
+ */
10
+ export const COMPANY = [
11
+ 'id',
12
+ 'name',
13
+ 'trade_name',
14
+ 'legal_name',
15
+ 'legal_form',
16
+ 'country',
17
+ 'fiscal_country',
18
+ 'vat_number',
19
+ 'registration_number',
20
+ 'address_line1',
21
+ 'address_line2',
22
+ 'postal_code',
23
+ 'city',
24
+ 'country',
25
+ 'region',
26
+ 'email',
27
+ 'phone',
28
+ 'website',
29
+ 'logo_url',
30
+ 'share_capital::text',
31
+ 'share_capital_currency',
32
+ 'activity_code',
33
+ 'activity_scheme',
34
+ 'document_template',
35
+ 'default_bank_account_id',
36
+ 'language',
37
+ 'currency_code',
38
+ 'lock_date::text',
39
+ 'tax_lock_date::text',
40
+ 'receivable_account_id',
41
+ 'payable_account_id',
42
+ 'suspense_account_id',
43
+ 'retained_earnings_account_id',
44
+ 'sales_journal_id',
45
+ 'purchase_journal_id',
46
+ 'miscellaneous_journal_id',
47
+ ];
48
+ export const FISCAL_YEAR = ['id', 'name', 'start_date::text', 'end_date::text', 'is_closed'];
49
+ export const ACCOUNT = [
50
+ 'id',
51
+ 'code',
52
+ 'name',
53
+ 'account_type',
54
+ 'internal_group',
55
+ 'reconcilable',
56
+ 'currency_code',
57
+ 'deprecated',
58
+ ];
59
+ export const JOURNAL = ['id', 'code', 'name', 'journal_type', 'active'];
60
+ export const CONTACT = [
61
+ 'id',
62
+ 'name',
63
+ 'contact_type',
64
+ 'vat_number',
65
+ 'auxiliary_code',
66
+ 'email',
67
+ 'country',
68
+ 'payment_terms_days',
69
+ 'receivable_account_id',
70
+ 'payable_account_id',
71
+ 'active',
72
+ ];
73
+ export const TAX = [
74
+ 'id',
75
+ 'code',
76
+ 'name',
77
+ 'amount::text',
78
+ 'amount_type',
79
+ 'applies_to',
80
+ 'treatment',
81
+ 'vat_category',
82
+ 'valid_from::text',
83
+ 'valid_to::text',
84
+ 'legal_reference',
85
+ // The generalised engine. `tax_kind` and `jurisdiction` say what a tax is
86
+ // where the code alone would have to be guessed at; `recoverable` and
87
+ // `price_include` change what a client should show; `cash_basis` is here so
88
+ // a reader is not surprised by it once cash-basis VAT starts writing it.
89
+ 'tax_kind',
90
+ 'recoverable',
91
+ 'jurisdiction',
92
+ 'price_include',
93
+ 'cash_basis',
94
+ 'active',
95
+ ];
96
+ export const DOCUMENT = [
97
+ 'id',
98
+ 'company_id',
99
+ 'doc_type',
100
+ 'state',
101
+ 'payment_state',
102
+ 'number',
103
+ 'supplier_reference',
104
+ 'contact_id',
105
+ 'journal_id',
106
+ 'document_date::text',
107
+ 'accounting_date::text',
108
+ 'due_date::text',
109
+ 'currency_code',
110
+ 'amount_untaxed::text',
111
+ 'amount_tax::text',
112
+ 'amount_total::text',
113
+ 'amount_paid::text',
114
+ 'amount_residual::text',
115
+ 'entry_id',
116
+ 'sent_at::text',
117
+ ];
118
+ /**
119
+ * The mentions the law of a country puts on one document, from the view that
120
+ * decides which of them apply. `text_i18n` crosses as it is: a renderer picks
121
+ * the language, and the server has no business choosing one.
122
+ */
123
+ export const DOCUMENT_LEGAL_MENTION = [
124
+ 'code',
125
+ 'applies_when',
126
+ 'text',
127
+ 'text_i18n',
128
+ 'sequence',
129
+ 'legal_reference',
130
+ ];
131
+ /**
132
+ * What the country of a document requires of it, beside the mentions: the
133
+ * payment term the law sets, how the number is built, when the tax falls due
134
+ * and how the document is exchanged. Read from `country_defaults`, which
135
+ * holds null wherever the pack has said nothing — and null is the answer, not
136
+ * an invitation to substitute another country's.
137
+ */
138
+ export const COUNTRY_DOCUMENT_RULES = [
139
+ 'country',
140
+ 'numbering_gapless',
141
+ 'number_format',
142
+ 'legal_payment_days',
143
+ 'late_payment_reference',
144
+ 'tax_point_rule',
145
+ 'einvoice_profile',
146
+ 'einvoice_mandatory_from::text',
147
+ 'party_scheme',
148
+ 'vat_scheme',
149
+ ];
150
+ /**
151
+ * The header of a document, from the view that assembles it: the seller, the
152
+ * buyer, the amounts, where it is paid and what the country of the document
153
+ * requires. `document_line_items` is the lines and `document_legal_mentions`
154
+ * the sentences — three reads, and no client holding a copy of the
155
+ * letterhead.
156
+ */
157
+ export const DOCUMENT_HEADER = [
158
+ 'document_id',
159
+ 'company_id',
160
+ 'doc_type',
161
+ 'state',
162
+ 'payment_state',
163
+ 'number',
164
+ 'supplier_reference',
165
+ 'document_date::text',
166
+ 'accounting_date::text',
167
+ 'due_date::text',
168
+ 'delivery_date::text',
169
+ 'currency_code',
170
+ 'amount_untaxed::text',
171
+ 'amount_tax::text',
172
+ 'amount_total::text',
173
+ 'amount_paid::text',
174
+ 'amount_residual::text',
175
+ 'payment_terms',
176
+ 'payment_means_code',
177
+ 'payment_reference',
178
+ 'buyer_reference',
179
+ 'order_reference',
180
+ 'contract_reference',
181
+ 'project_reference',
182
+ 'note',
183
+ 'payee_iban',
184
+ 'payee_bic',
185
+ 'seller_name',
186
+ 'seller_legal_name',
187
+ 'seller_legal_form',
188
+ 'seller_vat_number',
189
+ 'seller_registration_number',
190
+ 'seller_address_line1',
191
+ 'seller_address_line2',
192
+ 'seller_postal_code',
193
+ 'seller_city',
194
+ 'seller_country',
195
+ 'seller_email',
196
+ 'seller_phone',
197
+ 'seller_website',
198
+ 'seller_logo_url',
199
+ 'seller_share_capital::text',
200
+ 'seller_share_capital_currency',
201
+ 'seller_activity_code',
202
+ 'seller_activity_scheme',
203
+ 'document_template',
204
+ 'buyer_id',
205
+ 'buyer_name',
206
+ 'buyer_vat_number',
207
+ 'buyer_registration_number',
208
+ 'buyer_address_line1',
209
+ 'buyer_address_line2',
210
+ 'buyer_postal_code',
211
+ 'buyer_city',
212
+ 'buyer_country',
213
+ 'buyer_email',
214
+ 'country',
215
+ 'number_format',
216
+ 'numbering_gapless',
217
+ 'legal_payment_days',
218
+ 'late_payment_reference',
219
+ 'tax_point_rule',
220
+ 'einvoice_profile',
221
+ 'einvoice_mandatory_from::text',
222
+ 'party_scheme',
223
+ 'vat_scheme',
224
+ ];
225
+ export const PRODUCT = [
226
+ 'id',
227
+ 'company_id',
228
+ 'code',
229
+ 'name',
230
+ 'description',
231
+ 'kind',
232
+ 'unit_code',
233
+ 'currency_code',
234
+ 'sale_price::text',
235
+ 'purchase_price::text',
236
+ 'sale_account_id',
237
+ 'purchase_account_id',
238
+ 'sale_tax_id',
239
+ 'purchase_tax_id',
240
+ 'active',
241
+ ];
242
+ export const DOCUMENT_LINE = [
243
+ 'id',
244
+ 'document_id',
245
+ 'sequence',
246
+ 'line_type',
247
+ 'name',
248
+ 'description',
249
+ 'product_id',
250
+ 'quantity::text',
251
+ 'unit_code',
252
+ 'unit_price::text',
253
+ 'discount_percent::text',
254
+ 'tax_id',
255
+ 'account_id',
256
+ 'vat_category',
257
+ 'vat_rate::text',
258
+ 'amount_untaxed::text',
259
+ ];
260
+ export const ENTRY = [
261
+ 'id',
262
+ 'company_id',
263
+ 'journal_id',
264
+ 'number',
265
+ 'entry_date::text',
266
+ 'reference',
267
+ 'description',
268
+ 'state',
269
+ 'kind',
270
+ 'document_id',
271
+ 'total_debit::text',
272
+ 'total_credit::text',
273
+ 'is_balanced',
274
+ 'posted_at::text',
275
+ ];
276
+ export const ENTRY_LINE = [
277
+ 'id',
278
+ 'entry_id',
279
+ 'account_id',
280
+ 'sequence',
281
+ 'name',
282
+ 'debit::text',
283
+ 'credit::text',
284
+ 'balance::text',
285
+ 'contact_id',
286
+ 'date_maturity::text',
287
+ 'tax_id',
288
+ 'tax_line',
289
+ 'declaration_box',
290
+ 'box_amount::text',
291
+ 'matching_number',
292
+ 'matched_amount::text',
293
+ // The currency of the line and its amount in it, written whenever that
294
+ // currency is not the company's. A client matching two foreign lines needs
295
+ // both: that is the scale the matching is worked out on.
296
+ 'currency_code',
297
+ 'amount_currency::text',
298
+ ];
299
+ export const BANK_ACCOUNT = [
300
+ 'id',
301
+ 'name',
302
+ 'iban',
303
+ 'bic',
304
+ 'bank_name',
305
+ 'currency_code',
306
+ 'account_id',
307
+ 'journal_id',
308
+ 'active',
309
+ ];
310
+ export const BANK_TRANSACTION = [
311
+ 'id',
312
+ 'company_id',
313
+ 'bank_account_id',
314
+ 'statement_id',
315
+ 'transaction_date::text',
316
+ 'value_date::text',
317
+ 'amount::text',
318
+ 'currency_code',
319
+ 'description',
320
+ 'counterpart_name',
321
+ 'counterpart_iban',
322
+ 'reference',
323
+ 'structured_reference',
324
+ 'contact_id',
325
+ 'entry_id',
326
+ 'state',
327
+ ];
328
+ export const PAYMENT = [
329
+ 'id',
330
+ 'company_id',
331
+ 'direction',
332
+ 'payment_date::text',
333
+ 'amount::text',
334
+ 'currency_code',
335
+ 'contact_id',
336
+ 'journal_id',
337
+ 'bank_account_id',
338
+ 'entry_id',
339
+ 'reference',
340
+ 'memo',
341
+ 'state',
342
+ ];
343
+ /**
344
+ * An invitation, without its secret. `token_hash` is deliberately absent: it
345
+ * is of no use to a client, and a list of hashes is a thing to leak rather
346
+ * than a thing to show.
347
+ */
348
+ /** What one person chose for themselves. Null everywhere is the fresh state. */
349
+ export const USER_PREFERENCES = [
350
+ 'user_id',
351
+ 'preferred_company_id',
352
+ 'language',
353
+ 'timezone',
354
+ 'date_display_format',
355
+ 'number_display_format',
356
+ 'theme',
357
+ 'updated_at::text',
358
+ ];
359
+ export const INVITATION = [
360
+ 'id',
361
+ 'company_id',
362
+ 'email',
363
+ 'role',
364
+ 'capabilities_granted',
365
+ 'invited_by',
366
+ 'created_at::text',
367
+ 'expires_at::text',
368
+ 'accepted_at::text',
369
+ 'accepted_by',
370
+ 'revoked_at::text',
371
+ ];
372
+ /** A machine key, without its hash. The secret is returned once, elsewhere. */
373
+ export const API_KEY = [
374
+ 'id',
375
+ 'company_id',
376
+ 'name',
377
+ 'prefix',
378
+ 'capabilities',
379
+ 'created_by',
380
+ 'created_at::text',
381
+ 'expires_at::text',
382
+ 'last_used_at::text',
383
+ 'revoked_at::text',
384
+ ];
385
+ export const INSTANCE = [
386
+ 'instance_id',
387
+ 'organization_name',
388
+ 'country',
389
+ 'edition',
390
+ 'schema_version',
391
+ 'installed_at::text',
392
+ 'registered_at::text',
393
+ ];
394
+ export const RECONCILIATION = [
395
+ 'id',
396
+ 'debit_line_id',
397
+ 'credit_line_id',
398
+ 'amount::text',
399
+ 'matching_number',
400
+ 'matched_at::text',
401
+ // What the matching revealed, when it revealed something: the entry that
402
+ // booked the realised exchange difference, and the one that moved the share
403
+ // of a cash-basis tax the settlement made due. A client that shows a
404
+ // matching shows what it caused.
405
+ 'fx_entry_id',
406
+ 'tax_transfer_entry_id',
407
+ ];
408
+ export const AUDIT_LOG = [
409
+ 'id',
410
+ 'occurred_at::text',
411
+ 'actor_id',
412
+ 'api_key_id',
413
+ 'company_id',
414
+ 'table_name',
415
+ 'record_id',
416
+ 'record_key',
417
+ 'operation',
418
+ 'action',
419
+ 'old_values',
420
+ 'new_values',
421
+ ];
422
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.js","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,aAAa;IACb,MAAM;IACN,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,SAAS;IACT,UAAU;IACV,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,iBAAiB;IACjB,mBAAmB;IACnB,yBAAyB;IACzB,UAAU;IACV,eAAe;IACf,iBAAiB;IACjB,qBAAqB;IACrB,uBAAuB;IACvB,oBAAoB;IACpB,qBAAqB;IACrB,8BAA8B;IAC9B,kBAAkB;IAClB,qBAAqB;IACrB,0BAA0B;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,MAAM;IACN,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,YAAY;CACb,CAAC;AAEF,MAAM,CAA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
11
  *
12
12
  * The one thing this file exists to refuse is a `service_role` key. It would
13
13
  * work — that is the problem. Every policy in the schema would be bypassed,
14
- * and an assistant that can read every company of an installation is not the
14
+ * and an agent that can read every company of an installation is not the
15
15
  * thing anybody asked for. It is refused wherever it can arrive, and there are
16
16
  * two doors, not one: `SUPABASE_ANON_KEY` is the obvious paste, and
17
17
  * `EKWO_ACCESS_TOKEN` is the quiet one — it goes into the `Authorization`
package/dist/config.js CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * The one thing this file exists to refuse is a `service_role` key. It would
13
13
  * work — that is the problem. Every policy in the schema would be bypassed,
14
- * and an assistant that can read every company of an installation is not the
14
+ * and an agent that can read every company of an installation is not the
15
15
  * thing anybody asked for. It is refused wherever it can arrive, and there are
16
16
  * two doors, not one: `SUPABASE_ANON_KEY` is the obvious paste, and
17
17
  * `EKWO_ACCESS_TOKEN` is the quiet one — it goes into the `Authorization`
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Amounts as decimal strings, everywhere, in both directions.
3
+ *
4
+ * Postgres holds `numeric` exactly and hands it over as text; a table read
5
+ * asks for `amount::text` so that is what arrives. The one place a float can
6
+ * appear is a function result crossing PostgREST as JSON, where `1210.00`
7
+ * becomes a number before any code of ours sees it. `money()` puts it back to
8
+ * two decimals, which is exact for every amount a ledger holds, and a model
9
+ * reading `"1210.00"` never has to wonder whether `1210.0000000001` was the
10
+ * VAT rounding or the transport.
11
+ */
12
+ export type Decimal = string;
13
+ /** A numeric, as the decimal string the ledger holds. */
14
+ export declare function money(value: unknown): Decimal | null;
15
+ /** The same, for a quantity or a rate, where two decimals would be a lie. */
16
+ export declare function decimal(value: unknown): Decimal | null;
17
+ /** Applies `money()` to the named keys of every row. */
18
+ export declare function moneyFields<T extends Record<string, unknown>>(rows: T[], keys: string[]): T[];
19
+ /** An amount on its way into the database: `"1210.00"`, never 1210.0000001. */
20
+ export declare function amountIn(value: string | number): string;
21
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,yDAAyD;AACzD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAKpD;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAItD;AAED,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAQ7F;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMvD"}