@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.d.ts CHANGED
@@ -6,6 +6,9 @@ export { VERSION } from './version.js';
6
6
  export { DefaultInsurUpClient } from './client/client.js';
7
7
  export type { GraphQLRequest, GraphQLResponse } from './client/graphql.js';
8
8
  export { GraphQLTransport } from './client/graphql.js';
9
+ export { SignalRTransport } from './client/signalr.js';
10
+ export type { ProposalDetailHandlers, SignalRTransportOptions } from './client/signalr.js';
11
+ export { LogLevel as SignalRLogLevel } from '@microsoft/signalr';
9
12
  export { InsurUpAgentClient } from './clients/agent.js';
10
13
  export { InsurUpAgentBranchClient } from './clients/agentBranch.js';
11
14
  export { InsurUpAgentRoleClient } from './clients/agentRole.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qB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ACtB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EAEvB,cAAc,EACd,YAAY,EAEZ,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE9D,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,MAAM,GACP,MAAM,mBAAmB,CAAC;AAG3B,cAAc,oBAAoB,CAAC;AAGnC,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "@insurup/sdk",
10
- version: "0.1.14",
10
+ version: "0.1.16",
11
11
  description: "Type-safe TypeScript SDK for the InsurUp insurance platform with GraphQL support. Tree-shakeable, works everywhere.",
12
12
  keywords: [
13
13
  "insurup",
@@ -88,7 +88,8 @@ var package_default = {
88
88
  vitest: "^4.1.6"
89
89
  },
90
90
  dependencies: {
91
- "@insurup/contracts": "workspace:*"
91
+ "@insurup/contracts": "workspace:*",
92
+ "@microsoft/signalr": "^10.0.0"
92
93
  }
93
94
  };
94
95
 
@@ -1198,6 +1199,175 @@ var GraphQLTransport = class {
1198
1199
  }
1199
1200
  };
1200
1201
 
1202
+ // src/client/signalr.ts
1203
+ import {
1204
+ HttpTransportType,
1205
+ HubConnectionBuilder,
1206
+ HubConnectionState,
1207
+ LogLevel
1208
+ } from "@microsoft/signalr";
1209
+ var HUB_METHODS = {
1210
+ success: "ReceiveProposalProductSuccess",
1211
+ failed: "ReceiveProposalProductFailed",
1212
+ inProgress: "ReceiveProposalProductInProgress",
1213
+ revised: "ReceiveProposalProductRevised",
1214
+ purchasing: "ReceiveProposalProductPurchasing",
1215
+ purchased: "ReceiveProposalProductPurchased",
1216
+ purchaseFailed: "ReceiveProposalProductPurchaseFailed",
1217
+ coverage: "ReceiveProposalProductCoverage"
1218
+ };
1219
+ var HUB_PATH = "/hubs/proposal-detail";
1220
+ var REGISTER_METHOD = "Register";
1221
+ var SignalRTransport = class {
1222
+ hubUrl;
1223
+ tokenProvider;
1224
+ logLevel;
1225
+ connection = null;
1226
+ /** Pending or in-flight start, shared by concurrent subscribers. */
1227
+ startPromise = null;
1228
+ /** Active subscriptions keyed by proposalId. */
1229
+ subscribers = /* @__PURE__ */ new Map();
1230
+ constructor(options) {
1231
+ this.hubUrl = new URL(HUB_PATH, ensureTrailingSlash(options.hubsBaseUrl)).toString();
1232
+ this.tokenProvider = options.tokenProvider;
1233
+ this.logLevel = options.logLevel ?? LogLevel.Warning;
1234
+ }
1235
+ /**
1236
+ * Subscribe to proposal-detail events for a given proposal. Opens the
1237
+ * underlying hub connection on first subscribe.
1238
+ *
1239
+ * @returns an unsubscribe function. When the last subscriber for the last
1240
+ * proposal unsubscribes, the underlying connection is stopped.
1241
+ */
1242
+ async subscribeProposalDetail(proposalId, handlers) {
1243
+ if (!proposalId) {
1244
+ throw new Error("subscribeProposalDetail: proposalId is required");
1245
+ }
1246
+ let bucket = this.subscribers.get(proposalId);
1247
+ const isFirstForProposal = bucket === void 0;
1248
+ if (bucket === void 0) {
1249
+ bucket = /* @__PURE__ */ new Set();
1250
+ this.subscribers.set(proposalId, bucket);
1251
+ }
1252
+ bucket.add(handlers);
1253
+ try {
1254
+ const connection = await this.ensureStarted();
1255
+ if (isFirstForProposal) {
1256
+ await connection.send(REGISTER_METHOD, { proposalId });
1257
+ }
1258
+ } catch (error) {
1259
+ bucket.delete(handlers);
1260
+ if (bucket.size === 0) {
1261
+ this.subscribers.delete(proposalId);
1262
+ }
1263
+ throw error;
1264
+ }
1265
+ let disposed = false;
1266
+ return () => {
1267
+ if (disposed) {
1268
+ return;
1269
+ }
1270
+ disposed = true;
1271
+ const current = this.subscribers.get(proposalId);
1272
+ if (!current) {
1273
+ return;
1274
+ }
1275
+ current.delete(handlers);
1276
+ if (current.size === 0) {
1277
+ this.subscribers.delete(proposalId);
1278
+ }
1279
+ if (this.subscribers.size === 0) {
1280
+ void this.stop();
1281
+ }
1282
+ };
1283
+ }
1284
+ /** Stop the underlying hub connection if open and drop all subscribers. */
1285
+ async close() {
1286
+ this.subscribers.clear();
1287
+ await this.stop();
1288
+ }
1289
+ async ensureStarted() {
1290
+ if (this.connection && this.connection.state === HubConnectionState.Connected) {
1291
+ return this.connection;
1292
+ }
1293
+ if (this.startPromise) {
1294
+ return this.startPromise;
1295
+ }
1296
+ const connection = this.buildConnection();
1297
+ this.connection = connection;
1298
+ this.startPromise = (async () => {
1299
+ await connection.start();
1300
+ return connection;
1301
+ })();
1302
+ try {
1303
+ return await this.startPromise;
1304
+ } catch (error) {
1305
+ this.connection = null;
1306
+ throw error;
1307
+ } finally {
1308
+ this.startPromise = null;
1309
+ }
1310
+ }
1311
+ buildConnection() {
1312
+ const tokenProvider = this.tokenProvider;
1313
+ const connection = new HubConnectionBuilder().withUrl(this.hubUrl, {
1314
+ accessTokenFactory: tokenProvider ? () => resolveToken(tokenProvider) : void 0,
1315
+ transport: HttpTransportType.WebSockets,
1316
+ skipNegotiation: true
1317
+ }).withAutomaticReconnect().configureLogging(this.logLevel).build();
1318
+ this.registerHandlers(connection);
1319
+ connection.onreconnected(() => {
1320
+ void this.reRegisterAll(connection);
1321
+ });
1322
+ return connection;
1323
+ }
1324
+ registerHandlers(connection) {
1325
+ const dispatch = (method, pick) => {
1326
+ connection.on(method, (event) => {
1327
+ const bucket = this.subscribers.get(event.proposalId);
1328
+ if (!bucket) {
1329
+ return;
1330
+ }
1331
+ for (const handlers of bucket) {
1332
+ const fn = pick(handlers);
1333
+ fn?.(event);
1334
+ }
1335
+ });
1336
+ };
1337
+ dispatch(HUB_METHODS.success, (h) => h.onProductSuccess);
1338
+ dispatch(HUB_METHODS.failed, (h) => h.onProductFailed);
1339
+ dispatch(HUB_METHODS.inProgress, (h) => h.onProductInProgress);
1340
+ dispatch(HUB_METHODS.revised, (h) => h.onProductRevised);
1341
+ dispatch(HUB_METHODS.purchasing, (h) => h.onProductPurchasing);
1342
+ dispatch(HUB_METHODS.purchased, (h) => h.onProductPurchased);
1343
+ dispatch(HUB_METHODS.purchaseFailed, (h) => h.onProductPurchaseFailed);
1344
+ dispatch(HUB_METHODS.coverage, (h) => h.onProductCoverage);
1345
+ }
1346
+ async reRegisterAll(connection) {
1347
+ for (const proposalId of this.subscribers.keys()) {
1348
+ await connection.send(REGISTER_METHOD, { proposalId });
1349
+ }
1350
+ }
1351
+ async stop() {
1352
+ const current = this.connection;
1353
+ if (!current) {
1354
+ return;
1355
+ }
1356
+ this.connection = null;
1357
+ if (current.state === HubConnectionState.Disconnected || current.state === HubConnectionState.Disconnecting) {
1358
+ return;
1359
+ }
1360
+ await current.stop();
1361
+ }
1362
+ };
1363
+ function ensureTrailingSlash(url) {
1364
+ return url.endsWith("/") ? url : `${url}/`;
1365
+ }
1366
+ async function resolveToken(provider) {
1367
+ const result = await provider();
1368
+ return result ?? "";
1369
+ }
1370
+
1201
1371
  // src/core/endpoints.ts
1202
1372
  var endpoints_exports = {};
1203
1373
  __export(endpoints_exports, {
@@ -1332,6 +1502,10 @@ var customers = {
1332
1502
  definition: "customers/{CustomerId}",
1333
1503
  render: (customerId) => "customers/{CustomerId}".replace("{CustomerId}", encodeURIComponent(customerId))
1334
1504
  },
1505
+ getCustomerAssets: {
1506
+ definition: "customers/{CustomerId}/assets",
1507
+ render: (customerId) => "customers/{CustomerId}/assets".replace("{CustomerId}", encodeURIComponent(customerId))
1508
+ },
1335
1509
  getHealthInfo: {
1336
1510
  definition: "customers/{CustomerId}/health-info",
1337
1511
  render: (customerId) => "customers/{CustomerId}/health-info".replace("{CustomerId}", encodeURIComponent(customerId))
@@ -1356,6 +1530,20 @@ var customers = {
1356
1530
  getCustomerEmails: {
1357
1531
  definition: "customers/{CustomerId}/emails",
1358
1532
  render: (customerId) => "customers/{CustomerId}/emails".replace("{CustomerId}", encodeURIComponent(customerId))
1533
+ },
1534
+ getPrimaryCustomerEmail: {
1535
+ definition: "customers/{CustomerId}/emails/primary",
1536
+ render: (customerId) => "customers/{CustomerId}/emails/primary".replace(
1537
+ "{CustomerId}",
1538
+ encodeURIComponent(customerId)
1539
+ )
1540
+ },
1541
+ setPrimaryCustomerEmail: {
1542
+ definition: "customers/{CustomerId}/emails/primary",
1543
+ render: (customerId) => "customers/{CustomerId}/emails/primary".replace(
1544
+ "{CustomerId}",
1545
+ encodeURIComponent(customerId)
1546
+ )
1359
1547
  }
1360
1548
  },
1361
1549
  phoneNumbers: {
@@ -1380,6 +1568,20 @@ var customers = {
1380
1568
  "{CustomerId}",
1381
1569
  encodeURIComponent(customerId)
1382
1570
  )
1571
+ },
1572
+ getPrimaryCustomerPhoneNumber: {
1573
+ definition: "customers/{CustomerId}/phone-numbers/primary",
1574
+ render: (customerId) => "customers/{CustomerId}/phone-numbers/primary".replace(
1575
+ "{CustomerId}",
1576
+ encodeURIComponent(customerId)
1577
+ )
1578
+ },
1579
+ setPrimaryCustomerPhoneNumber: {
1580
+ definition: "customers/{CustomerId}/phone-numbers/primary",
1581
+ render: (customerId) => "customers/{CustomerId}/phone-numbers/primary".replace(
1582
+ "{CustomerId}",
1583
+ encodeURIComponent(customerId)
1584
+ )
1383
1585
  }
1384
1586
  },
1385
1587
  contactFlows: {
@@ -1453,11 +1655,8 @@ var customers = {
1453
1655
  render: (customerId) => "customers/{CustomerId}/consents".replace("{CustomerId}", encodeURIComponent(customerId))
1454
1656
  },
1455
1657
  revoke: {
1456
- definition: "customers/{CustomerId}/consents/revoke",
1457
- render: (customerId) => "customers/{CustomerId}/consents/revoke".replace(
1458
- "{CustomerId}",
1459
- encodeURIComponent(customerId)
1460
- )
1658
+ definition: "customers/{CustomerId}/consents/{ConsentType}",
1659
+ render: (customerId, consentType) => "customers/{CustomerId}/consents/{ConsentType}".replace("{CustomerId}", encodeURIComponent(customerId)).replace("{ConsentType}", encodeURIComponent(consentType))
1461
1660
  },
1462
1661
  getAll: {
1463
1662
  definition: "customers/{CustomerId}/consents",
@@ -2340,6 +2539,111 @@ import {
2340
2539
  ALL_AGENT_USER_FIELDS
2341
2540
  } from "@insurup/contracts";
2342
2541
  import { buildFieldSelection } from "@insurup/contracts";
2542
+
2543
+ // src/clients/_internal/normalize-search.ts
2544
+ var TEXT_INPUT_OPS = /* @__PURE__ */ new Set([
2545
+ "eq",
2546
+ "neq",
2547
+ "textSearch",
2548
+ "wildcard",
2549
+ "autocomplete",
2550
+ "contains",
2551
+ "notContains",
2552
+ "startsWith",
2553
+ "notStartsWith",
2554
+ "endsWith",
2555
+ "notEndsWith"
2556
+ ]);
2557
+ var TEXT_LIST_INPUT_OPS = /* @__PURE__ */ new Set(["in", "nin"]);
2558
+ var COMBINATOR_OPS = /* @__PURE__ */ new Set(["and", "or"]);
2559
+ function normalizeSearchInput(search) {
2560
+ if (search === null || search === void 0) return search;
2561
+ if (typeof search !== "object") return search;
2562
+ return normalizeNode(search);
2563
+ }
2564
+ function normalizeNode(node) {
2565
+ if (node === null || typeof node !== "object") return node;
2566
+ const out = {};
2567
+ for (const [key, value] of Object.entries(node)) {
2568
+ if (COMBINATOR_OPS.has(key) && Array.isArray(value)) {
2569
+ out[key] = value.map(normalizeNode);
2570
+ } else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
2571
+ out[key] = normalizeStringOps(value);
2572
+ } else {
2573
+ out[key] = value;
2574
+ }
2575
+ }
2576
+ return out;
2577
+ }
2578
+ function normalizeStringOps(field) {
2579
+ const out = {};
2580
+ for (const [op, value] of Object.entries(field)) {
2581
+ if (TEXT_INPUT_OPS.has(op) && typeof value === "string") {
2582
+ out[op] = { value };
2583
+ } else if (TEXT_LIST_INPUT_OPS.has(op) && Array.isArray(value)) {
2584
+ out[op] = { values: value };
2585
+ } else if (COMBINATOR_OPS.has(op) && Array.isArray(value)) {
2586
+ out[op] = value.map((item) => normalizeStringOps(item));
2587
+ } else {
2588
+ out[op] = value;
2589
+ }
2590
+ }
2591
+ return out;
2592
+ }
2593
+
2594
+ // src/clients/_internal/split-unified-filter.ts
2595
+ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
2596
+ var isSearchMarked = (v) => isObject(v) && v.$search === true;
2597
+ var stripMarker = ({ $search: _marker, ...rest }) => rest;
2598
+ var nonEmpty = (o) => Object.keys(o).length > 0;
2599
+ function splitUnifiedFilter(input) {
2600
+ if (input == null) return { filter: void 0, search: void 0 };
2601
+ const { filter, search } = splitNode(input);
2602
+ return {
2603
+ filter,
2604
+ search
2605
+ };
2606
+ }
2607
+ function splitNode(node) {
2608
+ const filter = {};
2609
+ const search = {};
2610
+ for (const [key, value] of Object.entries(node)) {
2611
+ if ((key === "and" || key === "or") && Array.isArray(value)) {
2612
+ const filterItems = [];
2613
+ const searchItems = [];
2614
+ for (const item of value) {
2615
+ if (!isObject(item)) {
2616
+ filterItems.push(item);
2617
+ continue;
2618
+ }
2619
+ const split = splitNode(item);
2620
+ if (split.filter) filterItems.push(split.filter);
2621
+ if (split.search) searchItems.push(split.search);
2622
+ }
2623
+ if (filterItems.length > 0) filter[key] = filterItems;
2624
+ if (searchItems.length > 0) search[key] = searchItems;
2625
+ } else if (isSearchMarked(value)) {
2626
+ search[key] = stripMarker(value);
2627
+ } else {
2628
+ filter[key] = value;
2629
+ }
2630
+ }
2631
+ return {
2632
+ filter: nonEmpty(filter) ? filter : void 0,
2633
+ search: nonEmpty(search) ? search : void 0
2634
+ };
2635
+ }
2636
+
2637
+ // src/clients/_internal/build-filter-search-variables.ts
2638
+ function buildFilterSearchVariables(input) {
2639
+ const { filter, search } = splitUnifiedFilter(input);
2640
+ const out = {};
2641
+ if (filter !== void 0) out.filter = filter;
2642
+ if (search !== void 0) out.search = normalizeSearchInput(search);
2643
+ return out;
2644
+ }
2645
+
2646
+ // src/clients/agentUser.ts
2343
2647
  var InsurUpAgentUserClient = class {
2344
2648
  constructor(http, graphql) {
2345
2649
  this.http = http;
@@ -2591,8 +2895,7 @@ var InsurUpAgentUserClient = class {
2591
2895
  after: requestOptions?.after,
2592
2896
  last: requestOptions?.last,
2593
2897
  before: requestOptions?.before,
2594
- search: requestOptions?.search,
2595
- filter: requestOptions?.filter,
2898
+ ...buildFilterSearchVariables(requestOptions?.filter),
2596
2899
  order: requestOptions?.order
2597
2900
  };
2598
2901
  const result = await this.graphql.query(query, variables, options);
@@ -2717,6 +3020,31 @@ var InsurUpCustomerClient = class {
2717
3020
  options
2718
3021
  );
2719
3022
  }
3023
+ /**
3024
+ * Retrieves the primary email address for a customer.
3025
+ *
3026
+ * Müşterinin birincil e-posta adresini getirir.
3027
+ */
3028
+ async getPrimaryCustomerEmail(customerId, options) {
3029
+ return this.http.get(
3030
+ endpoints.customers.emails.getPrimaryCustomerEmail.render(customerId),
3031
+ options
3032
+ );
3033
+ }
3034
+ /**
3035
+ * Sets the primary email address for a customer (upsert — adds to the customer's email
3036
+ * collection if missing, then marks it as primary).
3037
+ *
3038
+ * Müşterinin birincil e-posta adresini ayarlar (mevcut değilse koleksiyona ekler ve birincil
3039
+ * olarak işaretler).
3040
+ */
3041
+ async setPrimaryCustomerEmail(request, options) {
3042
+ return this.http.putNoContent(
3043
+ endpoints.customers.emails.setPrimaryCustomerEmail.render(request.customerId),
3044
+ request,
3045
+ options
3046
+ );
3047
+ }
2720
3048
  /**
2721
3049
  * Retrieves all phone numbers associated with a customer.
2722
3050
  */
@@ -2755,6 +3083,44 @@ var InsurUpCustomerClient = class {
2755
3083
  options
2756
3084
  );
2757
3085
  }
3086
+ /**
3087
+ * Retrieves the primary phone number for a customer.
3088
+ *
3089
+ * Müşterinin birincil telefon numarasını getirir.
3090
+ */
3091
+ async getPrimaryCustomerPhoneNumber(customerId, options) {
3092
+ return this.http.get(
3093
+ endpoints.customers.phoneNumbers.getPrimaryCustomerPhoneNumber.render(customerId),
3094
+ options
3095
+ );
3096
+ }
3097
+ /**
3098
+ * Sets the primary phone number for a customer (upsert — adds to the customer's phone
3099
+ * number collection if missing, then marks it as primary).
3100
+ *
3101
+ * Müşterinin birincil telefon numarasını ayarlar (mevcut değilse koleksiyona ekler ve
3102
+ * birincil olarak işaretler).
3103
+ */
3104
+ async setPrimaryCustomerPhoneNumber(request, options) {
3105
+ return this.http.putNoContent(
3106
+ endpoints.customers.phoneNumbers.setPrimaryCustomerPhoneNumber.render(request.customerId),
3107
+ request,
3108
+ options
3109
+ );
3110
+ }
3111
+ /**
3112
+ * Retrieves all of a customer's insurable assets (vehicles and properties) in a single
3113
+ * polymorphic list discriminated by the `$type` field.
3114
+ *
3115
+ * Müşterinin tüm sigortalanabilir varlıklarını (araçlar ve mülkler) `$type` alanı ile
3116
+ * ayırt edilen tek bir polimorfik listede getirir.
3117
+ */
3118
+ async getCustomerAssets(customerId, options) {
3119
+ return this.http.get(
3120
+ endpoints.customers.getCustomerAssets.render(customerId),
3121
+ options
3122
+ );
3123
+ }
2758
3124
  /**
2759
3125
  * Assigns a specific agent representative to manage a customer's account.
2760
3126
  */
@@ -2868,7 +3234,7 @@ var InsurUpCustomerClient = class {
2868
3234
  async giveCustomerConsent(customerId, request, options) {
2869
3235
  return this.http.postNoContent(
2870
3236
  endpoints.customers.consents.give.render(customerId),
2871
- request,
3237
+ { ...request, customerId },
2872
3238
  options
2873
3239
  );
2874
3240
  }
@@ -2878,13 +3244,12 @@ var InsurUpCustomerClient = class {
2878
3244
  * Müşteri veri hakları uyarınca önceden verilmiş bir müşteri iznini geri çeker.
2879
3245
  *
2880
3246
  * @param customerId Unique identifier of the customer / Müşterinin benzersiz tanımlayıcısı
2881
- * @param request Consent revocation request / İzin geri çekme talebi
3247
+ * @param consentType Type of consent to revoke / Geri çekilecek izin türü
2882
3248
  * @returns Operation result / İşlem sonucu
2883
3249
  */
2884
- async revokeCustomerConsent(customerId, request, options) {
2885
- return this.http.postNoContent(
2886
- endpoints.customers.consents.revoke.render(customerId),
2887
- request,
3250
+ async revokeCustomerConsent(customerId, consentType, options) {
3251
+ return this.http.deleteNoContent(
3252
+ endpoints.customers.consents.revoke.render(customerId, consentType),
2888
3253
  options
2889
3254
  );
2890
3255
  }
@@ -3054,18 +3419,15 @@ var InsurUpCustomerClient = class {
3054
3419
  }
3055
3420
  }
3056
3421
  `;
3057
- const variables = {};
3058
- if (requestOptions?.first === void 0 && requestOptions?.last === void 0) {
3059
- variables.first = 50;
3060
- } else {
3061
- if (requestOptions?.first !== void 0) variables.first = requestOptions.first;
3062
- if (requestOptions?.last !== void 0) variables.last = requestOptions.last;
3063
- }
3064
- if (requestOptions?.after !== void 0) variables.after = requestOptions.after;
3065
- if (requestOptions?.before !== void 0) variables.before = requestOptions.before;
3066
- if (requestOptions?.search !== void 0) variables.search = requestOptions.search;
3067
- if (requestOptions?.filter !== void 0) variables.filter = requestOptions.filter;
3068
- if (requestOptions?.order !== void 0) variables.order = requestOptions.order;
3422
+ const first = requestOptions?.first === void 0 && requestOptions?.last === void 0 ? 50 : requestOptions?.first;
3423
+ const variables = {
3424
+ first,
3425
+ after: requestOptions?.after,
3426
+ last: requestOptions?.last,
3427
+ before: requestOptions?.before,
3428
+ ...buildFilterSearchVariables(requestOptions?.filter),
3429
+ order: requestOptions?.order
3430
+ };
3069
3431
  const result = await this.graphql.query(query, variables, options);
3070
3432
  if (!result.isSuccess) {
3071
3433
  return result;
@@ -3756,8 +4118,7 @@ var InsurUpPolicyClient = class {
3756
4118
  after: requestOptions?.after,
3757
4119
  last: requestOptions?.last,
3758
4120
  before: requestOptions?.before,
3759
- search: requestOptions?.search,
3760
- filter: requestOptions?.filter,
4121
+ ...buildFilterSearchVariables(requestOptions?.filter),
3761
4122
  order: requestOptions?.order
3762
4123
  };
3763
4124
  const result = await this.graphql.query(query, variables, options);
@@ -3837,8 +4198,7 @@ var InsurUpPolicyClient = class {
3837
4198
  after: requestOptions?.after,
3838
4199
  last: requestOptions?.last,
3839
4200
  before: requestOptions?.before,
3840
- search: requestOptions?.search,
3841
- filter: requestOptions?.filter,
4201
+ ...buildFilterSearchVariables(requestOptions?.filter),
3842
4202
  order: requestOptions?.order
3843
4203
  };
3844
4204
  const result = await this.graphql.query(query, variables, options);
@@ -3918,8 +4278,7 @@ var InsurUpPolicyClient = class {
3918
4278
  after: requestOptions?.after,
3919
4279
  last: requestOptions?.last,
3920
4280
  before: requestOptions?.before,
3921
- search: requestOptions?.search,
3922
- filter: requestOptions?.filter,
4281
+ ...buildFilterSearchVariables(requestOptions?.filter),
3923
4282
  order: requestOptions?.order
3924
4283
  };
3925
4284
  const result = await this.graphql.query(query, variables, options);
@@ -4265,8 +4624,7 @@ var InsurUpCaseClient = class {
4265
4624
  after: requestOptions?.after,
4266
4625
  last: requestOptions?.last,
4267
4626
  before: requestOptions?.before,
4268
- search: requestOptions?.search,
4269
- filter: requestOptions?.filter,
4627
+ ...buildFilterSearchVariables(requestOptions?.filter),
4270
4628
  order: requestOptions?.order
4271
4629
  };
4272
4630
  const result = await this.graphql.query(query, variables, options);
@@ -4452,8 +4810,7 @@ var InsurUpWebhookClient = class {
4452
4810
  after: requestOptions?.after,
4453
4811
  last: requestOptions?.last,
4454
4812
  before: requestOptions?.before,
4455
- search: requestOptions?.search,
4456
- filter: requestOptions?.filter,
4813
+ ...buildFilterSearchVariables(requestOptions?.filter),
4457
4814
  order: requestOptions?.order
4458
4815
  };
4459
4816
  const result = await this.graphql.query(query, variables, options);
@@ -4698,9 +5055,42 @@ import {
4698
5055
  } from "@insurup/contracts";
4699
5056
  import { buildFieldSelection as buildFieldSelection6 } from "@insurup/contracts";
4700
5057
  var InsurUpProposalClient = class {
4701
- constructor(http, graphql) {
5058
+ constructor(http, graphql, signalR) {
4702
5059
  this.http = http;
4703
5060
  this.graphql = graphql;
5061
+ this.signalR = signalR;
5062
+ }
5063
+ /**
5064
+ * Subscribe to real-time updates for a proposal via the InsurUp SignalR
5065
+ * ProposalDetailHub. The first subscriber opens the underlying hub
5066
+ * connection lazily; subscriptions for additional proposals are multiplexed
5067
+ * over the same connection. Pass only the handlers you care about.
5068
+ *
5069
+ * Teklif için gerçek zamanlı güncellemelere SignalR üzerinden abone olur.
5070
+ *
5071
+ * @param proposalId - The proposal to subscribe to / Abone olunacak teklif
5072
+ * @param handlers - Per-event callbacks; missing entries are ignored
5073
+ * @returns An unsubscribe function. When the last subscription is torn
5074
+ * down, the underlying hub connection is stopped.
5075
+ * @throws If the SDK client was constructed without SignalR support
5076
+ *
5077
+ * @example
5078
+ * ```typescript
5079
+ * const unsub = await client.proposals.subscribeToDetail(proposalId, {
5080
+ * onProductSuccess: (event) => console.log('priced', event),
5081
+ * onProductFailed: (event) => console.warn('failed', event.errorMessage),
5082
+ * });
5083
+ * // later
5084
+ * unsub();
5085
+ * ```
5086
+ */
5087
+ async subscribeToDetail(proposalId, handlers) {
5088
+ if (!this.signalR) {
5089
+ throw new Error(
5090
+ "subscribeToDetail requires SignalR support; construct the client via DefaultInsurUpClient"
5091
+ );
5092
+ }
5093
+ return this.signalR.subscribeProposalDetail(proposalId, handlers);
4704
5094
  }
4705
5095
  /**
4706
5096
  * Creates a new insurance proposal with customer information, coverage selections, and product options for quotation.
@@ -5085,8 +5475,7 @@ var InsurUpProposalClient = class {
5085
5475
  after: requestOptions?.after,
5086
5476
  last: requestOptions?.last,
5087
5477
  before: requestOptions?.before,
5088
- search: requestOptions?.search,
5089
- filter: requestOptions?.filter,
5478
+ ...buildFilterSearchVariables(requestOptions?.filter),
5090
5479
  order: requestOptions?.order
5091
5480
  };
5092
5481
  const result = await this.graphql.query(query, variables, options);
@@ -5231,6 +5620,7 @@ var InsurUpTemplateClient = class {
5231
5620
  var DefaultInsurUpClient = class {
5232
5621
  http;
5233
5622
  graphql;
5623
+ signalR;
5234
5624
  /**
5235
5625
  * Agent Management Client
5236
5626
  *
@@ -5355,6 +5745,11 @@ var DefaultInsurUpClient = class {
5355
5745
  this.http = new HttpTransport(options);
5356
5746
  this.graphql = new GraphQLTransport(this.http);
5357
5747
  this.options = options || {};
5748
+ this.signalR = new SignalRTransport({
5749
+ hubsBaseUrl: options?.hubsBaseUrl ?? deriveHubsBaseUrl(options?.baseUrl),
5750
+ tokenProvider: options?.tokenProvider,
5751
+ logLevel: options?.signalRLogLevel
5752
+ });
5358
5753
  this.agents = new InsurUpAgentClient(this.http);
5359
5754
  this.agentBranches = new InsurUpAgentBranchClient(this.http);
5360
5755
  this.agentRoles = new InsurUpAgentRoleClient(this.http);
@@ -5368,14 +5763,27 @@ var DefaultInsurUpClient = class {
5368
5763
  this.webhooks = new InsurUpWebhookClient(this.http, this.graphql);
5369
5764
  this.coverage = new InsurUpCoverageClient(this.http);
5370
5765
  this.insurance = new InsurUpInsuranceClient(this.http);
5371
- this.proposals = new InsurUpProposalClient(this.http, this.graphql);
5766
+ this.proposals = new InsurUpProposalClient(this.http, this.graphql, this.signalR);
5372
5767
  this.files = new InsurUpFileClient(this.http);
5373
5768
  this.languages = new InsurUpLanguageClient(this.http);
5374
5769
  this.templates = new InsurUpTemplateClient(this.http);
5375
5770
  }
5771
+ /**
5772
+ * Stop any open SignalR connection and drop pending subscribers. Safe to
5773
+ * call multiple times. Call this when disposing of the SDK client (e.g. on
5774
+ * app teardown or test cleanup).
5775
+ */
5776
+ async close() {
5777
+ await this.signalR.close();
5778
+ }
5376
5779
  };
5780
+ function deriveHubsBaseUrl(baseUrl) {
5781
+ const resolved = baseUrl ?? "https://api.insurup.com/api/";
5782
+ return new URL(resolved).origin;
5783
+ }
5377
5784
 
5378
5785
  // src/index.ts
5786
+ import { LogLevel as LogLevel2 } from "@microsoft/signalr";
5379
5787
  export * from "@insurup/contracts";
5380
5788
  export {
5381
5789
  DefaultInsurUpClient,
@@ -5402,6 +5810,8 @@ export {
5402
5810
  InsurUpTemplateClient,
5403
5811
  InsurUpVehicleClient,
5404
5812
  InsurUpWebhookClient,
5813
+ LogLevel2 as SignalRLogLevel,
5814
+ SignalRTransport,
5405
5815
  VERSION,
5406
5816
  createGraphQLErrors,
5407
5817
  extractError,