@insurup/sdk 0.1.14 → 0.1.15

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 +37 -1
  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 +40 -0
  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 +441 -30
  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 +444 -30
  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.15",
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: {
@@ -2340,6 +2542,111 @@ import {
2340
2542
  ALL_AGENT_USER_FIELDS
2341
2543
  } from "@insurup/contracts";
2342
2544
  import { buildFieldSelection } from "@insurup/contracts";
2545
+
2546
+ // src/clients/_internal/normalize-search.ts
2547
+ var TEXT_INPUT_OPS = /* @__PURE__ */ new Set([
2548
+ "eq",
2549
+ "neq",
2550
+ "textSearch",
2551
+ "wildcard",
2552
+ "autocomplete",
2553
+ "contains",
2554
+ "notContains",
2555
+ "startsWith",
2556
+ "notStartsWith",
2557
+ "endsWith",
2558
+ "notEndsWith"
2559
+ ]);
2560
+ var TEXT_LIST_INPUT_OPS = /* @__PURE__ */ new Set(["in", "nin"]);
2561
+ var COMBINATOR_OPS = /* @__PURE__ */ new Set(["and", "or"]);
2562
+ function normalizeSearchInput(search) {
2563
+ if (search === null || search === void 0) return search;
2564
+ if (typeof search !== "object") return search;
2565
+ return normalizeNode(search);
2566
+ }
2567
+ function normalizeNode(node) {
2568
+ if (node === null || typeof node !== "object") return node;
2569
+ const out = {};
2570
+ for (const [key, value] of Object.entries(node)) {
2571
+ if (COMBINATOR_OPS.has(key) && Array.isArray(value)) {
2572
+ out[key] = value.map(normalizeNode);
2573
+ } else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
2574
+ out[key] = normalizeStringOps(value);
2575
+ } else {
2576
+ out[key] = value;
2577
+ }
2578
+ }
2579
+ return out;
2580
+ }
2581
+ function normalizeStringOps(field) {
2582
+ const out = {};
2583
+ for (const [op, value] of Object.entries(field)) {
2584
+ if (TEXT_INPUT_OPS.has(op) && typeof value === "string") {
2585
+ out[op] = { value };
2586
+ } else if (TEXT_LIST_INPUT_OPS.has(op) && Array.isArray(value)) {
2587
+ out[op] = { values: value };
2588
+ } else if (COMBINATOR_OPS.has(op) && Array.isArray(value)) {
2589
+ out[op] = value.map((item) => normalizeStringOps(item));
2590
+ } else {
2591
+ out[op] = value;
2592
+ }
2593
+ }
2594
+ return out;
2595
+ }
2596
+
2597
+ // src/clients/_internal/split-unified-filter.ts
2598
+ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
2599
+ var isSearchMarked = (v) => isObject(v) && v.$search === true;
2600
+ var stripMarker = ({ $search: _marker, ...rest }) => rest;
2601
+ var nonEmpty = (o) => Object.keys(o).length > 0;
2602
+ function splitUnifiedFilter(input) {
2603
+ if (input == null) return { filter: void 0, search: void 0 };
2604
+ const { filter, search } = splitNode(input);
2605
+ return {
2606
+ filter,
2607
+ search
2608
+ };
2609
+ }
2610
+ function splitNode(node) {
2611
+ const filter = {};
2612
+ const search = {};
2613
+ for (const [key, value] of Object.entries(node)) {
2614
+ if ((key === "and" || key === "or") && Array.isArray(value)) {
2615
+ const filterItems = [];
2616
+ const searchItems = [];
2617
+ for (const item of value) {
2618
+ if (!isObject(item)) {
2619
+ filterItems.push(item);
2620
+ continue;
2621
+ }
2622
+ const split = splitNode(item);
2623
+ if (split.filter) filterItems.push(split.filter);
2624
+ if (split.search) searchItems.push(split.search);
2625
+ }
2626
+ if (filterItems.length > 0) filter[key] = filterItems;
2627
+ if (searchItems.length > 0) search[key] = searchItems;
2628
+ } else if (isSearchMarked(value)) {
2629
+ search[key] = stripMarker(value);
2630
+ } else {
2631
+ filter[key] = value;
2632
+ }
2633
+ }
2634
+ return {
2635
+ filter: nonEmpty(filter) ? filter : void 0,
2636
+ search: nonEmpty(search) ? search : void 0
2637
+ };
2638
+ }
2639
+
2640
+ // src/clients/_internal/build-filter-search-variables.ts
2641
+ function buildFilterSearchVariables(input) {
2642
+ const { filter, search } = splitUnifiedFilter(input);
2643
+ const out = {};
2644
+ if (filter !== void 0) out.filter = filter;
2645
+ if (search !== void 0) out.search = normalizeSearchInput(search);
2646
+ return out;
2647
+ }
2648
+
2649
+ // src/clients/agentUser.ts
2343
2650
  var InsurUpAgentUserClient = class {
2344
2651
  constructor(http, graphql) {
2345
2652
  this.http = http;
@@ -2591,8 +2898,7 @@ var InsurUpAgentUserClient = class {
2591
2898
  after: requestOptions?.after,
2592
2899
  last: requestOptions?.last,
2593
2900
  before: requestOptions?.before,
2594
- search: requestOptions?.search,
2595
- filter: requestOptions?.filter,
2901
+ ...buildFilterSearchVariables(requestOptions?.filter),
2596
2902
  order: requestOptions?.order
2597
2903
  };
2598
2904
  const result = await this.graphql.query(query, variables, options);
@@ -2717,6 +3023,31 @@ var InsurUpCustomerClient = class {
2717
3023
  options
2718
3024
  );
2719
3025
  }
3026
+ /**
3027
+ * Retrieves the primary email address for a customer.
3028
+ *
3029
+ * Müşterinin birincil e-posta adresini getirir.
3030
+ */
3031
+ async getPrimaryCustomerEmail(customerId, options) {
3032
+ return this.http.get(
3033
+ endpoints.customers.emails.getPrimaryCustomerEmail.render(customerId),
3034
+ options
3035
+ );
3036
+ }
3037
+ /**
3038
+ * Sets the primary email address for a customer (upsert — adds to the customer's email
3039
+ * collection if missing, then marks it as primary).
3040
+ *
3041
+ * Müşterinin birincil e-posta adresini ayarlar (mevcut değilse koleksiyona ekler ve birincil
3042
+ * olarak işaretler).
3043
+ */
3044
+ async setPrimaryCustomerEmail(request, options) {
3045
+ return this.http.putNoContent(
3046
+ endpoints.customers.emails.setPrimaryCustomerEmail.render(request.customerId),
3047
+ request,
3048
+ options
3049
+ );
3050
+ }
2720
3051
  /**
2721
3052
  * Retrieves all phone numbers associated with a customer.
2722
3053
  */
@@ -2755,6 +3086,44 @@ var InsurUpCustomerClient = class {
2755
3086
  options
2756
3087
  );
2757
3088
  }
3089
+ /**
3090
+ * Retrieves the primary phone number for a customer.
3091
+ *
3092
+ * Müşterinin birincil telefon numarasını getirir.
3093
+ */
3094
+ async getPrimaryCustomerPhoneNumber(customerId, options) {
3095
+ return this.http.get(
3096
+ endpoints.customers.phoneNumbers.getPrimaryCustomerPhoneNumber.render(customerId),
3097
+ options
3098
+ );
3099
+ }
3100
+ /**
3101
+ * Sets the primary phone number for a customer (upsert — adds to the customer's phone
3102
+ * number collection if missing, then marks it as primary).
3103
+ *
3104
+ * Müşterinin birincil telefon numarasını ayarlar (mevcut değilse koleksiyona ekler ve
3105
+ * birincil olarak işaretler).
3106
+ */
3107
+ async setPrimaryCustomerPhoneNumber(request, options) {
3108
+ return this.http.putNoContent(
3109
+ endpoints.customers.phoneNumbers.setPrimaryCustomerPhoneNumber.render(request.customerId),
3110
+ request,
3111
+ options
3112
+ );
3113
+ }
3114
+ /**
3115
+ * Retrieves all of a customer's insurable assets (vehicles and properties) in a single
3116
+ * polymorphic list discriminated by the `$type` field.
3117
+ *
3118
+ * Müşterinin tüm sigortalanabilir varlıklarını (araçlar ve mülkler) `$type` alanı ile
3119
+ * ayırt edilen tek bir polimorfik listede getirir.
3120
+ */
3121
+ async getCustomerAssets(customerId, options) {
3122
+ return this.http.get(
3123
+ endpoints.customers.getCustomerAssets.render(customerId),
3124
+ options
3125
+ );
3126
+ }
2758
3127
  /**
2759
3128
  * Assigns a specific agent representative to manage a customer's account.
2760
3129
  */
@@ -3054,18 +3423,15 @@ var InsurUpCustomerClient = class {
3054
3423
  }
3055
3424
  }
3056
3425
  `;
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;
3426
+ const first = requestOptions?.first === void 0 && requestOptions?.last === void 0 ? 50 : requestOptions?.first;
3427
+ const variables = {
3428
+ first,
3429
+ after: requestOptions?.after,
3430
+ last: requestOptions?.last,
3431
+ before: requestOptions?.before,
3432
+ ...buildFilterSearchVariables(requestOptions?.filter),
3433
+ order: requestOptions?.order
3434
+ };
3069
3435
  const result = await this.graphql.query(query, variables, options);
3070
3436
  if (!result.isSuccess) {
3071
3437
  return result;
@@ -3756,8 +4122,7 @@ var InsurUpPolicyClient = class {
3756
4122
  after: requestOptions?.after,
3757
4123
  last: requestOptions?.last,
3758
4124
  before: requestOptions?.before,
3759
- search: requestOptions?.search,
3760
- filter: requestOptions?.filter,
4125
+ ...buildFilterSearchVariables(requestOptions?.filter),
3761
4126
  order: requestOptions?.order
3762
4127
  };
3763
4128
  const result = await this.graphql.query(query, variables, options);
@@ -3837,8 +4202,7 @@ var InsurUpPolicyClient = class {
3837
4202
  after: requestOptions?.after,
3838
4203
  last: requestOptions?.last,
3839
4204
  before: requestOptions?.before,
3840
- search: requestOptions?.search,
3841
- filter: requestOptions?.filter,
4205
+ ...buildFilterSearchVariables(requestOptions?.filter),
3842
4206
  order: requestOptions?.order
3843
4207
  };
3844
4208
  const result = await this.graphql.query(query, variables, options);
@@ -3918,8 +4282,7 @@ var InsurUpPolicyClient = class {
3918
4282
  after: requestOptions?.after,
3919
4283
  last: requestOptions?.last,
3920
4284
  before: requestOptions?.before,
3921
- search: requestOptions?.search,
3922
- filter: requestOptions?.filter,
4285
+ ...buildFilterSearchVariables(requestOptions?.filter),
3923
4286
  order: requestOptions?.order
3924
4287
  };
3925
4288
  const result = await this.graphql.query(query, variables, options);
@@ -4265,8 +4628,7 @@ var InsurUpCaseClient = class {
4265
4628
  after: requestOptions?.after,
4266
4629
  last: requestOptions?.last,
4267
4630
  before: requestOptions?.before,
4268
- search: requestOptions?.search,
4269
- filter: requestOptions?.filter,
4631
+ ...buildFilterSearchVariables(requestOptions?.filter),
4270
4632
  order: requestOptions?.order
4271
4633
  };
4272
4634
  const result = await this.graphql.query(query, variables, options);
@@ -4452,8 +4814,7 @@ var InsurUpWebhookClient = class {
4452
4814
  after: requestOptions?.after,
4453
4815
  last: requestOptions?.last,
4454
4816
  before: requestOptions?.before,
4455
- search: requestOptions?.search,
4456
- filter: requestOptions?.filter,
4817
+ ...buildFilterSearchVariables(requestOptions?.filter),
4457
4818
  order: requestOptions?.order
4458
4819
  };
4459
4820
  const result = await this.graphql.query(query, variables, options);
@@ -4698,9 +5059,42 @@ import {
4698
5059
  } from "@insurup/contracts";
4699
5060
  import { buildFieldSelection as buildFieldSelection6 } from "@insurup/contracts";
4700
5061
  var InsurUpProposalClient = class {
4701
- constructor(http, graphql) {
5062
+ constructor(http, graphql, signalR) {
4702
5063
  this.http = http;
4703
5064
  this.graphql = graphql;
5065
+ this.signalR = signalR;
5066
+ }
5067
+ /**
5068
+ * Subscribe to real-time updates for a proposal via the InsurUp SignalR
5069
+ * ProposalDetailHub. The first subscriber opens the underlying hub
5070
+ * connection lazily; subscriptions for additional proposals are multiplexed
5071
+ * over the same connection. Pass only the handlers you care about.
5072
+ *
5073
+ * Teklif için gerçek zamanlı güncellemelere SignalR üzerinden abone olur.
5074
+ *
5075
+ * @param proposalId - The proposal to subscribe to / Abone olunacak teklif
5076
+ * @param handlers - Per-event callbacks; missing entries are ignored
5077
+ * @returns An unsubscribe function. When the last subscription is torn
5078
+ * down, the underlying hub connection is stopped.
5079
+ * @throws If the SDK client was constructed without SignalR support
5080
+ *
5081
+ * @example
5082
+ * ```typescript
5083
+ * const unsub = await client.proposals.subscribeToDetail(proposalId, {
5084
+ * onProductSuccess: (event) => console.log('priced', event),
5085
+ * onProductFailed: (event) => console.warn('failed', event.errorMessage),
5086
+ * });
5087
+ * // later
5088
+ * unsub();
5089
+ * ```
5090
+ */
5091
+ async subscribeToDetail(proposalId, handlers) {
5092
+ if (!this.signalR) {
5093
+ throw new Error(
5094
+ "subscribeToDetail requires SignalR support; construct the client via DefaultInsurUpClient"
5095
+ );
5096
+ }
5097
+ return this.signalR.subscribeProposalDetail(proposalId, handlers);
4704
5098
  }
4705
5099
  /**
4706
5100
  * Creates a new insurance proposal with customer information, coverage selections, and product options for quotation.
@@ -5085,8 +5479,7 @@ var InsurUpProposalClient = class {
5085
5479
  after: requestOptions?.after,
5086
5480
  last: requestOptions?.last,
5087
5481
  before: requestOptions?.before,
5088
- search: requestOptions?.search,
5089
- filter: requestOptions?.filter,
5482
+ ...buildFilterSearchVariables(requestOptions?.filter),
5090
5483
  order: requestOptions?.order
5091
5484
  };
5092
5485
  const result = await this.graphql.query(query, variables, options);
@@ -5231,6 +5624,7 @@ var InsurUpTemplateClient = class {
5231
5624
  var DefaultInsurUpClient = class {
5232
5625
  http;
5233
5626
  graphql;
5627
+ signalR;
5234
5628
  /**
5235
5629
  * Agent Management Client
5236
5630
  *
@@ -5355,6 +5749,11 @@ var DefaultInsurUpClient = class {
5355
5749
  this.http = new HttpTransport(options);
5356
5750
  this.graphql = new GraphQLTransport(this.http);
5357
5751
  this.options = options || {};
5752
+ this.signalR = new SignalRTransport({
5753
+ hubsBaseUrl: options?.hubsBaseUrl ?? deriveHubsBaseUrl(options?.baseUrl),
5754
+ tokenProvider: options?.tokenProvider,
5755
+ logLevel: options?.signalRLogLevel
5756
+ });
5358
5757
  this.agents = new InsurUpAgentClient(this.http);
5359
5758
  this.agentBranches = new InsurUpAgentBranchClient(this.http);
5360
5759
  this.agentRoles = new InsurUpAgentRoleClient(this.http);
@@ -5368,14 +5767,27 @@ var DefaultInsurUpClient = class {
5368
5767
  this.webhooks = new InsurUpWebhookClient(this.http, this.graphql);
5369
5768
  this.coverage = new InsurUpCoverageClient(this.http);
5370
5769
  this.insurance = new InsurUpInsuranceClient(this.http);
5371
- this.proposals = new InsurUpProposalClient(this.http, this.graphql);
5770
+ this.proposals = new InsurUpProposalClient(this.http, this.graphql, this.signalR);
5372
5771
  this.files = new InsurUpFileClient(this.http);
5373
5772
  this.languages = new InsurUpLanguageClient(this.http);
5374
5773
  this.templates = new InsurUpTemplateClient(this.http);
5375
5774
  }
5775
+ /**
5776
+ * Stop any open SignalR connection and drop pending subscribers. Safe to
5777
+ * call multiple times. Call this when disposing of the SDK client (e.g. on
5778
+ * app teardown or test cleanup).
5779
+ */
5780
+ async close() {
5781
+ await this.signalR.close();
5782
+ }
5376
5783
  };
5784
+ function deriveHubsBaseUrl(baseUrl) {
5785
+ const resolved = baseUrl ?? "https://api.insurup.com/api/";
5786
+ return new URL(resolved).origin;
5787
+ }
5377
5788
 
5378
5789
  // src/index.ts
5790
+ import { LogLevel as LogLevel2 } from "@microsoft/signalr";
5379
5791
  export * from "@insurup/contracts";
5380
5792
  export {
5381
5793
  DefaultInsurUpClient,
@@ -5402,6 +5814,8 @@ export {
5402
5814
  InsurUpTemplateClient,
5403
5815
  InsurUpVehicleClient,
5404
5816
  InsurUpWebhookClient,
5817
+ LogLevel2 as SignalRLogLevel,
5818
+ SignalRTransport,
5405
5819
  VERSION,
5406
5820
  createGraphQLErrors,
5407
5821
  extractError,