@proteos/sdk 0.44.0 → 0.46.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/dist/{chunk-33EULWIM.cjs → chunk-F5DHWOGW.cjs} +195 -27
- package/dist/chunk-F5DHWOGW.cjs.map +1 -0
- package/dist/{chunk-IGIAJVX6.js → chunk-Y4CEHIRX.js} +191 -28
- package/dist/chunk-Y4CEHIRX.js.map +1 -0
- package/dist/index.cjs +453 -178
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +686 -13
- package/dist/index.d.ts +686 -13
- package/dist/index.js +355 -96
- package/dist/index.js.map +1 -1
- package/dist/meta/index.cjs +69 -53
- package/dist/meta/index.d.cts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.js +1 -1
- package/dist/{types-BTdBFq34.d.cts → types-D1PRIsSO.d.cts} +406 -14
- package/dist/{types-BTdBFq34.d.ts → types-D1PRIsSO.d.ts} +406 -14
- package/package.json +3 -3
- package/src/auth/index.ts +58 -1
- package/src/auth/me.ts +14 -1
- package/src/auth/platform-entities.ts +27 -0
- package/src/auth/roles.ts +3 -1
- package/src/auth/shares.ts +181 -0
- package/src/auth/teams.ts +135 -0
- package/src/auth/types.ts +192 -4
- package/src/auth/user-role-assignments.ts +65 -0
- package/src/conversation/index.ts +42 -0
- package/src/conversation/types.ts +37 -0
- package/src/index.ts +36 -0
- package/src/knowledge/graph.ts +6 -2
- package/src/knowledge/index.ts +15 -0
- package/src/knowledge/nodes.ts +4 -1
- package/src/knowledge/spaces.ts +86 -0
- package/src/knowledge/types.ts +89 -0
- package/src/meta/index.ts +11 -0
- package/src/meta/layout/control-registry.json +151 -26
- package/src/meta/types.ts +186 -4
- package/src/workflow/types.ts +20 -3
- package/dist/chunk-33EULWIM.cjs.map +0 -1
- package/dist/chunk-IGIAJVX6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuditFieldsSchema, AttributeSchema, UserRefSchema, PageIterator } from './chunk-
|
|
2
|
-
export { AppSchema, AttributeSchema, AuditFieldsSchema, ColumnSchema, ComponentSchema, CurrencyAttributeMetaSchema, DEFAULT_PAGE_SIZE, DONE, DesignReferenceSchema, EntitySchema, EntityWithSchemaSchema, FileRefSchema, FilterElementSchema, FilterGroupSchema, ListSchema, ListViewSchema, MenuConfigurationSchema, MenuItemSchema, MenuItemType, MetaClient, ModuleSchema, OnDeleteActionSchema, PLATFORM_ATTRIBUTE_NAMES, PLATFORM_USER_ID, PageActionSchema, PageIterator, PageLayoutSchema, PageSchema, RelationAttributeMetaSchema, ResponseMetaSchema, SortConfigSchema, UserRefSchema, VariableSchema, allCurrencyCodes, createIterator, createListResultSchema, currencyLabel, currencySymbol, currencySymbolSide, formatAmount, formatMoney, isPlatformAttributeName, localeNumberSeparators, parseAmount, parseCurrencyMeta, parseFileMeta, parseRelationMeta, platformAttributes } from './chunk-
|
|
1
|
+
import { AuditFieldsSchema, FileRefSchema, PrincipalRefSchema, AttributeSchema, UserRefSchema, PageIterator } from './chunk-Y4CEHIRX.js';
|
|
2
|
+
export { AppSchema, AttributeSchema, AuditFieldsSchema, CURRENT_USER_DEFAULT, ColumnSchema, ComponentSchema, CurrencyAttributeMetaSchema, DEFAULT_PAGE_SIZE, DONE, DesignReferenceSchema, EntitySchema, EntityWithSchemaSchema, FileRefSchema, FilterElementSchema, FilterGroupSchema, ListSchema, ListViewSchema, MenuConfigurationSchema, MenuItemSchema, MenuItemType, MetaClient, ModuleSchema, OnDeleteActionSchema, PLATFORM_ATTRIBUTE_NAMES, PLATFORM_USER_ID, PageActionSchema, PageIterator, PageLayoutSchema, PageSchema, RelationAttributeMetaSchema, ResponseMetaSchema, SortConfigSchema, UserRefSchema, VariableSchema, acceptsCurrentUserDefault, allCurrencyCodes, createIterator, createListResultSchema, currencyLabel, currencySymbol, currencySymbolSide, formatAmount, formatMoney, isCurrentUserDefault, isPlatformAttributeName, localeNumberSeparators, parseAmount, parseCurrencyMeta, parseFileMeta, parseRelationMeta, platformAttributes } from './chunk-Y4CEHIRX.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
5
5
|
|
|
@@ -419,6 +419,9 @@ var MeServiceImpl = class {
|
|
|
419
419
|
async get() {
|
|
420
420
|
return this.client.request("GET", ME_BASE_PATH);
|
|
421
421
|
}
|
|
422
|
+
async update(request) {
|
|
423
|
+
return this.client.request("PATCH", ME_BASE_PATH, request);
|
|
424
|
+
}
|
|
422
425
|
async organizations() {
|
|
423
426
|
const response = await this.client.request(
|
|
424
427
|
"GET",
|
|
@@ -512,6 +515,222 @@ var RoleServiceImpl = class {
|
|
|
512
515
|
}
|
|
513
516
|
};
|
|
514
517
|
|
|
518
|
+
// src/errors.ts
|
|
519
|
+
var ErrorCode = {
|
|
520
|
+
NOT_FOUND: "not_found",
|
|
521
|
+
UNAUTHORIZED: "unauthorized",
|
|
522
|
+
FORBIDDEN: "forbidden",
|
|
523
|
+
BAD_REQUEST: "bad_request",
|
|
524
|
+
CONFLICT: "conflict",
|
|
525
|
+
INTERNAL_SERVER_ERROR: "internal_server_error",
|
|
526
|
+
INVALID_PAYLOAD: "invalid_payload",
|
|
527
|
+
INVALID_PERSONA: "invalid_persona"
|
|
528
|
+
};
|
|
529
|
+
var ProteosError = class extends Error {
|
|
530
|
+
/** HTTP status code of the response */
|
|
531
|
+
httpStatus;
|
|
532
|
+
/** API error code (e.g., 'not_found', 'unauthorized') */
|
|
533
|
+
code;
|
|
534
|
+
constructor(message, httpStatus, code) {
|
|
535
|
+
super(message);
|
|
536
|
+
this.name = "ProteosError";
|
|
537
|
+
this.httpStatus = httpStatus;
|
|
538
|
+
this.code = code;
|
|
539
|
+
const v8Capture = Error.captureStackTrace;
|
|
540
|
+
if (v8Capture) v8Capture(this, this.constructor);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Returns a formatted string representation of the error.
|
|
544
|
+
*/
|
|
545
|
+
toString() {
|
|
546
|
+
return `${this.code}: ${this.message} (HTTP ${this.httpStatus})`;
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
function isProteosError(error) {
|
|
550
|
+
return error instanceof ProteosError;
|
|
551
|
+
}
|
|
552
|
+
function isNotFound(error) {
|
|
553
|
+
return isProteosError(error) && error.httpStatus === 404;
|
|
554
|
+
}
|
|
555
|
+
function isUnauthorized(error) {
|
|
556
|
+
return isProteosError(error) && error.httpStatus === 401;
|
|
557
|
+
}
|
|
558
|
+
function isForbidden(error) {
|
|
559
|
+
return isProteosError(error) && error.httpStatus === 403;
|
|
560
|
+
}
|
|
561
|
+
function isBadRequest(error) {
|
|
562
|
+
return isProteosError(error) && error.httpStatus === 400;
|
|
563
|
+
}
|
|
564
|
+
function isConflict(error) {
|
|
565
|
+
return isProteosError(error) && error.httpStatus === 409;
|
|
566
|
+
}
|
|
567
|
+
function getDefaultErrorCode(httpStatus) {
|
|
568
|
+
switch (httpStatus) {
|
|
569
|
+
case 400:
|
|
570
|
+
return ErrorCode.BAD_REQUEST;
|
|
571
|
+
case 401:
|
|
572
|
+
return ErrorCode.UNAUTHORIZED;
|
|
573
|
+
case 403:
|
|
574
|
+
return ErrorCode.FORBIDDEN;
|
|
575
|
+
case 404:
|
|
576
|
+
return ErrorCode.NOT_FOUND;
|
|
577
|
+
case 409:
|
|
578
|
+
return ErrorCode.CONFLICT;
|
|
579
|
+
default:
|
|
580
|
+
return ErrorCode.INTERNAL_SERVER_ERROR;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function parseErrorResponse(response) {
|
|
584
|
+
const httpStatus = response.status;
|
|
585
|
+
let code = getDefaultErrorCode(httpStatus);
|
|
586
|
+
let message = "Unknown error";
|
|
587
|
+
try {
|
|
588
|
+
const body = await response.text();
|
|
589
|
+
try {
|
|
590
|
+
const json = JSON.parse(body);
|
|
591
|
+
if (json.code) {
|
|
592
|
+
code = json.code;
|
|
593
|
+
}
|
|
594
|
+
if (json.message) {
|
|
595
|
+
message = json.message;
|
|
596
|
+
} else {
|
|
597
|
+
message = body || `HTTP ${httpStatus}`;
|
|
598
|
+
}
|
|
599
|
+
} catch {
|
|
600
|
+
message = body.trim() || `HTTP ${httpStatus}`;
|
|
601
|
+
}
|
|
602
|
+
} catch {
|
|
603
|
+
message = `HTTP ${httpStatus}`;
|
|
604
|
+
}
|
|
605
|
+
return new ProteosError(message, httpStatus, code);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/auth/shares.ts
|
|
609
|
+
var PLATFORM_ENTITY_SERVICE = {
|
|
610
|
+
// Agent suite (agent-service)
|
|
611
|
+
agents: "/agents",
|
|
612
|
+
prompts: "/agents",
|
|
613
|
+
skills: "/agents",
|
|
614
|
+
tools: "/agents",
|
|
615
|
+
toolsets: "/agents",
|
|
616
|
+
"mcp-servers": "/agents",
|
|
617
|
+
// Knowledge (knowledge-service)
|
|
618
|
+
"knowledge-spaces": "/knowledge",
|
|
619
|
+
"knowledge-nodes": "/knowledge",
|
|
620
|
+
// Conversations (conversation-service)
|
|
621
|
+
conversations: "/conversations",
|
|
622
|
+
connections: "/conversations"
|
|
623
|
+
};
|
|
624
|
+
var SERVICES_WITH_SHARING = /* @__PURE__ */ new Set(["/data", "/knowledge"]);
|
|
625
|
+
var DEFAULT_SERVICE = "/data";
|
|
626
|
+
function shareRouteFor(entitySlug) {
|
|
627
|
+
const service = PLATFORM_ENTITY_SERVICE[entitySlug] ?? DEFAULT_SERVICE;
|
|
628
|
+
if (!SERVICES_WITH_SHARING.has(service)) {
|
|
629
|
+
throw new ProteosError(
|
|
630
|
+
`Sharing is not available for '${entitySlug}' yet \u2014 ${service.slice(1)}-service does not serve a share endpoint.`,
|
|
631
|
+
501,
|
|
632
|
+
"sharing_not_supported"
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
return `${service}/v1/shares`;
|
|
636
|
+
}
|
|
637
|
+
function isShareable(entitySlug) {
|
|
638
|
+
const service = PLATFORM_ENTITY_SERVICE[entitySlug] ?? DEFAULT_SERVICE;
|
|
639
|
+
return SERVICES_WITH_SHARING.has(service);
|
|
640
|
+
}
|
|
641
|
+
var ShareServiceImpl = class {
|
|
642
|
+
constructor(client) {
|
|
643
|
+
this.client = client;
|
|
644
|
+
}
|
|
645
|
+
client;
|
|
646
|
+
async share(entitySlug, recordId, principal, permission) {
|
|
647
|
+
await this.client.request("POST", shareRouteFor(entitySlug), {
|
|
648
|
+
entity_slug: entitySlug,
|
|
649
|
+
record_id: recordId,
|
|
650
|
+
principal,
|
|
651
|
+
permission
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
async unshare(entitySlug, recordId, principal, permission) {
|
|
655
|
+
await this.client.request("DELETE", shareRouteFor(entitySlug), {
|
|
656
|
+
entity_slug: entitySlug,
|
|
657
|
+
record_id: recordId,
|
|
658
|
+
principal,
|
|
659
|
+
permission
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
async listShares(entitySlug, recordId) {
|
|
663
|
+
const query = new URLSearchParams({ entity_slug: entitySlug, record_id: recordId });
|
|
664
|
+
const response = await this.client.request(
|
|
665
|
+
"GET",
|
|
666
|
+
`${shareRouteFor(entitySlug)}?${query.toString()}`
|
|
667
|
+
);
|
|
668
|
+
return response.shares ?? [];
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
// src/auth/teams.ts
|
|
673
|
+
var TEAMS_BASE_PATH = "/accounts/v1/teams";
|
|
674
|
+
var TeamServiceImpl = class {
|
|
675
|
+
constructor(client) {
|
|
676
|
+
this.client = client;
|
|
677
|
+
}
|
|
678
|
+
client;
|
|
679
|
+
list(options = {}) {
|
|
680
|
+
return new PageIterator((opts) => this.listPage(opts), options);
|
|
681
|
+
}
|
|
682
|
+
async listPage(options = {}) {
|
|
683
|
+
return this.client.requestWithQuery("GET", TEAMS_BASE_PATH, options);
|
|
684
|
+
}
|
|
685
|
+
async get(slug) {
|
|
686
|
+
return this.client.request("GET", `${TEAMS_BASE_PATH}/${slug}`);
|
|
687
|
+
}
|
|
688
|
+
async create(request) {
|
|
689
|
+
return this.client.request("POST", TEAMS_BASE_PATH, request);
|
|
690
|
+
}
|
|
691
|
+
async update(slug, request) {
|
|
692
|
+
return this.client.request("PATCH", `${TEAMS_BASE_PATH}/${slug}`, request);
|
|
693
|
+
}
|
|
694
|
+
async delete(slug) {
|
|
695
|
+
await this.client.request("DELETE", `${TEAMS_BASE_PATH}/${slug}`);
|
|
696
|
+
}
|
|
697
|
+
getMembers(slug, options = {}) {
|
|
698
|
+
return new PageIterator((opts) => this.fetchMembersPage(slug, opts), options);
|
|
699
|
+
}
|
|
700
|
+
async addMember(slug, request) {
|
|
701
|
+
return this.client.request("POST", `${TEAMS_BASE_PATH}/${slug}/members`, request);
|
|
702
|
+
}
|
|
703
|
+
async removeMember(slug, userId) {
|
|
704
|
+
await this.client.request("DELETE", `${TEAMS_BASE_PATH}/${slug}/members/${userId}`);
|
|
705
|
+
}
|
|
706
|
+
async fetchMembersPage(slug, options) {
|
|
707
|
+
return this.client.requestWithQuery(
|
|
708
|
+
"GET",
|
|
709
|
+
`${TEAMS_BASE_PATH}/${slug}/members`,
|
|
710
|
+
options
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// src/auth/user-role-assignments.ts
|
|
716
|
+
var USER_ROLE_ASSIGNMENTS_BASE_PATH = "/accounts/v1/user-role-assignments";
|
|
717
|
+
var UserRoleAssignmentServiceImpl = class {
|
|
718
|
+
constructor(client) {
|
|
719
|
+
this.client = client;
|
|
720
|
+
}
|
|
721
|
+
client;
|
|
722
|
+
list(options = {}) {
|
|
723
|
+
return new PageIterator((opts) => this.listPage(opts), options);
|
|
724
|
+
}
|
|
725
|
+
async listPage(options = {}) {
|
|
726
|
+
return this.client.requestWithQuery(
|
|
727
|
+
"GET",
|
|
728
|
+
USER_ROLE_ASSIGNMENTS_BASE_PATH,
|
|
729
|
+
options
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
515
734
|
// src/auth/users.ts
|
|
516
735
|
var USERS_BASE_PATH = "/accounts/v1/users";
|
|
517
736
|
var UserServiceImpl = class {
|
|
@@ -581,6 +800,12 @@ var PLATFORM_ENTITIES = [
|
|
|
581
800
|
{ slug: "roles", name: "Roles" },
|
|
582
801
|
{ slug: "user-role-assignments", name: "User Role Assignments" },
|
|
583
802
|
{ slug: "role-entity-permissions", name: "Role Entity Permissions" },
|
|
803
|
+
// Teams are the org's structure and a principal that can hold access anywhere
|
|
804
|
+
// a user can. Membership is a separate slug: seeing the org chart and changing
|
|
805
|
+
// who is in it are different decisions, and membership is what moves access.
|
|
806
|
+
{ slug: "teams", name: "Teams" },
|
|
807
|
+
{ slug: "team-members", name: "Team Members" },
|
|
808
|
+
// The share audit trail — a distinct grant from the resources it references.
|
|
584
809
|
// Schema / content (metadata-service)
|
|
585
810
|
{ slug: "entities", name: "Entities" },
|
|
586
811
|
{ slug: "pages", name: "Pages" },
|
|
@@ -606,6 +831,7 @@ var PLATFORM_ENTITIES = [
|
|
|
606
831
|
{ slug: "knowledge-nodes", name: "Knowledge Nodes" },
|
|
607
832
|
{ slug: "knowledge-links", name: "Knowledge Links" },
|
|
608
833
|
{ slug: "knowledge-labels", name: "Knowledge Labels" },
|
|
834
|
+
{ slug: "knowledge-spaces", name: "Knowledge Spaces" },
|
|
609
835
|
// Agent suite (agent-service)
|
|
610
836
|
{ slug: "agents", name: "Agents" },
|
|
611
837
|
{ slug: "prompts", name: "Prompts" },
|
|
@@ -629,6 +855,17 @@ var PLATFORM_ENTITIES = [
|
|
|
629
855
|
{ slug: "glossary-terms", name: "Glossary Terms" },
|
|
630
856
|
// Mistranscribed terms proposed by the post-transcription review pass.
|
|
631
857
|
{ slug: "mistranscribed-terms", name: "Mistranscribed Terms" },
|
|
858
|
+
// The person-level identity layer (contacts + addresses + merges + consent +
|
|
859
|
+
// erasure) — one grant governs the whole aggregate.
|
|
860
|
+
{ slug: "contacts", name: "Contacts" },
|
|
861
|
+
// Ingest-time filter rules + their drop-audit events.
|
|
862
|
+
{ slug: "conversation-filters", name: "Conversation Filters" },
|
|
863
|
+
// The org's conversation taxonomy (read by the pre-summary classifier).
|
|
864
|
+
{ slug: "conversation-types", name: "Conversation Types" },
|
|
865
|
+
// Generic org-shared audience taxonomy; membership lives on the contact.
|
|
866
|
+
{ slug: "contact-groups", name: "Contact Groups" },
|
|
867
|
+
// Tone-of-voice synthesis: per-user setups + generated instruction profiles.
|
|
868
|
+
{ slug: "tone-profiles", name: "Tone Profiles" },
|
|
632
869
|
// Connectors (connector-service). `connections` above is shared; this is the
|
|
633
870
|
// manifest catalog.
|
|
634
871
|
{ slug: "connectors", name: "Connectors" }
|
|
@@ -636,6 +873,7 @@ var PLATFORM_ENTITIES = [
|
|
|
636
873
|
var PLATFORM_ENTITY_SLUGS = PLATFORM_ENTITIES.map(
|
|
637
874
|
(entity) => entity.slug
|
|
638
875
|
);
|
|
876
|
+
var SCOPED_PLATFORM_ENTITY_SLUGS = ["knowledge-nodes"];
|
|
639
877
|
function isPlatformEntity(slug) {
|
|
640
878
|
return PLATFORM_ENTITY_SLUGS.includes(slug);
|
|
641
879
|
}
|
|
@@ -643,7 +881,7 @@ var RoleEntityPermissionSchema = AuditFieldsSchema.extend({
|
|
|
643
881
|
id: z.string(),
|
|
644
882
|
role_slug: z.string(),
|
|
645
883
|
entity_slug: z.string(),
|
|
646
|
-
permission: z.enum(["read", "write", "delete"])
|
|
884
|
+
permission: z.enum(["read", "write", "delete", "read_scoped", "write_scoped", "delete_scoped"])
|
|
647
885
|
});
|
|
648
886
|
var UserRoleAssignmentSchema = AuditFieldsSchema.extend({
|
|
649
887
|
id: z.string(),
|
|
@@ -657,7 +895,8 @@ var UserSchema = AuditFieldsSchema.extend({
|
|
|
657
895
|
given_name: z.string(),
|
|
658
896
|
family_name: z.string(),
|
|
659
897
|
external_id: z.string(),
|
|
660
|
-
default_org_id: z.string()
|
|
898
|
+
default_org_id: z.string(),
|
|
899
|
+
profile_image: FileRefSchema.nullish()
|
|
661
900
|
});
|
|
662
901
|
AuditFieldsSchema.extend({
|
|
663
902
|
id: z.string(),
|
|
@@ -675,11 +914,31 @@ var RoleSchema = AuditFieldsSchema.extend({
|
|
|
675
914
|
org_id: z.string(),
|
|
676
915
|
description: z.string()
|
|
677
916
|
});
|
|
917
|
+
AuditFieldsSchema.extend({
|
|
918
|
+
slug: z.string(),
|
|
919
|
+
name: z.string(),
|
|
920
|
+
org_id: z.string(),
|
|
921
|
+
description: z.string(),
|
|
922
|
+
parent_team_slug: z.string()
|
|
923
|
+
});
|
|
924
|
+
AuditFieldsSchema.extend({
|
|
925
|
+
id: z.string(),
|
|
926
|
+
org_id: z.string(),
|
|
927
|
+
team_slug: z.string(),
|
|
928
|
+
user_id: z.string()
|
|
929
|
+
});
|
|
678
930
|
var OrganizationSchema = AuditFieldsSchema.extend({
|
|
679
931
|
id: z.string(),
|
|
680
932
|
name: z.string(),
|
|
681
933
|
description: z.string()
|
|
682
934
|
});
|
|
935
|
+
var SharePermissionSchema = z.enum(["read", "write", "delete"]);
|
|
936
|
+
z.object({
|
|
937
|
+
entity_slug: z.string(),
|
|
938
|
+
record_id: z.string(),
|
|
939
|
+
principal: PrincipalRefSchema,
|
|
940
|
+
permission: SharePermissionSchema
|
|
941
|
+
});
|
|
683
942
|
|
|
684
943
|
// src/auth/index.ts
|
|
685
944
|
var AccountClient = class {
|
|
@@ -695,10 +954,28 @@ var AccountClient = class {
|
|
|
695
954
|
* Service for managing roles and their entity permissions.
|
|
696
955
|
*/
|
|
697
956
|
roles;
|
|
957
|
+
/**
|
|
958
|
+
* Service for the org-wide user-role-assignment listing ("who holds which
|
|
959
|
+
* role" in one request).
|
|
960
|
+
*/
|
|
961
|
+
userRoleAssignments;
|
|
698
962
|
/**
|
|
699
963
|
* Service for managing organizations.
|
|
700
964
|
*/
|
|
701
965
|
organizations;
|
|
966
|
+
/**
|
|
967
|
+
* Service for managing teams and their membership.
|
|
968
|
+
*/
|
|
969
|
+
teams;
|
|
970
|
+
/**
|
|
971
|
+
* Service for sharing individual resources with a principal.
|
|
972
|
+
*
|
|
973
|
+
* Lives here rather than on the owning resource's client because sharing is
|
|
974
|
+
* ONE concept across every resource type — a deal, a conversation, a
|
|
975
|
+
* knowledge space. Callers name an entity; which service handles the write is
|
|
976
|
+
* the SDK's problem, so centralizing it server-side later moves no caller.
|
|
977
|
+
*/
|
|
978
|
+
shares;
|
|
702
979
|
/**
|
|
703
980
|
* Creates a new AccountClient instance.
|
|
704
981
|
*
|
|
@@ -708,100 +985,13 @@ var AccountClient = class {
|
|
|
708
985
|
this.me = new MeServiceImpl(client);
|
|
709
986
|
this.users = new UserServiceImpl(client);
|
|
710
987
|
this.roles = new RoleServiceImpl(client);
|
|
988
|
+
this.userRoleAssignments = new UserRoleAssignmentServiceImpl(client);
|
|
711
989
|
this.organizations = new OrganizationServiceImpl(client);
|
|
990
|
+
this.teams = new TeamServiceImpl(client);
|
|
991
|
+
this.shares = new ShareServiceImpl(client);
|
|
712
992
|
}
|
|
713
993
|
};
|
|
714
994
|
|
|
715
|
-
// src/errors.ts
|
|
716
|
-
var ErrorCode = {
|
|
717
|
-
NOT_FOUND: "not_found",
|
|
718
|
-
UNAUTHORIZED: "unauthorized",
|
|
719
|
-
FORBIDDEN: "forbidden",
|
|
720
|
-
BAD_REQUEST: "bad_request",
|
|
721
|
-
CONFLICT: "conflict",
|
|
722
|
-
INTERNAL_SERVER_ERROR: "internal_server_error",
|
|
723
|
-
INVALID_PAYLOAD: "invalid_payload",
|
|
724
|
-
INVALID_PERSONA: "invalid_persona"
|
|
725
|
-
};
|
|
726
|
-
var ProteosError = class extends Error {
|
|
727
|
-
/** HTTP status code of the response */
|
|
728
|
-
httpStatus;
|
|
729
|
-
/** API error code (e.g., 'not_found', 'unauthorized') */
|
|
730
|
-
code;
|
|
731
|
-
constructor(message, httpStatus, code) {
|
|
732
|
-
super(message);
|
|
733
|
-
this.name = "ProteosError";
|
|
734
|
-
this.httpStatus = httpStatus;
|
|
735
|
-
this.code = code;
|
|
736
|
-
const v8Capture = Error.captureStackTrace;
|
|
737
|
-
if (v8Capture) v8Capture(this, this.constructor);
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Returns a formatted string representation of the error.
|
|
741
|
-
*/
|
|
742
|
-
toString() {
|
|
743
|
-
return `${this.code}: ${this.message} (HTTP ${this.httpStatus})`;
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
function isProteosError(error) {
|
|
747
|
-
return error instanceof ProteosError;
|
|
748
|
-
}
|
|
749
|
-
function isNotFound(error) {
|
|
750
|
-
return isProteosError(error) && error.httpStatus === 404;
|
|
751
|
-
}
|
|
752
|
-
function isUnauthorized(error) {
|
|
753
|
-
return isProteosError(error) && error.httpStatus === 401;
|
|
754
|
-
}
|
|
755
|
-
function isForbidden(error) {
|
|
756
|
-
return isProteosError(error) && error.httpStatus === 403;
|
|
757
|
-
}
|
|
758
|
-
function isBadRequest(error) {
|
|
759
|
-
return isProteosError(error) && error.httpStatus === 400;
|
|
760
|
-
}
|
|
761
|
-
function isConflict(error) {
|
|
762
|
-
return isProteosError(error) && error.httpStatus === 409;
|
|
763
|
-
}
|
|
764
|
-
function getDefaultErrorCode(httpStatus) {
|
|
765
|
-
switch (httpStatus) {
|
|
766
|
-
case 400:
|
|
767
|
-
return ErrorCode.BAD_REQUEST;
|
|
768
|
-
case 401:
|
|
769
|
-
return ErrorCode.UNAUTHORIZED;
|
|
770
|
-
case 403:
|
|
771
|
-
return ErrorCode.FORBIDDEN;
|
|
772
|
-
case 404:
|
|
773
|
-
return ErrorCode.NOT_FOUND;
|
|
774
|
-
case 409:
|
|
775
|
-
return ErrorCode.CONFLICT;
|
|
776
|
-
default:
|
|
777
|
-
return ErrorCode.INTERNAL_SERVER_ERROR;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
async function parseErrorResponse(response) {
|
|
781
|
-
const httpStatus = response.status;
|
|
782
|
-
let code = getDefaultErrorCode(httpStatus);
|
|
783
|
-
let message = "Unknown error";
|
|
784
|
-
try {
|
|
785
|
-
const body = await response.text();
|
|
786
|
-
try {
|
|
787
|
-
const json = JSON.parse(body);
|
|
788
|
-
if (json.code) {
|
|
789
|
-
code = json.code;
|
|
790
|
-
}
|
|
791
|
-
if (json.message) {
|
|
792
|
-
message = json.message;
|
|
793
|
-
} else {
|
|
794
|
-
message = body || `HTTP ${httpStatus}`;
|
|
795
|
-
}
|
|
796
|
-
} catch {
|
|
797
|
-
message = body.trim() || `HTTP ${httpStatus}`;
|
|
798
|
-
}
|
|
799
|
-
} catch {
|
|
800
|
-
message = `HTTP ${httpStatus}`;
|
|
801
|
-
}
|
|
802
|
-
return new ProteosError(message, httpStatus, code);
|
|
803
|
-
}
|
|
804
|
-
|
|
805
995
|
// src/http/query-params.ts
|
|
806
996
|
function toQueryParams(obj) {
|
|
807
997
|
const params = new URLSearchParams();
|
|
@@ -1436,6 +1626,9 @@ var ContactServiceImpl = class {
|
|
|
1436
1626
|
`${CONVERSATION_BASE_PATH}/contacts/${encodeURIComponent(id)}`
|
|
1437
1627
|
);
|
|
1438
1628
|
}
|
|
1629
|
+
create(request) {
|
|
1630
|
+
return this.client.request("POST", `${CONVERSATION_BASE_PATH}/contacts`, request);
|
|
1631
|
+
}
|
|
1439
1632
|
update(id, request) {
|
|
1440
1633
|
return this.client.request(
|
|
1441
1634
|
"PATCH",
|
|
@@ -1456,6 +1649,28 @@ var ContactServiceImpl = class {
|
|
|
1456
1649
|
`${CONVERSATION_BASE_PATH}/contacts/${encodeURIComponent(contactId)}/addresses/${encodeURIComponent(addressId)}`
|
|
1457
1650
|
);
|
|
1458
1651
|
}
|
|
1652
|
+
linkRecord(request) {
|
|
1653
|
+
return this.client.request("POST", `${CONVERSATION_BASE_PATH}/contact-record-links`, request);
|
|
1654
|
+
}
|
|
1655
|
+
listRecordLinks(query = {}) {
|
|
1656
|
+
return this.client.requestWithQuery(
|
|
1657
|
+
"GET",
|
|
1658
|
+
`${CONVERSATION_BASE_PATH}/contact-record-links`,
|
|
1659
|
+
query
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
getRecordLink(linkId) {
|
|
1663
|
+
return this.client.request(
|
|
1664
|
+
"GET",
|
|
1665
|
+
`${CONVERSATION_BASE_PATH}/contact-record-links/${encodeURIComponent(linkId)}`
|
|
1666
|
+
);
|
|
1667
|
+
}
|
|
1668
|
+
unlinkRecord(linkId) {
|
|
1669
|
+
return this.client.request(
|
|
1670
|
+
"DELETE",
|
|
1671
|
+
`${CONVERSATION_BASE_PATH}/contact-record-links/${encodeURIComponent(linkId)}`
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1459
1674
|
merge(contactId, request) {
|
|
1460
1675
|
return this.client.request(
|
|
1461
1676
|
"POST",
|
|
@@ -2219,6 +2434,9 @@ var GraphServiceImpl = class {
|
|
|
2219
2434
|
if (options.label_ids && options.label_ids.length > 0) {
|
|
2220
2435
|
query.label_ids = options.label_ids.join(",");
|
|
2221
2436
|
}
|
|
2437
|
+
if (options.space_slugs && options.space_slugs.length > 0) {
|
|
2438
|
+
query.space_slugs = options.space_slugs.join(",");
|
|
2439
|
+
}
|
|
2222
2440
|
return this.client.requestWithQuery("GET", GRAPH_BASE_PATH, query);
|
|
2223
2441
|
}
|
|
2224
2442
|
};
|
|
@@ -2292,11 +2510,14 @@ var NodeServiceImpl = class {
|
|
|
2292
2510
|
return new PageIterator((opts) => this.listPage(opts), options);
|
|
2293
2511
|
}
|
|
2294
2512
|
async listPage(options = {}) {
|
|
2295
|
-
const { label_ids, ...rest } = options;
|
|
2513
|
+
const { label_ids, space_slugs, ...rest } = options;
|
|
2296
2514
|
const query = { ...rest };
|
|
2297
2515
|
if (label_ids && label_ids.length > 0) {
|
|
2298
2516
|
query.label_ids = label_ids.join(",");
|
|
2299
2517
|
}
|
|
2518
|
+
if (space_slugs && space_slugs.length > 0) {
|
|
2519
|
+
query.space_slugs = space_slugs.join(",");
|
|
2520
|
+
}
|
|
2300
2521
|
return this.client.requestWithQuery(
|
|
2301
2522
|
"GET",
|
|
2302
2523
|
NODES_BASE_PATH,
|
|
@@ -2375,6 +2596,37 @@ var NodeServiceImpl = class {
|
|
|
2375
2596
|
}
|
|
2376
2597
|
};
|
|
2377
2598
|
|
|
2599
|
+
// src/knowledge/spaces.ts
|
|
2600
|
+
var SPACES_BASE_PATH = "/knowledge/v1/spaces";
|
|
2601
|
+
var SpaceServiceImpl = class {
|
|
2602
|
+
constructor(client) {
|
|
2603
|
+
this.client = client;
|
|
2604
|
+
}
|
|
2605
|
+
client;
|
|
2606
|
+
list(options = {}) {
|
|
2607
|
+
return new PageIterator((opts) => this.listPage(opts), options);
|
|
2608
|
+
}
|
|
2609
|
+
async listPage(options = {}) {
|
|
2610
|
+
return this.client.requestWithQuery(
|
|
2611
|
+
"GET",
|
|
2612
|
+
SPACES_BASE_PATH,
|
|
2613
|
+
options
|
|
2614
|
+
);
|
|
2615
|
+
}
|
|
2616
|
+
async get(slug) {
|
|
2617
|
+
return this.client.request("GET", `${SPACES_BASE_PATH}/${slug}`);
|
|
2618
|
+
}
|
|
2619
|
+
async create(request) {
|
|
2620
|
+
return this.client.request("POST", SPACES_BASE_PATH, request);
|
|
2621
|
+
}
|
|
2622
|
+
async update(slug, request) {
|
|
2623
|
+
return this.client.request("PATCH", `${SPACES_BASE_PATH}/${slug}`, request);
|
|
2624
|
+
}
|
|
2625
|
+
async delete(slug) {
|
|
2626
|
+
await this.client.request("DELETE", `${SPACES_BASE_PATH}/${slug}`);
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
|
|
2378
2630
|
// src/knowledge/record-links.ts
|
|
2379
2631
|
var RECORD_LINKS_BASE_PATH = "/knowledge/v1/record-links";
|
|
2380
2632
|
var RecordLinkServiceImpl = class {
|
|
@@ -2402,6 +2654,7 @@ var RecordLinkServiceImpl = class {
|
|
|
2402
2654
|
await this.client.request("DELETE", `${RECORD_LINKS_BASE_PATH}/${id}`);
|
|
2403
2655
|
}
|
|
2404
2656
|
};
|
|
2657
|
+
var UNASSIGNED_SPACE_SLUG = "__unassigned__";
|
|
2405
2658
|
var KnowledgeNodeMetadataSchema = z.object({
|
|
2406
2659
|
id: z.string(),
|
|
2407
2660
|
org_id: z.string(),
|
|
@@ -2492,6 +2745,11 @@ var KnowledgeClient = class {
|
|
|
2492
2745
|
/** Node→record edges (links to data-service records): `knowledge.recordLinks`. */
|
|
2493
2746
|
recordLinks;
|
|
2494
2747
|
labels;
|
|
2748
|
+
/**
|
|
2749
|
+
* Knowledge spaces — the containers nodes live in: `knowledge.spaces`.
|
|
2750
|
+
* Access to a space is granted through `auth.shares`, not here.
|
|
2751
|
+
*/
|
|
2752
|
+
spaces;
|
|
2495
2753
|
/** Whole-org graph bulk read (radiant graph view): `knowledge.graph.get()`. */
|
|
2496
2754
|
graph;
|
|
2497
2755
|
constructor(client) {
|
|
@@ -2499,6 +2757,7 @@ var KnowledgeClient = class {
|
|
|
2499
2757
|
this.links = new LinkServiceImpl(client);
|
|
2500
2758
|
this.recordLinks = new RecordLinkServiceImpl(client);
|
|
2501
2759
|
this.labels = new LabelServiceImpl(client);
|
|
2760
|
+
this.spaces = new SpaceServiceImpl(client);
|
|
2502
2761
|
this.graph = new GraphServiceImpl(client);
|
|
2503
2762
|
}
|
|
2504
2763
|
};
|
|
@@ -2784,6 +3043,6 @@ var WorkflowClient = class {
|
|
|
2784
3043
|
}
|
|
2785
3044
|
};
|
|
2786
3045
|
|
|
2787
|
-
export { AccountClient, ActionSchema, ActionScopeSchema, AgentClient, BatchTransactionErrorSchema, BatchUpsertRecordsResponseSchema, BatchUpsertTransactionResultSchema, BatchUpsertTransactionSchema, ConnectorClient, ConversationClient, DEFAULT_OPTIONS, DEFAULT_PORT, DataClient, ERROR_PORT, ErrorCode, EventsClient, FunctionsClient, KnowledgeClient, KnowledgeLabelSchema, KnowledgeLinkSchema, KnowledgeNodeLabelSchema, KnowledgeNodeMetadataSchema, KnowledgeNodeSchema, KnowledgeNodeSearchResultSchema, KnowledgeRecordLinkSchema, NodeNeighborhoodSchema, OrganizationSchema, PLATFORM_ENTITIES, PLATFORM_ENTITY_SLUGS, ProteosClient, ProteosError, RoleEntityPermissionSchema, RoleSchema, StorageClient, UserRoleAssignmentSchema, UserSchema, WorkflowClient, buildUrl, getDefaultErrorCode, isBadRequest, isConflict, isForbidden, isNotFound, isPlatformEntity, isProteosError, isUnauthorized, parseErrorResponse, resolveOptions, toQueryParams, toQueryString };
|
|
3046
|
+
export { AccountClient, ActionSchema, ActionScopeSchema, AgentClient, BatchTransactionErrorSchema, BatchUpsertRecordsResponseSchema, BatchUpsertTransactionResultSchema, BatchUpsertTransactionSchema, ConnectorClient, ConversationClient, DEFAULT_OPTIONS, DEFAULT_PORT, DataClient, ERROR_PORT, ErrorCode, EventsClient, FunctionsClient, KnowledgeClient, KnowledgeLabelSchema, KnowledgeLinkSchema, KnowledgeNodeLabelSchema, KnowledgeNodeMetadataSchema, KnowledgeNodeSchema, KnowledgeNodeSearchResultSchema, KnowledgeRecordLinkSchema, NodeNeighborhoodSchema, OrganizationSchema, PLATFORM_ENTITIES, PLATFORM_ENTITY_SLUGS, ProteosClient, ProteosError, RoleEntityPermissionSchema, RoleSchema, SCOPED_PLATFORM_ENTITY_SLUGS, StorageClient, UNASSIGNED_SPACE_SLUG, UserRoleAssignmentSchema, UserSchema, WorkflowClient, buildUrl, getDefaultErrorCode, isBadRequest, isConflict, isForbidden, isNotFound, isPlatformEntity, isProteosError, isShareable, isUnauthorized, parseErrorResponse, resolveOptions, shareRouteFor, toQueryParams, toQueryString };
|
|
2788
3047
|
//# sourceMappingURL=index.js.map
|
|
2789
3048
|
//# sourceMappingURL=index.js.map
|