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