@techzunction/sdk 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/dist/index.cjs CHANGED
@@ -3,6 +3,9 @@
3
3
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
4
4
  // src/query.ts
5
5
  var TZQuery = class _TZQuery {
6
+ controller;
7
+ _promise;
8
+ _executor;
6
9
  constructor(executor) {
7
10
  this._executor = executor;
8
11
  this.controller = new AbortController();
@@ -42,6 +45,9 @@ var TZQuery = class _TZQuery {
42
45
  }
43
46
  };
44
47
  var TZPaginatedQuery = class extends TZQuery {
48
+ _page;
49
+ _limit;
50
+ _pageFactory;
45
51
  constructor(executor, page, limit, pageFactory) {
46
52
  super(executor);
47
53
  this._page = page;
@@ -116,9 +122,15 @@ function toQs(params) {
116
122
  return entries.length ? "?" + new URLSearchParams(entries).toString() : "";
117
123
  }
118
124
  var TZClient = class {
125
+ baseUrl;
126
+ orgSlug;
127
+ orgKey;
128
+ store;
129
+ keys;
130
+ onAuthExpired;
131
+ enduserRefreshPromise = null;
132
+ staffRefreshPromise = null;
119
133
  constructor(config) {
120
- this.enduserRefreshPromise = null;
121
- this.staffRefreshPromise = null;
122
134
  this.baseUrl = config.baseUrl.replace(/\/+$/, "");
123
135
  this.orgSlug = config.orgSlug;
124
136
  this.orgKey = config.orgKey;
@@ -376,7 +388,7 @@ var ScopedClient = class {
376
388
  const executor = async (signal) => {
377
389
  const rawRes = await this.root.rawRequest("GET", fp, { scope, signal, sendOrgKey: this.sendOrgKey });
378
390
  const envelope = rawRes.raw;
379
- const pagination = envelope.pagination ?? { page: p, limit: l, total: 0, totalPages: 0, hasNextPage: false, hasPrevPage: false };
391
+ const pagination = envelope["pagination"] ?? { page: p, limit: l, total: 0, totalPages: 0, hasNextPage: false, hasPrevPage: false };
380
392
  return {
381
393
  data: { data: rawRes.data, pagination },
382
394
  raw: rawRes.raw,
@@ -1070,6 +1082,168 @@ function createStorefrontConnectedSources(c) {
1070
1082
  };
1071
1083
  }
1072
1084
 
1085
+ // src/storefront/banking.ts
1086
+ function createStorefrontBanking(c) {
1087
+ return {
1088
+ // ─── KYC ────────────────────────────────────────────────────────
1089
+ kyc: {
1090
+ submit(data) {
1091
+ return c.post("/banking/kyc", data, "enduser");
1092
+ },
1093
+ getStatus() {
1094
+ return c.get("/banking/kyc/status", "enduser");
1095
+ }
1096
+ },
1097
+ // ─── Accounts ───────────────────────────────────────────────────
1098
+ accounts: {
1099
+ list() {
1100
+ return c.get("/banking/accounts", "enduser");
1101
+ },
1102
+ get(id) {
1103
+ return c.get(`/banking/accounts/${id}`, "enduser");
1104
+ },
1105
+ getBalance(id) {
1106
+ return c.get(`/banking/accounts/${id}/balance`, "enduser");
1107
+ },
1108
+ updateNickname(id, data) {
1109
+ return c.patch(`/banking/accounts/${id}/nickname`, data, "enduser");
1110
+ },
1111
+ setAutoSweep(id, data) {
1112
+ return c.patch(`/banking/accounts/${id}/auto-sweep`, data, "enduser");
1113
+ },
1114
+ getStatement(id, params) {
1115
+ return c.paginated(`/banking/accounts/${id}/statement`, params);
1116
+ }
1117
+ },
1118
+ // ─── Fixed Deposits ─────────────────────────────────────────────
1119
+ fixedDeposits: {
1120
+ list() {
1121
+ return c.get("/banking/accounts/fixed-deposits/list", "enduser");
1122
+ },
1123
+ create(data) {
1124
+ return c.post("/banking/accounts/fixed-deposits", data, "enduser");
1125
+ },
1126
+ close(fdId) {
1127
+ return c.del(`/banking/accounts/fixed-deposits/${fdId}`, "enduser");
1128
+ }
1129
+ },
1130
+ // ─── Transfers ──────────────────────────────────────────────────
1131
+ transfers: {
1132
+ initiate(data) {
1133
+ return c.post("/banking/transfers", data, "enduser");
1134
+ }
1135
+ },
1136
+ // ─── Beneficiaries ──────────────────────────────────────────────
1137
+ beneficiaries: {
1138
+ list() {
1139
+ return c.get("/banking/transfers/beneficiaries", "enduser");
1140
+ },
1141
+ add(data) {
1142
+ return c.post("/banking/transfers/beneficiaries", data, "enduser");
1143
+ },
1144
+ remove(id) {
1145
+ return c.del(`/banking/transfers/beneficiaries/${id}`, "enduser");
1146
+ },
1147
+ toggleFavorite(id) {
1148
+ return c.patch(`/banking/transfers/beneficiaries/${id}/favorite`, {}, "enduser");
1149
+ }
1150
+ },
1151
+ // ─── Scheduled Transfers ────────────────────────────────────────
1152
+ scheduledTransfers: {
1153
+ list() {
1154
+ return c.get("/banking/transfers/scheduled", "enduser");
1155
+ },
1156
+ create(data) {
1157
+ return c.post("/banking/transfers/scheduled", data, "enduser");
1158
+ },
1159
+ cancel(id) {
1160
+ return c.del(`/banking/transfers/scheduled/${id}`, "enduser");
1161
+ }
1162
+ },
1163
+ // ─── Bill Payments ──────────────────────────────────────────────
1164
+ bills: {
1165
+ pay(data) {
1166
+ return c.post("/banking/transfers/bills", data, "enduser");
1167
+ },
1168
+ list(params) {
1169
+ return c.paginated("/banking/transfers/bills", params);
1170
+ }
1171
+ },
1172
+ // ─── Cards ──────────────────────────────────────────────────────
1173
+ cards: {
1174
+ list() {
1175
+ return c.get("/banking/cards", "enduser");
1176
+ },
1177
+ get(id) {
1178
+ return c.get(`/banking/cards/${id}`, "enduser");
1179
+ },
1180
+ generateVirtual(data) {
1181
+ return c.post("/banking/cards", data, "enduser");
1182
+ },
1183
+ block(id) {
1184
+ return c.post(`/banking/cards/${id}/block`, {}, "enduser");
1185
+ },
1186
+ unblock(id) {
1187
+ return c.post(`/banking/cards/${id}/unblock`, {}, "enduser");
1188
+ },
1189
+ updateLimits(id, data) {
1190
+ return c.patch(`/banking/cards/${id}/limits`, data, "enduser");
1191
+ },
1192
+ toggleInternational(id, data) {
1193
+ return c.patch(`/banking/cards/${id}/international`, data, "enduser");
1194
+ },
1195
+ toggleContactless(id, data) {
1196
+ return c.patch(`/banking/cards/${id}/contactless`, data, "enduser");
1197
+ },
1198
+ toggleOnline(id, data) {
1199
+ return c.patch(`/banking/cards/${id}/online`, data, "enduser");
1200
+ }
1201
+ },
1202
+ // ─── Analytics ──────────────────────────────────────────────────
1203
+ analytics: {
1204
+ getSpendingBreakdown(months) {
1205
+ return c.get(`/banking/analytics/spending${toQs({ months })}`, "enduser");
1206
+ },
1207
+ getMonthlyTrends(months) {
1208
+ return c.get(`/banking/analytics/trends${toQs({ months })}`, "enduser");
1209
+ },
1210
+ getCashFlow(startDate, endDate) {
1211
+ return c.get(`/banking/analytics/cash-flow${toQs({ startDate, endDate })}`, "enduser");
1212
+ },
1213
+ getNetWorth() {
1214
+ return c.get("/banking/analytics/net-worth", "enduser");
1215
+ },
1216
+ getCategories() {
1217
+ return c.get("/banking/analytics/categories");
1218
+ }
1219
+ },
1220
+ // ─── Budgets ────────────────────────────────────────────────────
1221
+ budgets: {
1222
+ list() {
1223
+ return c.get("/banking/analytics/budgets", "enduser");
1224
+ },
1225
+ set(data) {
1226
+ return c.post("/banking/analytics/budgets", data, "enduser");
1227
+ },
1228
+ remove(category) {
1229
+ return c.del(`/banking/analytics/budgets/${category}`, "enduser");
1230
+ }
1231
+ },
1232
+ // ─── Anomaly Alerts ─────────────────────────────────────────────
1233
+ alerts: {
1234
+ list(params) {
1235
+ return c.paginated("/banking/analytics/alerts", params);
1236
+ },
1237
+ markRead(id) {
1238
+ return c.post(`/banking/analytics/alerts/${id}/read`, {}, "enduser");
1239
+ },
1240
+ dismiss(id) {
1241
+ return c.post(`/banking/analytics/alerts/${id}/dismiss`, {}, "enduser");
1242
+ }
1243
+ }
1244
+ };
1245
+ }
1246
+
1073
1247
  // src/storefront/index.ts
1074
1248
  function createStorefront(c) {
1075
1249
  return {
@@ -1103,7 +1277,8 @@ function createStorefront(c) {
1103
1277
  help: createStorefrontHelp(c),
1104
1278
  rooms: createStorefrontRooms(c),
1105
1279
  earnings: createStorefrontEarnings(c),
1106
- connectedSources: createStorefrontConnectedSources(c)
1280
+ connectedSources: createStorefrontConnectedSources(c),
1281
+ banking: createStorefrontBanking(c)
1107
1282
  };
1108
1283
  }
1109
1284
 
@@ -2456,10 +2631,10 @@ var TZ = {
2456
2631
  const config = {
2457
2632
  baseUrl,
2458
2633
  orgSlug,
2459
- orgKey,
2460
2634
  keyPrefix: options.keyPrefix ?? "tz",
2461
- tokenStore: options.tokenStore,
2462
- onAuthExpired: options.onAuthExpired
2635
+ ...orgKey != null ? { orgKey } : {},
2636
+ ...options.tokenStore != null ? { tokenStore: options.tokenStore } : {},
2637
+ ...options.onAuthExpired != null ? { onAuthExpired: options.onAuthExpired } : {}
2463
2638
  };
2464
2639
  _client = new TZClient(config);
2465
2640
  _sf = _client.scoped("/storefront", "public", true);
@@ -2511,10 +2686,10 @@ function createTZ(options = {}) {
2511
2686
  const client = new TZClient({
2512
2687
  baseUrl,
2513
2688
  orgSlug,
2514
- orgKey,
2515
2689
  keyPrefix: options.keyPrefix ?? "tz",
2516
- tokenStore: options.tokenStore,
2517
- onAuthExpired: options.onAuthExpired
2690
+ ...orgKey != null ? { orgKey } : {},
2691
+ ...options.tokenStore != null ? { tokenStore: options.tokenStore } : {},
2692
+ ...options.onAuthExpired != null ? { onAuthExpired: options.onAuthExpired } : {}
2518
2693
  });
2519
2694
  const sf = client.scoped("/storefront", "public", true);
2520
2695
  const admin = client.scoped("", "staff", false);