@firfi/huly-mcp 0.29.0 → 0.30.1
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 +740 -204
- 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.1" : "0.0.0-dev";
|
|
174282
174507
|
|
|
174283
174508
|
// src/mcp/tool-output-schema.ts
|
|
174284
174509
|
var defaultToolOutputSchema = {
|
|
@@ -174391,6 +174616,22 @@ var findActivityMessage = (client, messageId) => findOneOrFail(
|
|
|
174391
174616
|
() => new ActivityMessageNotFoundError({ messageId })
|
|
174392
174617
|
);
|
|
174393
174618
|
|
|
174619
|
+
// src/huly/operations/thread-replies-shared.ts
|
|
174620
|
+
var removeThreadReply = (client, reply) => Effect_exports.gen(function* () {
|
|
174621
|
+
const removeCollection = client.removeCollection;
|
|
174622
|
+
if (removeCollection === void 0) {
|
|
174623
|
+
return yield* new HulyError({ message: "Huly client does not support removeCollection" });
|
|
174624
|
+
}
|
|
174625
|
+
yield* removeCollection(
|
|
174626
|
+
chunter.class.ThreadMessage,
|
|
174627
|
+
reply.space,
|
|
174628
|
+
reply._id,
|
|
174629
|
+
reply.attachedTo,
|
|
174630
|
+
reply.attachedToClass,
|
|
174631
|
+
reply.collection
|
|
174632
|
+
);
|
|
174633
|
+
});
|
|
174634
|
+
|
|
174394
174635
|
// src/huly/operations/activity-messages.ts
|
|
174395
174636
|
var getActivityMessage = (params) => Effect_exports.gen(function* () {
|
|
174396
174637
|
const client = yield* HulyClient;
|
|
@@ -174507,7 +174748,7 @@ var deleteActivityReply = (params) => Effect_exports.gen(function* () {
|
|
|
174507
174748
|
hulyQuery({ _id: toRef(params.replyId) }),
|
|
174508
174749
|
() => new ActivityMessageNotFoundError({ messageId: params.replyId })
|
|
174509
174750
|
);
|
|
174510
|
-
yield* client
|
|
174751
|
+
yield* removeThreadReply(client, reply);
|
|
174511
174752
|
return { replyId: ActivityMessageId.make(reply._id), deleted: true };
|
|
174512
174753
|
});
|
|
174513
174754
|
|
|
@@ -179376,11 +179617,7 @@ var updateThreadReply = (params) => Effect_exports.gen(function* () {
|
|
|
179376
179617
|
var deleteThreadReply = (params) => Effect_exports.gen(function* () {
|
|
179377
179618
|
const { channel, client, message } = yield* findChannelMessage(params);
|
|
179378
179619
|
const reply = yield* findReply(client, channel, message, params.replyId);
|
|
179379
|
-
yield* client
|
|
179380
|
-
chunter.class.ThreadMessage,
|
|
179381
|
-
channel._id,
|
|
179382
|
-
reply._id
|
|
179383
|
-
);
|
|
179620
|
+
yield* removeThreadReply(client, reply);
|
|
179384
179621
|
return { id: ThreadReplyId.make(reply._id), deleted: true };
|
|
179385
179622
|
});
|
|
179386
179623
|
|
|
@@ -180065,6 +180302,321 @@ var commentTools = [
|
|
|
180065
180302
|
}
|
|
180066
180303
|
];
|
|
180067
180304
|
|
|
180305
|
+
// src/huly/operations/contact-channel-providers.ts
|
|
180306
|
+
var CONTACT_CHANNEL_PROVIDER_SDK_KEYS = ContactChannelProviderSdkKeys;
|
|
180307
|
+
var exactChannelProviderSdkKeys = (value3) => value3;
|
|
180308
|
+
exactChannelProviderSdkKeys(true);
|
|
180309
|
+
var sdkKeyEntryForProvider = (provider) => [
|
|
180310
|
+
CONTACT_CHANNEL_PROVIDER_SDK_KEYS[provider],
|
|
180311
|
+
provider
|
|
180312
|
+
];
|
|
180313
|
+
var CONTACT_CHANNEL_PROVIDER_BY_SDK_KEY = Object.fromEntries(
|
|
180314
|
+
ContactChannelProviderValues.map(sdkKeyEntryForProvider)
|
|
180315
|
+
);
|
|
180316
|
+
var listContactChannelProviderLabels = () => ContactChannelProviderValues;
|
|
180317
|
+
var toContactChannelProviderRef = (provider) => contact.channelProvider[CONTACT_CHANNEL_PROVIDER_SDK_KEYS[provider]];
|
|
180318
|
+
var fromContactChannelProviderRef = (providerRef) => {
|
|
180319
|
+
const provider = ContactChannelProviderValues.find(
|
|
180320
|
+
(candidate) => toContactChannelProviderRef(candidate) === providerRef
|
|
180321
|
+
);
|
|
180322
|
+
return provider ?? new InvalidContactProviderError({ provider: providerRef });
|
|
180323
|
+
};
|
|
180324
|
+
|
|
180325
|
+
// src/huly/operations/contact-channel-mappers.ts
|
|
180326
|
+
var channelSummary = (channel) => Effect_exports.gen(function* () {
|
|
180327
|
+
const provider = fromContactChannelProviderRef(channel.provider);
|
|
180328
|
+
if (provider instanceof InvalidContactProviderError) {
|
|
180329
|
+
return yield* provider;
|
|
180330
|
+
}
|
|
180331
|
+
return {
|
|
180332
|
+
channelId: ChannelId.make(channel._id),
|
|
180333
|
+
provider,
|
|
180334
|
+
value: channel.value,
|
|
180335
|
+
items: channel.items !== void 0 ? Count.make(channel.items) : void 0,
|
|
180336
|
+
lastMessage: channel.lastMessage !== void 0 ? Timestamp.make(channel.lastMessage) : void 0
|
|
180337
|
+
};
|
|
180338
|
+
});
|
|
180339
|
+
var channelSummaryWithValue = (channel, provider, value3) => ({
|
|
180340
|
+
channelId: ChannelId.make(channel._id),
|
|
180341
|
+
provider,
|
|
180342
|
+
value: value3,
|
|
180343
|
+
items: channel.items !== void 0 ? Count.make(channel.items) : void 0,
|
|
180344
|
+
lastMessage: channel.lastMessage !== void 0 ? Timestamp.make(channel.lastMessage) : void 0
|
|
180345
|
+
});
|
|
180346
|
+
|
|
180347
|
+
// src/huly/operations/organization-resolvers.ts
|
|
180348
|
+
var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180349
|
+
const byId = Option_exports.fromNullable(
|
|
180350
|
+
yield* client.findOne(
|
|
180351
|
+
contact.class.Organization,
|
|
180352
|
+
hulyQuery({ _id: toRef(identifier2) })
|
|
180353
|
+
)
|
|
180354
|
+
);
|
|
180355
|
+
if (Option_exports.isSome(byId)) return byId;
|
|
180356
|
+
const byName = yield* client.findAll(
|
|
180357
|
+
contact.class.Organization,
|
|
180358
|
+
hulyQuery({ name: identifier2 })
|
|
180359
|
+
);
|
|
180360
|
+
if (byName.length === 0) return Option_exports.none();
|
|
180361
|
+
if (byName.length > 1) {
|
|
180362
|
+
return yield* new OrganizationIdentifierAmbiguousError({
|
|
180363
|
+
identifier: identifier2,
|
|
180364
|
+
matches: Count.make(byName.length)
|
|
180365
|
+
});
|
|
180366
|
+
}
|
|
180367
|
+
return Option_exports.some(byName[0]);
|
|
180368
|
+
});
|
|
180369
|
+
var resolveOrganizationByIdentifier = (client, identifier2) => Effect_exports.flatMap(findOrganizationByIdentifier(client, identifier2), (organization) => Option_exports.match(organization, {
|
|
180370
|
+
onNone: () => Effect_exports.fail(new OrganizationNotFoundError({ identifier: identifier2 })),
|
|
180371
|
+
onSome: Effect_exports.succeed
|
|
180372
|
+
}));
|
|
180373
|
+
|
|
180374
|
+
// src/huly/operations/contact-channel-owners.ts
|
|
180375
|
+
var resolvePerson = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180376
|
+
const byId = Option_exports.fromNullable(yield* findPersonById(client, identifier2));
|
|
180377
|
+
return yield* Option_exports.match(byId, {
|
|
180378
|
+
onNone: () => Effect_exports.flatMap(
|
|
180379
|
+
Effect_exports.map(
|
|
180380
|
+
findPersonByExactEmailOrName(
|
|
180381
|
+
client,
|
|
180382
|
+
Schema_exports.is(Email)(identifier2) ? identifier2 : PersonName.make(identifier2)
|
|
180383
|
+
),
|
|
180384
|
+
Option_exports.fromNullable
|
|
180385
|
+
),
|
|
180386
|
+
(byEmailOrName) => Option_exports.match(byEmailOrName, {
|
|
180387
|
+
onNone: () => Effect_exports.fail(new PersonNotFoundError({ identifier: identifier2 })),
|
|
180388
|
+
onSome: Effect_exports.succeed
|
|
180389
|
+
})
|
|
180390
|
+
),
|
|
180391
|
+
onSome: Effect_exports.succeed
|
|
180392
|
+
});
|
|
180393
|
+
});
|
|
180394
|
+
var resolvePersonOwner = (client, identifier2) => Effect_exports.map(resolvePerson(client, identifier2), (person) => ({
|
|
180395
|
+
id: person._id,
|
|
180396
|
+
ownerClass: contact.class.Person,
|
|
180397
|
+
identifier: identifier2
|
|
180398
|
+
}));
|
|
180399
|
+
var resolveOrganizationOwner = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180400
|
+
const org = yield* resolveOrganizationByIdentifier(client, identifier2);
|
|
180401
|
+
return { id: org._id, ownerClass: contact.class.Organization, identifier: identifier2 };
|
|
180402
|
+
});
|
|
180403
|
+
|
|
180404
|
+
// src/huly/operations/contact-channels.ts
|
|
180405
|
+
var listContactChannelProviders = () => Effect_exports.succeed(listContactChannelProviderLabels());
|
|
180406
|
+
var channelIdentifier = (locator) => locator._tag === "channelId" ? locator.channelId : `${locator.provider}:${locator.value}`;
|
|
180407
|
+
var INVALID_CHANNEL_LOCATOR_REASON = "provide exactly one channel locator: channelId, or provider plus value";
|
|
180408
|
+
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;
|
|
180409
|
+
var validateChannelLocator2 = (ownerIdentifier, locator) => Effect_exports.gen(function* () {
|
|
180410
|
+
const hasChannelId = locator.channelId !== void 0;
|
|
180411
|
+
const hasProvider = locator.provider !== void 0;
|
|
180412
|
+
const hasValue = locator.value !== void 0;
|
|
180413
|
+
if (hasChannelId && !hasProvider && !hasValue) {
|
|
180414
|
+
return { _tag: "channelId", channelId: ChannelId.make(locator.channelId) };
|
|
180415
|
+
}
|
|
180416
|
+
if (!hasChannelId && hasProvider && hasValue) {
|
|
180417
|
+
yield* validateProviderValue(locator.provider, locator.value);
|
|
180418
|
+
return { _tag: "providerValue", provider: locator.provider, value: locator.value };
|
|
180419
|
+
}
|
|
180420
|
+
return yield* new InvalidContactChannelLocatorError({
|
|
180421
|
+
ownerIdentifier,
|
|
180422
|
+
reason: INVALID_CHANNEL_LOCATOR_REASON
|
|
180423
|
+
});
|
|
180424
|
+
});
|
|
180425
|
+
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;
|
|
180426
|
+
var findChannelsForOwner = (client, owner) => client.findAll(
|
|
180427
|
+
contact.class.Channel,
|
|
180428
|
+
hulyQuery({
|
|
180429
|
+
attachedTo: owner.id,
|
|
180430
|
+
attachedToClass: owner.ownerClass
|
|
180431
|
+
})
|
|
180432
|
+
);
|
|
180433
|
+
var findExactChannels = (client, owner, provider, value3) => client.findAll(
|
|
180434
|
+
contact.class.Channel,
|
|
180435
|
+
hulyQuery({
|
|
180436
|
+
attachedTo: owner.id,
|
|
180437
|
+
attachedToClass: owner.ownerClass,
|
|
180438
|
+
provider: toContactChannelProviderRef(provider),
|
|
180439
|
+
value: value3
|
|
180440
|
+
})
|
|
180441
|
+
);
|
|
180442
|
+
var findChannelByIdForOwner = (client, owner, channelId) => Effect_exports.map(
|
|
180443
|
+
client.findOne(
|
|
180444
|
+
contact.class.Channel,
|
|
180445
|
+
hulyQuery({
|
|
180446
|
+
_id: toRef(channelId),
|
|
180447
|
+
attachedTo: owner.id,
|
|
180448
|
+
attachedToClass: owner.ownerClass
|
|
180449
|
+
})
|
|
180450
|
+
),
|
|
180451
|
+
Option_exports.fromNullable
|
|
180452
|
+
);
|
|
180453
|
+
var resolveChannelByLocator = (client, owner, locator) => Effect_exports.gen(function* () {
|
|
180454
|
+
if (locator._tag === "channelId") {
|
|
180455
|
+
return yield* Effect_exports.flatMap(findChannelByIdForOwner(client, owner, locator.channelId), (channel) => Option_exports.match(channel, {
|
|
180456
|
+
onNone: () => Effect_exports.fail(
|
|
180457
|
+
new ContactChannelNotFoundError({
|
|
180458
|
+
ownerIdentifier: owner.identifier,
|
|
180459
|
+
channelIdentifier: locator.channelId
|
|
180460
|
+
})
|
|
180461
|
+
),
|
|
180462
|
+
onSome: Effect_exports.succeed
|
|
180463
|
+
}));
|
|
180464
|
+
}
|
|
180465
|
+
const matches = yield* findExactChannels(client, owner, locator.provider, locator.value);
|
|
180466
|
+
if (matches.length === 0) {
|
|
180467
|
+
return yield* new ContactChannelNotFoundError({
|
|
180468
|
+
ownerIdentifier: owner.identifier,
|
|
180469
|
+
channelIdentifier: channelIdentifier(locator)
|
|
180470
|
+
});
|
|
180471
|
+
}
|
|
180472
|
+
if (matches.length > 1) {
|
|
180473
|
+
return yield* new ContactChannelIdentifierAmbiguousError({
|
|
180474
|
+
ownerIdentifier: owner.identifier,
|
|
180475
|
+
channelIdentifier: channelIdentifier(locator),
|
|
180476
|
+
matches: Count.make(matches.length)
|
|
180477
|
+
});
|
|
180478
|
+
}
|
|
180479
|
+
return matches[0];
|
|
180480
|
+
});
|
|
180481
|
+
var findRemovableChannel = (client, owner, locator) => Effect_exports.gen(function* () {
|
|
180482
|
+
if (locator._tag === "channelId") {
|
|
180483
|
+
return yield* findChannelByIdForOwner(client, owner, locator.channelId);
|
|
180484
|
+
}
|
|
180485
|
+
const matches = yield* findExactChannels(client, owner, locator.provider, locator.value);
|
|
180486
|
+
if (matches.length > 1) {
|
|
180487
|
+
return yield* new ContactChannelIdentifierAmbiguousError({
|
|
180488
|
+
ownerIdentifier: owner.identifier,
|
|
180489
|
+
channelIdentifier: channelIdentifier(locator),
|
|
180490
|
+
matches: Count.make(matches.length)
|
|
180491
|
+
});
|
|
180492
|
+
}
|
|
180493
|
+
return Option_exports.fromNullable(matches[0]);
|
|
180494
|
+
});
|
|
180495
|
+
var ensureNoTargetConflict = (client, owner, currentChannelId, provider, value3) => Effect_exports.gen(function* () {
|
|
180496
|
+
const matches = yield* findExactChannels(client, owner, provider, value3);
|
|
180497
|
+
const conflicting = matches.some((channel) => channel._id !== currentChannelId);
|
|
180498
|
+
if (conflicting) {
|
|
180499
|
+
return yield* new ContactChannelConflictError({
|
|
180500
|
+
ownerIdentifier: owner.identifier,
|
|
180501
|
+
provider,
|
|
180502
|
+
value: value3
|
|
180503
|
+
});
|
|
180504
|
+
}
|
|
180505
|
+
});
|
|
180506
|
+
var listOwnerChannels = (client, owner) => Effect_exports.gen(function* () {
|
|
180507
|
+
const channels = yield* findChannelsForOwner(client, owner);
|
|
180508
|
+
return yield* Effect_exports.all(channels.map(channelSummary));
|
|
180509
|
+
});
|
|
180510
|
+
var addOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180511
|
+
yield* validateProviderValue(params.provider, params.value);
|
|
180512
|
+
const existing = yield* findExactChannels(client, owner, params.provider, params.value);
|
|
180513
|
+
if (existing.length > 0) {
|
|
180514
|
+
return { added: false, channel: yield* channelSummary(existing[0]) };
|
|
180515
|
+
}
|
|
180516
|
+
const channelId = yield* client.addCollection(
|
|
180517
|
+
contact.class.Channel,
|
|
180518
|
+
contact.space.Contacts,
|
|
180519
|
+
owner.id,
|
|
180520
|
+
owner.ownerClass,
|
|
180521
|
+
"channels",
|
|
180522
|
+
{ provider: toContactChannelProviderRef(params.provider), value: params.value }
|
|
180523
|
+
);
|
|
180524
|
+
return {
|
|
180525
|
+
added: true,
|
|
180526
|
+
channel: {
|
|
180527
|
+
channelId: ChannelId.make(channelId),
|
|
180528
|
+
provider: params.provider,
|
|
180529
|
+
value: params.value
|
|
180530
|
+
}
|
|
180531
|
+
};
|
|
180532
|
+
});
|
|
180533
|
+
var updateOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180534
|
+
yield* requireChannelUpdateFields(params);
|
|
180535
|
+
const locator = yield* validateChannelLocator2(owner.identifier, params);
|
|
180536
|
+
const channel = yield* resolveChannelByLocator(client, owner, locator);
|
|
180537
|
+
const currentProvider = fromContactChannelProviderRef(channel.provider);
|
|
180538
|
+
if (currentProvider instanceof InvalidContactProviderError) {
|
|
180539
|
+
return yield* currentProvider;
|
|
180540
|
+
}
|
|
180541
|
+
const nextProvider = params.newProvider ?? currentProvider;
|
|
180542
|
+
const nextValue = params.newValue ?? channel.value;
|
|
180543
|
+
yield* validateProviderValue(nextProvider, nextValue);
|
|
180544
|
+
const nextProviderRef = toContactChannelProviderRef(nextProvider);
|
|
180545
|
+
if (channel.provider === nextProviderRef && channel.value === nextValue) {
|
|
180546
|
+
return { updated: false, channel: yield* channelSummary(channel) };
|
|
180547
|
+
}
|
|
180548
|
+
yield* ensureNoTargetConflict(client, owner, channel._id, nextProvider, nextValue);
|
|
180549
|
+
const operations = {
|
|
180550
|
+
provider: nextProviderRef,
|
|
180551
|
+
value: nextValue
|
|
180552
|
+
};
|
|
180553
|
+
yield* client.updateDoc(contact.class.Channel, contact.space.Contacts, channel._id, operations);
|
|
180554
|
+
return { updated: true, channel: channelSummaryWithValue(channel, nextProvider, nextValue) };
|
|
180555
|
+
});
|
|
180556
|
+
var removeOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
|
|
180557
|
+
const locator = yield* validateChannelLocator2(owner.identifier, params);
|
|
180558
|
+
const channel = yield* findRemovableChannel(client, owner, locator);
|
|
180559
|
+
if (Option_exports.isNone(channel)) {
|
|
180560
|
+
return locator._tag === "channelId" ? { removed: false, channelId: locator.channelId } : { removed: false };
|
|
180561
|
+
}
|
|
180562
|
+
yield* client.removeDoc(contact.class.Channel, contact.space.Contacts, channel.value._id);
|
|
180563
|
+
return { removed: true, channelId: ChannelId.make(channel.value._id) };
|
|
180564
|
+
});
|
|
180565
|
+
var listPersonChannels = (params) => Effect_exports.gen(function* () {
|
|
180566
|
+
const client = yield* HulyClient;
|
|
180567
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180568
|
+
return {
|
|
180569
|
+
personId: PersonId.make(owner.id),
|
|
180570
|
+
channels: yield* listOwnerChannels(client, owner)
|
|
180571
|
+
};
|
|
180572
|
+
});
|
|
180573
|
+
var addPersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180574
|
+
const client = yield* HulyClient;
|
|
180575
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180576
|
+
const result = yield* addOwnerChannel(client, owner, params);
|
|
180577
|
+
return { personId: PersonId.make(owner.id), ...result };
|
|
180578
|
+
});
|
|
180579
|
+
var updatePersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180580
|
+
const client = yield* HulyClient;
|
|
180581
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180582
|
+
const result = yield* updateOwnerChannel(client, owner, params);
|
|
180583
|
+
return { personId: PersonId.make(owner.id), ...result };
|
|
180584
|
+
});
|
|
180585
|
+
var removePersonChannel = (params) => Effect_exports.gen(function* () {
|
|
180586
|
+
const client = yield* HulyClient;
|
|
180587
|
+
const owner = yield* resolvePersonOwner(client, params.person);
|
|
180588
|
+
const result = yield* removeOwnerChannel(client, owner, params);
|
|
180589
|
+
const personId = PersonId.make(owner.id);
|
|
180590
|
+
return "channelId" in result ? { personId, removed: result.removed, channelId: result.channelId } : { personId, removed: result.removed };
|
|
180591
|
+
});
|
|
180592
|
+
var listOrganizationChannels = (params) => Effect_exports.gen(function* () {
|
|
180593
|
+
const client = yield* HulyClient;
|
|
180594
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180595
|
+
return {
|
|
180596
|
+
organizationId: OrganizationId.make(owner.id),
|
|
180597
|
+
channels: yield* listOwnerChannels(client, owner)
|
|
180598
|
+
};
|
|
180599
|
+
});
|
|
180600
|
+
var addOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180601
|
+
const client = yield* HulyClient;
|
|
180602
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180603
|
+
const result = yield* addOwnerChannel(client, owner, params);
|
|
180604
|
+
return { id: OrganizationId.make(owner.id), ...result };
|
|
180605
|
+
});
|
|
180606
|
+
var updateOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180607
|
+
const client = yield* HulyClient;
|
|
180608
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180609
|
+
const result = yield* updateOwnerChannel(client, owner, params);
|
|
180610
|
+
return { organizationId: OrganizationId.make(owner.id), ...result };
|
|
180611
|
+
});
|
|
180612
|
+
var removeOrganizationChannel = (params) => Effect_exports.gen(function* () {
|
|
180613
|
+
const client = yield* HulyClient;
|
|
180614
|
+
const owner = yield* resolveOrganizationOwner(client, params.organizationId);
|
|
180615
|
+
const result = yield* removeOwnerChannel(client, owner, params);
|
|
180616
|
+
const organizationId = OrganizationId.make(owner.id);
|
|
180617
|
+
return "channelId" in result ? { organizationId, removed: result.removed, channelId: result.channelId } : { organizationId, removed: result.removed };
|
|
180618
|
+
});
|
|
180619
|
+
|
|
180068
180620
|
// src/huly/operations/organizations.ts
|
|
180069
180621
|
var import_contact = __toESM(require_lib28(), 1);
|
|
180070
180622
|
var import_core34 = __toESM(require_lib4(), 1);
|
|
@@ -180082,81 +180634,19 @@ var leadClassIds = {
|
|
|
180082
180634
|
}
|
|
180083
180635
|
};
|
|
180084
180636
|
|
|
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
180637
|
// 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
180638
|
var resolvePersonIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
|
|
180155
|
-
const
|
|
180156
|
-
|
|
180157
|
-
|
|
180158
|
-
|
|
180159
|
-
|
|
180639
|
+
const byId = Option_exports.fromNullable(yield* findPersonById(client, identifier2));
|
|
180640
|
+
return yield* Option_exports.match(byId, {
|
|
180641
|
+
onNone: () => Effect_exports.flatMap(
|
|
180642
|
+
Effect_exports.map(findPersonByEmail(client, identifier2), Option_exports.fromNullable),
|
|
180643
|
+
(byEmail) => Option_exports.match(byEmail, {
|
|
180644
|
+
onNone: () => Effect_exports.fail(new PersonNotFoundError({ identifier: identifier2 })),
|
|
180645
|
+
onSome: Effect_exports.succeed
|
|
180646
|
+
})
|
|
180647
|
+
),
|
|
180648
|
+
onSome: Effect_exports.succeed
|
|
180649
|
+
});
|
|
180160
180650
|
});
|
|
180161
180651
|
var resolvePersonIdentifiers = (client, identifiers) => Effect_exports.gen(function* () {
|
|
180162
180652
|
const resolvedPeople = [];
|
|
@@ -180225,10 +180715,7 @@ var createOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180225
180715
|
});
|
|
180226
180716
|
var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
180227
180717
|
const client = yield* HulyClient;
|
|
180228
|
-
const org = yield*
|
|
180229
|
-
if (org === void 0) {
|
|
180230
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180231
|
-
}
|
|
180718
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180232
180719
|
const descriptionText = org.description !== null ? yield* client.fetchMarkup(
|
|
180233
180720
|
contact.class.Organization,
|
|
180234
180721
|
org._id,
|
|
@@ -180237,11 +180724,13 @@ var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180237
180724
|
"markdown"
|
|
180238
180725
|
) : void 0;
|
|
180239
180726
|
const id = OrganizationId.make(org._id);
|
|
180727
|
+
const channelsResult = yield* listOrganizationChannels({ organizationId: org._id });
|
|
180240
180728
|
return {
|
|
180241
180729
|
id,
|
|
180242
180730
|
name: org.name,
|
|
180243
180731
|
city: org.city || void 0,
|
|
180244
180732
|
description: descriptionText,
|
|
180733
|
+
channels: channelsResult.channels,
|
|
180245
180734
|
members: Count.make(org.members),
|
|
180246
180735
|
url: buildContactUrlFromConfig(client.workbenchUrlConfig, id),
|
|
180247
180736
|
modifiedOn: org.modifiedOn
|
|
@@ -180250,10 +180739,7 @@ var getOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180250
180739
|
var updateOrganization = (params) => Effect_exports.gen(function* () {
|
|
180251
180740
|
yield* requireUpdateFields("update_organization", params, UPDATE_ORGANIZATION_FIELDS);
|
|
180252
180741
|
const client = yield* HulyClient;
|
|
180253
|
-
const org = yield*
|
|
180254
|
-
if (org === void 0) {
|
|
180255
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180256
|
-
}
|
|
180742
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180257
180743
|
const updateEntries = {
|
|
180258
180744
|
name: Effect_exports.succeed(params.name === void 0 ? {} : { name: params.name }),
|
|
180259
180745
|
city: Effect_exports.succeed(params.city === void 0 ? {} : { city: params.city === null ? "" : params.city }),
|
|
@@ -180292,10 +180778,7 @@ var updateOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180292
180778
|
});
|
|
180293
180779
|
var deleteOrganization = (params) => Effect_exports.gen(function* () {
|
|
180294
180780
|
const client = yield* HulyClient;
|
|
180295
|
-
const org = yield*
|
|
180296
|
-
if (org === void 0) {
|
|
180297
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180298
|
-
}
|
|
180781
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180299
180782
|
yield* client.removeDoc(
|
|
180300
180783
|
contact.class.Organization,
|
|
180301
180784
|
contact.space.Contacts,
|
|
@@ -180305,10 +180788,7 @@ var deleteOrganization = (params) => Effect_exports.gen(function* () {
|
|
|
180305
180788
|
});
|
|
180306
180789
|
var makeOrganizationCustomer = (params) => Effect_exports.gen(function* () {
|
|
180307
180790
|
const client = yield* HulyClient;
|
|
180308
|
-
const org = yield*
|
|
180309
|
-
if (org === void 0) {
|
|
180310
|
-
return yield* new OrganizationNotFoundError({ identifier: params.identifier });
|
|
180311
|
-
}
|
|
180791
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.identifier);
|
|
180312
180792
|
const alreadyCustomer = org[leadClassIds.mixin.Customer] !== void 0;
|
|
180313
180793
|
if (alreadyCustomer) {
|
|
180314
180794
|
return { id: OrganizationId.make(org._id), applied: false };
|
|
@@ -180322,29 +180802,9 @@ var makeOrganizationCustomer = (params) => Effect_exports.gen(function* () {
|
|
|
180322
180802
|
);
|
|
180323
180803
|
return { id: OrganizationId.make(org._id), applied: true };
|
|
180324
180804
|
});
|
|
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
180805
|
var addOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
180343
180806
|
const client = yield* HulyClient;
|
|
180344
|
-
const org = yield*
|
|
180345
|
-
if (org === void 0) {
|
|
180346
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180347
|
-
}
|
|
180807
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180348
180808
|
const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
|
|
180349
180809
|
const existingMemberships = yield* findOrganizationMemberships(client, org._id, person._id);
|
|
180350
180810
|
if (existingMemberships.length > 0) {
|
|
@@ -180362,10 +180822,7 @@ var addOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
|
180362
180822
|
});
|
|
180363
180823
|
var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
180364
180824
|
const client = yield* HulyClient;
|
|
180365
|
-
const org = yield*
|
|
180366
|
-
if (org === void 0) {
|
|
180367
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180368
|
-
}
|
|
180825
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180369
180826
|
const members = yield* client.findAll(
|
|
180370
180827
|
contact.class.Member,
|
|
180371
180828
|
{ attachedTo: org._id }
|
|
@@ -180381,11 +180838,14 @@ var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
|
180381
180838
|
const emails = yield* batchGetEmailsForPersons(client, personIds);
|
|
180382
180839
|
const entries2 = persons.map((p) => {
|
|
180383
180840
|
const email3 = emails.get(p._id);
|
|
180384
|
-
|
|
180841
|
+
const entry = {
|
|
180385
180842
|
personId: PersonId.make(p._id),
|
|
180386
|
-
name: PersonName.make(p.name)
|
|
180387
|
-
email: email3 !== void 0 ? Email.make(email3) : void 0
|
|
180843
|
+
name: PersonName.make(p.name)
|
|
180388
180844
|
};
|
|
180845
|
+
return Option_exports.match(Option_exports.map(Option_exports.fromNullable(email3), Email.make), {
|
|
180846
|
+
onNone: () => entry,
|
|
180847
|
+
onSome: (memberEmail) => ({ ...entry, email: memberEmail })
|
|
180848
|
+
});
|
|
180389
180849
|
});
|
|
180390
180850
|
return {
|
|
180391
180851
|
organizationId: OrganizationId.make(org._id),
|
|
@@ -180394,10 +180854,7 @@ var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
|
|
|
180394
180854
|
});
|
|
180395
180855
|
var removeOrganizationMember = (params) => Effect_exports.gen(function* () {
|
|
180396
180856
|
const client = yield* HulyClient;
|
|
180397
|
-
const org = yield*
|
|
180398
|
-
if (org === void 0) {
|
|
180399
|
-
return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
|
|
180400
|
-
}
|
|
180857
|
+
const org = yield* resolveOrganizationByIdentifier(client, params.organizationId);
|
|
180401
180858
|
const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
|
|
180402
180859
|
const memberDocs = yield* findOrganizationMemberships(client, org._id, person._id);
|
|
180403
180860
|
if (memberDocs.length === 0) {
|
|
@@ -180501,16 +180958,10 @@ var getPerson = (params) => Effect_exports.gen(function* () {
|
|
|
180501
180958
|
const identifier2 = "personId" in params ? params.personId : params.email;
|
|
180502
180959
|
return yield* new PersonNotFoundError({ identifier: identifier2 });
|
|
180503
180960
|
}
|
|
180504
|
-
const
|
|
180505
|
-
contact.class.Channel,
|
|
180506
|
-
{
|
|
180507
|
-
attachedTo: person._id,
|
|
180508
|
-
attachedToClass: contact.class.Person
|
|
180509
|
-
}
|
|
180510
|
-
);
|
|
180961
|
+
const channelsResult = yield* listPersonChannels({ person: person._id });
|
|
180511
180962
|
const organizations = yield* findOrganizationsForPerson(client, person._id);
|
|
180512
180963
|
const { firstName, lastName } = parseName(person.name);
|
|
180513
|
-
const emailChannel = channels.find((c) => c.provider ===
|
|
180964
|
+
const emailChannel = channelsResult.channels.find((c) => c.provider === "email");
|
|
180514
180965
|
const id = PersonId.make(person._id);
|
|
180515
180966
|
return {
|
|
180516
180967
|
id,
|
|
@@ -180519,10 +180970,7 @@ var getPerson = (params) => Effect_exports.gen(function* () {
|
|
|
180519
180970
|
lastName,
|
|
180520
180971
|
city: person.city,
|
|
180521
180972
|
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
|
-
})),
|
|
180973
|
+
channels: channelsResult.channels,
|
|
180526
180974
|
organizations: organizations.length > 0 ? organizations : void 0,
|
|
180527
180975
|
url: buildContactUrlFromConfig(client.workbenchUrlConfig, id),
|
|
180528
180976
|
modifiedOn: person.modifiedOn,
|
|
@@ -180713,6 +181161,61 @@ var contactTools = [
|
|
|
180713
181161
|
listEmployees
|
|
180714
181162
|
)
|
|
180715
181163
|
},
|
|
181164
|
+
{
|
|
181165
|
+
name: "list_contact_channel_providers",
|
|
181166
|
+
description: "List supported contact channel provider labels for person and organization channel tools.",
|
|
181167
|
+
category: CATEGORY9,
|
|
181168
|
+
inputSchema: listContactChannelProvidersParamsJsonSchema,
|
|
181169
|
+
handler: createToolHandler(
|
|
181170
|
+
"list_contact_channel_providers",
|
|
181171
|
+
parseListContactChannelProvidersParams,
|
|
181172
|
+
listContactChannelProviders
|
|
181173
|
+
)
|
|
181174
|
+
},
|
|
181175
|
+
{
|
|
181176
|
+
name: "list_person_channels",
|
|
181177
|
+
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.",
|
|
181178
|
+
category: CATEGORY9,
|
|
181179
|
+
inputSchema: listPersonChannelsParamsJsonSchema,
|
|
181180
|
+
handler: createToolHandler(
|
|
181181
|
+
"list_person_channels",
|
|
181182
|
+
parseListPersonChannelsParams,
|
|
181183
|
+
listPersonChannels
|
|
181184
|
+
)
|
|
181185
|
+
},
|
|
181186
|
+
{
|
|
181187
|
+
name: "add_person_channel",
|
|
181188
|
+
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.",
|
|
181189
|
+
category: CATEGORY9,
|
|
181190
|
+
inputSchema: addPersonChannelParamsJsonSchema,
|
|
181191
|
+
handler: createToolHandler(
|
|
181192
|
+
"add_person_channel",
|
|
181193
|
+
parseAddPersonChannelParams,
|
|
181194
|
+
addPersonChannel
|
|
181195
|
+
)
|
|
181196
|
+
},
|
|
181197
|
+
{
|
|
181198
|
+
name: "update_person_channel",
|
|
181199
|
+
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.",
|
|
181200
|
+
category: CATEGORY9,
|
|
181201
|
+
inputSchema: updatePersonChannelParamsJsonSchema,
|
|
181202
|
+
handler: createToolHandler(
|
|
181203
|
+
"update_person_channel",
|
|
181204
|
+
parseUpdatePersonChannelParams,
|
|
181205
|
+
updatePersonChannel
|
|
181206
|
+
)
|
|
181207
|
+
},
|
|
181208
|
+
{
|
|
181209
|
+
name: "remove_person_channel",
|
|
181210
|
+
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.",
|
|
181211
|
+
category: CATEGORY9,
|
|
181212
|
+
inputSchema: removePersonChannelParamsJsonSchema,
|
|
181213
|
+
handler: createToolHandler(
|
|
181214
|
+
"remove_person_channel",
|
|
181215
|
+
parseRemovePersonChannelParams,
|
|
181216
|
+
removePersonChannel
|
|
181217
|
+
)
|
|
181218
|
+
},
|
|
180716
181219
|
{
|
|
180717
181220
|
name: "list_organizations",
|
|
180718
181221
|
description: "List all organizations in the Huly workspace. Returns organizations sorted by modification date (newest first).",
|
|
@@ -180781,7 +181284,7 @@ var contactTools = [
|
|
|
180781
181284
|
},
|
|
180782
181285
|
{
|
|
180783
181286
|
name: "add_organization_channel",
|
|
180784
|
-
description: "
|
|
181287
|
+
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
181288
|
category: CATEGORY9,
|
|
180786
181289
|
inputSchema: addOrganizationChannelParamsJsonSchema,
|
|
180787
181290
|
handler: createToolHandler(
|
|
@@ -180790,6 +181293,39 @@ var contactTools = [
|
|
|
180790
181293
|
addOrganizationChannel
|
|
180791
181294
|
)
|
|
180792
181295
|
},
|
|
181296
|
+
{
|
|
181297
|
+
name: "list_organization_channels",
|
|
181298
|
+
description: "List contact channels for an organization identified by ID or exact unique organization name. Returns channelId, provider label, value, and optional activity metadata.",
|
|
181299
|
+
category: CATEGORY9,
|
|
181300
|
+
inputSchema: listOrganizationChannelsParamsJsonSchema,
|
|
181301
|
+
handler: createToolHandler(
|
|
181302
|
+
"list_organization_channels",
|
|
181303
|
+
parseListOrganizationChannelsParams,
|
|
181304
|
+
listOrganizationChannels
|
|
181305
|
+
)
|
|
181306
|
+
},
|
|
181307
|
+
{
|
|
181308
|
+
name: "update_organization_channel",
|
|
181309
|
+
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.",
|
|
181310
|
+
category: CATEGORY9,
|
|
181311
|
+
inputSchema: updateOrganizationChannelParamsJsonSchema,
|
|
181312
|
+
handler: createToolHandler(
|
|
181313
|
+
"update_organization_channel",
|
|
181314
|
+
parseUpdateOrganizationChannelParams,
|
|
181315
|
+
updateOrganizationChannel
|
|
181316
|
+
)
|
|
181317
|
+
},
|
|
181318
|
+
{
|
|
181319
|
+
name: "remove_organization_channel",
|
|
181320
|
+
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.",
|
|
181321
|
+
category: CATEGORY9,
|
|
181322
|
+
inputSchema: removeOrganizationChannelParamsJsonSchema,
|
|
181323
|
+
handler: createToolHandler(
|
|
181324
|
+
"remove_organization_channel",
|
|
181325
|
+
parseRemoveOrganizationChannelParams,
|
|
181326
|
+
removeOrganizationChannel
|
|
181327
|
+
)
|
|
181328
|
+
},
|
|
180793
181329
|
{
|
|
180794
181330
|
name: "add_organization_member",
|
|
180795
181331
|
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.",
|