@insurup/sdk 0.1.14 → 0.1.16

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 (34) hide show
  1. package/README.md +46 -14
  2. package/dist/client/client.d.ts +7 -0
  3. package/dist/client/client.d.ts.map +1 -1
  4. package/dist/client/signalr.d.ts +69 -0
  5. package/dist/client/signalr.d.ts.map +1 -0
  6. package/dist/clients/_internal/build-filter-search-variables.d.ts +12 -0
  7. package/dist/clients/_internal/build-filter-search-variables.d.ts.map +1 -0
  8. package/dist/clients/_internal/normalize-search.d.ts +21 -0
  9. package/dist/clients/_internal/normalize-search.d.ts.map +1 -0
  10. package/dist/clients/_internal/split-unified-filter.d.ts +16 -0
  11. package/dist/clients/_internal/split-unified-filter.d.ts.map +1 -0
  12. package/dist/clients/agentUser.d.ts.map +1 -1
  13. package/dist/clients/case.d.ts.map +1 -1
  14. package/dist/clients/customer.d.ts +39 -3
  15. package/dist/clients/customer.d.ts.map +1 -1
  16. package/dist/clients/policy.d.ts.map +1 -1
  17. package/dist/clients/proposal.d.ts +28 -1
  18. package/dist/clients/proposal.d.ts.map +1 -1
  19. package/dist/clients/webhook.d.ts.map +1 -1
  20. package/dist/core/config.d.ts +1 -1
  21. package/dist/core/config.d.ts.map +1 -1
  22. package/dist/core/endpoints.d.ts +45 -4
  23. package/dist/core/endpoints.d.ts.map +1 -1
  24. package/dist/core/options.d.ts +13 -0
  25. package/dist/core/options.d.ts.map +1 -1
  26. package/dist/index.browser.js +24 -24
  27. package/dist/index.browser.js.map +1 -1
  28. package/dist/index.cjs +448 -41
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +451 -41
  33. package/dist/index.js.map +1 -1
  34. package/package.json +3 -2
package/dist/index.cjs CHANGED
@@ -45,6 +45,8 @@ __export(index_exports, {
45
45
  InsurUpTemplateClient: () => InsurUpTemplateClient,
46
46
  InsurUpVehicleClient: () => InsurUpVehicleClient,
47
47
  InsurUpWebhookClient: () => InsurUpWebhookClient,
48
+ SignalRLogLevel: () => import_signalr4.LogLevel,
49
+ SignalRTransport: () => SignalRTransport,
48
50
  VERSION: () => VERSION,
49
51
  createGraphQLErrors: () => createGraphQLErrors,
50
52
  extractError: () => extractError,
@@ -58,7 +60,7 @@ module.exports = __toCommonJS(index_exports);
58
60
  // package.json
59
61
  var package_default = {
60
62
  name: "@insurup/sdk",
61
- version: "0.1.14",
63
+ version: "0.1.16",
62
64
  description: "Type-safe TypeScript SDK for the InsurUp insurance platform with GraphQL support. Tree-shakeable, works everywhere.",
63
65
  keywords: [
64
66
  "insurup",
@@ -139,7 +141,8 @@ var package_default = {
139
141
  vitest: "^4.1.6"
140
142
  },
141
143
  dependencies: {
142
- "@insurup/contracts": "workspace:*"
144
+ "@insurup/contracts": "workspace:*",
145
+ "@microsoft/signalr": "^10.0.0"
143
146
  }
144
147
  };
145
148
 
@@ -1249,6 +1252,170 @@ var GraphQLTransport = class {
1249
1252
  }
1250
1253
  };
1251
1254
 
1255
+ // src/client/signalr.ts
1256
+ var import_signalr = require("@microsoft/signalr");
1257
+ var HUB_METHODS = {
1258
+ success: "ReceiveProposalProductSuccess",
1259
+ failed: "ReceiveProposalProductFailed",
1260
+ inProgress: "ReceiveProposalProductInProgress",
1261
+ revised: "ReceiveProposalProductRevised",
1262
+ purchasing: "ReceiveProposalProductPurchasing",
1263
+ purchased: "ReceiveProposalProductPurchased",
1264
+ purchaseFailed: "ReceiveProposalProductPurchaseFailed",
1265
+ coverage: "ReceiveProposalProductCoverage"
1266
+ };
1267
+ var HUB_PATH = "/hubs/proposal-detail";
1268
+ var REGISTER_METHOD = "Register";
1269
+ var SignalRTransport = class {
1270
+ hubUrl;
1271
+ tokenProvider;
1272
+ logLevel;
1273
+ connection = null;
1274
+ /** Pending or in-flight start, shared by concurrent subscribers. */
1275
+ startPromise = null;
1276
+ /** Active subscriptions keyed by proposalId. */
1277
+ subscribers = /* @__PURE__ */ new Map();
1278
+ constructor(options) {
1279
+ this.hubUrl = new URL(HUB_PATH, ensureTrailingSlash(options.hubsBaseUrl)).toString();
1280
+ this.tokenProvider = options.tokenProvider;
1281
+ this.logLevel = options.logLevel ?? import_signalr.LogLevel.Warning;
1282
+ }
1283
+ /**
1284
+ * Subscribe to proposal-detail events for a given proposal. Opens the
1285
+ * underlying hub connection on first subscribe.
1286
+ *
1287
+ * @returns an unsubscribe function. When the last subscriber for the last
1288
+ * proposal unsubscribes, the underlying connection is stopped.
1289
+ */
1290
+ async subscribeProposalDetail(proposalId, handlers) {
1291
+ if (!proposalId) {
1292
+ throw new Error("subscribeProposalDetail: proposalId is required");
1293
+ }
1294
+ let bucket = this.subscribers.get(proposalId);
1295
+ const isFirstForProposal = bucket === void 0;
1296
+ if (bucket === void 0) {
1297
+ bucket = /* @__PURE__ */ new Set();
1298
+ this.subscribers.set(proposalId, bucket);
1299
+ }
1300
+ bucket.add(handlers);
1301
+ try {
1302
+ const connection = await this.ensureStarted();
1303
+ if (isFirstForProposal) {
1304
+ await connection.send(REGISTER_METHOD, { proposalId });
1305
+ }
1306
+ } catch (error) {
1307
+ bucket.delete(handlers);
1308
+ if (bucket.size === 0) {
1309
+ this.subscribers.delete(proposalId);
1310
+ }
1311
+ throw error;
1312
+ }
1313
+ let disposed = false;
1314
+ return () => {
1315
+ if (disposed) {
1316
+ return;
1317
+ }
1318
+ disposed = true;
1319
+ const current = this.subscribers.get(proposalId);
1320
+ if (!current) {
1321
+ return;
1322
+ }
1323
+ current.delete(handlers);
1324
+ if (current.size === 0) {
1325
+ this.subscribers.delete(proposalId);
1326
+ }
1327
+ if (this.subscribers.size === 0) {
1328
+ void this.stop();
1329
+ }
1330
+ };
1331
+ }
1332
+ /** Stop the underlying hub connection if open and drop all subscribers. */
1333
+ async close() {
1334
+ this.subscribers.clear();
1335
+ await this.stop();
1336
+ }
1337
+ async ensureStarted() {
1338
+ if (this.connection && this.connection.state === import_signalr.HubConnectionState.Connected) {
1339
+ return this.connection;
1340
+ }
1341
+ if (this.startPromise) {
1342
+ return this.startPromise;
1343
+ }
1344
+ const connection = this.buildConnection();
1345
+ this.connection = connection;
1346
+ this.startPromise = (async () => {
1347
+ await connection.start();
1348
+ return connection;
1349
+ })();
1350
+ try {
1351
+ return await this.startPromise;
1352
+ } catch (error) {
1353
+ this.connection = null;
1354
+ throw error;
1355
+ } finally {
1356
+ this.startPromise = null;
1357
+ }
1358
+ }
1359
+ buildConnection() {
1360
+ const tokenProvider = this.tokenProvider;
1361
+ const connection = new import_signalr.HubConnectionBuilder().withUrl(this.hubUrl, {
1362
+ accessTokenFactory: tokenProvider ? () => resolveToken(tokenProvider) : void 0,
1363
+ transport: import_signalr.HttpTransportType.WebSockets,
1364
+ skipNegotiation: true
1365
+ }).withAutomaticReconnect().configureLogging(this.logLevel).build();
1366
+ this.registerHandlers(connection);
1367
+ connection.onreconnected(() => {
1368
+ void this.reRegisterAll(connection);
1369
+ });
1370
+ return connection;
1371
+ }
1372
+ registerHandlers(connection) {
1373
+ const dispatch = (method, pick) => {
1374
+ connection.on(method, (event) => {
1375
+ const bucket = this.subscribers.get(event.proposalId);
1376
+ if (!bucket) {
1377
+ return;
1378
+ }
1379
+ for (const handlers of bucket) {
1380
+ const fn = pick(handlers);
1381
+ fn?.(event);
1382
+ }
1383
+ });
1384
+ };
1385
+ dispatch(HUB_METHODS.success, (h) => h.onProductSuccess);
1386
+ dispatch(HUB_METHODS.failed, (h) => h.onProductFailed);
1387
+ dispatch(HUB_METHODS.inProgress, (h) => h.onProductInProgress);
1388
+ dispatch(HUB_METHODS.revised, (h) => h.onProductRevised);
1389
+ dispatch(HUB_METHODS.purchasing, (h) => h.onProductPurchasing);
1390
+ dispatch(HUB_METHODS.purchased, (h) => h.onProductPurchased);
1391
+ dispatch(HUB_METHODS.purchaseFailed, (h) => h.onProductPurchaseFailed);
1392
+ dispatch(HUB_METHODS.coverage, (h) => h.onProductCoverage);
1393
+ }
1394
+ async reRegisterAll(connection) {
1395
+ for (const proposalId of this.subscribers.keys()) {
1396
+ await connection.send(REGISTER_METHOD, { proposalId });
1397
+ }
1398
+ }
1399
+ async stop() {
1400
+ const current = this.connection;
1401
+ if (!current) {
1402
+ return;
1403
+ }
1404
+ this.connection = null;
1405
+ if (current.state === import_signalr.HubConnectionState.Disconnected || current.state === import_signalr.HubConnectionState.Disconnecting) {
1406
+ return;
1407
+ }
1408
+ await current.stop();
1409
+ }
1410
+ };
1411
+ function ensureTrailingSlash(url) {
1412
+ return url.endsWith("/") ? url : `${url}/`;
1413
+ }
1414
+ async function resolveToken(provider) {
1415
+ const result = await provider();
1416
+ return result ?? "";
1417
+ }
1418
+
1252
1419
  // src/core/endpoints.ts
1253
1420
  var endpoints_exports = {};
1254
1421
  __export(endpoints_exports, {
@@ -1383,6 +1550,10 @@ var customers = {
1383
1550
  definition: "customers/{CustomerId}",
1384
1551
  render: (customerId) => "customers/{CustomerId}".replace("{CustomerId}", encodeURIComponent(customerId))
1385
1552
  },
1553
+ getCustomerAssets: {
1554
+ definition: "customers/{CustomerId}/assets",
1555
+ render: (customerId) => "customers/{CustomerId}/assets".replace("{CustomerId}", encodeURIComponent(customerId))
1556
+ },
1386
1557
  getHealthInfo: {
1387
1558
  definition: "customers/{CustomerId}/health-info",
1388
1559
  render: (customerId) => "customers/{CustomerId}/health-info".replace("{CustomerId}", encodeURIComponent(customerId))
@@ -1407,6 +1578,20 @@ var customers = {
1407
1578
  getCustomerEmails: {
1408
1579
  definition: "customers/{CustomerId}/emails",
1409
1580
  render: (customerId) => "customers/{CustomerId}/emails".replace("{CustomerId}", encodeURIComponent(customerId))
1581
+ },
1582
+ getPrimaryCustomerEmail: {
1583
+ definition: "customers/{CustomerId}/emails/primary",
1584
+ render: (customerId) => "customers/{CustomerId}/emails/primary".replace(
1585
+ "{CustomerId}",
1586
+ encodeURIComponent(customerId)
1587
+ )
1588
+ },
1589
+ setPrimaryCustomerEmail: {
1590
+ definition: "customers/{CustomerId}/emails/primary",
1591
+ render: (customerId) => "customers/{CustomerId}/emails/primary".replace(
1592
+ "{CustomerId}",
1593
+ encodeURIComponent(customerId)
1594
+ )
1410
1595
  }
1411
1596
  },
1412
1597
  phoneNumbers: {
@@ -1431,6 +1616,20 @@ var customers = {
1431
1616
  "{CustomerId}",
1432
1617
  encodeURIComponent(customerId)
1433
1618
  )
1619
+ },
1620
+ getPrimaryCustomerPhoneNumber: {
1621
+ definition: "customers/{CustomerId}/phone-numbers/primary",
1622
+ render: (customerId) => "customers/{CustomerId}/phone-numbers/primary".replace(
1623
+ "{CustomerId}",
1624
+ encodeURIComponent(customerId)
1625
+ )
1626
+ },
1627
+ setPrimaryCustomerPhoneNumber: {
1628
+ definition: "customers/{CustomerId}/phone-numbers/primary",
1629
+ render: (customerId) => "customers/{CustomerId}/phone-numbers/primary".replace(
1630
+ "{CustomerId}",
1631
+ encodeURIComponent(customerId)
1632
+ )
1434
1633
  }
1435
1634
  },
1436
1635
  contactFlows: {
@@ -1504,11 +1703,8 @@ var customers = {
1504
1703
  render: (customerId) => "customers/{CustomerId}/consents".replace("{CustomerId}", encodeURIComponent(customerId))
1505
1704
  },
1506
1705
  revoke: {
1507
- definition: "customers/{CustomerId}/consents/revoke",
1508
- render: (customerId) => "customers/{CustomerId}/consents/revoke".replace(
1509
- "{CustomerId}",
1510
- encodeURIComponent(customerId)
1511
- )
1706
+ definition: "customers/{CustomerId}/consents/{ConsentType}",
1707
+ render: (customerId, consentType) => "customers/{CustomerId}/consents/{ConsentType}".replace("{CustomerId}", encodeURIComponent(customerId)).replace("{ConsentType}", encodeURIComponent(consentType))
1512
1708
  },
1513
1709
  getAll: {
1514
1710
  definition: "customers/{CustomerId}/consents",
@@ -2389,6 +2585,111 @@ var InsurUpAgentSetupClient = class {
2389
2585
  // src/clients/agentUser.ts
2390
2586
  var import_contracts = require("@insurup/contracts");
2391
2587
  var import_contracts2 = require("@insurup/contracts");
2588
+
2589
+ // src/clients/_internal/normalize-search.ts
2590
+ var TEXT_INPUT_OPS = /* @__PURE__ */ new Set([
2591
+ "eq",
2592
+ "neq",
2593
+ "textSearch",
2594
+ "wildcard",
2595
+ "autocomplete",
2596
+ "contains",
2597
+ "notContains",
2598
+ "startsWith",
2599
+ "notStartsWith",
2600
+ "endsWith",
2601
+ "notEndsWith"
2602
+ ]);
2603
+ var TEXT_LIST_INPUT_OPS = /* @__PURE__ */ new Set(["in", "nin"]);
2604
+ var COMBINATOR_OPS = /* @__PURE__ */ new Set(["and", "or"]);
2605
+ function normalizeSearchInput(search) {
2606
+ if (search === null || search === void 0) return search;
2607
+ if (typeof search !== "object") return search;
2608
+ return normalizeNode(search);
2609
+ }
2610
+ function normalizeNode(node) {
2611
+ if (node === null || typeof node !== "object") return node;
2612
+ const out = {};
2613
+ for (const [key, value] of Object.entries(node)) {
2614
+ if (COMBINATOR_OPS.has(key) && Array.isArray(value)) {
2615
+ out[key] = value.map(normalizeNode);
2616
+ } else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
2617
+ out[key] = normalizeStringOps(value);
2618
+ } else {
2619
+ out[key] = value;
2620
+ }
2621
+ }
2622
+ return out;
2623
+ }
2624
+ function normalizeStringOps(field) {
2625
+ const out = {};
2626
+ for (const [op, value] of Object.entries(field)) {
2627
+ if (TEXT_INPUT_OPS.has(op) && typeof value === "string") {
2628
+ out[op] = { value };
2629
+ } else if (TEXT_LIST_INPUT_OPS.has(op) && Array.isArray(value)) {
2630
+ out[op] = { values: value };
2631
+ } else if (COMBINATOR_OPS.has(op) && Array.isArray(value)) {
2632
+ out[op] = value.map((item) => normalizeStringOps(item));
2633
+ } else {
2634
+ out[op] = value;
2635
+ }
2636
+ }
2637
+ return out;
2638
+ }
2639
+
2640
+ // src/clients/_internal/split-unified-filter.ts
2641
+ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
2642
+ var isSearchMarked = (v) => isObject(v) && v.$search === true;
2643
+ var stripMarker = ({ $search: _marker, ...rest }) => rest;
2644
+ var nonEmpty = (o) => Object.keys(o).length > 0;
2645
+ function splitUnifiedFilter(input) {
2646
+ if (input == null) return { filter: void 0, search: void 0 };
2647
+ const { filter, search } = splitNode(input);
2648
+ return {
2649
+ filter,
2650
+ search
2651
+ };
2652
+ }
2653
+ function splitNode(node) {
2654
+ const filter = {};
2655
+ const search = {};
2656
+ for (const [key, value] of Object.entries(node)) {
2657
+ if ((key === "and" || key === "or") && Array.isArray(value)) {
2658
+ const filterItems = [];
2659
+ const searchItems = [];
2660
+ for (const item of value) {
2661
+ if (!isObject(item)) {
2662
+ filterItems.push(item);
2663
+ continue;
2664
+ }
2665
+ const split = splitNode(item);
2666
+ if (split.filter) filterItems.push(split.filter);
2667
+ if (split.search) searchItems.push(split.search);
2668
+ }
2669
+ if (filterItems.length > 0) filter[key] = filterItems;
2670
+ if (searchItems.length > 0) search[key] = searchItems;
2671
+ } else if (isSearchMarked(value)) {
2672
+ search[key] = stripMarker(value);
2673
+ } else {
2674
+ filter[key] = value;
2675
+ }
2676
+ }
2677
+ return {
2678
+ filter: nonEmpty(filter) ? filter : void 0,
2679
+ search: nonEmpty(search) ? search : void 0
2680
+ };
2681
+ }
2682
+
2683
+ // src/clients/_internal/build-filter-search-variables.ts
2684
+ function buildFilterSearchVariables(input) {
2685
+ const { filter, search } = splitUnifiedFilter(input);
2686
+ const out = {};
2687
+ if (filter !== void 0) out.filter = filter;
2688
+ if (search !== void 0) out.search = normalizeSearchInput(search);
2689
+ return out;
2690
+ }
2691
+
2692
+ // src/clients/agentUser.ts
2392
2693
  var InsurUpAgentUserClient = class {
2393
2694
  constructor(http, graphql) {
2394
2695
  this.http = http;
@@ -2640,8 +2941,7 @@ var InsurUpAgentUserClient = class {
2640
2941
  after: requestOptions?.after,
2641
2942
  last: requestOptions?.last,
2642
2943
  before: requestOptions?.before,
2643
- search: requestOptions?.search,
2644
- filter: requestOptions?.filter,
2944
+ ...buildFilterSearchVariables(requestOptions?.filter),
2645
2945
  order: requestOptions?.order
2646
2946
  };
2647
2947
  const result = await this.graphql.query(query, variables, options);
@@ -2763,6 +3063,31 @@ var InsurUpCustomerClient = class {
2763
3063
  options
2764
3064
  );
2765
3065
  }
3066
+ /**
3067
+ * Retrieves the primary email address for a customer.
3068
+ *
3069
+ * Müşterinin birincil e-posta adresini getirir.
3070
+ */
3071
+ async getPrimaryCustomerEmail(customerId, options) {
3072
+ return this.http.get(
3073
+ endpoints.customers.emails.getPrimaryCustomerEmail.render(customerId),
3074
+ options
3075
+ );
3076
+ }
3077
+ /**
3078
+ * Sets the primary email address for a customer (upsert — adds to the customer's email
3079
+ * collection if missing, then marks it as primary).
3080
+ *
3081
+ * Müşterinin birincil e-posta adresini ayarlar (mevcut değilse koleksiyona ekler ve birincil
3082
+ * olarak işaretler).
3083
+ */
3084
+ async setPrimaryCustomerEmail(request, options) {
3085
+ return this.http.putNoContent(
3086
+ endpoints.customers.emails.setPrimaryCustomerEmail.render(request.customerId),
3087
+ request,
3088
+ options
3089
+ );
3090
+ }
2766
3091
  /**
2767
3092
  * Retrieves all phone numbers associated with a customer.
2768
3093
  */
@@ -2801,6 +3126,44 @@ var InsurUpCustomerClient = class {
2801
3126
  options
2802
3127
  );
2803
3128
  }
3129
+ /**
3130
+ * Retrieves the primary phone number for a customer.
3131
+ *
3132
+ * Müşterinin birincil telefon numarasını getirir.
3133
+ */
3134
+ async getPrimaryCustomerPhoneNumber(customerId, options) {
3135
+ return this.http.get(
3136
+ endpoints.customers.phoneNumbers.getPrimaryCustomerPhoneNumber.render(customerId),
3137
+ options
3138
+ );
3139
+ }
3140
+ /**
3141
+ * Sets the primary phone number for a customer (upsert — adds to the customer's phone
3142
+ * number collection if missing, then marks it as primary).
3143
+ *
3144
+ * Müşterinin birincil telefon numarasını ayarlar (mevcut değilse koleksiyona ekler ve
3145
+ * birincil olarak işaretler).
3146
+ */
3147
+ async setPrimaryCustomerPhoneNumber(request, options) {
3148
+ return this.http.putNoContent(
3149
+ endpoints.customers.phoneNumbers.setPrimaryCustomerPhoneNumber.render(request.customerId),
3150
+ request,
3151
+ options
3152
+ );
3153
+ }
3154
+ /**
3155
+ * Retrieves all of a customer's insurable assets (vehicles and properties) in a single
3156
+ * polymorphic list discriminated by the `$type` field.
3157
+ *
3158
+ * Müşterinin tüm sigortalanabilir varlıklarını (araçlar ve mülkler) `$type` alanı ile
3159
+ * ayırt edilen tek bir polimorfik listede getirir.
3160
+ */
3161
+ async getCustomerAssets(customerId, options) {
3162
+ return this.http.get(
3163
+ endpoints.customers.getCustomerAssets.render(customerId),
3164
+ options
3165
+ );
3166
+ }
2804
3167
  /**
2805
3168
  * Assigns a specific agent representative to manage a customer's account.
2806
3169
  */
@@ -2914,7 +3277,7 @@ var InsurUpCustomerClient = class {
2914
3277
  async giveCustomerConsent(customerId, request, options) {
2915
3278
  return this.http.postNoContent(
2916
3279
  endpoints.customers.consents.give.render(customerId),
2917
- request,
3280
+ { ...request, customerId },
2918
3281
  options
2919
3282
  );
2920
3283
  }
@@ -2924,13 +3287,12 @@ var InsurUpCustomerClient = class {
2924
3287
  * Müşteri veri hakları uyarınca önceden verilmiş bir müşteri iznini geri çeker.
2925
3288
  *
2926
3289
  * @param customerId Unique identifier of the customer / Müşterinin benzersiz tanımlayıcısı
2927
- * @param request Consent revocation request / İzin geri çekme talebi
3290
+ * @param consentType Type of consent to revoke / Geri çekilecek izin türü
2928
3291
  * @returns Operation result / İşlem sonucu
2929
3292
  */
2930
- async revokeCustomerConsent(customerId, request, options) {
2931
- return this.http.postNoContent(
2932
- endpoints.customers.consents.revoke.render(customerId),
2933
- request,
3293
+ async revokeCustomerConsent(customerId, consentType, options) {
3294
+ return this.http.deleteNoContent(
3295
+ endpoints.customers.consents.revoke.render(customerId, consentType),
2934
3296
  options
2935
3297
  );
2936
3298
  }
@@ -3100,18 +3462,15 @@ var InsurUpCustomerClient = class {
3100
3462
  }
3101
3463
  }
3102
3464
  `;
3103
- const variables = {};
3104
- if (requestOptions?.first === void 0 && requestOptions?.last === void 0) {
3105
- variables.first = 50;
3106
- } else {
3107
- if (requestOptions?.first !== void 0) variables.first = requestOptions.first;
3108
- if (requestOptions?.last !== void 0) variables.last = requestOptions.last;
3109
- }
3110
- if (requestOptions?.after !== void 0) variables.after = requestOptions.after;
3111
- if (requestOptions?.before !== void 0) variables.before = requestOptions.before;
3112
- if (requestOptions?.search !== void 0) variables.search = requestOptions.search;
3113
- if (requestOptions?.filter !== void 0) variables.filter = requestOptions.filter;
3114
- if (requestOptions?.order !== void 0) variables.order = requestOptions.order;
3465
+ const first = requestOptions?.first === void 0 && requestOptions?.last === void 0 ? 50 : requestOptions?.first;
3466
+ const variables = {
3467
+ first,
3468
+ after: requestOptions?.after,
3469
+ last: requestOptions?.last,
3470
+ before: requestOptions?.before,
3471
+ ...buildFilterSearchVariables(requestOptions?.filter),
3472
+ order: requestOptions?.order
3473
+ };
3115
3474
  const result = await this.graphql.query(query, variables, options);
3116
3475
  if (!result.isSuccess) {
3117
3476
  return result;
@@ -3796,8 +4155,7 @@ var InsurUpPolicyClient = class {
3796
4155
  after: requestOptions?.after,
3797
4156
  last: requestOptions?.last,
3798
4157
  before: requestOptions?.before,
3799
- search: requestOptions?.search,
3800
- filter: requestOptions?.filter,
4158
+ ...buildFilterSearchVariables(requestOptions?.filter),
3801
4159
  order: requestOptions?.order
3802
4160
  };
3803
4161
  const result = await this.graphql.query(query, variables, options);
@@ -3877,8 +4235,7 @@ var InsurUpPolicyClient = class {
3877
4235
  after: requestOptions?.after,
3878
4236
  last: requestOptions?.last,
3879
4237
  before: requestOptions?.before,
3880
- search: requestOptions?.search,
3881
- filter: requestOptions?.filter,
4238
+ ...buildFilterSearchVariables(requestOptions?.filter),
3882
4239
  order: requestOptions?.order
3883
4240
  };
3884
4241
  const result = await this.graphql.query(query, variables, options);
@@ -3958,8 +4315,7 @@ var InsurUpPolicyClient = class {
3958
4315
  after: requestOptions?.after,
3959
4316
  last: requestOptions?.last,
3960
4317
  before: requestOptions?.before,
3961
- search: requestOptions?.search,
3962
- filter: requestOptions?.filter,
4318
+ ...buildFilterSearchVariables(requestOptions?.filter),
3963
4319
  order: requestOptions?.order
3964
4320
  };
3965
4321
  const result = await this.graphql.query(query, variables, options);
@@ -4303,8 +4659,7 @@ var InsurUpCaseClient = class {
4303
4659
  after: requestOptions?.after,
4304
4660
  last: requestOptions?.last,
4305
4661
  before: requestOptions?.before,
4306
- search: requestOptions?.search,
4307
- filter: requestOptions?.filter,
4662
+ ...buildFilterSearchVariables(requestOptions?.filter),
4308
4663
  order: requestOptions?.order
4309
4664
  };
4310
4665
  const result = await this.graphql.query(query, variables, options);
@@ -4488,8 +4843,7 @@ var InsurUpWebhookClient = class {
4488
4843
  after: requestOptions?.after,
4489
4844
  last: requestOptions?.last,
4490
4845
  before: requestOptions?.before,
4491
- search: requestOptions?.search,
4492
- filter: requestOptions?.filter,
4846
+ ...buildFilterSearchVariables(requestOptions?.filter),
4493
4847
  order: requestOptions?.order
4494
4848
  };
4495
4849
  const result = await this.graphql.query(query, variables, options);
@@ -4732,9 +5086,42 @@ var InsurUpInsuranceClient = class {
4732
5086
  var import_contracts13 = require("@insurup/contracts");
4733
5087
  var import_contracts14 = require("@insurup/contracts");
4734
5088
  var InsurUpProposalClient = class {
4735
- constructor(http, graphql) {
5089
+ constructor(http, graphql, signalR) {
4736
5090
  this.http = http;
4737
5091
  this.graphql = graphql;
5092
+ this.signalR = signalR;
5093
+ }
5094
+ /**
5095
+ * Subscribe to real-time updates for a proposal via the InsurUp SignalR
5096
+ * ProposalDetailHub. The first subscriber opens the underlying hub
5097
+ * connection lazily; subscriptions for additional proposals are multiplexed
5098
+ * over the same connection. Pass only the handlers you care about.
5099
+ *
5100
+ * Teklif için gerçek zamanlı güncellemelere SignalR üzerinden abone olur.
5101
+ *
5102
+ * @param proposalId - The proposal to subscribe to / Abone olunacak teklif
5103
+ * @param handlers - Per-event callbacks; missing entries are ignored
5104
+ * @returns An unsubscribe function. When the last subscription is torn
5105
+ * down, the underlying hub connection is stopped.
5106
+ * @throws If the SDK client was constructed without SignalR support
5107
+ *
5108
+ * @example
5109
+ * ```typescript
5110
+ * const unsub = await client.proposals.subscribeToDetail(proposalId, {
5111
+ * onProductSuccess: (event) => console.log('priced', event),
5112
+ * onProductFailed: (event) => console.warn('failed', event.errorMessage),
5113
+ * });
5114
+ * // later
5115
+ * unsub();
5116
+ * ```
5117
+ */
5118
+ async subscribeToDetail(proposalId, handlers) {
5119
+ if (!this.signalR) {
5120
+ throw new Error(
5121
+ "subscribeToDetail requires SignalR support; construct the client via DefaultInsurUpClient"
5122
+ );
5123
+ }
5124
+ return this.signalR.subscribeProposalDetail(proposalId, handlers);
4738
5125
  }
4739
5126
  /**
4740
5127
  * Creates a new insurance proposal with customer information, coverage selections, and product options for quotation.
@@ -5119,8 +5506,7 @@ var InsurUpProposalClient = class {
5119
5506
  after: requestOptions?.after,
5120
5507
  last: requestOptions?.last,
5121
5508
  before: requestOptions?.before,
5122
- search: requestOptions?.search,
5123
- filter: requestOptions?.filter,
5509
+ ...buildFilterSearchVariables(requestOptions?.filter),
5124
5510
  order: requestOptions?.order
5125
5511
  };
5126
5512
  const result = await this.graphql.query(query, variables, options);
@@ -5265,6 +5651,7 @@ var InsurUpTemplateClient = class {
5265
5651
  var DefaultInsurUpClient = class {
5266
5652
  http;
5267
5653
  graphql;
5654
+ signalR;
5268
5655
  /**
5269
5656
  * Agent Management Client
5270
5657
  *
@@ -5389,6 +5776,11 @@ var DefaultInsurUpClient = class {
5389
5776
  this.http = new HttpTransport(options);
5390
5777
  this.graphql = new GraphQLTransport(this.http);
5391
5778
  this.options = options || {};
5779
+ this.signalR = new SignalRTransport({
5780
+ hubsBaseUrl: options?.hubsBaseUrl ?? deriveHubsBaseUrl(options?.baseUrl),
5781
+ tokenProvider: options?.tokenProvider,
5782
+ logLevel: options?.signalRLogLevel
5783
+ });
5392
5784
  this.agents = new InsurUpAgentClient(this.http);
5393
5785
  this.agentBranches = new InsurUpAgentBranchClient(this.http);
5394
5786
  this.agentRoles = new InsurUpAgentRoleClient(this.http);
@@ -5402,14 +5794,27 @@ var DefaultInsurUpClient = class {
5402
5794
  this.webhooks = new InsurUpWebhookClient(this.http, this.graphql);
5403
5795
  this.coverage = new InsurUpCoverageClient(this.http);
5404
5796
  this.insurance = new InsurUpInsuranceClient(this.http);
5405
- this.proposals = new InsurUpProposalClient(this.http, this.graphql);
5797
+ this.proposals = new InsurUpProposalClient(this.http, this.graphql, this.signalR);
5406
5798
  this.files = new InsurUpFileClient(this.http);
5407
5799
  this.languages = new InsurUpLanguageClient(this.http);
5408
5800
  this.templates = new InsurUpTemplateClient(this.http);
5409
5801
  }
5802
+ /**
5803
+ * Stop any open SignalR connection and drop pending subscribers. Safe to
5804
+ * call multiple times. Call this when disposing of the SDK client (e.g. on
5805
+ * app teardown or test cleanup).
5806
+ */
5807
+ async close() {
5808
+ await this.signalR.close();
5809
+ }
5410
5810
  };
5811
+ function deriveHubsBaseUrl(baseUrl) {
5812
+ const resolved = baseUrl ?? "https://api.insurup.com/api/";
5813
+ return new URL(resolved).origin;
5814
+ }
5411
5815
 
5412
5816
  // src/index.ts
5817
+ var import_signalr4 = require("@microsoft/signalr");
5413
5818
  __reExport(index_exports, require("@insurup/contracts"), module.exports);
5414
5819
  // Annotate the CommonJS export names for ESM import in node:
5415
5820
  0 && (module.exports = {
@@ -5437,6 +5842,8 @@ __reExport(index_exports, require("@insurup/contracts"), module.exports);
5437
5842
  InsurUpTemplateClient,
5438
5843
  InsurUpVehicleClient,
5439
5844
  InsurUpWebhookClient,
5845
+ SignalRLogLevel,
5846
+ SignalRTransport,
5440
5847
  VERSION,
5441
5848
  createGraphQLErrors,
5442
5849
  extractError,