@firfi/huly-mcp 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/index.cjs +722 -198
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -449,13 +449,21 @@ SDK upgrade revisit:
|
|
|
449
449
|
| `update_person` | Update fields on an existing person. Only provided fields are modified. |
|
|
450
450
|
| `delete_person` | Permanently delete a person from Huly. This action cannot be undone. |
|
|
451
451
|
| `list_employees` | List employees (persons who are team members). Returns employees sorted by modification date (newest first). |
|
|
452
|
+
| `list_contact_channel_providers` | List supported contact channel provider labels for person and organization channel tools. |
|
|
453
|
+
| `list_person_channels` | List contact channels for a person. Person accepts person ID, exact email address, or exact Huly display name; ambiguous names fail and should be retried with email or person ID. |
|
|
454
|
+
| `add_person_channel` | Idempotently add a contact channel to a person. Person accepts person ID, exact email address, or exact Huly display name. Provider labels match list_contact_channel_providers. Returns added=false and the existing channel when the exact provider+value already exists. |
|
|
455
|
+
| `update_person_channel` | Update one contact channel on a person. Person accepts person ID, exact email, or exact display name. Identify the channel with exactly one locator: channelId, or provider plus value. Provide newProvider, newValue, or both. Updating to an existing provider+value on the same person fails with a conflict. |
|
|
456
|
+
| `remove_person_channel` | Remove one contact channel from a person. Person accepts person ID, exact email, or exact display name. Identify the channel with exactly one locator: channelId, or provider plus value. Returns removed=false when the locator is absent for that person. |
|
|
452
457
|
| `list_organizations` | List all organizations in the Huly workspace. Returns organizations sorted by modification date (newest first). |
|
|
453
458
|
| `create_organization` | Create a new organization in Huly. Optionally add members by person ID or email. Fails if any requested member cannot be resolved. Returns the created organization ID. |
|
|
454
459
|
| `get_organization` | Retrieve full details for an organization by ID or exact name when that name is unique - including city, description, member count, and modification timestamp. If multiple organizations share the same name, use the organization ID. |
|
|
455
460
|
| `update_organization` | Update fields on an existing organization identified by ID or exact name when that name is unique. Only provided fields are modified. Description supports multi-line plain text and is the right place to store CRM notes / revenue summaries / context. Pass null to clear city or description. If multiple organizations share the same name, use the organization ID. |
|
|
456
461
|
| `delete_organization` | Permanently delete an organization identified by ID or exact name when that name is unique. Use with care - this cannot be undone. Useful for cleaning up duplicate organizations after merging their data elsewhere. If multiple organizations share the same name, use the organization ID. |
|
|
457
462
|
| `make_organization_customer` | Apply the Customer mixin to an organization so it appears in the Huly Leads > Customers view. Idempotent - safe to call on organizations that are already customers. Takes the organization ID or exact name when that name is unique. |
|
|
458
|
-
| `add_organization_channel` |
|
|
463
|
+
| `add_organization_channel` | Idempotently add a contact channel to an organization identified by ID or exact unique name. Provider labels: email, phone, linkedin, twitter, github, facebook, telegram, homepage, whatsapp, skype, profile, viber. Returns added=false and the existing channel when the exact provider+value already exists. |
|
|
464
|
+
| `list_organization_channels` | List contact channels for an organization identified by ID or exact unique organization name. Returns channelId, provider label, value, and optional activity metadata. |
|
|
465
|
+
| `update_organization_channel` | Update one contact channel on an organization identified by ID or exact unique name. Identify the channel with exactly one locator: channelId, or provider plus value. Provide newProvider, newValue, or both. Updating to an existing provider+value on the same organization fails with a conflict. |
|
|
466
|
+
| `remove_organization_channel` | Remove one contact channel from an organization identified by ID or exact unique name. Identify the channel with exactly one locator: channelId, or provider plus value. Returns removed=false when the locator is absent for that organization. |
|
|
459
467
|
| `add_organization_member` | Link a person as a member of an organization. The person appears under the org's Members tab in Huly. Use person ID or email to identify the person. Idempotent: returns added=false if that person is already a member. |
|
|
460
468
|
| `list_organization_members` | List all persons who are members of an organization. Returns each member's person ID, name, and primary email (if any). When using a name instead of an ID, that name must identify exactly one organization. |
|
|
461
469
|
| `list_person_organizations` | List all organizations that a person is a member of. Provide personId or email. Returns each organization's ID and name. |
|
package/dist/index.cjs
CHANGED
|
@@ -81771,7 +81771,7 @@ var require_connection2 = __commonJS({
|
|
|
81771
81771
|
});
|
|
81772
81772
|
module2.exports = __toCommonJS2(connection_exports);
|
|
81773
81773
|
var import_analytics = require_lib2();
|
|
81774
|
-
var
|
|
81774
|
+
var import_client66 = __toESM2(require_lib6());
|
|
81775
81775
|
var import_core80 = __toESM2(require_lib4());
|
|
81776
81776
|
var import_platform4 = __toESM2(require_lib());
|
|
81777
81777
|
var import_rpc = require_lib18();
|
|
@@ -81882,7 +81882,7 @@ var require_connection2 = __commonJS({
|
|
|
81882
81882
|
}
|
|
81883
81883
|
if (!this.closed) {
|
|
81884
81884
|
void this.sendRequest({
|
|
81885
|
-
method:
|
|
81885
|
+
method: import_client66.pingConst,
|
|
81886
81886
|
params: [],
|
|
81887
81887
|
once: true,
|
|
81888
81888
|
handleResult: /* @__PURE__ */ __name(async (result) => {
|
|
@@ -81915,7 +81915,7 @@ var require_connection2 = __commonJS({
|
|
|
81915
81915
|
}
|
|
81916
81916
|
}
|
|
81917
81917
|
isConnected() {
|
|
81918
|
-
return this.websocket != null && this.websocket.readyState ===
|
|
81918
|
+
return this.websocket != null && this.websocket.readyState === import_client66.ClientSocketReadyState.OPEN && this.helloReceived;
|
|
81919
81919
|
}
|
|
81920
81920
|
delay = 0;
|
|
81921
81921
|
onConnectHandlers = [];
|
|
@@ -82055,8 +82055,8 @@ var require_connection2 = __commonJS({
|
|
|
82055
82055
|
}
|
|
82056
82056
|
return;
|
|
82057
82057
|
}
|
|
82058
|
-
if (resp.result ===
|
|
82059
|
-
void this.sendRequest({ method:
|
|
82058
|
+
if (resp.result === import_client66.pingConst) {
|
|
82059
|
+
void this.sendRequest({ method: import_client66.pingConst, params: [] }).catch((err) => {
|
|
82060
82060
|
this.ctx.error("failed to send ping", { err });
|
|
82061
82061
|
});
|
|
82062
82062
|
return;
|
|
@@ -82148,15 +82148,15 @@ var require_connection2 = __commonJS({
|
|
|
82148
82148
|
}
|
|
82149
82149
|
}
|
|
82150
82150
|
checkArrayBufferPing(data) {
|
|
82151
|
-
if (data.byteLength ===
|
|
82151
|
+
if (data.byteLength === import_client66.pingConst.length || data.byteLength === import_client66.pongConst.length) {
|
|
82152
82152
|
const text = new TextDecoder().decode(data);
|
|
82153
|
-
if (text ===
|
|
82154
|
-
void this.sendRequest({ method:
|
|
82153
|
+
if (text === import_client66.pingConst) {
|
|
82154
|
+
void this.sendRequest({ method: import_client66.pingConst, params: [] }).catch((err) => {
|
|
82155
82155
|
this.ctx.error("failed to send ping", { err });
|
|
82156
82156
|
});
|
|
82157
82157
|
return true;
|
|
82158
82158
|
}
|
|
82159
|
-
if (text ===
|
|
82159
|
+
if (text === import_client66.pongConst) {
|
|
82160
82160
|
this.pingResponse = Date.now();
|
|
82161
82161
|
return true;
|
|
82162
82162
|
}
|
|
@@ -82166,7 +82166,7 @@ var require_connection2 = __commonJS({
|
|
|
82166
82166
|
openConnection(ctx, socketId) {
|
|
82167
82167
|
this.binaryMode = false;
|
|
82168
82168
|
this.helloReceived = false;
|
|
82169
|
-
const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform4.getMetadata)(
|
|
82169
|
+
const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform4.getMetadata)(import_client66.default.metadata.ClientSocketFactory) ?? ((url4) => {
|
|
82170
82170
|
const s = new WebSocket(url4);
|
|
82171
82171
|
return s;
|
|
82172
82172
|
});
|
|
@@ -82201,12 +82201,12 @@ var require_connection2 = __commonJS({
|
|
|
82201
82201
|
if (this.websocket !== wsocket) {
|
|
82202
82202
|
return;
|
|
82203
82203
|
}
|
|
82204
|
-
if (event.data ===
|
|
82204
|
+
if (event.data === import_client66.pongConst) {
|
|
82205
82205
|
this.pingResponse = Date.now();
|
|
82206
82206
|
return;
|
|
82207
82207
|
}
|
|
82208
|
-
if (event.data ===
|
|
82209
|
-
void this.sendRequest({ method:
|
|
82208
|
+
if (event.data === import_client66.pingConst) {
|
|
82209
|
+
void this.sendRequest({ method: import_client66.pingConst, params: [] }).catch((err) => {
|
|
82210
82210
|
this.ctx.error("failed to send ping", { err });
|
|
82211
82211
|
});
|
|
82212
82212
|
return;
|
|
@@ -82271,8 +82271,8 @@ var require_connection2 = __commonJS({
|
|
|
82271
82271
|
if (this.websocket !== wsocket) {
|
|
82272
82272
|
return;
|
|
82273
82273
|
}
|
|
82274
|
-
const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform4.getMetadata)(
|
|
82275
|
-
this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform4.getMetadata)(
|
|
82274
|
+
const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform4.getMetadata)(import_client66.default.metadata.UseBinaryProtocol) ?? true;
|
|
82275
|
+
this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform4.getMetadata)(import_client66.default.metadata.UseProtocolCompression) ?? false;
|
|
82276
82276
|
const helloRequest = {
|
|
82277
82277
|
method: "hello",
|
|
82278
82278
|
params: [],
|
|
@@ -82318,13 +82318,13 @@ var require_connection2 = __commonJS({
|
|
|
82318
82318
|
if (w instanceof Promise) {
|
|
82319
82319
|
await w;
|
|
82320
82320
|
}
|
|
82321
|
-
if (data.method !==
|
|
82321
|
+
if (data.method !== import_client66.pingConst) {
|
|
82322
82322
|
this.requests.set(id, promise4);
|
|
82323
82323
|
}
|
|
82324
82324
|
promise4.sendData = () => {
|
|
82325
|
-
if (this.websocket?.readyState ===
|
|
82325
|
+
if (this.websocket?.readyState === import_client66.ClientSocketReadyState.OPEN) {
|
|
82326
82326
|
promise4.startTime = Date.now();
|
|
82327
|
-
if (data.method !==
|
|
82327
|
+
if (data.method !== import_client66.pingConst) {
|
|
82328
82328
|
const dta = this.rpcHandler.serialize(
|
|
82329
82329
|
{
|
|
82330
82330
|
method: data.method,
|
|
@@ -82337,7 +82337,7 @@ var require_connection2 = __commonJS({
|
|
|
82337
82337
|
);
|
|
82338
82338
|
this.websocket?.send(dta);
|
|
82339
82339
|
} else {
|
|
82340
|
-
this.websocket?.send(
|
|
82340
|
+
this.websocket?.send(import_client66.pingConst);
|
|
82341
82341
|
}
|
|
82342
82342
|
}
|
|
82343
82343
|
};
|
|
@@ -82351,7 +82351,7 @@ var require_connection2 = __commonJS({
|
|
|
82351
82351
|
};
|
|
82352
82352
|
}
|
|
82353
82353
|
promise4.sendData();
|
|
82354
|
-
if (data.method !==
|
|
82354
|
+
if (data.method !== import_client66.pingConst) {
|
|
82355
82355
|
return await promise4.promise;
|
|
82356
82356
|
}
|
|
82357
82357
|
},
|
|
@@ -82517,7 +82517,7 @@ var require_lib19 = __commonJS({
|
|
|
82517
82517
|
default: () => index_default
|
|
82518
82518
|
});
|
|
82519
82519
|
module2.exports = __toCommonJS2(index_exports2);
|
|
82520
|
-
var
|
|
82520
|
+
var import_client66 = __toESM2(require_lib6());
|
|
82521
82521
|
var import_core80 = __toESM2(require_lib4());
|
|
82522
82522
|
var import_platform4 = __toESM2(require_lib());
|
|
82523
82523
|
var import_connection = require_connection2();
|
|
@@ -82561,8 +82561,8 @@ var require_lib19 = __commonJS({
|
|
|
82561
82561
|
return {
|
|
82562
82562
|
function: {
|
|
82563
82563
|
GetClient: /* @__PURE__ */ __name(async (token, endpoint, opt) => {
|
|
82564
|
-
const filterModel = (0, import_platform4.getMetadata)(
|
|
82565
|
-
const extraFilter = (0, import_platform4.getMetadata)(
|
|
82564
|
+
const filterModel = (0, import_platform4.getMetadata)(import_client66.default.metadata.FilterModel) ?? "none";
|
|
82565
|
+
const extraFilter = (0, import_platform4.getMetadata)(import_client66.default.metadata.ExtraFilter) ?? [];
|
|
82566
82566
|
const handler = /* @__PURE__ */ __name(async (handler2) => {
|
|
82567
82567
|
const url4 = (0, import_core80.concatLink)(endpoint, `/${token}`);
|
|
82568
82568
|
const upgradeHandler = /* @__PURE__ */ __name((...txes) => {
|
|
@@ -82590,7 +82590,7 @@ var require_lib19 = __commonJS({
|
|
|
82590
82590
|
throw new Error("Workspace or account not found in token");
|
|
82591
82591
|
}
|
|
82592
82592
|
const newOpt = { ...opt };
|
|
82593
|
-
const connectTimeout = opt?.connectionTimeout ?? (0, import_platform4.getMetadata)(
|
|
82593
|
+
const connectTimeout = opt?.connectionTimeout ?? (0, import_platform4.getMetadata)(import_client66.default.metadata.ConnectionTimeout);
|
|
82594
82594
|
let connectPromise;
|
|
82595
82595
|
if ((connectTimeout ?? 0) > 0) {
|
|
82596
82596
|
connectPromise = new Promise((resolve2, reject) => {
|
|
@@ -82642,7 +82642,7 @@ var require_lib19 = __commonJS({
|
|
|
82642
82642
|
function returnUITxes(txes, extraFilter) {
|
|
82643
82643
|
const configs = /* @__PURE__ */ new Map();
|
|
82644
82644
|
(0, import_core80.fillConfiguration)(txes, configs);
|
|
82645
|
-
const allowedPlugins = [...(0, import_platform4.getPlugins)(), ...(0, import_platform4.getMetadata)(
|
|
82645
|
+
const allowedPlugins = [...(0, import_platform4.getPlugins)(), ...(0, import_platform4.getMetadata)(import_client66.default.metadata.ExtraPlugins) ?? []];
|
|
82646
82646
|
const excludedPlugins = Array.from(configs.values()).filter(
|
|
82647
82647
|
(it) => !it.enabled || !allowedPlugins.includes(it.pluginId) || extraFilter.includes(it.pluginId)
|
|
82648
82648
|
);
|
|
@@ -82690,7 +82690,7 @@ var require_lib19 = __commonJS({
|
|
|
82690
82690
|
}
|
|
82691
82691
|
__name(returnClientTxes, "returnClientTxes");
|
|
82692
82692
|
function createModelPersistence(workspace) {
|
|
82693
|
-
const overrideStore = (0, import_platform4.getMetadata)(
|
|
82693
|
+
const overrideStore = (0, import_platform4.getMetadata)(import_client66.default.metadata.OverridePersistenceStore);
|
|
82694
82694
|
if (overrideStore !== void 0) {
|
|
82695
82695
|
return overrideStore;
|
|
82696
82696
|
}
|
|
@@ -82787,7 +82787,7 @@ var require_client6 = __commonJS({
|
|
|
82787
82787
|
});
|
|
82788
82788
|
module2.exports = __toCommonJS2(client_exports);
|
|
82789
82789
|
var import_account_client2 = require_lib5();
|
|
82790
|
-
var
|
|
82790
|
+
var import_client66 = __toESM2(require_lib6());
|
|
82791
82791
|
var import_core80 = require_lib4();
|
|
82792
82792
|
var import_platform4 = require_lib();
|
|
82793
82793
|
var import_config9 = require_config();
|
|
@@ -82813,9 +82813,9 @@ var require_client6 = __commonJS({
|
|
|
82813
82813
|
}
|
|
82814
82814
|
__name(connect, "connect");
|
|
82815
82815
|
async function createClient(url4, endpoint, token, workspaceUuid, account, config3, options) {
|
|
82816
|
-
(0, import_platform4.addLocation)(
|
|
82816
|
+
(0, import_platform4.addLocation)(import_client66.clientId, () => Promise.resolve().then(() => __toESM(require_lib19())));
|
|
82817
82817
|
const { socketFactory, connectionTimeout } = options;
|
|
82818
|
-
const clientFactory = await (0, import_platform4.getResource)(
|
|
82818
|
+
const clientFactory = await (0, import_platform4.getResource)(import_client66.default.function.GetClient);
|
|
82819
82819
|
const connection = await clientFactory(token, endpoint, {
|
|
82820
82820
|
socketFactory,
|
|
82821
82821
|
connectionTimeout
|
|
@@ -83936,11 +83936,11 @@ var require_storage2 = __commonJS({
|
|
|
83936
83936
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
83937
83937
|
var storage_exports = {};
|
|
83938
83938
|
__export2(storage_exports, {
|
|
83939
|
-
connectStorage: () =>
|
|
83940
|
-
createStorageClient: () =>
|
|
83939
|
+
connectStorage: () => import_client66.connectStorage,
|
|
83940
|
+
createStorageClient: () => import_client66.createStorageClient
|
|
83941
83941
|
});
|
|
83942
83942
|
module2.exports = __toCommonJS2(storage_exports);
|
|
83943
|
-
var
|
|
83943
|
+
var import_client66 = require_client7();
|
|
83944
83944
|
__reExport2(storage_exports, require_error3(), module2.exports);
|
|
83945
83945
|
__reExport2(storage_exports, require_types8(), module2.exports);
|
|
83946
83946
|
}
|
|
@@ -152893,6 +152893,63 @@ var InvalidContactProviderError = class extends Schema_exports.TaggedError()(
|
|
|
152893
152893
|
return `Invalid contact provider: '${this.provider}'`;
|
|
152894
152894
|
}
|
|
152895
152895
|
};
|
|
152896
|
+
var ContactChannelNotFoundError = class extends Schema_exports.TaggedError()(
|
|
152897
|
+
"ContactChannelNotFoundError",
|
|
152898
|
+
{
|
|
152899
|
+
ownerIdentifier: Schema_exports.String,
|
|
152900
|
+
channelIdentifier: Schema_exports.String
|
|
152901
|
+
}
|
|
152902
|
+
) {
|
|
152903
|
+
get message() {
|
|
152904
|
+
return `Contact channel '${this.channelIdentifier}' not found for '${this.ownerIdentifier}'`;
|
|
152905
|
+
}
|
|
152906
|
+
};
|
|
152907
|
+
var ContactChannelIdentifierAmbiguousError = class extends Schema_exports.TaggedError()(
|
|
152908
|
+
"ContactChannelIdentifierAmbiguousError",
|
|
152909
|
+
{
|
|
152910
|
+
ownerIdentifier: Schema_exports.String,
|
|
152911
|
+
channelIdentifier: Schema_exports.String,
|
|
152912
|
+
matches: AmbiguousMatchCount
|
|
152913
|
+
}
|
|
152914
|
+
) {
|
|
152915
|
+
get message() {
|
|
152916
|
+
return `Contact channel '${this.channelIdentifier}' matched ${this.matches} channels for '${this.ownerIdentifier}'; use channelId instead`;
|
|
152917
|
+
}
|
|
152918
|
+
};
|
|
152919
|
+
var InvalidContactChannelLocatorError = class extends Schema_exports.TaggedError()(
|
|
152920
|
+
"InvalidContactChannelLocatorError",
|
|
152921
|
+
{
|
|
152922
|
+
ownerIdentifier: Schema_exports.String,
|
|
152923
|
+
reason: Schema_exports.String
|
|
152924
|
+
}
|
|
152925
|
+
) {
|
|
152926
|
+
get message() {
|
|
152927
|
+
return `Invalid contact channel locator for '${this.ownerIdentifier}': ${this.reason}`;
|
|
152928
|
+
}
|
|
152929
|
+
};
|
|
152930
|
+
var ContactChannelConflictError = class extends Schema_exports.TaggedError()(
|
|
152931
|
+
"ContactChannelConflictError",
|
|
152932
|
+
{
|
|
152933
|
+
ownerIdentifier: Schema_exports.String,
|
|
152934
|
+
provider: Schema_exports.String,
|
|
152935
|
+
value: Schema_exports.String
|
|
152936
|
+
}
|
|
152937
|
+
) {
|
|
152938
|
+
get message() {
|
|
152939
|
+
return `Contact channel '${this.provider}:${this.value}' already exists for '${this.ownerIdentifier}'`;
|
|
152940
|
+
}
|
|
152941
|
+
};
|
|
152942
|
+
var InvalidContactChannelValueError = class extends Schema_exports.TaggedError()(
|
|
152943
|
+
"InvalidContactChannelValueError",
|
|
152944
|
+
{
|
|
152945
|
+
provider: Schema_exports.String,
|
|
152946
|
+
value: Schema_exports.String
|
|
152947
|
+
}
|
|
152948
|
+
) {
|
|
152949
|
+
get message() {
|
|
152950
|
+
return `Invalid value '${this.value}' for contact channel provider '${this.provider}'`;
|
|
152951
|
+
}
|
|
152952
|
+
};
|
|
152896
152953
|
var InvalidPersonUuidError = class extends Schema_exports.TaggedError()(
|
|
152897
152954
|
"InvalidPersonUuidError",
|
|
152898
152955
|
{
|
|
@@ -154731,6 +154788,11 @@ var HulyDomainError = Schema_exports.Union(
|
|
|
154731
154788
|
IssueNotFoundError,
|
|
154732
154789
|
ProjectNotFoundError,
|
|
154733
154790
|
InvalidStatusError,
|
|
154791
|
+
ContactChannelConflictError,
|
|
154792
|
+
ContactChannelIdentifierAmbiguousError,
|
|
154793
|
+
ContactChannelNotFoundError,
|
|
154794
|
+
InvalidContactChannelLocatorError,
|
|
154795
|
+
InvalidContactChannelValueError,
|
|
154734
154796
|
PersonIdentifierAmbiguousError,
|
|
154735
154797
|
PersonNotFoundError,
|
|
154736
154798
|
OrganizationNotFoundError,
|
|
@@ -165692,6 +165754,11 @@ var INVALID_PARAMS_TAGS = /* @__PURE__ */ new Set([
|
|
|
165692
165754
|
"OrganizationNotFoundError",
|
|
165693
165755
|
"OrganizationIdentifierAmbiguousError",
|
|
165694
165756
|
"InvalidContactProviderError",
|
|
165757
|
+
"ContactChannelNotFoundError",
|
|
165758
|
+
"ContactChannelIdentifierAmbiguousError",
|
|
165759
|
+
"ContactChannelConflictError",
|
|
165760
|
+
"InvalidContactChannelLocatorError",
|
|
165761
|
+
"InvalidContactChannelValueError",
|
|
165695
165762
|
"InvalidFileDataError",
|
|
165696
165763
|
"FileNotFoundError",
|
|
165697
165764
|
"TeamspaceNotFoundError",
|
|
@@ -169555,6 +169622,194 @@ var parseUpdateMilestoneParams = Schema_exports.decodeUnknown(UpdateMilestonePar
|
|
|
169555
169622
|
var parseSetIssueMilestoneParams = Schema_exports.decodeUnknown(SetIssueMilestoneParamsSchema);
|
|
169556
169623
|
var parseDeleteMilestoneParams = Schema_exports.decodeUnknown(DeleteMilestoneParamsSchema);
|
|
169557
169624
|
|
|
169625
|
+
// src/domain/schemas/contact-channels.ts
|
|
169626
|
+
var CHANNEL_UPDATE_FIELDS = ["newProvider", "newValue"];
|
|
169627
|
+
var ContactChannelProviderValues = [
|
|
169628
|
+
"email",
|
|
169629
|
+
"phone",
|
|
169630
|
+
"linkedin",
|
|
169631
|
+
"twitter",
|
|
169632
|
+
"github",
|
|
169633
|
+
"facebook",
|
|
169634
|
+
"telegram",
|
|
169635
|
+
"homepage",
|
|
169636
|
+
"whatsapp",
|
|
169637
|
+
"skype",
|
|
169638
|
+
"profile",
|
|
169639
|
+
"viber"
|
|
169640
|
+
];
|
|
169641
|
+
var ContactChannelProviderSdkKeys = {
|
|
169642
|
+
email: "Email",
|
|
169643
|
+
phone: "Phone",
|
|
169644
|
+
linkedin: "LinkedIn",
|
|
169645
|
+
twitter: "Twitter",
|
|
169646
|
+
github: "GitHub",
|
|
169647
|
+
facebook: "Facebook",
|
|
169648
|
+
telegram: "Telegram",
|
|
169649
|
+
homepage: "Homepage",
|
|
169650
|
+
whatsapp: "Whatsapp",
|
|
169651
|
+
skype: "Skype",
|
|
169652
|
+
profile: "Profile",
|
|
169653
|
+
viber: "Viber"
|
|
169654
|
+
};
|
|
169655
|
+
var ContactChannelProviderSchema = Schema_exports.Literal(...ContactChannelProviderValues);
|
|
169656
|
+
var ContactChannelSummarySchema = Schema_exports.Struct({
|
|
169657
|
+
channelId: ChannelId,
|
|
169658
|
+
provider: ContactChannelProviderSchema,
|
|
169659
|
+
value: NonEmptyString2,
|
|
169660
|
+
items: Schema_exports.optional(Count),
|
|
169661
|
+
lastMessage: Schema_exports.optional(Timestamp)
|
|
169662
|
+
});
|
|
169663
|
+
var ListContactChannelProvidersParamsSchema = EmptyParamsSchema.annotations({
|
|
169664
|
+
title: "ListContactChannelProvidersParams",
|
|
169665
|
+
description: "Parameters for listing supported contact channel provider labels."
|
|
169666
|
+
});
|
|
169667
|
+
var providerDescription = `Channel provider label: ${enumValuesDescription(ContactChannelProviderValues)}.`;
|
|
169668
|
+
var validateEmailChannelValue = (provider, value3) => provider === "email" && !Schema_exports.is(Email)(value3) ? "email provider values must be valid email addresses." : void 0;
|
|
169669
|
+
var ChannelProviderValueSchema = Schema_exports.Struct({
|
|
169670
|
+
provider: ContactChannelProviderSchema.annotations({ description: providerDescription }),
|
|
169671
|
+
value: NonEmptyString2.annotations({
|
|
169672
|
+
description: "Channel value. Email providers require a valid email address; all other providers require text."
|
|
169673
|
+
})
|
|
169674
|
+
}).pipe(Schema_exports.filter((params) => validateEmailChannelValue(params.provider, params.value)));
|
|
169675
|
+
var hasProviderValueLocator = (params) => params.provider !== void 0 && params.value !== void 0;
|
|
169676
|
+
var channelLocatorMessage = "Provide exactly one channel locator: channelId, or provider plus value.";
|
|
169677
|
+
var validateChannelLocator = (params) => {
|
|
169678
|
+
const hasChannelId = params.channelId !== void 0;
|
|
169679
|
+
const hasAnyProviderValue = params.provider !== void 0 || params.value !== void 0;
|
|
169680
|
+
const hasProviderValue = hasProviderValueLocator(params);
|
|
169681
|
+
if (hasChannelId && !hasAnyProviderValue) return void 0;
|
|
169682
|
+
if (!hasChannelId && hasProviderValue) return void 0;
|
|
169683
|
+
return channelLocatorMessage;
|
|
169684
|
+
};
|
|
169685
|
+
var updateTargetValueMessage = "At least one update field must be provided: newProvider, newValue.";
|
|
169686
|
+
var validateUpdateTargetValue = (params) => {
|
|
169687
|
+
if (!hasAtLeastOneDefined(params, CHANNEL_UPDATE_FIELDS)) return updateTargetValueMessage;
|
|
169688
|
+
const targetProvider = params.newProvider ?? params.provider;
|
|
169689
|
+
const targetValue = params.newValue ?? params.value;
|
|
169690
|
+
return targetProvider !== void 0 && targetValue !== void 0 ? validateEmailChannelValue(targetProvider, targetValue) : void 0;
|
|
169691
|
+
};
|
|
169692
|
+
var ContactChannelLocatorFieldsSchema = Schema_exports.Struct({
|
|
169693
|
+
channelId: Schema_exports.optional(ChannelId.annotations({
|
|
169694
|
+
description: "Raw channel document ID returned by list/get/add channel tools."
|
|
169695
|
+
})),
|
|
169696
|
+
provider: Schema_exports.optional(ContactChannelProviderSchema.annotations({ description: providerDescription })),
|
|
169697
|
+
value: Schema_exports.optional(NonEmptyString2.annotations({
|
|
169698
|
+
description: "Existing channel value to pair with provider when channelId is not used."
|
|
169699
|
+
}))
|
|
169700
|
+
}).pipe(
|
|
169701
|
+
Schema_exports.filter(
|
|
169702
|
+
(params) => params.provider !== void 0 && params.value !== void 0 ? validateEmailChannelValue(params.provider, params.value) : void 0
|
|
169703
|
+
),
|
|
169704
|
+
Schema_exports.filter(validateChannelLocator)
|
|
169705
|
+
);
|
|
169706
|
+
var AddPersonChannelParamsSchema = ChannelProviderValueSchema.pipe(
|
|
169707
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169708
|
+
person: NonEmptyString2.annotations({
|
|
169709
|
+
description: "Person ID, exact email address, or exact Huly display name."
|
|
169710
|
+
})
|
|
169711
|
+
}))
|
|
169712
|
+
).annotations({
|
|
169713
|
+
title: "AddPersonChannelParams",
|
|
169714
|
+
description: "Add a contact channel to a person. Idempotent by exact provider plus value."
|
|
169715
|
+
});
|
|
169716
|
+
var ListPersonChannelsParamsSchema = Schema_exports.Struct({
|
|
169717
|
+
person: NonEmptyString2.annotations({
|
|
169718
|
+
description: "Person ID, exact email address, or exact Huly display name."
|
|
169719
|
+
})
|
|
169720
|
+
}).annotations({
|
|
169721
|
+
title: "ListPersonChannelsParams",
|
|
169722
|
+
description: "List contact channels for a person."
|
|
169723
|
+
});
|
|
169724
|
+
var UpdatePersonChannelParamsSchema = ContactChannelLocatorFieldsSchema.pipe(
|
|
169725
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169726
|
+
person: NonEmptyString2.annotations({
|
|
169727
|
+
description: "Person ID, exact email address, or exact Huly display name."
|
|
169728
|
+
}),
|
|
169729
|
+
newProvider: Schema_exports.optional(ContactChannelProviderSchema.annotations({ description: providerDescription })),
|
|
169730
|
+
newValue: Schema_exports.optional(NonEmptyString2.annotations({ description: "Replacement channel value." }))
|
|
169731
|
+
})),
|
|
169732
|
+
Schema_exports.filter(validateUpdateTargetValue)
|
|
169733
|
+
).annotations({
|
|
169734
|
+
title: "UpdatePersonChannelParams",
|
|
169735
|
+
description: `Update one contact channel on a person. ${channelLocatorMessage} ${updateTargetValueMessage}`
|
|
169736
|
+
});
|
|
169737
|
+
var RemovePersonChannelParamsSchema = ContactChannelLocatorFieldsSchema.pipe(
|
|
169738
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169739
|
+
person: NonEmptyString2.annotations({
|
|
169740
|
+
description: "Person ID, exact email address, or exact Huly display name."
|
|
169741
|
+
})
|
|
169742
|
+
}))
|
|
169743
|
+
).annotations({
|
|
169744
|
+
title: "RemovePersonChannelParams",
|
|
169745
|
+
description: `Remove one contact channel from a person. ${channelLocatorMessage}`
|
|
169746
|
+
});
|
|
169747
|
+
var ListOrganizationChannelsParamsSchema = Schema_exports.Struct({
|
|
169748
|
+
organizationId: NonEmptyString2.annotations({
|
|
169749
|
+
description: "Organization ID or exact unique organization name."
|
|
169750
|
+
})
|
|
169751
|
+
}).annotations({
|
|
169752
|
+
title: "ListOrganizationChannelsParams",
|
|
169753
|
+
description: "List contact channels for an organization."
|
|
169754
|
+
});
|
|
169755
|
+
var AddOrganizationChannelParamsSchema = ChannelProviderValueSchema.pipe(
|
|
169756
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169757
|
+
organizationId: NonEmptyString2.annotations({
|
|
169758
|
+
description: "Organization ID or exact unique organization name."
|
|
169759
|
+
})
|
|
169760
|
+
}))
|
|
169761
|
+
).annotations({
|
|
169762
|
+
title: "AddOrganizationChannelParams",
|
|
169763
|
+
description: "Add a contact channel to an organization. Idempotent by exact provider plus value."
|
|
169764
|
+
});
|
|
169765
|
+
var UpdateOrganizationChannelParamsSchema = ContactChannelLocatorFieldsSchema.pipe(
|
|
169766
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169767
|
+
organizationId: NonEmptyString2.annotations({
|
|
169768
|
+
description: "Organization ID or exact unique organization name."
|
|
169769
|
+
}),
|
|
169770
|
+
newProvider: Schema_exports.optional(ContactChannelProviderSchema.annotations({ description: providerDescription })),
|
|
169771
|
+
newValue: Schema_exports.optional(NonEmptyString2.annotations({ description: "Replacement channel value." }))
|
|
169772
|
+
})),
|
|
169773
|
+
Schema_exports.filter(validateUpdateTargetValue)
|
|
169774
|
+
).annotations({
|
|
169775
|
+
title: "UpdateOrganizationChannelParams",
|
|
169776
|
+
description: `Update one contact channel on an organization. ${channelLocatorMessage} ${updateTargetValueMessage}`
|
|
169777
|
+
});
|
|
169778
|
+
var RemoveOrganizationChannelParamsSchema = ContactChannelLocatorFieldsSchema.pipe(
|
|
169779
|
+
Schema_exports.extend(Schema_exports.Struct({
|
|
169780
|
+
organizationId: NonEmptyString2.annotations({
|
|
169781
|
+
description: "Organization ID or exact unique organization name."
|
|
169782
|
+
})
|
|
169783
|
+
}))
|
|
169784
|
+
).annotations({
|
|
169785
|
+
title: "RemoveOrganizationChannelParams",
|
|
169786
|
+
description: `Remove one contact channel from an organization. ${channelLocatorMessage}`
|
|
169787
|
+
});
|
|
169788
|
+
var addPersonChannelParamsJsonSchema = JSONSchema_exports.make(AddPersonChannelParamsSchema);
|
|
169789
|
+
var listContactChannelProvidersParamsJsonSchema = JSONSchema_exports.make(ListContactChannelProvidersParamsSchema);
|
|
169790
|
+
var listPersonChannelsParamsJsonSchema = JSONSchema_exports.make(ListPersonChannelsParamsSchema);
|
|
169791
|
+
var updatePersonChannelParamsJsonSchema = withAtLeastOneRequired(
|
|
169792
|
+
JSONSchema_exports.make(UpdatePersonChannelParamsSchema),
|
|
169793
|
+
CHANNEL_UPDATE_FIELDS
|
|
169794
|
+
);
|
|
169795
|
+
var removePersonChannelParamsJsonSchema = JSONSchema_exports.make(RemovePersonChannelParamsSchema);
|
|
169796
|
+
var addOrganizationChannelParamsJsonSchema = JSONSchema_exports.make(AddOrganizationChannelParamsSchema);
|
|
169797
|
+
var listOrganizationChannelsParamsJsonSchema = JSONSchema_exports.make(ListOrganizationChannelsParamsSchema);
|
|
169798
|
+
var updateOrganizationChannelParamsJsonSchema = withAtLeastOneRequired(
|
|
169799
|
+
JSONSchema_exports.make(UpdateOrganizationChannelParamsSchema),
|
|
169800
|
+
CHANNEL_UPDATE_FIELDS
|
|
169801
|
+
);
|
|
169802
|
+
var removeOrganizationChannelParamsJsonSchema = JSONSchema_exports.make(RemoveOrganizationChannelParamsSchema);
|
|
169803
|
+
var parseAddPersonChannelParams = Schema_exports.decodeUnknown(AddPersonChannelParamsSchema);
|
|
169804
|
+
var parseListContactChannelProvidersParams = Schema_exports.decodeUnknown(ListContactChannelProvidersParamsSchema);
|
|
169805
|
+
var parseListPersonChannelsParams = Schema_exports.decodeUnknown(ListPersonChannelsParamsSchema);
|
|
169806
|
+
var parseUpdatePersonChannelParams = Schema_exports.decodeUnknown(UpdatePersonChannelParamsSchema);
|
|
169807
|
+
var parseRemovePersonChannelParams = Schema_exports.decodeUnknown(RemovePersonChannelParamsSchema);
|
|
169808
|
+
var parseAddOrganizationChannelParams = Schema_exports.decodeUnknown(AddOrganizationChannelParamsSchema);
|
|
169809
|
+
var parseListOrganizationChannelsParams = Schema_exports.decodeUnknown(ListOrganizationChannelsParamsSchema);
|
|
169810
|
+
var parseUpdateOrganizationChannelParams = Schema_exports.decodeUnknown(UpdateOrganizationChannelParamsSchema);
|
|
169811
|
+
var parseRemoveOrganizationChannelParams = Schema_exports.decodeUnknown(RemoveOrganizationChannelParamsSchema);
|
|
169812
|
+
|
|
169558
169813
|
// src/domain/schemas/contact-organizations.ts
|
|
169559
169814
|
var OrganizationSummarySchema = Schema_exports.Struct({
|
|
169560
169815
|
id: OrganizationId,
|
|
@@ -169660,21 +169915,6 @@ var ListPersonOrganizationsParamsSchema = Schema_exports.Union(
|
|
|
169660
169915
|
title: "ListPersonOrganizationsParams",
|
|
169661
169916
|
description: "List organizations a person is a member of (provide personId or email)"
|
|
169662
169917
|
});
|
|
169663
|
-
var OrganizationChannelProviderValues = [
|
|
169664
|
-
"email",
|
|
169665
|
-
"phone",
|
|
169666
|
-
"linkedin",
|
|
169667
|
-
"twitter",
|
|
169668
|
-
"github",
|
|
169669
|
-
"facebook",
|
|
169670
|
-
"telegram",
|
|
169671
|
-
"homepage",
|
|
169672
|
-
"whatsapp",
|
|
169673
|
-
"skype",
|
|
169674
|
-
"profile",
|
|
169675
|
-
"viber"
|
|
169676
|
-
];
|
|
169677
|
-
var OrganizationChannelProviderSchema = Schema_exports.Literal(...OrganizationChannelProviderValues);
|
|
169678
169918
|
var RemoveOrganizationMemberParamsSchema = Schema_exports.Struct({
|
|
169679
169919
|
organizationId: NonEmptyString2.annotations({
|
|
169680
169920
|
description: "Organization ID or exact name"
|
|
@@ -169686,20 +169926,6 @@ var RemoveOrganizationMemberParamsSchema = Schema_exports.Struct({
|
|
|
169686
169926
|
title: "RemoveOrganizationMemberParams",
|
|
169687
169927
|
description: "Parameters for removing a person from an organization"
|
|
169688
169928
|
});
|
|
169689
|
-
var AddOrganizationChannelParamsSchema = Schema_exports.Struct({
|
|
169690
|
-
organizationId: NonEmptyString2.annotations({
|
|
169691
|
-
description: "Organization ID or exact name"
|
|
169692
|
-
}),
|
|
169693
|
-
provider: OrganizationChannelProviderSchema.annotations({
|
|
169694
|
-
description: `Channel type: ${enumValuesDescription(OrganizationChannelProviderValues)}`
|
|
169695
|
-
}),
|
|
169696
|
-
value: NonEmptyString2.annotations({
|
|
169697
|
-
description: "Channel value (email address, phone number, URL, username)"
|
|
169698
|
-
})
|
|
169699
|
-
}).annotations({
|
|
169700
|
-
title: "AddOrganizationChannelParams",
|
|
169701
|
-
description: "Parameters for adding a contact channel to an organization"
|
|
169702
|
-
});
|
|
169703
169929
|
var AddOrganizationMemberParamsSchema = Schema_exports.Struct({
|
|
169704
169930
|
organizationId: NonEmptyString2.annotations({
|
|
169705
169931
|
description: "Organization ID or exact name"
|
|
@@ -169711,7 +169937,6 @@ var AddOrganizationMemberParamsSchema = Schema_exports.Struct({
|
|
|
169711
169937
|
title: "AddOrganizationMemberParams",
|
|
169712
169938
|
description: "Parameters for adding a person as an organization member"
|
|
169713
169939
|
});
|
|
169714
|
-
var addOrganizationChannelParamsJsonSchema = JSONSchema_exports.make(AddOrganizationChannelParamsSchema);
|
|
169715
169940
|
var addOrganizationMemberParamsJsonSchema = JSONSchema_exports.make(AddOrganizationMemberParamsSchema);
|
|
169716
169941
|
var listOrganizationMembersParamsJsonSchema = JSONSchema_exports.make(ListOrganizationMembersParamsSchema);
|
|
169717
169942
|
var listPersonOrganizationsParamsJsonSchema = JSONSchema_exports.make(ListPersonOrganizationsParamsSchema);
|
|
@@ -169724,7 +169949,6 @@ var updateOrganizationParamsJsonSchema = withAtLeastOneRequired(
|
|
|
169724
169949
|
UPDATE_ORGANIZATION_FIELDS
|
|
169725
169950
|
);
|
|
169726
169951
|
var deleteOrganizationParamsJsonSchema = JSONSchema_exports.make(DeleteOrganizationParamsSchema);
|
|
169727
|
-
var parseAddOrganizationChannelParams = Schema_exports.decodeUnknown(AddOrganizationChannelParamsSchema);
|
|
169728
169952
|
var parseAddOrganizationMemberParams = Schema_exports.decodeUnknown(AddOrganizationMemberParamsSchema);
|
|
169729
169953
|
var parseListOrganizationMembersParams = Schema_exports.decodeUnknown(ListOrganizationMembersParamsSchema);
|
|
169730
169954
|
var parseListPersonOrganizationsParams = Schema_exports.decodeUnknown(ListPersonOrganizationsParamsSchema);
|
|
@@ -169739,6 +169963,7 @@ var GetOrganizationResultSchema = Schema_exports.Struct({
|
|
|
169739
169963
|
name: NonEmptyString2,
|
|
169740
169964
|
city: Schema_exports.optional(Schema_exports.String),
|
|
169741
169965
|
description: Schema_exports.optional(Schema_exports.String),
|
|
169966
|
+
channels: Schema_exports.optional(Schema_exports.Array(ContactChannelSummarySchema)),
|
|
169742
169967
|
members: Count,
|
|
169743
169968
|
url: UrlString,
|
|
169744
169969
|
modifiedOn: Schema_exports.optional(Schema_exports.Number)
|
|
@@ -174278,7 +174503,7 @@ var parseDeleteDriveFileCommentParams = Schema_exports.decodeUnknown(DeleteDrive
|
|
|
174278
174503
|
var parseListDriveFileActivityParams = Schema_exports.decodeUnknown(ListDriveFileActivityParamsSchema);
|
|
174279
174504
|
|
|
174280
174505
|
// src/version.ts
|
|
174281
|
-
var VERSION = true ? "0.
|
|
174506
|
+
var VERSION = true ? "0.30.0" : "0.0.0-dev";
|
|
174282
174507
|
|
|
174283
174508
|
// src/mcp/tool-output-schema.ts
|
|
174284
174509
|
var defaultToolOutputSchema = {
|
|
@@ -180065,6 +180290,321 @@ var commentTools = [
|
|
|
180065
180290
|
}
|
|
180066
180291
|
];
|
|
180067
180292
|
|
|
180293
|
+
// src/huly/operations/contact-channel-providers.ts
|
|
180294
|
+
var CONTACT_CHANNEL_PROVIDER_SDK_KEYS = ContactChannelProviderSdkKeys;
|
|
180295
|
+
var exactChannelProviderSdkKeys = (value3) => value3;
|
|
180296
|
+
exactChannelProviderSdkKeys(true);
|
|
180297
|
+
var sdkKeyEntryForProvider = (provider) => [
|
|
180298
|
+
CONTACT_CHANNEL_PROVIDER_SDK_KEYS[provider],
|
|
180299
|
+
provider
|
|
180300
|
+
];
|
|
180301
|
+
var CONTACT_CHANNEL_PROVIDER_BY_SDK_KEY = Object.fromEntries(
|
|
180302
|
+
ContactChannelProviderValues.map(sdkKeyEntryForProvider)
|
|
180303
|
+
);
|
|
180304
|
+
var listContactChannelProviderLabels = () => ContactChannelProviderValues;
|
|
180305
|
+
var toContactChannelProviderRef = (provider) => contact.channelProvider[CONTACT_CHANNEL_PROVIDER_SDK_KEYS[provider]];
|
|
180306
|
+
var fromContactChannelProviderRef = (providerRef) => {
|
|
180307
|
+
const provider = ContactChannelProviderValues.find(
|
|
180308
|
+
(candidate) => toContactChannelProviderRef(candidate) === providerRef
|
|
180309
|
+
);
|
|
180310
|
+
return provider ?? new InvalidContactProviderError({ provider: providerRef });
|
|
180311
|
+
};
|
|
180312
|
+
|
|
180313
|
+
// src/huly/operations/contact-channel-mappers.ts
|
|
180314
|
+
var channelSummary = (channel) => Effect_exports.gen(function* () {
|
|
180315
|
+
const provider = fromContactChannelProviderRef(channel.provider);
|
|
180316
|
+
if (provider instanceof InvalidContactProviderError) {
|
|
180317
|
+
return yield* provider;
|
|
180318
|
+
}
|
|
180319
|
+
return {
|
|
180320
|
+
channelId: ChannelId.make(channel._id),
|
|
180321
|
+
provider,
|
|
180322
|
+
value: channel.value,
|
|
180323
|
+
items: channel.items !== void 0 ? Count.make(channel.items) : void 0,
|
|
180324
|
+
lastMessage: channel.lastMessage !== void 0 ? Timestamp.make(channel.lastMessage) : void 0
|
|
180325
|
+
};
|
|
180326
|
+
});
|
|
180327
|
+
var channelSummaryWithValue = (channel, provider, value3) => ({
|
|
180328
|
+
channelId: ChannelId.make(channel._id),
|
|
180329
|
+
provider,
|
|
180330
|
+
value: value3,
|
|
180331
|
+
items: channel.items !== void 0 ? Count.make(channel.items) : void 0,
|
|
180332
|
+
lastMessage: channel.lastMessage !== void 0 ? Timestamp.make(channel.lastMessage) : void 0
|
|
180333
|
+
});
|
|
180334
|
+
|
|
180335
|
+
// src/huly/operations/organization-resolvers.ts
|
|
180336
|
+
var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180337
|
+
const byId = Option_exports.fromNullable(
|
|
180338
|
+
yield* client.findOne(
|
|
180339
|
+
contact.class.Organization,
|
|
180340
|
+
hulyQuery({ _id: toRef(identifier2) })
|
|
180341
|
+
)
|
|
180342
|
+
);
|
|
180343
|
+
if (Option_exports.isSome(byId)) return byId;
|
|
180344
|
+
const byName = yield* client.findAll(
|
|
180345
|
+
contact.class.Organization,
|
|
180346
|
+
hulyQuery({ name: identifier2 })
|
|
180347
|
+
);
|
|
180348
|
+
if (byName.length === 0) return Option_exports.none();
|
|
180349
|
+
if (byName.length > 1) {
|
|
180350
|
+
return yield* new OrganizationIdentifierAmbiguousError({
|
|
180351
|
+
identifier: identifier2,
|
|
180352
|
+
matches: Count.make(byName.length)
|
|
180353
|
+
});
|
|
180354
|
+
}
|
|
180355
|
+
return Option_exports.some(byName[0]);
|
|
180356
|
+
});
|
|
180357
|
+
var resolveOrganizationByIdentifier = (client, identifier2) => Effect_exports.flatMap(findOrganizationByIdentifier(client, identifier2), (organization) => Option_exports.match(organization, {
|
|
180358
|
+
onNone: () => Effect_exports.fail(new OrganizationNotFoundError({ identifier: identifier2 })),
|
|
180359
|
+
onSome: Effect_exports.succeed
|
|
180360
|
+
}));
|
|
180361
|
+
|
|
180362
|
+
// src/huly/operations/contact-channel-owners.ts
|
|
180363
|
+
var resolvePerson = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180364
|
+
const byId = Option_exports.fromNullable(yield* findPersonById(client, identifier2));
|
|
180365
|
+
return yield* Option_exports.match(byId, {
|
|
180366
|
+
onNone: () => Effect_exports.flatMap(
|
|
180367
|
+
Effect_exports.map(
|
|
180368
|
+
findPersonByExactEmailOrName(
|
|
180369
|
+
client,
|
|
180370
|
+
Schema_exports.is(Email)(identifier2) ? identifier2 : PersonName.make(identifier2)
|
|
180371
|
+
),
|
|
180372
|
+
Option_exports.fromNullable
|
|
180373
|
+
),
|
|
180374
|
+
(byEmailOrName) => Option_exports.match(byEmailOrName, {
|
|
180375
|
+
onNone: () => Effect_exports.fail(new PersonNotFoundError({ identifier: identifier2 })),
|
|
180376
|
+
onSome: Effect_exports.succeed
|
|
180377
|
+
})
|
|
180378
|
+
),
|
|
180379
|
+
onSome: Effect_exports.succeed
|
|
180380
|
+
});
|
|
180381
|
+
});
|
|
180382
|
+
var resolvePersonOwner = (client, identifier2) => Effect_exports.map(resolvePerson(client, identifier2), (person) => ({
|
|
180383
|
+
id: person._id,
|
|
180384
|
+
ownerClass: contact.class.Person,
|
|
180385
|
+
identifier: identifier2
|
|
180386
|
+
}));
|
|
180387
|
+
var resolveOrganizationOwner = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180388
|
+
const org = yield* resolveOrganizationByIdentifier(client, identifier2);
|
|
180389
|
+
return { id: org._id, ownerClass: contact.class.Organization, identifier: identifier2 };
|
|
180390
|
+
});
|
|
180391
|
+
|
|
180392
|
+
// src/huly/operations/contact-channels.ts
|
|
180393
|
+
var listContactChannelProviders = () => Effect_exports.succeed(listContactChannelProviderLabels());
|
|
180394
|
+
var channelIdentifier = (locator) => locator._tag === "channelId" ? locator.channelId : `${locator.provider}:${locator.value}`;
|
|
180395
|
+
var INVALID_CHANNEL_LOCATOR_REASON = "provide exactly one channel locator: channelId, or provider plus value";
|
|
180396
|
+
var validateProviderValue = (provider, value3) => value3.length === 0 || provider === "email" && !Schema_exports.is(Email)(value3) ? Effect_exports.fail(new InvalidContactChannelValueError({ provider, value: value3 })) : Effect_exports.void;
|
|
180397
|
+
var validateChannelLocator2 = (ownerIdentifier, locator) => Effect_exports.gen(function* () {
|
|
180398
|
+
const hasChannelId = locator.channelId !== void 0;
|
|
180399
|
+
const hasProvider = locator.provider !== void 0;
|
|
180400
|
+
const hasValue = locator.value !== void 0;
|
|
180401
|
+
if (hasChannelId && !hasProvider && !hasValue) {
|
|
180402
|
+
return { _tag: "channelId", channelId: ChannelId.make(locator.channelId) };
|
|
180403
|
+
}
|
|
180404
|
+
if (!hasChannelId && hasProvider && hasValue) {
|
|
180405
|
+
yield* validateProviderValue(locator.provider, locator.value);
|
|
180406
|
+
return { _tag: "providerValue", provider: locator.provider, value: locator.value };
|
|
180407
|
+
}
|
|
180408
|
+
return yield* new InvalidContactChannelLocatorError({
|
|
180409
|
+
ownerIdentifier,
|
|
180410
|
+
reason: INVALID_CHANNEL_LOCATOR_REASON
|
|
180411
|
+
});
|
|
180412
|
+
});
|
|
180413
|
+
var requireChannelUpdateFields = (params) => params.newProvider === void 0 && params.newValue === void 0 ? Effect_exports.fail(new NoUpdateFieldsError({ operation: "update_contact_channel", fields: ["newProvider", "newValue"] })) : Effect_exports.void;
|
|
180414
|
+
var findChannelsForOwner = (client, owner) => client.findAll(
|
|
180415
|
+
contact.class.Channel,
|
|
180416
|
+
hulyQuery({
|
|
180417
|
+
attachedTo: owner.id,
|
|
180418
|
+
attachedToClass: owner.ownerClass
|
|
180419
|
+
})
|
|
180420
|
+
);
|
|
180421
|
+
var findExactChannels = (client, owner, provider, value3) => client.findAll(
|
|
180422
|
+
contact.class.Channel,
|
|
180423
|
+
hulyQuery({
|
|
180424
|
+
attachedTo: owner.id,
|
|
180425
|
+
attachedToClass: owner.ownerClass,
|
|
180426
|
+
provider: toContactChannelProviderRef(provider),
|
|
180427
|
+
value: value3
|
|
180428
|
+
})
|
|
180429
|
+
);
|
|
180430
|
+
var findChannelByIdForOwner = (client, owner, channelId) => Effect_exports.map(
|
|
180431
|
+
client.findOne(
|
|
180432
|
+
contact.class.Channel,
|
|
180433
|
+
hulyQuery({
|
|
180434
|
+
_id: toRef(channelId),
|
|
180435
|
+
attachedTo: owner.id,
|
|
180436
|
+
attachedToClass: owner.ownerClass
|
|
180437
|
+
})
|
|
180438
|
+
),
|
|
180439
|
+
Option_exports.fromNullable
|
|
180440
|
+
);
|
|
180441
|
+
var resolveChannelByLocator = (client, owner, locator) => Effect_exports.gen(function* () {
|
|
180442
|
+
if (locator._tag === "channelId") {
|
|
180443
|
+
return yield* Effect_exports.flatMap(findChannelByIdForOwner(client, owner, locator.channelId), (channel) => Option_exports.match(channel, {
|
|
180444
|
+
onNone: () => Effect_exports.fail(
|
|
180445
|
+
new ContactChannelNotFoundError({
|
|
180446
|
+
ownerIdentifier: owner.identifier,
|
|
180447
|
+
channelIdentifier: locator.channelId
|
|
180448
|
+
})
|
|
180449
|
+
),
|
|
180450
|
+
onSome: Effect_exports.succeed
|
|
180451
|
+
}));
|
|
180452
|
+
}
|
|
180453
|
+
const matches = yield* findExactChannels(client, owner, locator.provider, locator.value);
|
|
180454
|
+
if (matches.length === 0) {
|
|
180455
|
+
return yield* new ContactChannelNotFoundError({
|
|
180456
|
+
ownerIdentifier: owner.identifier,
|
|
180457
|
+
channelIdentifier: channelIdentifier(locator)
|
|
180458
|
+
});
|
|
180459
|
+
}
|
|
180460
|
+
if (matches.length > 1) {
|
|
180461
|
+
return yield* new ContactChannelIdentifierAmbiguousError({
|
|
180462
|
+
ownerIdentifier: owner.identifier,
|
|
180463
|
+
channelIdentifier: channelIdentifier(locator),
|
|
180464
|
+
matches: Count.make(matches.length)
|
|
180465
|
+
});
|
|
180466
|
+
}
|
|
180467
|
+
return matches[0];
|
|
180468
|
+
});
|
|
180469
|
+
var findRemovableChannel = (client, owner, locator) => Effect_exports.gen(function* () {
|
|
180470
|
+
if (locator._tag === "channelId") {
|
|
180471
|
+
return yield* findChannelByIdForOwner(client, owner, locator.channelId);
|
|
180472
|
+
}
|
|
180473
|
+
const matches = yield* findExactChannels(client, owner, locator.provider, locator.value);
|
|
180474
|
+
if (matches.length > 1) {
|
|
180475
|
+
return yield* new ContactChannelIdentifierAmbiguousError({
|
|
180476
|
+
ownerIdentifier: owner.identifier,
|
|
180477
|
+
channelIdentifier: channelIdentifier(locator),
|
|
180478
|
+
matches: Count.make(matches.length)
|
|
180479
|
+
});
|
|
180480
|
+
}
|
|
180481
|
+
return Option_exports.fromNullable(matches[0]);
|
|
180482
|
+
});
|
|
180483
|
+
var ensureNoTargetConflict = (client, owner, currentChannelId, provider, value3) => Effect_exports.gen(function* () {
|
|
180484
|
+
const matches = yield* findExactChannels(client, owner, provider, value3);
|
|
180485
|
+
const conflicting = matches.some((channel) => channel._id !== currentChannelId);
|
|
180486
|
+
if (conflicting) {
|
|
180487
|
+
return yield* new ContactChannelConflictError({
|
|
180488
|
+
ownerIdentifier: owner.identifier,
|
|
180489
|
+
provider,
|
|
180490
|
+
value: value3
|
|
180491
|
+
});
|
|
180492
|
+
}
|
|
180493
|
+
});
|
|
180494
|
+
var listOwnerChannels = (client, owner) => Effect_exports.gen(function* () {
|
|
180495
|
+
const channels = yield* findChannelsForOwner(client, owner);
|
|
180496
|
+
return yield* Effect_exports.all(channels.map(channelSummary));
|
|
180497
|
+
});
|
|
180498
|
+
var addOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180499
|
+
yield* validateProviderValue(params.provider, params.value);
|
|
180500
|
+
const existing = yield* findExactChannels(client, owner, params.provider, params.value);
|
|
180501
|
+
if (existing.length > 0) {
|
|
180502
|
+
return { added: false, channel: yield* channelSummary(existing[0]) };
|
|
180503
|
+
}
|
|
180504
|
+
const channelId = yield* client.addCollection(
|
|
180505
|
+
contact.class.Channel,
|
|
180506
|
+
contact.space.Contacts,
|
|
180507
|
+
owner.id,
|
|
180508
|
+
owner.ownerClass,
|
|
180509
|
+
"channels",
|
|
180510
|
+
{ provider: toContactChannelProviderRef(params.provider), value: params.value }
|
|
180511
|
+
);
|
|
180512
|
+
return {
|
|
180513
|
+
added: true,
|
|
180514
|
+
channel: {
|
|
180515
|
+
channelId: ChannelId.make(channelId),
|
|
180516
|
+
provider: params.provider,
|
|
180517
|
+
value: params.value
|
|
180518
|
+
}
|
|
180519
|
+
};
|
|
180520
|
+
});
|
|
180521
|
+
var updateOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180522
|
+
yield* requireChannelUpdateFields(params);
|
|
180523
|
+
const locator = yield* validateChannelLocator2(owner.identifier, params);
|
|
180524
|
+
const channel = yield* resolveChannelByLocator(client, owner, locator);
|
|
180525
|
+
const currentProvider = fromContactChannelProviderRef(channel.provider);
|
|
180526
|
+
if (currentProvider instanceof InvalidContactProviderError) {
|
|
180527
|
+
return yield* currentProvider;
|
|
180528
|
+
}
|
|
180529
|
+
const nextProvider = params.newProvider ?? currentProvider;
|
|
180530
|
+
const nextValue = params.newValue ?? channel.value;
|
|
180531
|
+
yield* validateProviderValue(nextProvider, nextValue);
|
|
180532
|
+
const nextProviderRef = toContactChannelProviderRef(nextProvider);
|
|
180533
|
+
if (channel.provider === nextProviderRef && channel.value === nextValue) {
|
|
180534
|
+
return { updated: false, channel: yield* channelSummary(channel) };
|
|
180535
|
+
}
|
|
180536
|
+
yield* ensureNoTargetConflict(client, owner, channel._id, nextProvider, nextValue);
|
|
180537
|
+
const operations = {
|
|
180538
|
+
provider: nextProviderRef,
|
|
180539
|
+
value: nextValue
|
|
180540
|
+
};
|
|
180541
|
+
yield* client.updateDoc(contact.class.Channel, contact.space.Contacts, channel._id, operations);
|
|
180542
|
+
return { updated: true, channel: channelSummaryWithValue(channel, nextProvider, nextValue) };
|
|
180543
|
+
});
|
|
180544
|
+
var removeOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180545
|
+
const locator = yield* validateChannelLocator2(owner.identifier, params);
|
|
180546
|
+
const channel = yield* findRemovableChannel(client, owner, locator);
|
|
180547
|
+
if (Option_exports.isNone(channel)) {
|
|
180548
|
+
return locator._tag === "channelId" ? { removed: false, channelId: locator.channelId } : { removed: false };
|
|
180549
|
+
}
|
|
180550
|
+
yield* client.removeDoc(contact.class.Channel, contact.space.Contacts, channel.value._id);
|
|
180551
|
+
return { removed: true, channelId: ChannelId.make(channel.value._id) };
|
|
180552
|
+
});
|
|
180553
|
+
var listPersonChannels = (params) => Effect_exports.gen(function* () {
|
|
180554
|
+
const client = yield* HulyClient;
|
|
180555
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180556
|
+
return {
|
|
180557
|
+
personId: PersonId.make(owner.id),
|
|
180558
|
+
channels: yield* listOwnerChannels(client, owner)
|
|
180559
|
+
};
|
|
180560
|
+
});
|
|
180561
|
+
var addPersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180562
|
+
const client = yield* HulyClient;
|
|
180563
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180564
|
+
const result = yield* addOwnerChannel(client, owner, params);
|
|
180565
|
+
return { personId: PersonId.make(owner.id), ...result };
|
|
180566
|
+
});
|
|
180567
|
+
var updatePersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180568
|
+
const client = yield* HulyClient;
|
|
180569
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180570
|
+
const result = yield* updateOwnerChannel(client, owner, params);
|
|
180571
|
+
return { personId: PersonId.make(owner.id), ...result };
|
|
180572
|
+
});
|
|
180573
|
+
var removePersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180574
|
+
const client = yield* HulyClient;
|
|
180575
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180576
|
+
const result = yield* removeOwnerChannel(client, owner, params);
|
|
180577
|
+
const personId = PersonId.make(owner.id);
|
|
180578
|
+
return "channelId" in result ? { personId, removed: result.removed, channelId: result.channelId } : { personId, removed: result.removed };
|
|
180579
|
+
});
|
|
180580
|
+
var listOrganizationChannels = (params) => Effect_exports.gen(function* () {
|
|
180581
|
+
const client = yield* HulyClient;
|
|
180582
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180583
|
+
return {
|
|
180584
|
+
organizationId: OrganizationId.make(owner.id),
|
|
180585
|
+
channels: yield* listOwnerChannels(client, owner)
|
|
180586
|
+
};
|
|
180587
|
+
});
|
|
180588
|
+
var addOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180589
|
+
const client = yield* HulyClient;
|
|
180590
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180591
|
+
const result = yield* addOwnerChannel(client, owner, params);
|
|
180592
|
+
return { id: OrganizationId.make(owner.id), ...result };
|
|
180593
|
+
});
|
|
180594
|
+
var updateOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180595
|
+
const client = yield* HulyClient;
|
|
180596
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180597
|
+
const result = yield* updateOwnerChannel(client, owner, params);
|
|
180598
|
+
return { organizationId: OrganizationId.make(owner.id), ...result };
|
|
180599
|
+
});
|
|
180600
|
+
var removeOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180601
|
+
const client = yield* HulyClient;
|
|
180602
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180603
|
+
const result = yield* removeOwnerChannel(client, owner, params);
|
|
180604
|
+
const organizationId = OrganizationId.make(owner.id);
|
|
180605
|
+
return "channelId" in result ? { organizationId, removed: result.removed, channelId: result.channelId } : { organizationId, removed: result.removed };
|
|
180606
|
+
});
|
|
180607
|
+
|
|
180068
180608
|
// src/huly/operations/organizations.ts
|
|
180069
180609
|
var import_contact = __toESM(require_lib28(), 1);
|
|
180070
180610
|
var import_core34 = __toESM(require_lib4(), 1);
|
|
@@ -180082,81 +180622,19 @@ var leadClassIds = {
|
|
|
180082
180622
|
}
|
|
180083
180623
|
};
|
|
180084
180624
|
|
|
180085
|
-
// src/huly/operations/organization-channel-providers.ts
|
|
180086
|
-
var CHANNEL_PROVIDER_REFS_BY_SDK_KEY = {
|
|
180087
|
-
Email: contact.channelProvider.Email,
|
|
180088
|
-
Phone: contact.channelProvider.Phone,
|
|
180089
|
-
LinkedIn: contact.channelProvider.LinkedIn,
|
|
180090
|
-
Twitter: contact.channelProvider.Twitter,
|
|
180091
|
-
Telegram: contact.channelProvider.Telegram,
|
|
180092
|
-
GitHub: contact.channelProvider.GitHub,
|
|
180093
|
-
Facebook: contact.channelProvider.Facebook,
|
|
180094
|
-
Homepage: contact.channelProvider.Homepage,
|
|
180095
|
-
Whatsapp: contact.channelProvider.Whatsapp,
|
|
180096
|
-
Skype: contact.channelProvider.Skype,
|
|
180097
|
-
Profile: contact.channelProvider.Profile,
|
|
180098
|
-
Viber: contact.channelProvider.Viber
|
|
180099
|
-
};
|
|
180100
|
-
var ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY = {
|
|
180101
|
-
Email: "email",
|
|
180102
|
-
Phone: "phone",
|
|
180103
|
-
LinkedIn: "linkedin",
|
|
180104
|
-
Twitter: "twitter",
|
|
180105
|
-
Telegram: "telegram",
|
|
180106
|
-
GitHub: "github",
|
|
180107
|
-
Facebook: "facebook",
|
|
180108
|
-
Homepage: "homepage",
|
|
180109
|
-
Whatsapp: "whatsapp",
|
|
180110
|
-
Skype: "skype",
|
|
180111
|
-
Profile: "profile",
|
|
180112
|
-
Viber: "viber"
|
|
180113
|
-
};
|
|
180114
|
-
var CHANNEL_PROVIDERS = {
|
|
180115
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Email]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Email,
|
|
180116
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Phone]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Phone,
|
|
180117
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.LinkedIn]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.LinkedIn,
|
|
180118
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Twitter]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Twitter,
|
|
180119
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Telegram]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Telegram,
|
|
180120
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.GitHub]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.GitHub,
|
|
180121
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Facebook]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Facebook,
|
|
180122
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Homepage]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Homepage,
|
|
180123
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Whatsapp]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Whatsapp,
|
|
180124
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Skype]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Skype,
|
|
180125
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Profile]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Profile,
|
|
180126
|
-
[ORGANIZATION_CHANNEL_PROVIDER_BY_SDK_KEY.Viber]: CHANNEL_PROVIDER_REFS_BY_SDK_KEY.Viber
|
|
180127
|
-
};
|
|
180128
|
-
var exactChannelProviderMapping = (value3) => value3;
|
|
180129
|
-
exactChannelProviderMapping(true);
|
|
180130
|
-
var toChannelProviderRef = (provider) => CHANNEL_PROVIDERS[provider];
|
|
180131
|
-
|
|
180132
180625
|
// src/huly/operations/organizations.ts
|
|
180133
|
-
var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180134
|
-
const byId = yield* client.findOne(
|
|
180135
|
-
contact.class.Organization,
|
|
180136
|
-
{ _id: toRef(identifier2) }
|
|
180137
|
-
);
|
|
180138
|
-
if (byId !== void 0) return byId;
|
|
180139
|
-
const byName = yield* client.findAll(
|
|
180140
|
-
contact.class.Organization,
|
|
180141
|
-
{ name: identifier2 }
|
|
180142
|
-
);
|
|
180143
|
-
if (byName.length === 0) {
|
|
180144
|
-
return void 0;
|
|
180145
|
-
}
|
|
180146
|
-
if (byName.length > 1) {
|
|
180147
|
-
return yield* new OrganizationIdentifierAmbiguousError({
|
|
180148
|
-
identifier: identifier2,
|
|
180149
|
-
matches: Count.make(byName.length)
|
|
180150
|
-
});
|
|
180151
|
-
}
|
|
180152
|
-
return byName[0];
|
|
180153
|
-
});
|
|
180154
180626
|
var resolvePersonIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180155
|
-
const
|
|
180156
|
-
|
|
180157
|
-
|
|
180158
|
-
|
|
180159
|
-
|
|
180627
|
+
const byId = Option_exports.fromNullable(yield* findPersonById(client, identifier2));
|
|
180628
|
+
return yield* Option_exports.match(byId, {
|
|
180629
|
+
onNone: () => Effect_exports.flatMap(
|
|
180630
|
+
Effect_exports.map(findPersonByEmail(client, identifier2), Option_exports.fromNullable),
|
|
180631
|
+
(byEmail) => Option_exports.match(byEmail, {
|
|
180632
|
+
onNone: () => Effect_exports.fail(new PersonNotFoundError({ identifier: identifier2 })),
|
|
180633
|
+
onSome: Effect_exports.succeed
|
|
180634
|
+
})
|
|
180635
|
+
),
|
|
180636
|
+
onSome: Effect_exports.succeed
|
|
180637
|
+
});
|
|
180160
180638
|
});
|
|
180161
180639
|
var resolvePersonIdentifiers = (client, identifiers) => Effect_exports.gen(function* () {
|
|
180162
180640
|
const resolvedPeople = [];
|
|
@@ -180225,10 +180703,7 @@ var createOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180225
180703
|
});
|
|
180226
180704
|
var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
180227
180705
|
const client = yield* HulyClient;
|
|
180228
|
-
const org = yield*
|
|
180229
|
-
if (org === void 0) {
|
|
180230
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180231
|
-
}
|
|
180706
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180232
180707
|
const descriptionText = org.description !== null ? yield* client.fetchMarkup(
|
|
180233
180708
|
contact.class.Organization,
|
|
180234
180709
|
org._id,
|
|
@@ -180237,11 +180712,13 @@ var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180237
180712
|
"markdown"
|
|
180238
180713
|
) : void 0;
|
|
180239
180714
|
const id = OrganizationId.make(org._id);
|
|
180715
|
+
const channelsResult = yield* listOrganizationChannels({ organizationId: org._id });
|
|
180240
180716
|
return {
|
|
180241
180717
|
id,
|
|
180242
180718
|
name: org.name,
|
|
180243
180719
|
city: org.city || void 0,
|
|
180244
180720
|
description: descriptionText,
|
|
180721
|
+
channels: channelsResult.channels,
|
|
180245
180722
|
members: Count.make(org.members),
|
|
180246
180723
|
url: buildContactUrlFromConfig(client.workbenchUrlConfig, id),
|
|
180247
180724
|
modifiedOn: org.modifiedOn
|
|
@@ -180250,10 +180727,7 @@ var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180250
180727
|
var updateOrganization = (params) => Effect_exports.gen(function* () {
|
|
180251
180728
|
yield* requireUpdateFields("update_organization", params, UPDATE_ORGANIZATION_FIELDS);
|
|
180252
180729
|
const client = yield* HulyClient;
|
|
180253
|
-
const org = yield*
|
|
180254
|
-
if (org === void 0) {
|
|
180255
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180256
|
-
}
|
|
180730
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180257
180731
|
const updateEntries = {
|
|
180258
180732
|
name: Effect_exports.succeed(params.name === void 0 ? {} : { name: params.name }),
|
|
180259
180733
|
city: Effect_exports.succeed(params.city === void 0 ? {} : { city: params.city === null ? "" : params.city }),
|
|
@@ -180292,10 +180766,7 @@ var updateOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180292
180766
|
});
|
|
180293
180767
|
var deleteOrganization = (params) => Effect_exports.gen(function* () {
|
|
180294
180768
|
const client = yield* HulyClient;
|
|
180295
|
-
const org = yield*
|
|
180296
|
-
if (org === void 0) {
|
|
180297
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180298
|
-
}
|
|
180769
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180299
180770
|
yield* client.removeDoc(
|
|
180300
180771
|
contact.class.Organization,
|
|
180301
180772
|
contact.space.Contacts,
|
|
@@ -180305,10 +180776,7 @@ var deleteOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180305
180776
|
});
|
|
180306
180777
|
var makeOrganizationCustomer = (params) => Effect_exports.gen(function* () {
|
|
180307
180778
|
const client = yield* HulyClient;
|
|
180308
|
-
const org = yield*
|
|
180309
|
-
if (org === void 0) {
|
|
180310
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180311
|
-
}
|
|
180779
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180312
180780
|
const alreadyCustomer = org[leadClassIds.mixin.Customer] !== void 0;
|
|
180313
180781
|
if (alreadyCustomer) {
|
|
180314
180782
|
return { id: OrganizationId.make(org._id), applied: false };
|
|
@@ -180322,29 +180790,9 @@ var makeOrganizationCustomer = (params) => Effect_exports.gen(function* () {
|
|
|
180322
180790
|
);
|
|
180323
180791
|
return { id: OrganizationId.make(org._id), applied: true };
|
|
180324
180792
|
});
|
|
180325
|
-
var addOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180326
|
-
const client = yield* HulyClient;
|
|
180327
|
-
const org = yield* findOrganizationByIdentifier(client, params.organizationId);
|
|
180328
|
-
if (org === void 0) {
|
|
180329
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180330
|
-
}
|
|
180331
|
-
const providerRef = toChannelProviderRef(params.provider);
|
|
180332
|
-
yield* client.addCollection(
|
|
180333
|
-
contact.class.Channel,
|
|
180334
|
-
contact.space.Contacts,
|
|
180335
|
-
org._id,
|
|
180336
|
-
contact.class.Organization,
|
|
180337
|
-
"channels",
|
|
180338
|
-
{ provider: providerRef, value: params.value }
|
|
180339
|
-
);
|
|
180340
|
-
return { id: OrganizationId.make(org._id), added: true };
|
|
180341
|
-
});
|
|
180342
180793
|
var addOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
180343
180794
|
const client = yield* HulyClient;
|
|
180344
|
-
const org = yield*
|
|
180345
|
-
if (org === void 0) {
|
|
180346
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180347
|
-
}
|
|
180795
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180348
180796
|
const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
|
|
180349
180797
|
const existingMemberships = yield* findOrganizationMemberships(client, org._id, person._id);
|
|
180350
180798
|
if (existingMemberships.length > 0) {
|
|
@@ -180362,10 +180810,7 @@ var addOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
|
180362
180810
|
});
|
|
180363
180811
|
var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
180364
180812
|
const client = yield* HulyClient;
|
|
180365
|
-
const org = yield*
|
|
180366
|
-
if (org === void 0) {
|
|
180367
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180368
|
-
}
|
|
180813
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180369
180814
|
const members = yield* client.findAll(
|
|
180370
180815
|
contact.class.Member,
|
|
180371
180816
|
{ attachedTo: org._id }
|
|
@@ -180381,11 +180826,14 @@ var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
|
180381
180826
|
const emails = yield* batchGetEmailsForPersons(client, personIds);
|
|
180382
180827
|
const entries2 = persons.map((p) => {
|
|
180383
180828
|
const email3 = emails.get(p._id);
|
|
180384
|
-
|
|
180829
|
+
const entry = {
|
|
180385
180830
|
personId: PersonId.make(p._id),
|
|
180386
|
-
name: PersonName.make(p.name)
|
|
180387
|
-
email: email3 !== void 0 ? Email.make(email3) : void 0
|
|
180831
|
+
name: PersonName.make(p.name)
|
|
180388
180832
|
};
|
|
180833
|
+
return Option_exports.match(Option_exports.map(Option_exports.fromNullable(email3), Email.make), {
|
|
180834
|
+
onNone: () => entry,
|
|
180835
|
+
onSome: (memberEmail) => ({ ...entry, email: memberEmail })
|
|
180836
|
+
});
|
|
180389
180837
|
});
|
|
180390
180838
|
return {
|
|
180391
180839
|
organizationId: OrganizationId.make(org._id),
|
|
@@ -180394,10 +180842,7 @@ var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
|
180394
180842
|
});
|
|
180395
180843
|
var removeOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
180396
180844
|
const client = yield* HulyClient;
|
|
180397
|
-
const org = yield*
|
|
180398
|
-
if (org === void 0) {
|
|
180399
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180400
|
-
}
|
|
180845
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180401
180846
|
const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
|
|
180402
180847
|
const memberDocs = yield* findOrganizationMemberships(client, org._id, person._id);
|
|
180403
180848
|
if (memberDocs.length === 0) {
|
|
@@ -180501,16 +180946,10 @@ var getPerson = (params) => Effect_exports.gen(function* () {
|
|
|
180501
180946
|
const identifier2 = "personId" in params ? params.personId : params.email;
|
|
180502
180947
|
return yield* new PersonNotFoundError({ identifier: identifier2 });
|
|
180503
180948
|
}
|
|
180504
|
-
const
|
|
180505
|
-
contact.class.Channel,
|
|
180506
|
-
{
|
|
180507
|
-
attachedTo: person._id,
|
|
180508
|
-
attachedToClass: contact.class.Person
|
|
180509
|
-
}
|
|
180510
|
-
);
|
|
180949
|
+
const channelsResult = yield* listPersonChannels({ person: person._id });
|
|
180511
180950
|
const organizations = yield* findOrganizationsForPerson(client, person._id);
|
|
180512
180951
|
const { firstName, lastName } = parseName(person.name);
|
|
180513
|
-
const emailChannel = channels.find((c) => c.provider ===
|
|
180952
|
+
const emailChannel = channelsResult.channels.find((c) => c.provider === "email");
|
|
180514
180953
|
const id = PersonId.make(person._id);
|
|
180515
180954
|
return {
|
|
180516
180955
|
id,
|
|
@@ -180519,10 +180958,7 @@ var getPerson = (params) => Effect_exports.gen(function* () {
|
|
|
180519
180958
|
lastName,
|
|
180520
180959
|
city: person.city,
|
|
180521
180960
|
email: emailChannel?.value !== void 0 ? Email.make(emailChannel.value) : void 0,
|
|
180522
|
-
channels: channels
|
|
180523
|
-
provider: ContactProvider.make(c.provider),
|
|
180524
|
-
value: c.value
|
|
180525
|
-
})),
|
|
180961
|
+
channels: channelsResult.channels,
|
|
180526
180962
|
organizations: organizations.length > 0 ? organizations : void 0,
|
|
180527
180963
|
url: buildContactUrlFromConfig(client.workbenchUrlConfig, id),
|
|
180528
180964
|
modifiedOn: person.modifiedOn,
|
|
@@ -180713,6 +181149,61 @@ var contactTools = [
|
|
|
180713
181149
|
listEmployees
|
|
180714
181150
|
)
|
|
180715
181151
|
},
|
|
181152
|
+
{
|
|
181153
|
+
name: "list_contact_channel_providers",
|
|
181154
|
+
description: "List supported contact channel provider labels for person and organization channel tools.",
|
|
181155
|
+
category: CATEGORY9,
|
|
181156
|
+
inputSchema: listContactChannelProvidersParamsJsonSchema,
|
|
181157
|
+
handler: createToolHandler(
|
|
181158
|
+
"list_contact_channel_providers",
|
|
181159
|
+
parseListContactChannelProvidersParams,
|
|
181160
|
+
listContactChannelProviders
|
|
181161
|
+
)
|
|
181162
|
+
},
|
|
181163
|
+
{
|
|
181164
|
+
name: "list_person_channels",
|
|
181165
|
+
description: "List contact channels for a person. Person accepts person ID, exact email address, or exact Huly display name; ambiguous names fail and should be retried with email or person ID.",
|
|
181166
|
+
category: CATEGORY9,
|
|
181167
|
+
inputSchema: listPersonChannelsParamsJsonSchema,
|
|
181168
|
+
handler: createToolHandler(
|
|
181169
|
+
"list_person_channels",
|
|
181170
|
+
parseListPersonChannelsParams,
|
|
181171
|
+
listPersonChannels
|
|
181172
|
+
)
|
|
181173
|
+
},
|
|
181174
|
+
{
|
|
181175
|
+
name: "add_person_channel",
|
|
181176
|
+
description: "Idempotently add a contact channel to a person. Person accepts person ID, exact email address, or exact Huly display name. Provider labels match list_contact_channel_providers. Returns added=false and the existing channel when the exact provider+value already exists.",
|
|
181177
|
+
category: CATEGORY9,
|
|
181178
|
+
inputSchema: addPersonChannelParamsJsonSchema,
|
|
181179
|
+
handler: createToolHandler(
|
|
181180
|
+
"add_person_channel",
|
|
181181
|
+
parseAddPersonChannelParams,
|
|
181182
|
+
addPersonChannel
|
|
181183
|
+
)
|
|
181184
|
+
},
|
|
181185
|
+
{
|
|
181186
|
+
name: "update_person_channel",
|
|
181187
|
+
description: "Update one contact channel on a person. Person accepts person ID, exact email, or exact display name. Identify the channel with exactly one locator: channelId, or provider plus value. Provide newProvider, newValue, or both. Updating to an existing provider+value on the same person fails with a conflict.",
|
|
181188
|
+
category: CATEGORY9,
|
|
181189
|
+
inputSchema: updatePersonChannelParamsJsonSchema,
|
|
181190
|
+
handler: createToolHandler(
|
|
181191
|
+
"update_person_channel",
|
|
181192
|
+
parseUpdatePersonChannelParams,
|
|
181193
|
+
updatePersonChannel
|
|
181194
|
+
)
|
|
181195
|
+
},
|
|
181196
|
+
{
|
|
181197
|
+
name: "remove_person_channel",
|
|
181198
|
+
description: "Remove one contact channel from a person. Person accepts person ID, exact email, or exact display name. Identify the channel with exactly one locator: channelId, or provider plus value. Returns removed=false when the locator is absent for that person.",
|
|
181199
|
+
category: CATEGORY9,
|
|
181200
|
+
inputSchema: removePersonChannelParamsJsonSchema,
|
|
181201
|
+
handler: createToolHandler(
|
|
181202
|
+
"remove_person_channel",
|
|
181203
|
+
parseRemovePersonChannelParams,
|
|
181204
|
+
removePersonChannel
|
|
181205
|
+
)
|
|
181206
|
+
},
|
|
180716
181207
|
{
|
|
180717
181208
|
name: "list_organizations",
|
|
180718
181209
|
description: "List all organizations in the Huly workspace. Returns organizations sorted by modification date (newest first).",
|
|
@@ -180781,7 +181272,7 @@ var contactTools = [
|
|
|
180781
181272
|
},
|
|
180782
181273
|
{
|
|
180783
181274
|
name: "add_organization_channel",
|
|
180784
|
-
description: "
|
|
181275
|
+
description: "Idempotently add a contact channel to an organization identified by ID or exact unique name. Provider labels: email, phone, linkedin, twitter, github, facebook, telegram, homepage, whatsapp, skype, profile, viber. Returns added=false and the existing channel when the exact provider+value already exists.",
|
|
180785
181276
|
category: CATEGORY9,
|
|
180786
181277
|
inputSchema: addOrganizationChannelParamsJsonSchema,
|
|
180787
181278
|
handler: createToolHandler(
|
|
@@ -180790,6 +181281,39 @@ var contactTools = [
|
|
|
180790
181281
|
addOrganizationChannel
|
|
180791
181282
|
)
|
|
180792
181283
|
},
|
|
181284
|
+
{
|
|
181285
|
+
name: "list_organization_channels",
|
|
181286
|
+
description: "List contact channels for an organization identified by ID or exact unique organization name. Returns channelId, provider label, value, and optional activity metadata.",
|
|
181287
|
+
category: CATEGORY9,
|
|
181288
|
+
inputSchema: listOrganizationChannelsParamsJsonSchema,
|
|
181289
|
+
handler: createToolHandler(
|
|
181290
|
+
"list_organization_channels",
|
|
181291
|
+
parseListOrganizationChannelsParams,
|
|
181292
|
+
listOrganizationChannels
|
|
181293
|
+
)
|
|
181294
|
+
},
|
|
181295
|
+
{
|
|
181296
|
+
name: "update_organization_channel",
|
|
181297
|
+
description: "Update one contact channel on an organization identified by ID or exact unique name. Identify the channel with exactly one locator: channelId, or provider plus value. Provide newProvider, newValue, or both. Updating to an existing provider+value on the same organization fails with a conflict.",
|
|
181298
|
+
category: CATEGORY9,
|
|
181299
|
+
inputSchema: updateOrganizationChannelParamsJsonSchema,
|
|
181300
|
+
handler: createToolHandler(
|
|
181301
|
+
"update_organization_channel",
|
|
181302
|
+
parseUpdateOrganizationChannelParams,
|
|
181303
|
+
updateOrganizationChannel
|
|
181304
|
+
)
|
|
181305
|
+
},
|
|
181306
|
+
{
|
|
181307
|
+
name: "remove_organization_channel",
|
|
181308
|
+
description: "Remove one contact channel from an organization identified by ID or exact unique name. Identify the channel with exactly one locator: channelId, or provider plus value. Returns removed=false when the locator is absent for that organization.",
|
|
181309
|
+
category: CATEGORY9,
|
|
181310
|
+
inputSchema: removeOrganizationChannelParamsJsonSchema,
|
|
181311
|
+
handler: createToolHandler(
|
|
181312
|
+
"remove_organization_channel",
|
|
181313
|
+
parseRemoveOrganizationChannelParams,
|
|
181314
|
+
removeOrganizationChannel
|
|
181315
|
+
)
|
|
181316
|
+
},
|
|
180793
181317
|
{
|
|
180794
181318
|
name: "add_organization_member",
|
|
180795
181319
|
description: "Link a person as a member of an organization. The person appears under the org's Members tab in Huly. Use person ID or email to identify the person. Idempotent: returns added=false if that person is already a member.",
|