@xemahq/kernel-contracts 0.25.0 → 0.27.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/biome/index.d.ts +1 -0
- package/dist/biome/index.d.ts.map +1 -1
- package/dist/biome/index.js +1 -0
- package/dist/biome/index.js.map +1 -1
- package/dist/biome/lib/biome-kind.d.ts +9 -0
- package/dist/biome/lib/biome-kind.d.ts.map +1 -0
- package/dist/biome/lib/biome-kind.js +13 -0
- package/dist/biome/lib/biome-kind.js.map +1 -0
- package/dist/biome/lib/biome-manifest.d.ts +9 -0
- package/dist/biome/lib/biome-manifest.d.ts.map +1 -1
- package/dist/biome/lib/biome-manifest.js +10 -0
- package/dist/biome/lib/biome-manifest.js.map +1 -1
- package/dist/connector/index.d.ts +1 -0
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -0
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/lib/connector-adapter-kind.d.ts +9 -0
- package/dist/connector/lib/connector-adapter-kind.d.ts.map +1 -0
- package/dist/connector/lib/connector-adapter-kind.js +13 -0
- package/dist/connector/lib/connector-adapter-kind.js.map +1 -0
- package/dist/connector/lib/connector-descriptor.d.ts +29 -1
- package/dist/connector/lib/connector-descriptor.d.ts.map +1 -1
- package/dist/connector/lib/connector-descriptor.js +10 -1
- package/dist/connector/lib/connector-descriptor.js.map +1 -1
- package/dist/connector/lib/integration-provider-contribution.d.ts +6 -0
- package/dist/connector/lib/integration-provider-contribution.d.ts.map +1 -1
- package/dist/object/lib/xema-object-ref.d.ts +5 -0
- package/dist/object/lib/xema-object-ref.d.ts.map +1 -1
- package/dist/object/lib/xema-object-ref.js +3 -2
- package/dist/object/lib/xema-object-ref.js.map +1 -1
- package/dist/search-source/index.d.ts +1 -0
- package/dist/search-source/index.d.ts.map +1 -1
- package/dist/search-source/index.js +1 -0
- package/dist/search-source/index.js.map +1 -1
- package/dist/search-source/lib/indexable-document.d.ts +28 -8
- package/dist/search-source/lib/indexable-document.d.ts.map +1 -1
- package/dist/search-source/lib/indexable-document.js +11 -4
- package/dist/search-source/lib/indexable-document.js.map +1 -1
- package/dist/search-source/lib/search-index-event.d.ts +30 -10
- package/dist/search-source/lib/search-index-event.d.ts.map +1 -1
- package/dist/search-source/lib/search-index-event.js +2 -3
- package/dist/search-source/lib/search-index-event.js.map +1 -1
- package/dist/search-source/lib/search-ref.d.ts +17 -0
- package/dist/search-source/lib/search-ref.d.ts.map +1 -0
- package/dist/search-source/lib/search-ref.js +72 -0
- package/dist/search-source/lib/search-ref.js.map +1 -0
- package/dist/search-source/lib/search-replay.d.ts +17 -4
- package/dist/search-source/lib/search-replay.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/biome/index.ts +1 -0
- package/src/biome/lib/biome-kind.ts +37 -0
- package/src/biome/lib/biome-manifest.ts +29 -0
- package/src/connector/index.ts +1 -0
- package/src/connector/lib/connector-adapter-kind.ts +44 -0
- package/src/connector/lib/connector-descriptor.ts +95 -1
- package/src/object/lib/xema-object-ref.ts +15 -3
- package/src/search-source/index.ts +1 -0
- package/src/search-source/lib/indexable-document.ts +72 -21
- package/src/search-source/lib/search-index-event.ts +10 -7
- package/src/search-source/lib/search-ref.ts +153 -0
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IndexableDocumentSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const object_1 = require("../../object");
|
|
6
|
+
const resource_1 = require("../../resource");
|
|
7
|
+
const space_1 = require("../../space");
|
|
8
|
+
const subject_1 = require("../../subject");
|
|
5
9
|
exports.IndexableDocumentSchema = zod_1.z
|
|
6
10
|
.object({
|
|
7
|
-
|
|
11
|
+
ref: object_1.XemaObjectRefSchema,
|
|
8
12
|
docType: zod_1.z.string().min(1),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
kind: object_1.XemaObjectKindSchema.optional(),
|
|
14
|
+
scope: space_1.SpaceRefSchema,
|
|
15
|
+
owner: subject_1.SubjectRefSchema,
|
|
16
|
+
classification: space_1.DataClassificationSchema.optional(),
|
|
17
|
+
resourceType: zod_1.z.string().min(1),
|
|
18
|
+
visibility: resource_1.ResourceVisibilityPatternSchema,
|
|
12
19
|
title: zod_1.z.string().optional(),
|
|
13
20
|
summary: zod_1.z.string().optional(),
|
|
14
21
|
content: zod_1.z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexable-document.js","sourceRoot":"","sources":["../../../src/search-source/lib/indexable-document.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;
|
|
1
|
+
{"version":3,"file":"indexable-document.js","sourceRoot":"","sources":["../../../src/search-source/lib/indexable-document.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,yCAKsB;AACtB,6CAGwB;AACxB,uCAKqB;AACrB,2CAAkE;AA4FrD,QAAA,uBAAuB,GAAG,OAAC;KACrC,MAAM,CAAC;IACN,GAAG,EAAE,4BAAmB;IACxB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,6BAAoB,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,sBAAc;IACrB,KAAK,EAAE,0BAAgB;IACvB,cAAc,EAAE,gCAAwB,CAAC,QAAQ,EAAE;IACnD,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,0CAA+B;IAC3C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtD,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type SpaceRef } from '../../space';
|
|
2
3
|
import { type IndexableDocument } from './indexable-document';
|
|
3
4
|
export declare enum SearchIndexOp {
|
|
4
5
|
Upsert = "upsert",
|
|
@@ -12,21 +13,32 @@ export interface SearchIndexUpsert {
|
|
|
12
13
|
}
|
|
13
14
|
export interface SearchIndexDelete {
|
|
14
15
|
readonly op: SearchIndexOp.Delete;
|
|
15
|
-
readonly
|
|
16
|
+
readonly scope: SpaceRef;
|
|
16
17
|
readonly docType: string;
|
|
17
18
|
readonly sourceId: string;
|
|
18
|
-
readonly orgId: string;
|
|
19
|
-
readonly projectId?: string;
|
|
20
19
|
}
|
|
21
20
|
export type SearchIndexChange = SearchIndexUpsert | SearchIndexDelete;
|
|
22
21
|
export declare const SearchIndexUpsertSchema: z.ZodObject<{
|
|
23
22
|
op: z.ZodLiteral<SearchIndexOp.Upsert>;
|
|
24
23
|
document: z.ZodObject<{
|
|
25
|
-
|
|
24
|
+
ref: z.ZodString & z.ZodType<`xema://${string}`, string, z.core.$ZodTypeInternals<`xema://${string}`, string>>;
|
|
26
25
|
docType: z.ZodString;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
kind: z.ZodOptional<z.ZodEnum<typeof import("../../object").XemaObjectKind>>;
|
|
27
|
+
scope: z.ZodObject<{
|
|
28
|
+
tier: z.ZodEnum<typeof import("../../space").SpaceKind>;
|
|
29
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
biomeId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
path: z.ZodOptional<z.ZodString>;
|
|
36
|
+
classification: z.ZodOptional<z.ZodEnum<typeof import("../../space").DataClassification>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
owner: z.ZodType<import("../../subject").SubjectRef, unknown, z.core.$ZodTypeInternals<import("../../subject").SubjectRef, unknown>>;
|
|
39
|
+
classification: z.ZodOptional<z.ZodEnum<typeof import("../../space").DataClassification>>;
|
|
40
|
+
resourceType: z.ZodString;
|
|
41
|
+
visibility: z.ZodEnum<typeof import("../../resource").ResourceVisibilityPattern>;
|
|
30
42
|
title: z.ZodOptional<z.ZodString>;
|
|
31
43
|
summary: z.ZodOptional<z.ZodString>;
|
|
32
44
|
content: z.ZodOptional<z.ZodString>;
|
|
@@ -44,10 +56,18 @@ export declare const SearchIndexUpsertSchema: z.ZodObject<{
|
|
|
44
56
|
}, z.core.$strict>;
|
|
45
57
|
export declare const SearchIndexDeleteSchema: z.ZodObject<{
|
|
46
58
|
op: z.ZodLiteral<SearchIndexOp.Delete>;
|
|
47
|
-
|
|
59
|
+
scope: z.ZodObject<{
|
|
60
|
+
tier: z.ZodEnum<typeof import("../../space").SpaceKind>;
|
|
61
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
biomeId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
path: z.ZodOptional<z.ZodString>;
|
|
68
|
+
classification: z.ZodOptional<z.ZodEnum<typeof import("../../space").DataClassification>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
48
70
|
docType: z.ZodString;
|
|
49
71
|
sourceId: z.ZodString;
|
|
50
|
-
orgId: z.ZodString;
|
|
51
|
-
projectId: z.ZodOptional<z.ZodString>;
|
|
52
72
|
}, z.core.$strict>;
|
|
53
73
|
//# sourceMappingURL=search-index-event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-index-event.d.ts","sourceRoot":"","sources":["../../../src/search-source/lib/search-index-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKvF,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAQD,eAAO,MAAM,8BAA8B,EAAG,qBAA8B,CAAC;AAC7E,eAAO,MAAM,8BAA8B,EAAG,qBAA8B,CAAC;AAG7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;CACtC;
|
|
1
|
+
{"version":3,"file":"search-index-event.d.ts","sourceRoot":"","sources":["../../../src/search-source/lib/search-index-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKvF,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAQD,eAAO,MAAM,8BAA8B,EAAG,qBAA8B,CAAC;AAC7E,eAAO,MAAM,8BAA8B,EAAG,qBAA8B,CAAC;AAG7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;CACtC;AASD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEtE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKzB,CAAC;AAEZ,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;kBAOzB,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SearchIndexDeleteSchema = exports.SearchIndexUpsertSchema = exports.SEARCH_INDEX_DELETE_EVENT_TYPE = exports.SEARCH_INDEX_UPSERT_EVENT_TYPE = exports.SearchIndexOp = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const space_1 = require("../../space");
|
|
5
6
|
const indexable_document_1 = require("./indexable-document");
|
|
6
7
|
var SearchIndexOp;
|
|
7
8
|
(function (SearchIndexOp) {
|
|
@@ -19,11 +20,9 @@ exports.SearchIndexUpsertSchema = zod_1.z
|
|
|
19
20
|
exports.SearchIndexDeleteSchema = zod_1.z
|
|
20
21
|
.object({
|
|
21
22
|
op: zod_1.z.literal(SearchIndexOp.Delete),
|
|
22
|
-
|
|
23
|
+
scope: space_1.SpaceRefSchema,
|
|
23
24
|
docType: zod_1.z.string().min(1),
|
|
24
25
|
sourceId: zod_1.z.string().min(1),
|
|
25
|
-
orgId: zod_1.z.string().min(1),
|
|
26
|
-
projectId: zod_1.z.string().min(1).optional(),
|
|
27
26
|
})
|
|
28
27
|
.strict();
|
|
29
28
|
//# sourceMappingURL=search-index-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-index-event.js","sourceRoot":"","sources":["../../../src/search-source/lib/search-index-event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,6DAAuF;AAKvF,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAQY,QAAA,8BAA8B,GAAG,qBAA8B,CAAC;AAChE,QAAA,8BAA8B,GAAG,qBAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"search-index-event.js","sourceRoot":"","sources":["../../../src/search-source/lib/search-index-event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,uCAA4D;AAC5D,6DAAuF;AAKvF,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAQY,QAAA,8BAA8B,GAAG,qBAA8B,CAAC;AAChE,QAAA,8BAA8B,GAAG,qBAA8B,CAAC;AAwBhE,QAAA,uBAAuB,GAAG,OAAC;KACrC,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,4CAAuB;CAClC,CAAC;KACD,MAAM,EAAE,CAAC;AAEC,QAAA,uBAAuB,GAAG,OAAC;KACrC,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,sBAAc;IACrB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5B,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type XemaObjectRef } from '../../object';
|
|
2
|
+
import { type SpaceRef } from '../../space';
|
|
3
|
+
export declare class SearchRefParseError extends Error {
|
|
4
|
+
readonly code = "SEARCH_REF_INVALID";
|
|
5
|
+
readonly ref: string;
|
|
6
|
+
readonly reason: string;
|
|
7
|
+
constructor(ref: string, reason: string);
|
|
8
|
+
}
|
|
9
|
+
export interface SearchRefParts {
|
|
10
|
+
readonly scope: SpaceRef;
|
|
11
|
+
readonly docType: string;
|
|
12
|
+
readonly sourceId: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function formatSearchRef(scope: SpaceRef, docType: string, sourceId: string): XemaObjectRef;
|
|
15
|
+
export declare function parseSearchRef(ref: string): SearchRefParts;
|
|
16
|
+
export declare function searchDocumentScope(orgId: string, projectId?: string): SpaceRef;
|
|
17
|
+
//# sourceMappingURL=search-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-ref.d.ts","sourceRoot":"","sources":["../../../src/search-source/lib/search-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkCvE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAgB,IAAI,wBAAwB;IAC5C,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM/C;AAGD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AA4BD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,aAAa,CAKf;AAQD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CA6B1D;AAUD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,GACjB,QAAQ,CASV"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchRefParseError = void 0;
|
|
4
|
+
exports.formatSearchRef = formatSearchRef;
|
|
5
|
+
exports.parseSearchRef = parseSearchRef;
|
|
6
|
+
exports.searchDocumentScope = searchDocumentScope;
|
|
7
|
+
const object_1 = require("../../object");
|
|
8
|
+
const space_1 = require("../../space");
|
|
9
|
+
const SEARCH_REF_PREFIX = 'xema://';
|
|
10
|
+
const DOC_TYPE_PATTERN = /^[a-z0-9][a-z0-9_.-]*$/;
|
|
11
|
+
class SearchRefParseError extends Error {
|
|
12
|
+
code = 'SEARCH_REF_INVALID';
|
|
13
|
+
ref;
|
|
14
|
+
reason;
|
|
15
|
+
constructor(ref, reason) {
|
|
16
|
+
super(`Invalid search ref "${ref}": ${reason}`);
|
|
17
|
+
this.name = 'SearchRefParseError';
|
|
18
|
+
this.ref = ref;
|
|
19
|
+
this.reason = reason;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.SearchRefParseError = SearchRefParseError;
|
|
23
|
+
function assertValidDocType(docType, refForError) {
|
|
24
|
+
if (!DOC_TYPE_PATTERN.test(docType)) {
|
|
25
|
+
throw new SearchRefParseError(refForError, `docType "${docType}" must match ${DOC_TYPE_PATTERN}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function assertValidSourceId(sourceId, refForError) {
|
|
29
|
+
if (sourceId.length === 0) {
|
|
30
|
+
throw new SearchRefParseError(refForError, 'sourceId must be non-empty');
|
|
31
|
+
}
|
|
32
|
+
if (/[/\s]/.test(sourceId)) {
|
|
33
|
+
throw new SearchRefParseError(refForError, `sourceId "${sourceId}" must not contain "/" or whitespace`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function formatSearchRef(scope, docType, sourceId) {
|
|
37
|
+
assertValidDocType(docType, '<unformatted>');
|
|
38
|
+
assertValidSourceId(sourceId, '<unformatted>');
|
|
39
|
+
const scopePath = (0, space_1.spaceRefToPath)(scope).replace(/^\//, '');
|
|
40
|
+
return `${SEARCH_REF_PREFIX}${scopePath}/${docType}/${sourceId}`;
|
|
41
|
+
}
|
|
42
|
+
function parseSearchRef(ref) {
|
|
43
|
+
if (!ref.startsWith(SEARCH_REF_PREFIX)) {
|
|
44
|
+
throw new SearchRefParseError(ref, `must start with "${SEARCH_REF_PREFIX}"`);
|
|
45
|
+
}
|
|
46
|
+
const body = ref.slice(SEARCH_REF_PREFIX.length);
|
|
47
|
+
if (body.length === 0) {
|
|
48
|
+
throw new SearchRefParseError(ref, 'empty body after scheme');
|
|
49
|
+
}
|
|
50
|
+
const segments = body.split('/').filter((segment) => segment.length > 0);
|
|
51
|
+
if (segments.length < 3) {
|
|
52
|
+
throw new SearchRefParseError(ref, 'must contain at least <scope>/<docType>/<sourceId>');
|
|
53
|
+
}
|
|
54
|
+
const { scope, consumed } = (0, object_1.parseObjectRefScopeSegments)(segments, ref);
|
|
55
|
+
const remaining = segments.slice(consumed);
|
|
56
|
+
if (remaining.length !== 2) {
|
|
57
|
+
throw new SearchRefParseError(ref, `expected exactly <docType>/<sourceId> after the scope segments, got ${remaining.length}`);
|
|
58
|
+
}
|
|
59
|
+
const [docType, sourceId] = remaining;
|
|
60
|
+
assertValidDocType(docType, ref);
|
|
61
|
+
assertValidSourceId(sourceId, ref);
|
|
62
|
+
return { scope, docType, sourceId };
|
|
63
|
+
}
|
|
64
|
+
function searchDocumentScope(orgId, projectId) {
|
|
65
|
+
if (!orgId) {
|
|
66
|
+
throw new Error('searchDocumentScope: orgId is required to scope a searchable document');
|
|
67
|
+
}
|
|
68
|
+
return projectId
|
|
69
|
+
? { tier: space_1.SpaceKind.Project, orgId, projectId }
|
|
70
|
+
: { tier: space_1.SpaceKind.Org, orgId };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=search-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-ref.js","sourceRoot":"","sources":["../../../src/search-source/lib/search-ref.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,11 +22,24 @@ export declare const SearchReplayRequestSchema: z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strict>;
|
|
23
23
|
export declare const SearchReplayResponseSchema: z.ZodObject<{
|
|
24
24
|
documents: z.ZodArray<z.ZodObject<{
|
|
25
|
-
|
|
25
|
+
ref: z.ZodString & z.ZodType<`xema://${string}`, string, z.core.$ZodTypeInternals<`xema://${string}`, string>>;
|
|
26
26
|
docType: z.ZodString;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
kind: z.ZodOptional<z.ZodEnum<typeof import("../../object").XemaObjectKind>>;
|
|
28
|
+
scope: z.ZodObject<{
|
|
29
|
+
tier: z.ZodEnum<typeof import("../../space").SpaceKind>;
|
|
30
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
biomeId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
36
|
+
path: z.ZodOptional<z.ZodString>;
|
|
37
|
+
classification: z.ZodOptional<z.ZodEnum<typeof import("../../space").DataClassification>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
owner: z.ZodType<import("../../subject").SubjectRef, unknown, z.core.$ZodTypeInternals<import("../../subject").SubjectRef, unknown>>;
|
|
40
|
+
classification: z.ZodOptional<z.ZodEnum<typeof import("../../space").DataClassification>>;
|
|
41
|
+
resourceType: z.ZodString;
|
|
42
|
+
visibility: z.ZodEnum<typeof import("../../resource").ResourceVisibilityPattern>;
|
|
30
43
|
title: z.ZodOptional<z.ZodString>;
|
|
31
44
|
summary: z.ZodOptional<z.ZodString>;
|
|
32
45
|
content: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-replay.d.ts","sourceRoot":"","sources":["../../../src/search-source/lib/search-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AASvF,eAAO,MAAM,6BAA6B,EAAG,eAAwB,CAAC;AAOtE,eAAO,MAAM,8BAA8B,EAAG,CAAU,CAAC;AAWzD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAcD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhE;AAOD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAOD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,yBAAyB;;;;;kBAO3B,CAAC;AAEZ,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"search-replay.d.ts","sourceRoot":"","sources":["../../../src/search-source/lib/search-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AASvF,eAAO,MAAM,6BAA6B,EAAG,eAAwB,CAAC;AAOtE,eAAO,MAAM,8BAA8B,EAAG,CAAU,CAAC;AAWzD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAcD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhE;AAOD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAOD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,yBAAyB;;;;;kBAO3B,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAK5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/kernel-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
|
package/src/biome/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './lib/biome-tier';
|
|
|
5
5
|
export * from './lib/biome-target';
|
|
6
6
|
export * from './lib/biome-audience';
|
|
7
7
|
export * from './lib/biome-origin';
|
|
8
|
+
export * from './lib/biome-kind';
|
|
8
9
|
export * from './lib/biome-trust-tier';
|
|
9
10
|
export * from './lib/biome-availability-grant';
|
|
10
11
|
export * from './lib/biome-lifecycle-hooks';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `BiomeKind` — WHAT kind of thing a biome is, orthogonal to its dependency
|
|
5
|
+
* tier (`BiomeTier`), audience (`BiomeAudience`), origin (`BiomeOrigin`), and
|
|
6
|
+
* install scope (`BiomeScope`). Declared as `xema.kind` in `xema-biome.json`.
|
|
7
|
+
*
|
|
8
|
+
* A Connector is NOT a new installable kind — it reuses the entire
|
|
9
|
+
* distribution / signing / source-registry / `biome-fetcher` machinery
|
|
10
|
+
* unchanged. `kind` is only a MARKER that lets the platform (a) list connectors
|
|
11
|
+
* in a dedicated store catalog, (b) enforce the connector-biome boundary
|
|
12
|
+
* (`tooling/boundaries/check-connector-biome.mjs`: a connector ships ≥1
|
|
13
|
+
* `integration-provider` contribution, NO web pages / product BFF, and NO
|
|
14
|
+
* cross-biome dependency), and (c) govern connectors distinctly. See
|
|
15
|
+
* `.claude/plans/connector-architecture-convergence.md`.
|
|
16
|
+
*
|
|
17
|
+
* - `app` — a normal product biome (the default): may ship web pages, a
|
|
18
|
+
* product BFF, agents, workflows, and depend on other biomes.
|
|
19
|
+
* - `connector` — a constrained, credential-bearing capability provider (a
|
|
20
|
+
* Connector Biome). Governed by the connector-biome boundary check.
|
|
21
|
+
* - `library` — a biome that only contributes reusable content (skills,
|
|
22
|
+
* capabilities, tool profiles) with no standalone product surface.
|
|
23
|
+
*
|
|
24
|
+
* Closed set; new values are a kernel change. OPTIONAL on the manifest — an
|
|
25
|
+
* existing `xema-biome.json` that omits `kind` stays valid and resolves to the
|
|
26
|
+
* default (`app`) via {@link DEFAULT_BIOME_KIND} / `getBiomeKind`.
|
|
27
|
+
*/
|
|
28
|
+
export enum BiomeKind {
|
|
29
|
+
App = 'app',
|
|
30
|
+
Connector = 'connector',
|
|
31
|
+
Library = 'library',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const BiomeKindSchema = z.nativeEnum(BiomeKind);
|
|
35
|
+
|
|
36
|
+
/** The default kind applied when a manifest omits `xema.kind`. */
|
|
37
|
+
export const DEFAULT_BIOME_KIND = BiomeKind.App;
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
DEFAULT_BIOME_AUDIENCE,
|
|
26
26
|
} from './biome-audience';
|
|
27
27
|
import { BiomeOriginSchema } from './biome-origin';
|
|
28
|
+
import { BiomeKind, BiomeKindSchema, DEFAULT_BIOME_KIND } from './biome-kind';
|
|
28
29
|
import {
|
|
29
30
|
BiomeEnginesSchema,
|
|
30
31
|
} from './biome-engines';
|
|
@@ -544,6 +545,16 @@ const XsiManifestExtensionsShape = {
|
|
|
544
545
|
* option). Resolve via `isBiomeStoreListed` — never read raw.
|
|
545
546
|
*/
|
|
546
547
|
storeListed: z.boolean().optional(),
|
|
548
|
+
/**
|
|
549
|
+
* WHAT kind of biome this is — `app` (default) | `connector` | `library`.
|
|
550
|
+
* OPTIONAL and ADDITIVE: an existing manifest that omits it stays valid and
|
|
551
|
+
* resolves to `app` via `getBiomeKind`. A `connector`-kind biome is a
|
|
552
|
+
* constrained capability provider enforced by
|
|
553
|
+
* `tooling/boundaries/check-connector-biome.mjs`. Resolve via `getBiomeKind`
|
|
554
|
+
* / `isConnectorBiome` — never read `xema.kind` raw, so the default is
|
|
555
|
+
* applied in exactly one place. See `BiomeKind` in `./biome-kind`.
|
|
556
|
+
*/
|
|
557
|
+
kind: BiomeKindSchema.optional(),
|
|
547
558
|
} as const;
|
|
548
559
|
|
|
549
560
|
/**
|
|
@@ -1085,3 +1096,21 @@ export function isBiomeStoreListed(manifest: BiomeManifest): boolean {
|
|
|
1085
1096
|
}
|
|
1086
1097
|
return manifest.xema.storeListed ?? true;
|
|
1087
1098
|
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Effective kind of a biome, applying the default (`app`) when the manifest
|
|
1102
|
+
* omits `xema.kind`. Never read `xema.kind` raw — go through this so the
|
|
1103
|
+
* default is applied in exactly one place.
|
|
1104
|
+
*/
|
|
1105
|
+
export function getBiomeKind(manifest: BiomeManifest): BiomeKind {
|
|
1106
|
+
return manifest.xema.kind ?? DEFAULT_BIOME_KIND;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Whether the biome is a Connector Biome (`xema.kind: "connector"`). A
|
|
1111
|
+
* connector is a constrained capability provider — see
|
|
1112
|
+
* `tooling/boundaries/check-connector-biome.mjs` for the enforced constraints.
|
|
1113
|
+
*/
|
|
1114
|
+
export function isConnectorBiome(manifest: BiomeManifest): boolean {
|
|
1115
|
+
return getBiomeKind(manifest) === BiomeKind.Connector;
|
|
1116
|
+
}
|
package/src/connector/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `ConnectorAdapterKind` — the unifying BACKEND discriminator for how a
|
|
5
|
+
* connector operation is actually executed server-side. It is deliberately
|
|
6
|
+
* hidden from agents: every operation is projected into ONE canonical
|
|
7
|
+
* `connector:<provider>.<verb>@N` capability and exposed through the single
|
|
8
|
+
* transparent capability-MCP; the adapter kind selects which backend the
|
|
9
|
+
* capability router dispatches to, but never leaks into the agent-facing tool
|
|
10
|
+
* surface.
|
|
11
|
+
*
|
|
12
|
+
* This enum is what converges the two historically-parallel connector paths —
|
|
13
|
+
* the `integration-provider` module path (`connector-gateway-api`) and the
|
|
14
|
+
* external-MCP / OpenAPI→MCP path (`mcp-gateway-api`) — into two BACKENDS of
|
|
15
|
+
* ONE Connector concept. See
|
|
16
|
+
* `.claude/plans/connector-architecture-convergence.md`.
|
|
17
|
+
*
|
|
18
|
+
* - `native-provider` — a biome-shipped `IntegrationProviderModule` executes
|
|
19
|
+
* the operation directly (the curated, code-capable connector: Gmail
|
|
20
|
+
* module, an SCM connector, …).
|
|
21
|
+
* - `external-mcp` — the operation is fulfilled by proxying a tool call to
|
|
22
|
+
* a registered external MCP server (the ad-hoc `OrgMcpServer` path).
|
|
23
|
+
* - `openapi-bridge` — the operation is fulfilled by an OpenAPI spec bridged
|
|
24
|
+
* into a tool (the "user adds openapi.json → MCP" path).
|
|
25
|
+
* - `email` — the operation is fulfilled by the generic
|
|
26
|
+
* `smtp`/`imap` gateway built-ins (mail send/fetch).
|
|
27
|
+
*
|
|
28
|
+
* Closed set; adding a member is a kernel change AND requires a matching
|
|
29
|
+
* dispatch branch in the capability router — do not add a member that has no
|
|
30
|
+
* backend.
|
|
31
|
+
*/
|
|
32
|
+
export enum ConnectorAdapterKind {
|
|
33
|
+
NativeProvider = 'native-provider',
|
|
34
|
+
ExternalMcp = 'external-mcp',
|
|
35
|
+
OpenApiBridge = 'openapi-bridge',
|
|
36
|
+
Email = 'email',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Zod mirror of {@link ConnectorAdapterKind} — value-identical to the enum.
|
|
41
|
+
* Used wherever an adapter kind crosses a trust boundary (a connector
|
|
42
|
+
* operation descriptor inside an `integration-provider` contribution).
|
|
43
|
+
*/
|
|
44
|
+
export const ConnectorAdapterKindSchema = z.nativeEnum(ConnectorAdapterKind);
|
|
@@ -20,10 +20,74 @@
|
|
|
20
20
|
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
|
|
23
|
+
import { CapabilityRefSchema, type CapabilityRef } from '../../capability';
|
|
24
|
+
|
|
23
25
|
import { CredentialKind } from './credential-kind';
|
|
26
|
+
import {
|
|
27
|
+
ConnectorAdapterKind,
|
|
28
|
+
ConnectorAdapterKindSchema,
|
|
29
|
+
} from './connector-adapter-kind';
|
|
24
30
|
|
|
25
31
|
import type { AdapterKindRef } from './adapter-kind';
|
|
26
32
|
|
|
33
|
+
/**
|
|
34
|
+
* One executable operation a connector projects into the capability plane.
|
|
35
|
+
*
|
|
36
|
+
* Each operation maps 1:1 onto a canonical `connector:<provider>.<verb>@N`
|
|
37
|
+
* {@link CapabilityRef} (`capabilityRef`) and names the {@link
|
|
38
|
+
* ConnectorAdapterKind} backend that fulfils it (`adapterKind`). Declaring
|
|
39
|
+
* operations on a descriptor makes the contribution → capability projection
|
|
40
|
+
* MECHANICAL: the connector registry emits one capability per operation rather
|
|
41
|
+
* than requiring a hand-authored capability contribution per verb.
|
|
42
|
+
*
|
|
43
|
+
* The block is ADDITIVE and OPTIONAL on {@link ConnectorDescriptor}: a
|
|
44
|
+
* descriptor that omits `operations` behaves exactly as before (its
|
|
45
|
+
* capabilities, if any, are declared out-of-band). When present, every
|
|
46
|
+
* operation is self-describing enough to drive the projection with no
|
|
47
|
+
* heuristics.
|
|
48
|
+
*/
|
|
49
|
+
export interface ConnectorOperationDescriptor {
|
|
50
|
+
/**
|
|
51
|
+
* The canonical capability this operation is exposed as. MUST be a
|
|
52
|
+
* `connector:<provider>.<verb>@<major>` ref — the ONE agent-facing grammar;
|
|
53
|
+
* the divergent `<slug>:<tool>@1` external-MCP grammar is retired in favour
|
|
54
|
+
* of this.
|
|
55
|
+
*/
|
|
56
|
+
readonly capabilityRef: CapabilityRef;
|
|
57
|
+
/**
|
|
58
|
+
* The BACKEND that executes this operation. Hidden from agents — it only
|
|
59
|
+
* selects the capability-router dispatch path.
|
|
60
|
+
*/
|
|
61
|
+
readonly adapterKind: ConnectorAdapterKind;
|
|
62
|
+
/**
|
|
63
|
+
* Incremental OAuth scopes THIS operation needs from the connector's
|
|
64
|
+
* provider, on top of what the connection already holds. A subset of the
|
|
65
|
+
* connector's `scopes`; empty for operations whose provider `appAuthKind` is
|
|
66
|
+
* `None` (IMAP/SMTP) or that need no additional scope. Drives the union the
|
|
67
|
+
* consent driver requests when the operation's capability is first granted.
|
|
68
|
+
*/
|
|
69
|
+
readonly scopes: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Whether executing this operation requires a resolved per-connection
|
|
72
|
+
* credential (a user/org token/password) via the credential broker. Almost
|
|
73
|
+
* always `true`; `false` only for operations backed purely by the provider's
|
|
74
|
+
* app credential with no per-connection secret. Explicit (never defaulted)
|
|
75
|
+
* so the broker resolution requirement is stated, not inferred.
|
|
76
|
+
*/
|
|
77
|
+
readonly requiresConnection: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Zod mirror of {@link ConnectorOperationDescriptor} — value-identical to the
|
|
82
|
+
* interface. Strict: unknown keys fail fast.
|
|
83
|
+
*/
|
|
84
|
+
export const ConnectorOperationDescriptorSchema = z.strictObject({
|
|
85
|
+
capabilityRef: CapabilityRefSchema,
|
|
86
|
+
adapterKind: ConnectorAdapterKindSchema,
|
|
87
|
+
scopes: z.array(z.string()).readonly(),
|
|
88
|
+
requiresConnection: z.boolean(),
|
|
89
|
+
});
|
|
90
|
+
|
|
27
91
|
/**
|
|
28
92
|
* A connector in the catalog. `connectorKey` aligns with the persisted
|
|
29
93
|
* `ConnectorKind` wire value (e.g. `GMAIL`, `IMAP_GENERIC`, `SMTP_GENERIC`)
|
|
@@ -67,6 +131,14 @@ export interface ConnectorDescriptor {
|
|
|
67
131
|
* surface the connector appears under.
|
|
68
132
|
*/
|
|
69
133
|
readonly adapterKind: AdapterKindRef;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The executable operations this connector projects into the capability
|
|
137
|
+
* plane. OPTIONAL and ADDITIVE — a descriptor without it is unchanged; when
|
|
138
|
+
* present, each entry drives a mechanical capability projection (see
|
|
139
|
+
* {@link ConnectorOperationDescriptor}).
|
|
140
|
+
*/
|
|
141
|
+
readonly operations?: readonly ConnectorOperationDescriptor[];
|
|
70
142
|
}
|
|
71
143
|
|
|
72
144
|
/**
|
|
@@ -85,12 +157,34 @@ export const ConnectorDescriptorSchema = z.strictObject({
|
|
|
85
157
|
scopes: z.array(z.string()).readonly(),
|
|
86
158
|
connectionCredentialKind: z.nativeEnum(CredentialKind),
|
|
87
159
|
adapterKind: z.string().min(1),
|
|
160
|
+
operations: z.array(ConnectorOperationDescriptorSchema).readonly().optional(),
|
|
88
161
|
});
|
|
89
162
|
|
|
90
163
|
// Compile-time value-identity guards: schema output <=> interface. The tuple
|
|
91
164
|
// export exists only so `noUnusedLocals` sees a use; no contract meaning.
|
|
165
|
+
// `AllowUndefinedOptionals` bridges zod's `?: T | undefined` optionals to the
|
|
166
|
+
// interfaces' exact optionals (`exactOptionalPropertyTypes`) — runtime shape
|
|
167
|
+
// is identical.
|
|
92
168
|
type AssertExtends<T extends U, U> = T;
|
|
169
|
+
type AllowUndefinedOptionals<T> = T extends readonly (infer E)[]
|
|
170
|
+
? readonly AllowUndefinedOptionals<E>[]
|
|
171
|
+
: T extends object
|
|
172
|
+
? { [K in keyof T]: AllowUndefinedOptionals<T[K]> | undefined }
|
|
173
|
+
: T;
|
|
174
|
+
export type ConnectorOperationDescriptorValueIdentityGuards = [
|
|
175
|
+
AssertExtends<
|
|
176
|
+
z.infer<typeof ConnectorOperationDescriptorSchema>,
|
|
177
|
+
ConnectorOperationDescriptor
|
|
178
|
+
>,
|
|
179
|
+
AssertExtends<
|
|
180
|
+
ConnectorOperationDescriptor,
|
|
181
|
+
z.infer<typeof ConnectorOperationDescriptorSchema>
|
|
182
|
+
>,
|
|
183
|
+
];
|
|
93
184
|
export type ConnectorDescriptorValueIdentityGuards = [
|
|
94
|
-
AssertExtends<
|
|
185
|
+
AssertExtends<
|
|
186
|
+
z.infer<typeof ConnectorDescriptorSchema>,
|
|
187
|
+
AllowUndefinedOptionals<ConnectorDescriptor>
|
|
188
|
+
>,
|
|
95
189
|
AssertExtends<ConnectorDescriptor, z.infer<typeof ConnectorDescriptorSchema>>,
|
|
96
190
|
];
|
|
@@ -69,7 +69,7 @@ const SLUG_SEGMENT = '[a-zA-Z0-9][a-zA-Z0-9_.-]*';
|
|
|
69
69
|
const SLUG_PATTERN = new RegExp(`^${SLUG_SEGMENT}(?:/${SLUG_SEGMENT})*$`);
|
|
70
70
|
const VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_.+-]*$/;
|
|
71
71
|
|
|
72
|
-
interface ScopeParse {
|
|
72
|
+
export interface ScopeParse {
|
|
73
73
|
scope: SpaceRef;
|
|
74
74
|
consumed: number;
|
|
75
75
|
}
|
|
@@ -87,7 +87,19 @@ function requireSegment(
|
|
|
87
87
|
return value;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Parse the leading scope segments of a `xema://` ref path into a
|
|
92
|
+
* {@link SpaceRef} plus the number of segments consumed. Shared by
|
|
93
|
+
* {@link parseXemaObjectRef} and the search-source `parseSearchRef` helper so
|
|
94
|
+
* the `xema://<scope-path>/...` scope grammar (plural `orgs`/`projects`, the
|
|
95
|
+
* same one {@link spaceRefToPath} formats) lives in exactly ONE place. The
|
|
96
|
+
* caller owns whatever follows the scope (a `<kind>/<slug>` for objects, a
|
|
97
|
+
* `<docType>/<sourceId>` for search refs).
|
|
98
|
+
*/
|
|
99
|
+
export function parseObjectRefScopeSegments(
|
|
100
|
+
segments: string[],
|
|
101
|
+
ref: string,
|
|
102
|
+
): ScopeParse {
|
|
91
103
|
const head = requireSegment(segments, 0, ref, 'scope');
|
|
92
104
|
switch (head) {
|
|
93
105
|
case 'system':
|
|
@@ -198,7 +210,7 @@ export function parseXemaObjectRef(ref: string): XemaObjectRefParts {
|
|
|
198
210
|
);
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
const { scope, consumed } =
|
|
213
|
+
const { scope, consumed } = parseObjectRefScopeSegments(segments, ref);
|
|
202
214
|
const remaining = segments.slice(consumed);
|
|
203
215
|
if (remaining.length < 2) {
|
|
204
216
|
throw new XemaObjectRefParseError(
|