@fayz-ai/plugin-banking-br 0.9.1 → 0.10.1
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 +39 -11
- package/dist/connectors/connectorDef.d.ts +1 -1
- package/dist/connectors/connectorDef.d.ts.map +1 -1
- package/dist/data/supabase.d.ts +14 -8
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +839 -127
- package/dist/index.js.map +1 -1
- package/dist/lib/banking-events.d.ts +13 -0
- package/dist/lib/banking-events.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +2 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/schema/index.d.ts +1 -422
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema.cjs +0 -36
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.js +0 -34
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +14 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/dist/settings/BankIntegrationSettings.d.ts +0 -3
- package/dist/settings/BankIntegrationSettings.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -23,13 +23,36 @@ Addon scope: it contributes a connector into its host (`plugin-financial`) and
|
|
|
23
23
|
surfaces under **Financial → settings → Integrations**. No left-nav entry of its own.
|
|
24
24
|
|
|
25
25
|
## What it owns
|
|
26
|
-
- **DB**:
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
- **DB**: none of its own — the connection is a `plg_connections` row and the
|
|
27
|
+
history is `plg_sync_runs` (migration `003_onto_connections`). The legacy
|
|
28
|
+
`bank_integrations` / `bank_integration_sync_log` tables still stand on the
|
|
29
|
+
live pool (with a plaintext `api_token`) until FAY-1360 retires them.
|
|
30
|
+
- **RPC**: `plugbank_import_movements(p_payload jsonb)` — the door the import
|
|
31
|
+
passes through. Takes the tenant from the integration row, never from the
|
|
32
|
+
request body, and is idempotent on the financial plugin's
|
|
33
|
+
`uq_plg_financial_movements_external` index.
|
|
34
|
+
- **Edge function** (declared in `functions[]`, deployed by the app):
|
|
35
|
+
`plugbank-sync` — calls the PlugBank API, normalizes lines, imports through the
|
|
36
|
+
RPC into `public.plg_financial_movements` tagged `external_source='plugbank'`.
|
|
37
|
+
- **Fact**: `financial.movement.imported`, emitted by a trigger on the ledger so
|
|
38
|
+
it exists whoever wrote the row.
|
|
39
|
+
- **UI**: connect/disconnect, fetch a statement, import selected lines, run history.
|
|
40
|
+
|
|
41
|
+
## Where the credential lives
|
|
42
|
+
|
|
43
|
+
**Today (verified 2026-08-12): still in the pool.** The live pool's
|
|
44
|
+
`bank_integrations.api_token` holds the PlugBank token in plaintext — migration
|
|
45
|
+
`002`, which drops the `api_token` / `cnpj` columns `001` created, is in this
|
|
46
|
+
repo but unapplied there, and the deployed `plugbank-sync` (v6) still reads the
|
|
47
|
+
column. The destination is the Fayz platform's encrypted store, redeemed by the
|
|
48
|
+
edge function per call — that move is FAY-1360, and the redeem path it needs is
|
|
49
|
+
FAY-1389. The reason the columns must go: `bank_integrations` is read from the
|
|
50
|
+
browser under tenant RLS, so any member of the tenant can read them — and a pool
|
|
51
|
+
is one Supabase project serving N tenants, so anything there holding
|
|
52
|
+
`service_role` reads every tenant's at once.
|
|
53
|
+
|
|
54
|
+
If a pool ever stored those values, **rotate them**. `DROP COLUMN` is a catalog
|
|
55
|
+
change; the old bytes leave the heap only at the next table rewrite.
|
|
33
56
|
|
|
34
57
|
## How it composes with the SDK
|
|
35
58
|
- Depends on `@fayz-ai/plugin-financial`. Imported lines are reconciled in
|
|
@@ -39,11 +62,16 @@ surfaces under **Financial → settings → Integrations**. No left-nav entry of
|
|
|
39
62
|
`matched_movement_id`) live in the SDK financial migration `007_reconciliation.sql`.
|
|
40
63
|
|
|
41
64
|
## Deploy
|
|
42
|
-
1. Apply the SDK financial migration `007_reconciliation.sql
|
|
43
|
-
`
|
|
65
|
+
1. Apply the SDK financial migration `007_reconciliation.sql`, the core
|
|
66
|
+
`027_domain_events.sql` (it ships `plg_emit_event`), then this plugin's
|
|
67
|
+
`001_openbanking.sql` and `002_credential_and_facts.sql`.
|
|
44
68
|
2. `supabase functions deploy plugbank-sync` with secrets
|
|
45
69
|
`PLUGBANK_BASE_URL`, plus the standard `SUPABASE_URL` / `SUPABASE_SERVICE_ROLE_KEY`.
|
|
70
|
+
The per-tenant token is **not** a function secret: a secret is per-pool and a
|
|
71
|
+
pool serves N tenants with N different bank accounts.
|
|
46
72
|
3. Register `createOpenBankingPlugin()` in the app config and enable the
|
|
47
73
|
financial `reconciliation` module.
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
|
|
75
|
+
The period picker in the import panel is deliberate, not a missing feature —
|
|
76
|
+
whoever reconciles wants to choose the window. Scheduled pulls belong to the Fayz
|
|
77
|
+
SCHEDULE worker (FAY-1347), which owns the clock for every connector.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectorDef.d.ts","sourceRoot":"","sources":["../../src/connectors/connectorDef.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connectorDef.d.ts","sourceRoot":"","sources":["../../src/connectors/connectorDef.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAA2C,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAiIjG,eAAO,MAAM,oBAAoB,EAAE,mBAsGlC,CAAA"}
|
package/dist/data/supabase.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConnectionConfig, SyncRun } from '@fayz-ai/core';
|
|
2
|
+
import type { BankIntegration, SaveIntegrationInput, BankSyncRun, FetchStatementResult, ImportResult, BankLine } from '../types';
|
|
3
|
+
export declare const PLUGBANK_CONNECTOR_ID = "plugbank";
|
|
4
|
+
export declare function toIntegration(connection: ConnectionConfig): BankIntegration;
|
|
5
|
+
/**
|
|
6
|
+
* The audit row, read as the connector contract's SyncRun. The three facts a
|
|
7
|
+
* MANUAL statement import has and a generic run does not — the period the
|
|
8
|
+
* operator picked, and the duplicates a re-import of that period produces by
|
|
9
|
+
* design — live in `stats`, which is the column that exists for exactly this.
|
|
10
|
+
*/
|
|
11
|
+
export declare function toSyncRun(run: SyncRun): BankSyncRun;
|
|
2
12
|
export interface OpenBankingProvider {
|
|
3
13
|
getIntegration(bankAccountId?: string): Promise<BankIntegration | null>;
|
|
4
|
-
saveIntegration(input
|
|
5
|
-
|
|
6
|
-
apiToken: string;
|
|
7
|
-
cnpj: string;
|
|
8
|
-
environment?: string;
|
|
9
|
-
}): Promise<TestConnectionResult>;
|
|
14
|
+
saveIntegration(input?: SaveIntegrationInput): Promise<BankIntegration>;
|
|
15
|
+
disconnect(bankAccountId?: string): Promise<void>;
|
|
10
16
|
fetchStatement(input: {
|
|
11
17
|
integrationId: string;
|
|
12
18
|
from: string;
|
|
@@ -19,7 +25,7 @@ export interface OpenBankingProvider {
|
|
|
19
25
|
to: string;
|
|
20
26
|
lines: BankLine[];
|
|
21
27
|
}): Promise<ImportResult>;
|
|
22
|
-
|
|
28
|
+
getSyncRuns(bankAccountId?: string): Promise<BankSyncRun[]>;
|
|
23
29
|
}
|
|
24
30
|
export declare function createOpenBankingProvider(): OpenBankingProvider;
|
|
25
31
|
//# sourceMappingURL=supabase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,OAAO,EAAE,MAAM,eAAe,CAAA;AAC/E,OAAO,KAAK,EACV,eAAe,EAAE,oBAAoB,EAAE,WAAW,EAClD,oBAAoB,EAAE,YAAY,EAAE,QAAQ,EAC7C,MAAM,UAAU,CAAA;AAIjB,eAAO,MAAM,qBAAqB,aAAa,CAAA;AAwB/C,wBAAgB,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,eAAe,CAW3E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAuBnD;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAA;IACvE,eAAe,CAAC,KAAK,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACvE,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,cAAc,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACzG,kBAAkB,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAChJ,WAAW,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;CAC5D;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,CA2D/D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PluginManifest } from '@fayz-ai/core';
|
|
2
2
|
export { createOpenBankingProvider } from './data/supabase';
|
|
3
3
|
export { openBankingConnector } from './connectors/connectorDef';
|
|
4
|
+
export { buildBankingDomainEvents, MOVEMENT_IMPORTED_FIELDS } from './lib/banking-events';
|
|
4
5
|
export * from './schema';
|
|
5
6
|
export * from './types';
|
|
6
7
|
export declare function createOpenBankingPlugin(): PluginManifest;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAKnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACzF,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAKvB,wBAAgB,uBAAuB,IAAI,cAAc,CAqFxD"}
|