@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.
- package/README.md +46 -14
- package/dist/client/client.d.ts +7 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/signalr.d.ts +69 -0
- package/dist/client/signalr.d.ts.map +1 -0
- package/dist/clients/_internal/build-filter-search-variables.d.ts +12 -0
- package/dist/clients/_internal/build-filter-search-variables.d.ts.map +1 -0
- package/dist/clients/_internal/normalize-search.d.ts +21 -0
- package/dist/clients/_internal/normalize-search.d.ts.map +1 -0
- package/dist/clients/_internal/split-unified-filter.d.ts +16 -0
- package/dist/clients/_internal/split-unified-filter.d.ts.map +1 -0
- package/dist/clients/agentUser.d.ts.map +1 -1
- package/dist/clients/case.d.ts.map +1 -1
- package/dist/clients/customer.d.ts +37 -1
- package/dist/clients/customer.d.ts.map +1 -1
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/proposal.d.ts +28 -1
- package/dist/clients/proposal.d.ts.map +1 -1
- package/dist/clients/webhook.d.ts.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/endpoints.d.ts +40 -0
- package/dist/core/endpoints.d.ts.map +1 -1
- package/dist/core/options.d.ts +13 -0
- package/dist/core/options.d.ts.map +1 -1
- package/dist/index.browser.js +24 -24
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +441 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +444 -30
- package/dist/index.js.map +1 -1
- 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.
|
|
63
|
+
version: "0.1.15",
|
|
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: {
|
|
@@ -2389,6 +2588,111 @@ var InsurUpAgentSetupClient = class {
|
|
|
2389
2588
|
// src/clients/agentUser.ts
|
|
2390
2589
|
var import_contracts = require("@insurup/contracts");
|
|
2391
2590
|
var import_contracts2 = require("@insurup/contracts");
|
|
2591
|
+
|
|
2592
|
+
// src/clients/_internal/normalize-search.ts
|
|
2593
|
+
var TEXT_INPUT_OPS = /* @__PURE__ */ new Set([
|
|
2594
|
+
"eq",
|
|
2595
|
+
"neq",
|
|
2596
|
+
"textSearch",
|
|
2597
|
+
"wildcard",
|
|
2598
|
+
"autocomplete",
|
|
2599
|
+
"contains",
|
|
2600
|
+
"notContains",
|
|
2601
|
+
"startsWith",
|
|
2602
|
+
"notStartsWith",
|
|
2603
|
+
"endsWith",
|
|
2604
|
+
"notEndsWith"
|
|
2605
|
+
]);
|
|
2606
|
+
var TEXT_LIST_INPUT_OPS = /* @__PURE__ */ new Set(["in", "nin"]);
|
|
2607
|
+
var COMBINATOR_OPS = /* @__PURE__ */ new Set(["and", "or"]);
|
|
2608
|
+
function normalizeSearchInput(search) {
|
|
2609
|
+
if (search === null || search === void 0) return search;
|
|
2610
|
+
if (typeof search !== "object") return search;
|
|
2611
|
+
return normalizeNode(search);
|
|
2612
|
+
}
|
|
2613
|
+
function normalizeNode(node) {
|
|
2614
|
+
if (node === null || typeof node !== "object") return node;
|
|
2615
|
+
const out = {};
|
|
2616
|
+
for (const [key, value] of Object.entries(node)) {
|
|
2617
|
+
if (COMBINATOR_OPS.has(key) && Array.isArray(value)) {
|
|
2618
|
+
out[key] = value.map(normalizeNode);
|
|
2619
|
+
} else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
2620
|
+
out[key] = normalizeStringOps(value);
|
|
2621
|
+
} else {
|
|
2622
|
+
out[key] = value;
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
return out;
|
|
2626
|
+
}
|
|
2627
|
+
function normalizeStringOps(field) {
|
|
2628
|
+
const out = {};
|
|
2629
|
+
for (const [op, value] of Object.entries(field)) {
|
|
2630
|
+
if (TEXT_INPUT_OPS.has(op) && typeof value === "string") {
|
|
2631
|
+
out[op] = { value };
|
|
2632
|
+
} else if (TEXT_LIST_INPUT_OPS.has(op) && Array.isArray(value)) {
|
|
2633
|
+
out[op] = { values: value };
|
|
2634
|
+
} else if (COMBINATOR_OPS.has(op) && Array.isArray(value)) {
|
|
2635
|
+
out[op] = value.map((item) => normalizeStringOps(item));
|
|
2636
|
+
} else {
|
|
2637
|
+
out[op] = value;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
return out;
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
// src/clients/_internal/split-unified-filter.ts
|
|
2644
|
+
var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
2645
|
+
var isSearchMarked = (v) => isObject(v) && v.$search === true;
|
|
2646
|
+
var stripMarker = ({ $search: _marker, ...rest }) => rest;
|
|
2647
|
+
var nonEmpty = (o) => Object.keys(o).length > 0;
|
|
2648
|
+
function splitUnifiedFilter(input) {
|
|
2649
|
+
if (input == null) return { filter: void 0, search: void 0 };
|
|
2650
|
+
const { filter, search } = splitNode(input);
|
|
2651
|
+
return {
|
|
2652
|
+
filter,
|
|
2653
|
+
search
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
function splitNode(node) {
|
|
2657
|
+
const filter = {};
|
|
2658
|
+
const search = {};
|
|
2659
|
+
for (const [key, value] of Object.entries(node)) {
|
|
2660
|
+
if ((key === "and" || key === "or") && Array.isArray(value)) {
|
|
2661
|
+
const filterItems = [];
|
|
2662
|
+
const searchItems = [];
|
|
2663
|
+
for (const item of value) {
|
|
2664
|
+
if (!isObject(item)) {
|
|
2665
|
+
filterItems.push(item);
|
|
2666
|
+
continue;
|
|
2667
|
+
}
|
|
2668
|
+
const split = splitNode(item);
|
|
2669
|
+
if (split.filter) filterItems.push(split.filter);
|
|
2670
|
+
if (split.search) searchItems.push(split.search);
|
|
2671
|
+
}
|
|
2672
|
+
if (filterItems.length > 0) filter[key] = filterItems;
|
|
2673
|
+
if (searchItems.length > 0) search[key] = searchItems;
|
|
2674
|
+
} else if (isSearchMarked(value)) {
|
|
2675
|
+
search[key] = stripMarker(value);
|
|
2676
|
+
} else {
|
|
2677
|
+
filter[key] = value;
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
return {
|
|
2681
|
+
filter: nonEmpty(filter) ? filter : void 0,
|
|
2682
|
+
search: nonEmpty(search) ? search : void 0
|
|
2683
|
+
};
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
// src/clients/_internal/build-filter-search-variables.ts
|
|
2687
|
+
function buildFilterSearchVariables(input) {
|
|
2688
|
+
const { filter, search } = splitUnifiedFilter(input);
|
|
2689
|
+
const out = {};
|
|
2690
|
+
if (filter !== void 0) out.filter = filter;
|
|
2691
|
+
if (search !== void 0) out.search = normalizeSearchInput(search);
|
|
2692
|
+
return out;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// src/clients/agentUser.ts
|
|
2392
2696
|
var InsurUpAgentUserClient = class {
|
|
2393
2697
|
constructor(http, graphql) {
|
|
2394
2698
|
this.http = http;
|
|
@@ -2640,8 +2944,7 @@ var InsurUpAgentUserClient = class {
|
|
|
2640
2944
|
after: requestOptions?.after,
|
|
2641
2945
|
last: requestOptions?.last,
|
|
2642
2946
|
before: requestOptions?.before,
|
|
2643
|
-
|
|
2644
|
-
filter: requestOptions?.filter,
|
|
2947
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
2645
2948
|
order: requestOptions?.order
|
|
2646
2949
|
};
|
|
2647
2950
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -2763,6 +3066,31 @@ var InsurUpCustomerClient = class {
|
|
|
2763
3066
|
options
|
|
2764
3067
|
);
|
|
2765
3068
|
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Retrieves the primary email address for a customer.
|
|
3071
|
+
*
|
|
3072
|
+
* Müşterinin birincil e-posta adresini getirir.
|
|
3073
|
+
*/
|
|
3074
|
+
async getPrimaryCustomerEmail(customerId, options) {
|
|
3075
|
+
return this.http.get(
|
|
3076
|
+
endpoints.customers.emails.getPrimaryCustomerEmail.render(customerId),
|
|
3077
|
+
options
|
|
3078
|
+
);
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* Sets the primary email address for a customer (upsert — adds to the customer's email
|
|
3082
|
+
* collection if missing, then marks it as primary).
|
|
3083
|
+
*
|
|
3084
|
+
* Müşterinin birincil e-posta adresini ayarlar (mevcut değilse koleksiyona ekler ve birincil
|
|
3085
|
+
* olarak işaretler).
|
|
3086
|
+
*/
|
|
3087
|
+
async setPrimaryCustomerEmail(request, options) {
|
|
3088
|
+
return this.http.putNoContent(
|
|
3089
|
+
endpoints.customers.emails.setPrimaryCustomerEmail.render(request.customerId),
|
|
3090
|
+
request,
|
|
3091
|
+
options
|
|
3092
|
+
);
|
|
3093
|
+
}
|
|
2766
3094
|
/**
|
|
2767
3095
|
* Retrieves all phone numbers associated with a customer.
|
|
2768
3096
|
*/
|
|
@@ -2801,6 +3129,44 @@ var InsurUpCustomerClient = class {
|
|
|
2801
3129
|
options
|
|
2802
3130
|
);
|
|
2803
3131
|
}
|
|
3132
|
+
/**
|
|
3133
|
+
* Retrieves the primary phone number for a customer.
|
|
3134
|
+
*
|
|
3135
|
+
* Müşterinin birincil telefon numarasını getirir.
|
|
3136
|
+
*/
|
|
3137
|
+
async getPrimaryCustomerPhoneNumber(customerId, options) {
|
|
3138
|
+
return this.http.get(
|
|
3139
|
+
endpoints.customers.phoneNumbers.getPrimaryCustomerPhoneNumber.render(customerId),
|
|
3140
|
+
options
|
|
3141
|
+
);
|
|
3142
|
+
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Sets the primary phone number for a customer (upsert — adds to the customer's phone
|
|
3145
|
+
* number collection if missing, then marks it as primary).
|
|
3146
|
+
*
|
|
3147
|
+
* Müşterinin birincil telefon numarasını ayarlar (mevcut değilse koleksiyona ekler ve
|
|
3148
|
+
* birincil olarak işaretler).
|
|
3149
|
+
*/
|
|
3150
|
+
async setPrimaryCustomerPhoneNumber(request, options) {
|
|
3151
|
+
return this.http.putNoContent(
|
|
3152
|
+
endpoints.customers.phoneNumbers.setPrimaryCustomerPhoneNumber.render(request.customerId),
|
|
3153
|
+
request,
|
|
3154
|
+
options
|
|
3155
|
+
);
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Retrieves all of a customer's insurable assets (vehicles and properties) in a single
|
|
3159
|
+
* polymorphic list discriminated by the `$type` field.
|
|
3160
|
+
*
|
|
3161
|
+
* Müşterinin tüm sigortalanabilir varlıklarını (araçlar ve mülkler) `$type` alanı ile
|
|
3162
|
+
* ayırt edilen tek bir polimorfik listede getirir.
|
|
3163
|
+
*/
|
|
3164
|
+
async getCustomerAssets(customerId, options) {
|
|
3165
|
+
return this.http.get(
|
|
3166
|
+
endpoints.customers.getCustomerAssets.render(customerId),
|
|
3167
|
+
options
|
|
3168
|
+
);
|
|
3169
|
+
}
|
|
2804
3170
|
/**
|
|
2805
3171
|
* Assigns a specific agent representative to manage a customer's account.
|
|
2806
3172
|
*/
|
|
@@ -3100,18 +3466,15 @@ var InsurUpCustomerClient = class {
|
|
|
3100
3466
|
}
|
|
3101
3467
|
}
|
|
3102
3468
|
`;
|
|
3103
|
-
const
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
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;
|
|
3469
|
+
const first = requestOptions?.first === void 0 && requestOptions?.last === void 0 ? 50 : requestOptions?.first;
|
|
3470
|
+
const variables = {
|
|
3471
|
+
first,
|
|
3472
|
+
after: requestOptions?.after,
|
|
3473
|
+
last: requestOptions?.last,
|
|
3474
|
+
before: requestOptions?.before,
|
|
3475
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
3476
|
+
order: requestOptions?.order
|
|
3477
|
+
};
|
|
3115
3478
|
const result = await this.graphql.query(query, variables, options);
|
|
3116
3479
|
if (!result.isSuccess) {
|
|
3117
3480
|
return result;
|
|
@@ -3796,8 +4159,7 @@ var InsurUpPolicyClient = class {
|
|
|
3796
4159
|
after: requestOptions?.after,
|
|
3797
4160
|
last: requestOptions?.last,
|
|
3798
4161
|
before: requestOptions?.before,
|
|
3799
|
-
|
|
3800
|
-
filter: requestOptions?.filter,
|
|
4162
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
3801
4163
|
order: requestOptions?.order
|
|
3802
4164
|
};
|
|
3803
4165
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -3877,8 +4239,7 @@ var InsurUpPolicyClient = class {
|
|
|
3877
4239
|
after: requestOptions?.after,
|
|
3878
4240
|
last: requestOptions?.last,
|
|
3879
4241
|
before: requestOptions?.before,
|
|
3880
|
-
|
|
3881
|
-
filter: requestOptions?.filter,
|
|
4242
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
3882
4243
|
order: requestOptions?.order
|
|
3883
4244
|
};
|
|
3884
4245
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -3958,8 +4319,7 @@ var InsurUpPolicyClient = class {
|
|
|
3958
4319
|
after: requestOptions?.after,
|
|
3959
4320
|
last: requestOptions?.last,
|
|
3960
4321
|
before: requestOptions?.before,
|
|
3961
|
-
|
|
3962
|
-
filter: requestOptions?.filter,
|
|
4322
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
3963
4323
|
order: requestOptions?.order
|
|
3964
4324
|
};
|
|
3965
4325
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -4303,8 +4663,7 @@ var InsurUpCaseClient = class {
|
|
|
4303
4663
|
after: requestOptions?.after,
|
|
4304
4664
|
last: requestOptions?.last,
|
|
4305
4665
|
before: requestOptions?.before,
|
|
4306
|
-
|
|
4307
|
-
filter: requestOptions?.filter,
|
|
4666
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
4308
4667
|
order: requestOptions?.order
|
|
4309
4668
|
};
|
|
4310
4669
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -4488,8 +4847,7 @@ var InsurUpWebhookClient = class {
|
|
|
4488
4847
|
after: requestOptions?.after,
|
|
4489
4848
|
last: requestOptions?.last,
|
|
4490
4849
|
before: requestOptions?.before,
|
|
4491
|
-
|
|
4492
|
-
filter: requestOptions?.filter,
|
|
4850
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
4493
4851
|
order: requestOptions?.order
|
|
4494
4852
|
};
|
|
4495
4853
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -4732,9 +5090,42 @@ var InsurUpInsuranceClient = class {
|
|
|
4732
5090
|
var import_contracts13 = require("@insurup/contracts");
|
|
4733
5091
|
var import_contracts14 = require("@insurup/contracts");
|
|
4734
5092
|
var InsurUpProposalClient = class {
|
|
4735
|
-
constructor(http, graphql) {
|
|
5093
|
+
constructor(http, graphql, signalR) {
|
|
4736
5094
|
this.http = http;
|
|
4737
5095
|
this.graphql = graphql;
|
|
5096
|
+
this.signalR = signalR;
|
|
5097
|
+
}
|
|
5098
|
+
/**
|
|
5099
|
+
* Subscribe to real-time updates for a proposal via the InsurUp SignalR
|
|
5100
|
+
* ProposalDetailHub. The first subscriber opens the underlying hub
|
|
5101
|
+
* connection lazily; subscriptions for additional proposals are multiplexed
|
|
5102
|
+
* over the same connection. Pass only the handlers you care about.
|
|
5103
|
+
*
|
|
5104
|
+
* Teklif için gerçek zamanlı güncellemelere SignalR üzerinden abone olur.
|
|
5105
|
+
*
|
|
5106
|
+
* @param proposalId - The proposal to subscribe to / Abone olunacak teklif
|
|
5107
|
+
* @param handlers - Per-event callbacks; missing entries are ignored
|
|
5108
|
+
* @returns An unsubscribe function. When the last subscription is torn
|
|
5109
|
+
* down, the underlying hub connection is stopped.
|
|
5110
|
+
* @throws If the SDK client was constructed without SignalR support
|
|
5111
|
+
*
|
|
5112
|
+
* @example
|
|
5113
|
+
* ```typescript
|
|
5114
|
+
* const unsub = await client.proposals.subscribeToDetail(proposalId, {
|
|
5115
|
+
* onProductSuccess: (event) => console.log('priced', event),
|
|
5116
|
+
* onProductFailed: (event) => console.warn('failed', event.errorMessage),
|
|
5117
|
+
* });
|
|
5118
|
+
* // later
|
|
5119
|
+
* unsub();
|
|
5120
|
+
* ```
|
|
5121
|
+
*/
|
|
5122
|
+
async subscribeToDetail(proposalId, handlers) {
|
|
5123
|
+
if (!this.signalR) {
|
|
5124
|
+
throw new Error(
|
|
5125
|
+
"subscribeToDetail requires SignalR support; construct the client via DefaultInsurUpClient"
|
|
5126
|
+
);
|
|
5127
|
+
}
|
|
5128
|
+
return this.signalR.subscribeProposalDetail(proposalId, handlers);
|
|
4738
5129
|
}
|
|
4739
5130
|
/**
|
|
4740
5131
|
* Creates a new insurance proposal with customer information, coverage selections, and product options for quotation.
|
|
@@ -5119,8 +5510,7 @@ var InsurUpProposalClient = class {
|
|
|
5119
5510
|
after: requestOptions?.after,
|
|
5120
5511
|
last: requestOptions?.last,
|
|
5121
5512
|
before: requestOptions?.before,
|
|
5122
|
-
|
|
5123
|
-
filter: requestOptions?.filter,
|
|
5513
|
+
...buildFilterSearchVariables(requestOptions?.filter),
|
|
5124
5514
|
order: requestOptions?.order
|
|
5125
5515
|
};
|
|
5126
5516
|
const result = await this.graphql.query(query, variables, options);
|
|
@@ -5265,6 +5655,7 @@ var InsurUpTemplateClient = class {
|
|
|
5265
5655
|
var DefaultInsurUpClient = class {
|
|
5266
5656
|
http;
|
|
5267
5657
|
graphql;
|
|
5658
|
+
signalR;
|
|
5268
5659
|
/**
|
|
5269
5660
|
* Agent Management Client
|
|
5270
5661
|
*
|
|
@@ -5389,6 +5780,11 @@ var DefaultInsurUpClient = class {
|
|
|
5389
5780
|
this.http = new HttpTransport(options);
|
|
5390
5781
|
this.graphql = new GraphQLTransport(this.http);
|
|
5391
5782
|
this.options = options || {};
|
|
5783
|
+
this.signalR = new SignalRTransport({
|
|
5784
|
+
hubsBaseUrl: options?.hubsBaseUrl ?? deriveHubsBaseUrl(options?.baseUrl),
|
|
5785
|
+
tokenProvider: options?.tokenProvider,
|
|
5786
|
+
logLevel: options?.signalRLogLevel
|
|
5787
|
+
});
|
|
5392
5788
|
this.agents = new InsurUpAgentClient(this.http);
|
|
5393
5789
|
this.agentBranches = new InsurUpAgentBranchClient(this.http);
|
|
5394
5790
|
this.agentRoles = new InsurUpAgentRoleClient(this.http);
|
|
@@ -5402,14 +5798,27 @@ var DefaultInsurUpClient = class {
|
|
|
5402
5798
|
this.webhooks = new InsurUpWebhookClient(this.http, this.graphql);
|
|
5403
5799
|
this.coverage = new InsurUpCoverageClient(this.http);
|
|
5404
5800
|
this.insurance = new InsurUpInsuranceClient(this.http);
|
|
5405
|
-
this.proposals = new InsurUpProposalClient(this.http, this.graphql);
|
|
5801
|
+
this.proposals = new InsurUpProposalClient(this.http, this.graphql, this.signalR);
|
|
5406
5802
|
this.files = new InsurUpFileClient(this.http);
|
|
5407
5803
|
this.languages = new InsurUpLanguageClient(this.http);
|
|
5408
5804
|
this.templates = new InsurUpTemplateClient(this.http);
|
|
5409
5805
|
}
|
|
5806
|
+
/**
|
|
5807
|
+
* Stop any open SignalR connection and drop pending subscribers. Safe to
|
|
5808
|
+
* call multiple times. Call this when disposing of the SDK client (e.g. on
|
|
5809
|
+
* app teardown or test cleanup).
|
|
5810
|
+
*/
|
|
5811
|
+
async close() {
|
|
5812
|
+
await this.signalR.close();
|
|
5813
|
+
}
|
|
5410
5814
|
};
|
|
5815
|
+
function deriveHubsBaseUrl(baseUrl) {
|
|
5816
|
+
const resolved = baseUrl ?? "https://api.insurup.com/api/";
|
|
5817
|
+
return new URL(resolved).origin;
|
|
5818
|
+
}
|
|
5411
5819
|
|
|
5412
5820
|
// src/index.ts
|
|
5821
|
+
var import_signalr4 = require("@microsoft/signalr");
|
|
5413
5822
|
__reExport(index_exports, require("@insurup/contracts"), module.exports);
|
|
5414
5823
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5415
5824
|
0 && (module.exports = {
|
|
@@ -5437,6 +5846,8 @@ __reExport(index_exports, require("@insurup/contracts"), module.exports);
|
|
|
5437
5846
|
InsurUpTemplateClient,
|
|
5438
5847
|
InsurUpVehicleClient,
|
|
5439
5848
|
InsurUpWebhookClient,
|
|
5849
|
+
SignalRLogLevel,
|
|
5850
|
+
SignalRTransport,
|
|
5440
5851
|
VERSION,
|
|
5441
5852
|
createGraphQLErrors,
|
|
5442
5853
|
extractError,
|