@lssm/example.openbanking-powens 0.0.0-canary-20251217062139 → 0.0.0-canary-20251217072406

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 (43) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +74 -70
  2. package/.turbo/turbo-build.log +75 -29
  3. package/CHANGELOG.md +4 -3
  4. package/dist/docs/index.js +1 -1
  5. package/dist/docs/openbanking-powens.docblock.js +28 -12
  6. package/dist/example.js +39 -1
  7. package/dist/handlers/oauth-callback.js +63 -1
  8. package/dist/handlers/webhook-handler.js +87 -1
  9. package/dist/index.js +6 -1
  10. package/dist/integrations/providers-impls/dist/impls/powens-client.js +171 -1
  11. package/dist/integrations/providers-impls/dist/impls/powens-openbanking.js +218 -1
  12. package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
  13. package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
  14. package/dist/libs/contracts/dist/docs/index.js +29 -1
  15. package/dist/libs/contracts/dist/docs/presentations.js +71 -1
  16. package/dist/libs/contracts/dist/docs/registry.js +44 -1
  17. package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
  18. package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
  19. package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
  20. package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
  21. package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
  22. package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
  23. package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
  24. package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
  25. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
  26. package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
  27. package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
  28. package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
  29. package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
  30. package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
  31. package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
  32. package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
  33. package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
  34. package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
  35. package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
  36. package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
  37. package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
  38. package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
  39. package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
  40. package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
  41. package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
  42. package/package.json +6 -5
  43. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1,171 @@
1
- import{URL as e}from"node:url";const t={sandbox:`https://api-sandbox.powens.com/v2`,production:`https://api.powens.com/v2`};var n=class extends Error{status;code;requestId;response;constructor(e,t,n,r,i){super(e),this.name=`PowensClientError`,this.status=t,this.code=n,this.requestId=r,this.response=i}},r=class{clientId;clientSecret;apiKey;fetchImpl;logger;defaultTimeoutMs;token;baseUrl;constructor(e){this.clientId=e.clientId,this.clientSecret=e.clientSecret,this.apiKey=e.apiKey,this.fetchImpl=e.fetchImpl??fetch,this.logger=e.logger,this.defaultTimeoutMs=e.defaultTimeoutMs??15e3,this.baseUrl=e.baseUrl??t[e.environment]??t.production}async listAccounts(e){let t={cursor:e.cursor,limit:e.limit,include_balances:e.includeBalances,institution_uuid:e.institutionUuid};return await this.request({method:`GET`,path:`/users/${encodeURIComponent(e.userUuid)}/accounts`,searchParams:t})}async getAccount(e){return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e)}`})}async listTransactions(e){let t={cursor:e.cursor,limit:e.limit,from:e.from,to:e.to,include_pending:e.includePending};return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e.accountUuid)}/transactions`,searchParams:t})}async getBalances(e){return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/balances`})}async getConnectionStatus(e){return this.request({method:`GET`,path:`/connections/${encodeURIComponent(e)}`})}async request(t){let r=new e(t.path,this.baseUrl);if(t.searchParams)for(let[e,n]of Object.entries(t.searchParams))n!=null&&r.searchParams.set(e,String(n));let i={Accept:`application/json`,"Content-Type":`application/json`,...t.headers};this.apiKey&&(i[`x-api-key`]=this.apiKey),t.skipAuth||(i.Authorization=`Bearer ${await this.ensureAccessToken()}`);let a=new AbortController,o=setTimeout(()=>a.abort(),t.timeoutMs??this.defaultTimeoutMs);try{let e=await this.fetchImpl(r,{method:t.method,headers:i,body:t.body?JSON.stringify(t.body):void 0,signal:a.signal}),o=e.headers.get(`x-request-id`)??void 0;if(!e.ok){let t;try{t=await e.json()}catch{}let r=typeof t==`object`&&t?t:void 0,i=typeof r?.message==`string`?r.message:`Powens API request failed with status ${e.status}`,a=typeof r?.code==`string`?r.code:void 0;throw new n(i,e.status,a,o,t)}if(e.status===204)return;try{return await e.json()}catch(t){throw this.logger?.error?.(`[PowensClient] Failed to parse JSON response`,t),new n(`Failed to parse Powens response payload as JSON`,e.status,void 0,o)}}catch(e){throw e instanceof n?e:e.name===`AbortError`?new n(`Powens API request timed out after ${t.timeoutMs??this.defaultTimeoutMs}ms`,408):(this.logger?.error?.(`[PowensClient] Request failed`,e),new n(e.message??`Powens API request failed`,500))}finally{clearTimeout(o)}}async ensureAccessToken(){return this.token&&Date.now()<this.token.expiresAt-5e3||(this.token=await this.fetchAccessToken()),this.token.accessToken}async fetchAccessToken(){let t=new e(`/oauth/token`,this.baseUrl),r=Buffer.from(`${this.clientId}:${this.clientSecret}`,`utf-8`).toString(`base64`),i=await this.fetchImpl(t,{method:`POST`,headers:{Authorization:`Basic ${r}`,"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`},body:new URLSearchParams({grant_type:`client_credentials`}).toString()});if(!i.ok){let e;try{e=await i.json()}catch{}let t=typeof e==`object`&&e?e:void 0;throw new n(typeof t?.error_description==`string`?t.error_description:`Failed to obtain Powens access token`,i.status,void 0,void 0,e)}let a=await i.json(),o=Date.now()+a.expires_in*1e3;return this.logger?.debug?.(`[PowensClient] Received access token`,{expiresIn:a.expires_in}),{accessToken:a.access_token,expiresAt:o,scope:a.scope}}};export{n,r};
1
+ import { URL } from "node:url";
2
+
3
+ //#region ../../integrations/providers-impls/dist/impls/powens-client.js
4
+ const POWENS_BASE_URL = {
5
+ sandbox: "https://api-sandbox.powens.com/v2",
6
+ production: "https://api.powens.com/v2"
7
+ };
8
+ var PowensClientError = class extends Error {
9
+ status;
10
+ code;
11
+ requestId;
12
+ response;
13
+ constructor(message, status, code, requestId, response) {
14
+ super(message);
15
+ this.name = "PowensClientError";
16
+ this.status = status;
17
+ this.code = code;
18
+ this.requestId = requestId;
19
+ this.response = response;
20
+ }
21
+ };
22
+ var PowensClient = class {
23
+ clientId;
24
+ clientSecret;
25
+ apiKey;
26
+ fetchImpl;
27
+ logger;
28
+ defaultTimeoutMs;
29
+ token;
30
+ baseUrl;
31
+ constructor(options) {
32
+ this.clientId = options.clientId;
33
+ this.clientSecret = options.clientSecret;
34
+ this.apiKey = options.apiKey;
35
+ this.fetchImpl = options.fetchImpl ?? fetch;
36
+ this.logger = options.logger;
37
+ this.defaultTimeoutMs = options.defaultTimeoutMs ?? 15e3;
38
+ this.baseUrl = options.baseUrl ?? POWENS_BASE_URL[options.environment] ?? POWENS_BASE_URL.production;
39
+ }
40
+ async listAccounts(params) {
41
+ const searchParams = {
42
+ cursor: params.cursor,
43
+ limit: params.limit,
44
+ include_balances: params.includeBalances,
45
+ institution_uuid: params.institutionUuid
46
+ };
47
+ return await this.request({
48
+ method: "GET",
49
+ path: `/users/${encodeURIComponent(params.userUuid)}/accounts`,
50
+ searchParams
51
+ });
52
+ }
53
+ async getAccount(accountUuid) {
54
+ return this.request({
55
+ method: "GET",
56
+ path: `/accounts/${encodeURIComponent(accountUuid)}`
57
+ });
58
+ }
59
+ async listTransactions(params) {
60
+ const searchParams = {
61
+ cursor: params.cursor,
62
+ limit: params.limit,
63
+ from: params.from,
64
+ to: params.to,
65
+ include_pending: params.includePending
66
+ };
67
+ return this.request({
68
+ method: "GET",
69
+ path: `/accounts/${encodeURIComponent(params.accountUuid)}/transactions`,
70
+ searchParams
71
+ });
72
+ }
73
+ async getBalances(accountUuid) {
74
+ return this.request({
75
+ method: "GET",
76
+ path: `/accounts/${encodeURIComponent(accountUuid)}/balances`
77
+ });
78
+ }
79
+ async getConnectionStatus(connectionUuid) {
80
+ return this.request({
81
+ method: "GET",
82
+ path: `/connections/${encodeURIComponent(connectionUuid)}`
83
+ });
84
+ }
85
+ async request(options) {
86
+ const url = new URL(options.path, this.baseUrl);
87
+ if (options.searchParams) for (const [key, value] of Object.entries(options.searchParams)) {
88
+ if (value === void 0 || value === null) continue;
89
+ url.searchParams.set(key, String(value));
90
+ }
91
+ const headers = {
92
+ Accept: "application/json",
93
+ "Content-Type": "application/json",
94
+ ...options.headers
95
+ };
96
+ if (this.apiKey) headers["x-api-key"] = this.apiKey;
97
+ if (!options.skipAuth) headers.Authorization = `Bearer ${await this.ensureAccessToken()}`;
98
+ const controller = new AbortController();
99
+ const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.defaultTimeoutMs);
100
+ try {
101
+ const response = await this.fetchImpl(url, {
102
+ method: options.method,
103
+ headers,
104
+ body: options.body ? JSON.stringify(options.body) : void 0,
105
+ signal: controller.signal
106
+ });
107
+ const requestId = response.headers.get("x-request-id") ?? void 0;
108
+ if (!response.ok) {
109
+ let errorBody;
110
+ try {
111
+ errorBody = await response.json();
112
+ } catch {}
113
+ const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
114
+ const message = typeof errorObject?.message === "string" ? errorObject.message : `Powens API request failed with status ${response.status}`;
115
+ const code = typeof errorObject?.code === "string" ? errorObject.code : void 0;
116
+ throw new PowensClientError(message, response.status, code, requestId, errorBody);
117
+ }
118
+ if (response.status === 204) return;
119
+ try {
120
+ return await response.json();
121
+ } catch (error) {
122
+ this.logger?.error?.("[PowensClient] Failed to parse JSON response", error);
123
+ throw new PowensClientError("Failed to parse Powens response payload as JSON", response.status, void 0, requestId);
124
+ }
125
+ } catch (error) {
126
+ if (error instanceof PowensClientError) throw error;
127
+ if (error.name === "AbortError") throw new PowensClientError(`Powens API request timed out after ${options.timeoutMs ?? this.defaultTimeoutMs}ms`, 408);
128
+ this.logger?.error?.("[PowensClient] Request failed", error);
129
+ throw new PowensClientError(error.message ?? "Powens API request failed", 500);
130
+ } finally {
131
+ clearTimeout(timeout);
132
+ }
133
+ }
134
+ async ensureAccessToken() {
135
+ if (this.token && Date.now() < this.token.expiresAt - 5e3) return this.token.accessToken;
136
+ this.token = await this.fetchAccessToken();
137
+ return this.token.accessToken;
138
+ }
139
+ async fetchAccessToken() {
140
+ const url = new URL("/oauth/token", this.baseUrl);
141
+ const basicAuth = Buffer.from(`${this.clientId}:${this.clientSecret}`, "utf-8").toString("base64");
142
+ const response = await this.fetchImpl(url, {
143
+ method: "POST",
144
+ headers: {
145
+ Authorization: `Basic ${basicAuth}`,
146
+ "Content-Type": "application/x-www-form-urlencoded",
147
+ Accept: "application/json"
148
+ },
149
+ body: new URLSearchParams({ grant_type: "client_credentials" }).toString()
150
+ });
151
+ if (!response.ok) {
152
+ let errorBody;
153
+ try {
154
+ errorBody = await response.json();
155
+ } catch {}
156
+ const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
157
+ throw new PowensClientError(typeof errorObject?.error_description === "string" ? errorObject.error_description : "Failed to obtain Powens access token", response.status, void 0, void 0, errorBody);
158
+ }
159
+ const payload = await response.json();
160
+ const expiresAt = Date.now() + payload.expires_in * 1e3;
161
+ this.logger?.debug?.("[PowensClient] Received access token", { expiresIn: payload.expires_in });
162
+ return {
163
+ accessToken: payload.access_token,
164
+ expiresAt,
165
+ scope: payload.scope
166
+ };
167
+ }
168
+ };
169
+
170
+ //#endregion
171
+ export { PowensClient, PowensClientError };
@@ -1 +1,218 @@
1
- import{n as e,r as t}from"./powens-client.js";var n=class{client;logger;constructor(e){this.client=new t(e),this.logger=e.logger}async listAccounts(t){if(!t.userId)throw new e(`Powens account listing requires the upstream userId mapped to Powens user UUID.`,400);let n=this.toContext(t.tenantId,t.connectionId);try{let e=await this.client.listAccounts({userUuid:t.userId,cursor:t.cursor,limit:t.pageSize,includeBalances:t.includeBalances,institutionUuid:t.institutionId});return{accounts:e.accounts.map(e=>this.mapAccount(e,n)),nextCursor:e.pagination?.nextCursor,hasMore:e.pagination?.hasMore}}catch(e){this.handleError(`listAccounts`,e)}}async getAccountDetails(e){let t=this.toContext(e.tenantId,e.connectionId);try{let n=await this.client.getAccount(e.accountId);return this.mapAccountDetails(n,t)}catch(e){this.handleError(`getAccountDetails`,e)}}async listTransactions(e){let t=this.toContext(e.tenantId,e.connectionId);try{let n=await this.client.listTransactions({accountUuid:e.accountId,cursor:e.cursor,limit:e.pageSize,from:e.from,to:e.to,includePending:e.includePending});return{transactions:n.transactions.map(e=>this.mapTransaction(e,t)),nextCursor:n.pagination?.nextCursor,hasMore:n.pagination?.hasMore}}catch(e){this.handleError(`listTransactions`,e)}}async getBalances(e){let t=this.toContext(e.tenantId,e.connectionId);try{return(await this.client.getBalances(e.accountId)).filter(t=>e.balanceTypes?.length?e.balanceTypes.includes(t.type):!0).map(e=>this.mapBalance(e,t))}catch(e){this.handleError(`getBalances`,e)}}async getConnectionStatus(e){try{let t=await this.client.getConnectionStatus(e.connectionId);return{connectionId:e.connectionId,tenantId:e.tenantId,status:this.mapConnectionStatus(t.status),lastCheckedAt:t.lastAttemptAt,errorCode:t.errorCode,errorMessage:t.errorMessage,details:t.metadata}}catch(e){this.handleError(`getConnectionStatus`,e)}}mapAccount(e,t){return{id:e.uuid,externalId:e.reference??e.uuid,tenantId:t.tenantId,connectionId:t.connectionId,userId:e.userUuid,displayName:e.name,institutionId:e.institution.id,institutionName:e.institution.name,institutionLogoUrl:e.institution.logoUrl,accountType:e.type??`unknown`,iban:e.iban,bic:e.bic,currency:e.currency??`EUR`,accountNumberMasked:e.metadata?.account_number_masked,ownership:this.mapOwnership(e.metadata?.ownership),status:this.mapAccountStatus(e.status),lastSyncedAt:e.metadata?.last_sync_at,metadata:e.metadata}}mapAccountDetails(e,t){return{...this.mapAccount(e,t),productCode:e.metadata?.product_code,openedAt:e.metadata?.opened_at,closedAt:e.metadata?.closed_at,availableBalance:e.availableBalance??void 0,currentBalance:e.balance??void 0,creditLimit:e.metadata?.credit_limit,customFields:e.metadata}}mapTransaction(e,t){return{id:e.uuid,externalId:e.uuid,tenantId:t.tenantId,accountId:e.accountUuid,connectionId:t.connectionId,amount:e.amount,currency:e.currency,direction:e.direction===`credit`?`credit`:`debit`,description:e.description??e.rawLabel,bookingDate:e.bookingDate,valueDate:e.valueDate,postedAt:e.bookingDate,category:e.category,rawCategory:e.rawLabel,merchantName:e.merchantName,merchantCategoryCode:e.merchantCategoryCode,counterpartyName:e.counterpartyName,counterpartyAccount:e.counterpartyAccount,reference:e.metadata?.reference,status:this.mapTransactionStatus(e.status),metadata:e.metadata}}mapBalance(e,t){return{accountId:e.accountUuid,connectionId:t.connectionId,tenantId:t.tenantId,type:e.type??`current`,currency:e.currency??`EUR`,amount:e.amount,lastUpdatedAt:e.updatedAt,metadata:e.metadata}}toContext(e,t){return{tenantId:e,connectionId:t}}mapOwnership(e){switch(e?.toLowerCase()){case`individual`:case`personal`:return`individual`;case`joint`:return`joint`;case`business`:case`corporate`:return`business`;default:return`unknown`}}mapAccountStatus(e){switch(e?.toLowerCase()){case`active`:case`enabled`:return`active`;case`disabled`:case`inactive`:return`inactive`;case`closed`:return`closed`;case`suspended`:return`suspended`;default:return`active`}}mapTransactionStatus(e){switch(e?.toLowerCase()){case`pending`:case`authorised`:return`pending`;case`booked`:case`posted`:return`booked`;case`cancelled`:case`rejected`:return`cancelled`;default:return`booked`}}mapConnectionStatus(e){switch(e){case`healthy`:return`healthy`;case`pending`:return`degraded`;case`error`:return`error`;case`revoked`:return`disconnected`;default:return`degraded`}}handleError(t,n){throw n instanceof e?(this.logger?.error?.(`[PowensOpenBankingProvider] ${t} failed`,{status:n.status,code:n.code,requestId:n.requestId,message:n.message}),n):(this.logger?.error?.(`[PowensOpenBankingProvider] ${t} failed with unexpected error`,n),n instanceof Error?n:Error(`Powens operation "${t}" failed`))}};export{n};
1
+ import { PowensClient, PowensClientError } from "./powens-client.js";
2
+
3
+ //#region ../../integrations/providers-impls/dist/impls/powens-openbanking.js
4
+ var PowensOpenBankingProvider = class {
5
+ client;
6
+ logger;
7
+ constructor(options) {
8
+ this.client = new PowensClient(options);
9
+ this.logger = options.logger;
10
+ }
11
+ async listAccounts(params) {
12
+ if (!params.userId) throw new PowensClientError("Powens account listing requires the upstream userId mapped to Powens user UUID.", 400);
13
+ const context = this.toContext(params.tenantId, params.connectionId);
14
+ try {
15
+ const response = await this.client.listAccounts({
16
+ userUuid: params.userId,
17
+ cursor: params.cursor,
18
+ limit: params.pageSize,
19
+ includeBalances: params.includeBalances,
20
+ institutionUuid: params.institutionId
21
+ });
22
+ return {
23
+ accounts: response.accounts.map((account) => this.mapAccount(account, context)),
24
+ nextCursor: response.pagination?.nextCursor,
25
+ hasMore: response.pagination?.hasMore
26
+ };
27
+ } catch (error) {
28
+ this.handleError("listAccounts", error);
29
+ }
30
+ }
31
+ async getAccountDetails(params) {
32
+ const context = this.toContext(params.tenantId, params.connectionId);
33
+ try {
34
+ const account = await this.client.getAccount(params.accountId);
35
+ return this.mapAccountDetails(account, context);
36
+ } catch (error) {
37
+ this.handleError("getAccountDetails", error);
38
+ }
39
+ }
40
+ async listTransactions(params) {
41
+ const context = this.toContext(params.tenantId, params.connectionId);
42
+ try {
43
+ const response = await this.client.listTransactions({
44
+ accountUuid: params.accountId,
45
+ cursor: params.cursor,
46
+ limit: params.pageSize,
47
+ from: params.from,
48
+ to: params.to,
49
+ includePending: params.includePending
50
+ });
51
+ return {
52
+ transactions: response.transactions.map((transaction) => this.mapTransaction(transaction, context)),
53
+ nextCursor: response.pagination?.nextCursor,
54
+ hasMore: response.pagination?.hasMore
55
+ };
56
+ } catch (error) {
57
+ this.handleError("listTransactions", error);
58
+ }
59
+ }
60
+ async getBalances(params) {
61
+ const context = this.toContext(params.tenantId, params.connectionId);
62
+ try {
63
+ return (await this.client.getBalances(params.accountId)).filter((balance) => params.balanceTypes?.length ? params.balanceTypes.includes(balance.type) : true).map((balance) => this.mapBalance(balance, context));
64
+ } catch (error) {
65
+ this.handleError("getBalances", error);
66
+ }
67
+ }
68
+ async getConnectionStatus(params) {
69
+ try {
70
+ const status = await this.client.getConnectionStatus(params.connectionId);
71
+ return {
72
+ connectionId: params.connectionId,
73
+ tenantId: params.tenantId,
74
+ status: this.mapConnectionStatus(status.status),
75
+ lastCheckedAt: status.lastAttemptAt,
76
+ errorCode: status.errorCode,
77
+ errorMessage: status.errorMessage,
78
+ details: status.metadata
79
+ };
80
+ } catch (error) {
81
+ this.handleError("getConnectionStatus", error);
82
+ }
83
+ }
84
+ mapAccount(account, context) {
85
+ return {
86
+ id: account.uuid,
87
+ externalId: account.reference ?? account.uuid,
88
+ tenantId: context.tenantId,
89
+ connectionId: context.connectionId,
90
+ userId: account.userUuid,
91
+ displayName: account.name,
92
+ institutionId: account.institution.id,
93
+ institutionName: account.institution.name,
94
+ institutionLogoUrl: account.institution.logoUrl,
95
+ accountType: account.type ?? "unknown",
96
+ iban: account.iban,
97
+ bic: account.bic,
98
+ currency: account.currency ?? "EUR",
99
+ accountNumberMasked: account.metadata?.account_number_masked,
100
+ ownership: this.mapOwnership(account.metadata?.ownership),
101
+ status: this.mapAccountStatus(account.status),
102
+ lastSyncedAt: account.metadata?.last_sync_at,
103
+ metadata: account.metadata
104
+ };
105
+ }
106
+ mapAccountDetails(account, context) {
107
+ return {
108
+ ...this.mapAccount(account, context),
109
+ productCode: account.metadata?.product_code,
110
+ openedAt: account.metadata?.opened_at,
111
+ closedAt: account.metadata?.closed_at,
112
+ availableBalance: account.availableBalance ?? void 0,
113
+ currentBalance: account.balance ?? void 0,
114
+ creditLimit: account.metadata?.credit_limit,
115
+ customFields: account.metadata
116
+ };
117
+ }
118
+ mapTransaction(transaction, context) {
119
+ return {
120
+ id: transaction.uuid,
121
+ externalId: transaction.uuid,
122
+ tenantId: context.tenantId,
123
+ accountId: transaction.accountUuid,
124
+ connectionId: context.connectionId,
125
+ amount: transaction.amount,
126
+ currency: transaction.currency,
127
+ direction: transaction.direction === "credit" ? "credit" : "debit",
128
+ description: transaction.description ?? transaction.rawLabel,
129
+ bookingDate: transaction.bookingDate,
130
+ valueDate: transaction.valueDate,
131
+ postedAt: transaction.bookingDate,
132
+ category: transaction.category,
133
+ rawCategory: transaction.rawLabel,
134
+ merchantName: transaction.merchantName,
135
+ merchantCategoryCode: transaction.merchantCategoryCode,
136
+ counterpartyName: transaction.counterpartyName,
137
+ counterpartyAccount: transaction.counterpartyAccount,
138
+ reference: transaction.metadata?.reference,
139
+ status: this.mapTransactionStatus(transaction.status),
140
+ metadata: transaction.metadata
141
+ };
142
+ }
143
+ mapBalance(balance, context) {
144
+ return {
145
+ accountId: balance.accountUuid,
146
+ connectionId: context.connectionId,
147
+ tenantId: context.tenantId,
148
+ type: balance.type ?? "current",
149
+ currency: balance.currency ?? "EUR",
150
+ amount: balance.amount,
151
+ lastUpdatedAt: balance.updatedAt,
152
+ metadata: balance.metadata
153
+ };
154
+ }
155
+ toContext(tenantId, connectionId) {
156
+ return {
157
+ tenantId,
158
+ connectionId
159
+ };
160
+ }
161
+ mapOwnership(value) {
162
+ switch (value?.toLowerCase()) {
163
+ case "individual":
164
+ case "personal": return "individual";
165
+ case "joint": return "joint";
166
+ case "business":
167
+ case "corporate": return "business";
168
+ default: return "unknown";
169
+ }
170
+ }
171
+ mapAccountStatus(status) {
172
+ switch (status?.toLowerCase()) {
173
+ case "active":
174
+ case "enabled": return "active";
175
+ case "disabled":
176
+ case "inactive": return "inactive";
177
+ case "closed": return "closed";
178
+ case "suspended": return "suspended";
179
+ default: return "active";
180
+ }
181
+ }
182
+ mapTransactionStatus(status) {
183
+ switch (status?.toLowerCase()) {
184
+ case "pending":
185
+ case "authorised": return "pending";
186
+ case "booked":
187
+ case "posted": return "booked";
188
+ case "cancelled":
189
+ case "rejected": return "cancelled";
190
+ default: return "booked";
191
+ }
192
+ }
193
+ mapConnectionStatus(status) {
194
+ switch (status) {
195
+ case "healthy": return "healthy";
196
+ case "pending": return "degraded";
197
+ case "error": return "error";
198
+ case "revoked": return "disconnected";
199
+ default: return "degraded";
200
+ }
201
+ }
202
+ handleError(operation, error) {
203
+ if (error instanceof PowensClientError) {
204
+ this.logger?.error?.(`[PowensOpenBankingProvider] ${operation} failed`, {
205
+ status: error.status,
206
+ code: error.code,
207
+ requestId: error.requestId,
208
+ message: error.message
209
+ });
210
+ throw error;
211
+ }
212
+ this.logger?.error?.(`[PowensOpenBankingProvider] ${operation} failed with unexpected error`, error);
213
+ throw error instanceof Error ? error : /* @__PURE__ */ new Error(`Powens operation "${operation}" failed`);
214
+ }
215
+ };
216
+
217
+ //#endregion
218
+ export { PowensOpenBankingProvider };
@@ -1,76 +1,16 @@
1
- import{a as e}from"./registry.js";e([{id:`docs.PUBLISHING`,title:`Publishing ContractSpec Libraries`,summary:`This guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).`,kind:`reference`,visibility:`public`,route:`/docs/PUBLISHING`,tags:[`PUBLISHING`],body:`# Publishing ContractSpec Libraries
2
-
3
- This guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).
4
-
5
- ## Release Tracks
6
-
7
- | Track | Branch | npm Tag | Frequency | Versioning | Use Case |
8
- |-------|--------|---------|-----------|------------|----------|
9
- | **Stable** | \`release\` | \`latest\` | Manual | SemVer (e.g., \`1.7.4\`) | Production, external users |
10
- | **Canary** | \`main\` | \`canary\` | Every Push | Snapshot (e.g., \`1.7.4-canary...\`) | Dev, internal testing |
11
-
12
- ## Prerequisites
13
-
14
- - ✅ \`NPM_TOKEN\` secret is configured in GitHub (owner or automation token with _publish_ scope).
15
- - ✅ \`GITHUB_TOKEN\` (built-in) has permissions to create PRs (enabled by default in new repos).
16
- - ✅ For stable releases: \`release\` branch exists and is protected.
17
-
18
- ## Canary Workflow (Automatic)
19
-
20
- Every commit pushed to \`main\` triggers the \`.github/workflows/publish-canary.yml\` workflow.
21
-
22
- 1. **Trigger**: Push to \`main\`.
23
- 2. **Versioning**: Runs \`changeset version --snapshot canary\` to generate a temporary snapshot version.
24
- 3. **Publish**: Packages are published to npm with the \`canary\` tag using \`changeset publish --tag canary\`.
25
-
26
- ### Consuming Canary Builds
27
-
28
- To install the latest bleeding-edge version:
29
-
30
- \`\`\`bash
31
- npm install @lssm/lib.contracts@canary
32
- # or
33
- bun add @lssm/lib.contracts@canary
34
- \`\`\`
35
-
36
- ## Stable Release Workflow (Manual)
37
-
38
- Stable releases are managed via the \`release\` branch using the standard [Changesets Action](https://github.com/changesets/action).
39
-
40
- 1. **Develop on \`main\`**: Create features and fixes.
41
- 2. **Add Changesets**: Run \`bun changeset\` to document changes and impact (major/minor/patch).
42
- 3. **Merge to \`release\`**: When ready to ship, open a PR from \`main\` to \`release\` or merge manually.
43
- 4. **"Version Packages" PR**:
44
- - The GitHub Action detects new changesets and automatically creates a Pull Request titled **"Version Packages"**.
45
- - This PR contains the version bumps and updated \`CHANGELOG.md\` files.
46
- 5. **Merge & Publish**:
47
- - Review and merge the "Version Packages" PR.
48
- - The Action runs again, detects the versions have been bumped, builds the libraries, and publishes them to npm with the \`latest\` tag.
49
-
50
- ### Publishing Steps
51
-
52
- 1. Ensure all changesets are present on \`main\`.
53
- 2. Merge \`main\` into \`release\`:
54
- \`\`\`bash
55
- git checkout release
56
- git pull origin release
57
- git merge main
58
- git push origin release
59
- \`\`\`
60
- 3. Go to GitHub Pull Requests. You will see a **"Version Packages"** PR created by the bot.
61
- 4. Merge that PR.
62
- 5. The release is now live on npm!
63
-
64
- ## Manual Verification (Optional)
65
-
66
- Before publishing a new version you can run:
67
-
68
- \`\`\`bash
69
- bun run build:not-apps
70
- npx npm-packlist --json packages/libs/contracts
71
- \`\`\`
72
-
73
- ## Rollback
74
-
75
- If a publish fails mid-way, re-run the workflow once the issue is fixed. Already published packages are skipped automatically. Use \`npm deprecate <package>@<version>\` if we need to warn consumers about a broken release.
76
- `}]);
1
+ import { registerDocBlocks } from "./registry.js";
2
+
3
+ //#region ../../libs/contracts/dist/docs/PUBLISHING.docblock.js
4
+ const PUBLISHING_DocBlocks = [{
5
+ id: "docs.PUBLISHING",
6
+ title: "Publishing ContractSpec Libraries",
7
+ summary: "This guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/PUBLISHING",
11
+ tags: ["PUBLISHING"],
12
+ body: "# Publishing ContractSpec Libraries\n\nThis guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).\n\n## Release Tracks\n\n| Track | Branch | npm Tag | Frequency | Versioning | Use Case |\n|-------|--------|---------|-----------|------------|----------|\n| **Stable** | `release` | `latest` | Manual | SemVer (e.g., `1.7.4`) | Production, external users |\n| **Canary** | `main` | `canary` | Every Push | Snapshot (e.g., `1.7.4-canary...`) | Dev, internal testing |\n\n## Prerequisites\n\n- ✅ `NPM_TOKEN` secret is configured in GitHub (owner or automation token with _publish_ scope).\n- ✅ `GITHUB_TOKEN` (built-in) has permissions to create PRs (enabled by default in new repos).\n- ✅ For stable releases: `release` branch exists and is protected.\n\n## Canary Workflow (Automatic)\n\nEvery commit pushed to `main` triggers the `.github/workflows/publish-canary.yml` workflow.\n\n1. **Trigger**: Push to `main`.\n2. **Versioning**: Runs `changeset version --snapshot canary` to generate a temporary snapshot version.\n3. **Publish**: Packages are published to npm with the `canary` tag using `changeset publish --tag canary`.\n\n### Consuming Canary Builds\n\nTo install the latest bleeding-edge version:\n\n```bash\nnpm install @lssm/lib.contracts@canary\n# or\nbun add @lssm/lib.contracts@canary\n```\n\n## Stable Release Workflow (Manual)\n\nStable releases are managed via the `release` branch using the standard [Changesets Action](https://github.com/changesets/action).\n\n1. **Develop on `main`**: Create features and fixes.\n2. **Add Changesets**: Run `bun changeset` to document changes and impact (major/minor/patch).\n3. **Merge to `release`**: When ready to ship, open a PR from `main` to `release` or merge manually.\n4. **\"Version Packages\" PR**:\n - The GitHub Action detects new changesets and automatically creates a Pull Request titled **\"Version Packages\"**.\n - This PR contains the version bumps and updated `CHANGELOG.md` files.\n5. **Merge & Publish**:\n - Review and merge the \"Version Packages\" PR.\n - The Action runs again, detects the versions have been bumped, builds the libraries, and publishes them to npm with the `latest` tag.\n\n### Publishing Steps\n\n1. Ensure all changesets are present on `main`.\n2. Merge `main` into `release`:\n ```bash\n git checkout release\n git pull origin release\n git merge main\n git push origin release\n ```\n3. Go to GitHub Pull Requests. You will see a **\"Version Packages\"** PR created by the bot.\n4. Merge that PR.\n5. The release is now live on npm!\n\n## Manual Verification (Optional)\n\nBefore publishing a new version you can run:\n\n```bash\nbun run build:not-apps\nnpx npm-packlist --json packages/libs/contracts\n```\n\n## Rollback\n\nIf a publish fails mid-way, re-run the workflow once the issue is fixed. Already published packages are skipped automatically. Use `npm deprecate <package>@<version>` if we need to warn consumers about a broken release.\n"
13
+ }];
14
+ registerDocBlocks(PUBLISHING_DocBlocks);
15
+
16
+ //#endregion