@xemahq/kernel-contracts 0.38.0 → 0.40.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/canonical-object/index.d.ts +3 -0
- package/dist/canonical-object/index.d.ts.map +1 -0
- package/dist/canonical-object/index.js +19 -0
- package/dist/canonical-object/index.js.map +1 -0
- package/dist/canonical-object/lib/canonical-object-type-contribution.d.ts +14 -0
- package/dist/canonical-object/lib/canonical-object-type-contribution.d.ts.map +1 -0
- package/dist/canonical-object/lib/canonical-object-type-contribution.js +34 -0
- package/dist/canonical-object/lib/canonical-object-type-contribution.js.map +1 -0
- package/dist/canonical-object/lib/canonical-object-type.d.ts +5 -0
- package/dist/canonical-object/lib/canonical-object-type.d.ts.map +1 -0
- package/dist/canonical-object/lib/canonical-object-type.js +14 -0
- package/dist/canonical-object/lib/canonical-object-type.js.map +1 -0
- 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/canonical-operation-binding.d.ts +18 -0
- package/dist/connector/lib/canonical-operation-binding.d.ts.map +1 -0
- package/dist/connector/lib/canonical-operation-binding.js +76 -0
- package/dist/connector/lib/canonical-operation-binding.js.map +1 -0
- package/dist/connector/lib/connector-descriptor.d.ts +4 -0
- package/dist/connector/lib/connector-descriptor.d.ts.map +1 -1
- package/dist/connector/lib/connector-descriptor.js +12 -0
- package/dist/connector/lib/connector-descriptor.js.map +1 -1
- package/dist/connector/lib/integration-provider-contribution.d.ts +1 -0
- package/dist/connector/lib/integration-provider-contribution.d.ts.map +1 -1
- package/dist/contribution/lib/contribution-kind.d.ts +2 -1
- package/dist/contribution/lib/contribution-kind.d.ts.map +1 -1
- package/dist/contribution/lib/contribution-kind.js +1 -0
- package/dist/contribution/lib/contribution-kind.js.map +1 -1
- package/package.json +1 -1
- package/src/canonical-object/index.ts +2 -0
- package/src/canonical-object/lib/canonical-object-type-contribution.ts +108 -0
- package/src/canonical-object/lib/canonical-object-type.ts +49 -0
- package/src/connector/index.ts +1 -0
- package/src/connector/lib/canonical-operation-binding.ts +160 -0
- package/src/connector/lib/connector-descriptor.ts +29 -0
- package/src/contribution/lib/contribution-kind.ts +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonical-object/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/canonical-object-type"), exports);
|
|
18
|
+
__exportStar(require("./lib/canonical-object-type-contribution"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/canonical-object/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,2EAAyD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type CanonicalObjectTypeRef } from './canonical-object-type';
|
|
3
|
+
export interface CanonicalObjectTypeContributionManifest {
|
|
4
|
+
readonly key: CanonicalObjectTypeRef;
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly displayName: string;
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
readonly schema: Record<string, unknown>;
|
|
9
|
+
readonly naturalKeyFields: readonly string[];
|
|
10
|
+
readonly titleField?: string;
|
|
11
|
+
readonly category?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const CanonicalObjectTypeContributionManifestSchema: z.ZodType<CanonicalObjectTypeContributionManifest>;
|
|
14
|
+
//# sourceMappingURL=canonical-object-type-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-object-type-contribution.d.ts","sourceRoot":"","sources":["../../../src/canonical-object/lib/canonical-object-type-contribution.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAsBjC,MAAM,WAAW,uCAAuC;IAOtD,QAAQ,CAAC,GAAG,EAAE,sBAAsB,CAAC;IAErC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAO9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAMzC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,6CAA6C,EAAE,CAAC,CAAC,OAAO,CAAC,uCAAuC,CA0BtC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CanonicalObjectTypeContributionManifestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const canonical_object_type_1 = require("./canonical-object-type");
|
|
6
|
+
const CANONICAL_OBJECT_STRING_MAX = 200;
|
|
7
|
+
const NATURAL_KEY_FIELDS_MAX = 8;
|
|
8
|
+
const FieldNameSchema = zod_1.z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.max(CANONICAL_OBJECT_STRING_MAX)
|
|
12
|
+
.regex(/^[A-Za-z][A-Za-z0-9_]*$/, 'field name must be an identifier-like property of the object schema');
|
|
13
|
+
exports.CanonicalObjectTypeContributionManifestSchema = zod_1.z
|
|
14
|
+
.object({
|
|
15
|
+
key: canonical_object_type_1.CanonicalObjectTypeRefSchema,
|
|
16
|
+
version: canonical_object_type_1.CanonicalObjectTypeVersionSchema,
|
|
17
|
+
displayName: zod_1.z.string().min(1).max(CANONICAL_OBJECT_STRING_MAX),
|
|
18
|
+
description: zod_1.z.string().max(2000).optional(),
|
|
19
|
+
schema: zod_1.z
|
|
20
|
+
.record(zod_1.z.string(), zod_1.z.unknown())
|
|
21
|
+
.refine((s) => Object.keys(s).length > 0, 'schema must be a non-empty JSON Schema object'),
|
|
22
|
+
naturalKeyFields: zod_1.z
|
|
23
|
+
.array(FieldNameSchema)
|
|
24
|
+
.min(1, 'at least one natural-key field is required')
|
|
25
|
+
.max(NATURAL_KEY_FIELDS_MAX),
|
|
26
|
+
titleField: FieldNameSchema.optional(),
|
|
27
|
+
category: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.min(1)
|
|
30
|
+
.max(CANONICAL_OBJECT_STRING_MAX)
|
|
31
|
+
.regex(/^[a-z][a-z0-9-]*$/, 'category must be lower-kebab')
|
|
32
|
+
.optional(),
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=canonical-object-type-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-object-type-contribution.js","sourceRoot":"","sources":["../../../src/canonical-object/lib/canonical-object-type-contribution.ts"],"names":[],"mappings":";;;AAoBA,6BAAwB;AAExB,mEAIiC;AAGjC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAGxC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAGjC,MAAM,eAAe,GAAG,OAAC;KACtB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,2BAA2B,CAAC;KAChC,KAAK,CACJ,yBAAyB,EACzB,qEAAqE,CACtE,CAAC;AAuCS,QAAA,6CAA6C,GACxD,OAAC;KACE,MAAM,CAAC;IACN,GAAG,EAAE,oDAA4B;IACjC,OAAO,EAAE,wDAAgC;IACzC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,2BAA2B,CAAC;IAC/D,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IAG5C,MAAM,EAAE,OAAC;SACN,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,+CAA+C,CAAC;IAC5F,gBAAgB,EAAE,OAAC;SAChB,KAAK,CAAC,eAAe,CAAC;SACtB,GAAG,CAAC,CAAC,EAAE,4CAA4C,CAAC;SACpD,GAAG,CAAC,sBAAsB,CAAC;IAI9B,UAAU,EAAE,eAAe,CAAC,QAAQ,EAAE;IACtC,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,2BAA2B,CAAC;SAChC,KAAK,CAAC,mBAAmB,EAAE,8BAA8B,CAAC;SAC1D,QAAQ,EAAE;CACd,CAAkE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type CanonicalObjectTypeRef = string;
|
|
3
|
+
export declare const CanonicalObjectTypeRefSchema: z.ZodType<CanonicalObjectTypeRef>;
|
|
4
|
+
export declare const CanonicalObjectTypeVersionSchema: z.ZodString;
|
|
5
|
+
//# sourceMappingURL=canonical-object-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-object-type.d.ts","sourceRoot":"","sources":["../../../src/canonical-object/lib/canonical-object-type.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE5C,eAAO,MAAM,4BAA4B,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAOxE,CAAC;AAGJ,eAAO,MAAM,gCAAgC,aAE0B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CanonicalObjectTypeVersionSchema = exports.CanonicalObjectTypeRefSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const CANONICAL_OBJECT_TYPE_KEY_MAX = 100;
|
|
6
|
+
exports.CanonicalObjectTypeRefSchema = zod_1.z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(CANONICAL_OBJECT_TYPE_KEY_MAX)
|
|
10
|
+
.regex(/^[a-z][a-z0-9_]*$/, 'a canonical-object-type key must be lower_snake (e.g. sales_opportunity)');
|
|
11
|
+
exports.CanonicalObjectTypeVersionSchema = zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^\d+\.\d+\.\d+$/, 'version must be semver MAJOR.MINOR.PATCH');
|
|
14
|
+
//# sourceMappingURL=canonical-object-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-object-type.js","sourceRoot":"","sources":["../../../src/canonical-object/lib/canonical-object-type.ts"],"names":[],"mappings":";;;AAuBA,6BAAwB;AAGxB,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAU7B,QAAA,4BAA4B,GAAsC,OAAC;KAC7E,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,6BAA6B,CAAC;KAClC,KAAK,CACJ,mBAAmB,EACnB,0EAA0E,CAC3E,CAAC;AAGS,QAAA,gCAAgC,GAAG,OAAC;KAC9C,MAAM,EAAE;KACR,KAAK,CAAC,iBAAiB,EAAE,0CAA0C,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ export * from './lib/connector-adapter-kind';
|
|
|
3
3
|
export * from './lib/connector-http-request';
|
|
4
4
|
export * from './lib/capability';
|
|
5
5
|
export * from './lib/credential-kind';
|
|
6
|
+
export * from './lib/canonical-operation-binding';
|
|
6
7
|
export * from './lib/credential-strategy-contribution';
|
|
7
8
|
export * from './lib/onboarding-manifest';
|
|
8
9
|
export * from './lib/provider-descriptor';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC"}
|
package/dist/connector/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./lib/connector-adapter-kind"), exports);
|
|
|
19
19
|
__exportStar(require("./lib/connector-http-request"), exports);
|
|
20
20
|
__exportStar(require("./lib/capability"), exports);
|
|
21
21
|
__exportStar(require("./lib/credential-kind"), exports);
|
|
22
|
+
__exportStar(require("./lib/canonical-operation-binding"), exports);
|
|
22
23
|
__exportStar(require("./lib/credential-strategy-contribution"), exports);
|
|
23
24
|
__exportStar(require("./lib/onboarding-manifest"), exports);
|
|
24
25
|
__exportStar(require("./lib/provider-descriptor"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+DAA6C;AAC7C,+DAA6C;AAC7C,mDAAiC;AACjC,wDAAsC;AACtC,yEAAuD;AACvD,4DAA0C;AAC1C,4DAA0C;AAC1C,wDAAsC;AACtC,6DAA2C;AAC3C,wDAAsC;AACtC,oDAAkC;AAClC,2DAAyC;AACzC,6DAA2C;AAC3C,0EAAwD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+DAA6C;AAC7C,+DAA6C;AAC7C,mDAAiC;AACjC,wDAAsC;AACtC,oEAAkD;AAClD,yEAAuD;AACvD,4DAA0C;AAC1C,4DAA0C;AAC1C,wDAAsC;AACtC,6DAA2C;AAC3C,wDAAsC;AACtC,oDAAkC;AAClC,2DAAyC;AACzC,6DAA2C;AAC3C,0EAAwD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type CanonicalObjectTypeRef } from '../../canonical-object/lib/canonical-object-type';
|
|
3
|
+
export declare enum CanonicalMappingDirection {
|
|
4
|
+
Read = "read",
|
|
5
|
+
Write = "write"
|
|
6
|
+
}
|
|
7
|
+
export declare const CanonicalMappingDirectionSchema: z.ZodEnum<typeof CanonicalMappingDirection>;
|
|
8
|
+
export interface CanonicalOperationBinding {
|
|
9
|
+
readonly objectType: CanonicalObjectTypeRef;
|
|
10
|
+
readonly direction: CanonicalMappingDirection;
|
|
11
|
+
readonly fieldMap?: Readonly<Record<string, string>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const CanonicalOperationBindingSchema: z.ZodType<CanonicalOperationBinding>;
|
|
14
|
+
export declare function getByPath(source: unknown, path: string): unknown;
|
|
15
|
+
export declare function setByPath(target: Record<string, unknown>, path: string, value: unknown): void;
|
|
16
|
+
export declare function projectProviderToCanonical(providerRecord: unknown, fieldMap: Readonly<Record<string, string>>): Record<string, unknown>;
|
|
17
|
+
export declare function projectCanonicalToProvider(canonicalObject: Readonly<Record<string, unknown>>, fieldMap: Readonly<Record<string, string>>): Record<string, unknown>;
|
|
18
|
+
//# sourceMappingURL=canonical-operation-binding.d.ts.map
|
|
@@ -0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E,OAAO,CAAC,CASzB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CanonicalOperationBindingSchema = exports.CanonicalMappingDirectionSchema = exports.CanonicalMappingDirection = void 0;
|
|
4
|
+
exports.getByPath = getByPath;
|
|
5
|
+
exports.setByPath = setByPath;
|
|
6
|
+
exports.projectProviderToCanonical = projectProviderToCanonical;
|
|
7
|
+
exports.projectCanonicalToProvider = projectCanonicalToProvider;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const canonical_object_type_1 = require("../../canonical-object/lib/canonical-object-type");
|
|
10
|
+
var CanonicalMappingDirection;
|
|
11
|
+
(function (CanonicalMappingDirection) {
|
|
12
|
+
CanonicalMappingDirection["Read"] = "read";
|
|
13
|
+
CanonicalMappingDirection["Write"] = "write";
|
|
14
|
+
})(CanonicalMappingDirection || (exports.CanonicalMappingDirection = CanonicalMappingDirection = {}));
|
|
15
|
+
exports.CanonicalMappingDirectionSchema = zod_1.z.nativeEnum(CanonicalMappingDirection);
|
|
16
|
+
const CANONICAL_FIELD_MAP_MAX = 100;
|
|
17
|
+
const CanonicalFieldMapSchema = zod_1.z
|
|
18
|
+
.record(zod_1.z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1)
|
|
21
|
+
.max(200)
|
|
22
|
+
.regex(/^[A-Za-z][A-Za-z0-9_]*$/, 'canonical field name must be identifier-like'), zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.max(400)
|
|
26
|
+
.regex(/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/, 'provider path must be a dot-path of identifier segments'))
|
|
27
|
+
.refine((m) => Object.keys(m).length <= CANONICAL_FIELD_MAP_MAX, `at most ${CANONICAL_FIELD_MAP_MAX} mapped fields`);
|
|
28
|
+
exports.CanonicalOperationBindingSchema = zod_1.z.strictObject({
|
|
29
|
+
objectType: canonical_object_type_1.CanonicalObjectTypeRefSchema,
|
|
30
|
+
direction: exports.CanonicalMappingDirectionSchema,
|
|
31
|
+
fieldMap: CanonicalFieldMapSchema.optional(),
|
|
32
|
+
});
|
|
33
|
+
function getByPath(source, path) {
|
|
34
|
+
let cursor = source;
|
|
35
|
+
for (const segment of path.split('.')) {
|
|
36
|
+
if (cursor === null || typeof cursor !== 'object') {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
cursor = cursor[segment];
|
|
40
|
+
}
|
|
41
|
+
return cursor;
|
|
42
|
+
}
|
|
43
|
+
function setByPath(target, path, value) {
|
|
44
|
+
const segments = path.split('.');
|
|
45
|
+
let cursor = target;
|
|
46
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
47
|
+
const key = segments[i];
|
|
48
|
+
const next = cursor[key];
|
|
49
|
+
if (next === null || typeof next !== 'object' || Array.isArray(next)) {
|
|
50
|
+
cursor[key] = {};
|
|
51
|
+
}
|
|
52
|
+
cursor = cursor[key];
|
|
53
|
+
}
|
|
54
|
+
cursor[segments[segments.length - 1]] = value;
|
|
55
|
+
}
|
|
56
|
+
function projectProviderToCanonical(providerRecord, fieldMap) {
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [canonicalField, providerPath] of Object.entries(fieldMap)) {
|
|
59
|
+
const value = getByPath(providerRecord, providerPath);
|
|
60
|
+
if (value !== undefined) {
|
|
61
|
+
out[canonicalField] = value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function projectCanonicalToProvider(canonicalObject, fieldMap) {
|
|
67
|
+
const out = {};
|
|
68
|
+
for (const [canonicalField, providerPath] of Object.entries(fieldMap)) {
|
|
69
|
+
const value = canonicalObject[canonicalField];
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
setByPath(out, providerPath, value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=canonical-operation-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-operation-binding.js","sourceRoot":"","sources":["../../../src/connector/lib/canonical-operation-binding.ts"],"names":[],"mappings":";;;AA8FA,8BASC;AAGD,8BAgBC;AAOD,gEAYC;AAMD,gEAYC;AA1ID,6BAAwB;AAExB,4FAG0D;AAG1D,IAAY,yBAKX;AALD,WAAY,yBAAyB;IAEnC,0CAAa,CAAA;IAEb,4CAAe,CAAA;AACjB,CAAC,EALW,yBAAyB,yCAAzB,yBAAyB,QAKpC;AAEY,QAAA,+BAA+B,GAAG,OAAC,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;AAGvF,MAAM,uBAAuB,GAAG,GAAG,CAAC;AASpC,MAAM,uBAAuB,GAAG,OAAC;KAC9B,MAAM,CACL,OAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,yBAAyB,EAAE,8CAA8C,CAAC,EACnF,OAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CACJ,qDAAqD,EACrD,yDAAyD,CAC1D,CACJ;KACA,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,uBAAuB,EACvD,WAAW,uBAAuB,gBAAgB,CACnD,CAAC;AAmBS,QAAA,+BAA+B,GAC1C,OAAC,CAAC,YAAY,CAAC;IACb,UAAU,EAAE,oDAA4B;IACxC,SAAS,EAAE,uCAA+B;IAC1C,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,EAAE;CAC7C,CAAoD,CAAC;AAGxD,SAAgB,SAAS,CAAC,MAAe,EAAE,IAAY;IACrD,IAAI,MAAM,GAAY,MAAM,CAAC;IAC7B,KAAK,MAAM,OAAO,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CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,GAAG,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAMD,SAAgB,0BAA0B,CACxC,eAAkD,EAClD,QAA0C;IAE1C,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtE,MAAM,KAAK,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type CapabilityRef } from '../../capability';
|
|
3
|
+
import { type CanonicalOperationBinding } from './canonical-operation-binding';
|
|
3
4
|
import { type CredentialKindRef } from './credential-kind';
|
|
4
5
|
import { ConnectorAdapterKind } from './connector-adapter-kind';
|
|
5
6
|
import { type ConnectorHttpRequestTemplate } from './connector-http-request';
|
|
@@ -10,6 +11,7 @@ export interface ConnectorOperationDescriptor {
|
|
|
10
11
|
readonly scopes: readonly string[];
|
|
11
12
|
readonly requiresConnection: boolean;
|
|
12
13
|
readonly httpRequest?: ConnectorHttpRequestTemplate;
|
|
14
|
+
readonly canonical?: CanonicalOperationBinding;
|
|
13
15
|
}
|
|
14
16
|
export declare const ConnectorOperationDescriptorSchema: z.ZodObject<{
|
|
15
17
|
capabilityRef: z.ZodType<CapabilityRef, unknown, z.core.$ZodTypeInternals<CapabilityRef, unknown>>;
|
|
@@ -29,6 +31,7 @@ export declare const ConnectorOperationDescriptorSchema: z.ZodObject<{
|
|
|
29
31
|
queryParamName: z.ZodOptional<z.ZodString>;
|
|
30
32
|
}, z.core.$strict>;
|
|
31
33
|
}, z.core.$strict>>;
|
|
34
|
+
canonical: z.ZodOptional<z.ZodType<CanonicalOperationBinding, unknown, z.core.$ZodTypeInternals<CanonicalOperationBinding, unknown>>>;
|
|
32
35
|
}, z.core.$strict>;
|
|
33
36
|
export interface ConnectorDescriptor {
|
|
34
37
|
readonly connectorKey: string;
|
|
@@ -68,6 +71,7 @@ export declare const ConnectorDescriptorSchema: z.ZodObject<{
|
|
|
68
71
|
queryParamName: z.ZodOptional<z.ZodString>;
|
|
69
72
|
}, z.core.$strict>;
|
|
70
73
|
}, z.core.$strict>>;
|
|
74
|
+
canonical: z.ZodOptional<z.ZodType<CanonicalOperationBinding, unknown, z.core.$ZodTypeInternals<CanonicalOperationBinding, unknown>>>;
|
|
71
75
|
}, z.core.$strict>>>>;
|
|
72
76
|
}, z.core.$strict>;
|
|
73
77
|
type AssertExtends<T extends U, U> = T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-descriptor.d.ts","sourceRoot":"","sources":["../../../src/connector/lib/connector-descriptor.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBrD,MAAM,WAAW,4BAA4B;IAO3C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAKtC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAQ3C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,E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ema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const capability_1 = require("../../capability");
|
|
6
|
+
const canonical_operation_binding_1 = require("./canonical-operation-binding");
|
|
6
7
|
const credential_kind_1 = require("./credential-kind");
|
|
7
8
|
const connector_adapter_kind_1 = require("./connector-adapter-kind");
|
|
8
9
|
const connector_http_request_1 = require("./connector-http-request");
|
|
@@ -13,6 +14,7 @@ exports.ConnectorOperationDescriptorSchema = zod_1.z
|
|
|
13
14
|
scopes: zod_1.z.array(zod_1.z.string()).readonly(),
|
|
14
15
|
requiresConnection: zod_1.z.boolean(),
|
|
15
16
|
httpRequest: connector_http_request_1.ConnectorHttpRequestTemplateSchema.optional(),
|
|
17
|
+
canonical: canonical_operation_binding_1.CanonicalOperationBindingSchema.optional(),
|
|
16
18
|
})
|
|
17
19
|
.superRefine((op, ctx) => {
|
|
18
20
|
const isDeclarative = op.adapterKind === connector_adapter_kind_1.ConnectorAdapterKind.DeclarativeHttp;
|
|
@@ -31,6 +33,16 @@ exports.ConnectorOperationDescriptorSchema = zod_1.z
|
|
|
31
33
|
message: `httpRequest is only valid for adapterKind="declarative-http" (got "${op.adapterKind}").`,
|
|
32
34
|
});
|
|
33
35
|
}
|
|
36
|
+
if (isDeclarative &&
|
|
37
|
+
op.canonical !== undefined &&
|
|
38
|
+
op.canonical.fieldMap === undefined) {
|
|
39
|
+
ctx.addIssue({
|
|
40
|
+
code: 'custom',
|
|
41
|
+
path: ['canonical', 'fieldMap'],
|
|
42
|
+
message: 'A declarative-http operation bound to a canonical type MUST declare ' +
|
|
43
|
+
'canonical.fieldMap (there is no code path to map records).',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
34
46
|
});
|
|
35
47
|
exports.ConnectorDescriptorSchema = zod_1.z.strictObject({
|
|
36
48
|
connectorKey: zod_1.z.string().min(1),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-descriptor.js","sourceRoot":"","sources":["../../../src/connector/lib/connector-descriptor.ts"],"names":[],"mappings":";;;AAoBA,6BAAwB;AAExB,iDAA2E;AAE3E,uDAG2B;AAC3B,qEAGkC;AAClC,qEAGkC;
|
|
1
|
+
{"version":3,"file":"connector-descriptor.js","sourceRoot":"","sources":["../../../src/connector/lib/connector-descriptor.ts"],"names":[],"mappings":";;;AAoBA,6BAAwB;AAExB,iDAA2E;AAE3E,+EAGuC;AACvC,uDAG2B;AAC3B,qEAGkC;AAClC,qEAGkC;AA0ErB,QAAA,kCAAkC,GAAG,OAAC;KAChD,YAAY,CAAC;IACZ,aAAa,EAAE,gCAAmB;IAClC,WAAW,EAAE,mDAA0B;IACvC,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtC,kBAAkB,EAAE,OAAC,CAAC,OAAO,EAAE;IAC/B,WAAW,EAAE,2DAAkC,CAAC,QAAQ,EAAE;IAC1D,SAAS,EAAE,6DAA+B,CAAC,QAAQ,EAAE;CACtD,CAAC;KACD,WAAW,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IACvB,MAAM,aAAa,GACjB,EAAE,CAAC,WAAW,KAAK,6CAAoB,CAAC,eAAe,CAAC;IAC1D,IAAI,aAAa,IAAI,EAAE,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAClD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,aAAa,CAAC;YACrB,OAAO,EACL,qEAAqE;gBACrE,6CAA6C;SAChD,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACnD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,aAAa,CAAC;YACrB,OAAO,EAAE,sEAAsE,EAAE,CAAC,WAAW,KAAK;SACnG,CAAC,CAAC;IACL,CAAC;IAGD,IACE,aAAa;QACb,EAAE,CAAC,SAAS,KAAK,SAAS;QAC1B,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,EACnC,CAAC;QACD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;YAC/B,OAAO,EACL,sEAAsE;gBACtE,4DAA4D;SAC/D,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAoEQ,QAAA,yBAAyB,GAAG,OAAC,CAAC,YAAY,CAAC;IACtD,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtC,wBAAwB,EAAE,yCAAuB;IACjD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,0CAAkC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC9E,CAAC,CAAC"}
|
|
@@ -81,6 +81,7 @@ export declare const IntegrationProviderContributionManifestSchema: z.ZodObject<
|
|
|
81
81
|
queryParamName: z.ZodOptional<z.ZodString>;
|
|
82
82
|
}, z.core.$strict>;
|
|
83
83
|
}, z.core.$strict>>;
|
|
84
|
+
canonical: z.ZodOptional<z.ZodType<import("./canonical-operation-binding").CanonicalOperationBinding, unknown, z.core.$ZodTypeInternals<import("./canonical-operation-binding").CanonicalOperationBinding, unknown>>>;
|
|
84
85
|
}, z.core.$strict>>>>;
|
|
85
86
|
}, z.core.$strict>>>;
|
|
86
87
|
}, z.core.$strict>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-provider-contribution.d.ts","sourceRoot":"","sources":["../../../src/connector/lib/integration-provider-contribution.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BhE,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;kBACK,CAAC;AAEtD,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAQF,eAAO,MAAM,6CAA6C
|
|
1
|
+
{"version":3,"file":"integration-provider-contribution.d.ts","sourceRoot":"","sources":["../../../src/connector/lib/integration-provider-contribution.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BhE,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;kBACK,CAAC;AAEtD,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAQF,eAAO,MAAM,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqEtD,CAAC;AAEL,MAAM,MAAM,uCAAuC,GAAG,CAAC,CAAC,KAAK,CAC3D,OAAO,6CAA6C,CACrD,CAAC"}
|
|
@@ -31,7 +31,8 @@ export declare enum ContributionKind {
|
|
|
31
31
|
ResourceOwnership = "resource-ownership",
|
|
32
32
|
StageMachine = "stage-machine",
|
|
33
33
|
SearchType = "search-type",
|
|
34
|
-
CredentialStrategy = "credential-strategy"
|
|
34
|
+
CredentialStrategy = "credential-strategy",
|
|
35
|
+
CanonicalObjectType = "canonical-object-type"
|
|
35
36
|
}
|
|
36
37
|
export declare const ContributionKindSchema: z.ZodEnum<typeof ContributionKind>;
|
|
37
38
|
export type ContributionKindValue = `${ContributionKind}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contribution-kind.d.ts","sourceRoot":"","sources":["../../../src/contribution/lib/contribution-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkDxB,oBAAY,gBAAgB;IAS1B,WAAW,iBAAiB;IAO5B,OAAO,aAAa;IACpB,YAAY,kBAAkB;IAQ9B,UAAU,gBAAgB;IAK1B,YAAY,kBAAkB;IAC9B,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAS5B,wBAAwB,+BAA+B;IACvD,UAAU,gBAAgB;IAQ1B,YAAY,kBAAkB;IAM9B,WAAW,iBAAiB;IAW5B,cAAc,oBAAoB;IAMlC,kBAAkB,yBAAyB;IAK3C,IAAI,SAAS;IAEb,UAAU,gBAAgB;IAM1B,oBAAoB,0BAA0B;IAK9C,oBAAoB,2BAA2B;IAK/C,yBAAyB,gCAAgC;IAGzD,mBAAmB,yBAAyB;IAI5C,cAAc,oBAAoB;IAElC,eAAe,qBAAqB;IAEpC,iBAAiB,uBAAuB;IAMxC,yBAAyB,gCAAgC;IAEzD,WAAW,iBAAiB;IAI5B,UAAU,gBAAgB;IAO1B,YAAY,kBAAkB;IAM9B,cAAc,oBAAoB;IAgBlC,UAAU,eAAe;IAezB,iBAAiB,uBAAuB;IAcxC,YAAY,kBAAkB;IAkB9B,UAAU,gBAAgB;IAoB1B,kBAAkB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"contribution-kind.d.ts","sourceRoot":"","sources":["../../../src/contribution/lib/contribution-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkDxB,oBAAY,gBAAgB;IAS1B,WAAW,iBAAiB;IAO5B,OAAO,aAAa;IACpB,YAAY,kBAAkB;IAQ9B,UAAU,gBAAgB;IAK1B,YAAY,kBAAkB;IAC9B,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAS5B,wBAAwB,+BAA+B;IACvD,UAAU,gBAAgB;IAQ1B,YAAY,kBAAkB;IAM9B,WAAW,iBAAiB;IAW5B,cAAc,oBAAoB;IAMlC,kBAAkB,yBAAyB;IAK3C,IAAI,SAAS;IAEb,UAAU,gBAAgB;IAM1B,oBAAoB,0BAA0B;IAK9C,oBAAoB,2BAA2B;IAK/C,yBAAyB,gCAAgC;IAGzD,mBAAmB,yBAAyB;IAI5C,cAAc,oBAAoB;IAElC,eAAe,qBAAqB;IAEpC,iBAAiB,uBAAuB;IAMxC,yBAAyB,gCAAgC;IAEzD,WAAW,iBAAiB;IAI5B,UAAU,gBAAgB;IAO1B,YAAY,kBAAkB;IAM9B,cAAc,oBAAoB;IAgBlC,UAAU,eAAe;IAezB,iBAAiB,uBAAuB;IAcxC,YAAY,kBAAkB;IAkB9B,UAAU,gBAAgB;IAoB1B,kBAAkB,wBAAwB;IAmB1C,mBAAmB,0BAA0B;CAC9C;AAMD,eAAO,MAAM,sBAAsB,oCAAiC,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,GAAG,gBAAgB,EAAE,CAAC"}
|
|
@@ -36,6 +36,7 @@ var ContributionKind;
|
|
|
36
36
|
ContributionKind["StageMachine"] = "stage-machine";
|
|
37
37
|
ContributionKind["SearchType"] = "search-type";
|
|
38
38
|
ContributionKind["CredentialStrategy"] = "credential-strategy";
|
|
39
|
+
ContributionKind["CanonicalObjectType"] = "canonical-object-type";
|
|
39
40
|
})(ContributionKind || (exports.ContributionKind = ContributionKind = {}));
|
|
40
41
|
exports.ContributionKindSchema = zod_1.z.nativeEnum(ContributionKind);
|
|
41
42
|
//# sourceMappingURL=contribution-kind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contribution-kind.js","sourceRoot":"","sources":["../../../src/contribution/lib/contribution-kind.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAkDxB,IAAY,
|
|
1
|
+
{"version":3,"file":"contribution-kind.js","sourceRoot":"","sources":["../../../src/contribution/lib/contribution-kind.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAkDxB,IAAY,gBA2OX;AA3OD,WAAY,gBAAgB;IAS1B,gDAA4B,CAAA;IAO5B,wCAAoB,CAAA;IACpB,kDAA8B,CAAA;IAQ9B,8CAA0B,CAAA;IAK1B,kDAA8B,CAAA;IAC9B,8CAA0B,CAAA;IAC1B,gDAA4B,CAAA;IAS5B,2EAAuD,CAAA;IACvD,8CAA0B,CAAA;IAQ1B,kDAA8B,CAAA;IAM9B,gDAA4B,CAAA;IAW5B,sDAAkC,CAAA;IAMlC,+DAA2C,CAAA;IAK3C,iCAAa,CAAA;IAEb,8CAA0B,CAAA;IAM1B,kEAA8C,CAAA;IAK9C,mEAA+C,CAAA;IAK/C,6EAAyD,CAAA;IAGzD,gEAA4C,CAAA;IAI5C,sDAAkC,CAAA;IAElC,wDAAoC,CAAA;IAEpC,4DAAwC,CAAA;IAMxC,6EAAyD,CAAA;IAEzD,gDAA4B,CAAA;IAI5B,8CAA0B,CAAA;IAO1B,kDAA8B,CAAA;IAM9B,sDAAkC,CAAA;IAgBlC,6CAAyB,CAAA;IAezB,4DAAwC,CAAA;IAcxC,kDAA8B,CAAA;IAkB9B,8CAA0B,CAAA;IAoB1B,8DAA0C,CAAA;IAmB1C,iEAA6C,CAAA;AAC/C,CAAC,EA3OW,gBAAgB,gCAAhB,gBAAgB,QA2O3B;AAMY,QAAA,sBAAsB,GAAG,OAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/kernel-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.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)",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* Canonical-object-type contribution — the DECLARATIVE CDM registration
|
|
4
|
+
*
|
|
5
|
+
* A biome that owns a slice of the enterprise domain contributes one
|
|
6
|
+
* `ContributionKind.CanonicalObjectType` envelope per canonical business object
|
|
7
|
+
* it defines. It is pure DATA: the object's key, a versioned JSON-Schema shape,
|
|
8
|
+
* and its identity/title fields — NO executable code. The receiving service
|
|
9
|
+
* (the CDM registry in `connector-gateway-api`, the Enterprise-Context / CDM
|
|
10
|
+
* Adapter) stores it and exposes it so connectors can bind reads/writes to it
|
|
11
|
+
* and agents can read/write normalized objects of that type.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors `CapabilityContributionManifest` / `CredentialStrategyContribution
|
|
14
|
+
* Manifest`: a value-identical subset of the wire body the owning service
|
|
15
|
+
* accepts, validated fail-fast at biome-discovery time. Provenance
|
|
16
|
+
* (`biome.id`, `biome.version`) is NOT a field here — the parser stamps it from
|
|
17
|
+
* the discovering biome's manifest. Validation is fail-fast; no silent coercion.
|
|
18
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
CanonicalObjectTypeRefSchema,
|
|
25
|
+
CanonicalObjectTypeVersionSchema,
|
|
26
|
+
type CanonicalObjectTypeRef,
|
|
27
|
+
} from './canonical-object-type';
|
|
28
|
+
|
|
29
|
+
/** Bound on human-facing strings, keeping envelopes small. */
|
|
30
|
+
const CANONICAL_OBJECT_STRING_MAX = 200;
|
|
31
|
+
|
|
32
|
+
/** Hard cap on the number of natural-key fields. */
|
|
33
|
+
const NATURAL_KEY_FIELDS_MAX = 8;
|
|
34
|
+
|
|
35
|
+
/** A field-name of the canonical object (a JSON-Schema property key). */
|
|
36
|
+
const FieldNameSchema = z
|
|
37
|
+
.string()
|
|
38
|
+
.min(1)
|
|
39
|
+
.max(CANONICAL_OBJECT_STRING_MAX)
|
|
40
|
+
.regex(
|
|
41
|
+
/^[A-Za-z][A-Za-z0-9_]*$/,
|
|
42
|
+
'field name must be an identifier-like property of the object schema',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Manifest shape carried by every `ContributionKind.CanonicalObjectType`
|
|
47
|
+
* envelope. One contribution = one canonical business-object type.
|
|
48
|
+
*/
|
|
49
|
+
export interface CanonicalObjectTypeContributionManifest {
|
|
50
|
+
/**
|
|
51
|
+
* The OPEN canonical-object-type key (lower_snake, e.g. `sales_opportunity`).
|
|
52
|
+
* Unique across the registry — a second biome contributing the same key is a
|
|
53
|
+
* conflict the CDM registry rejects (first-writer / owner-scoped, enforced by
|
|
54
|
+
* the receiving service).
|
|
55
|
+
*/
|
|
56
|
+
readonly key: CanonicalObjectTypeRef;
|
|
57
|
+
/** Semver of THIS shape. A breaking field change bumps MAJOR. */
|
|
58
|
+
readonly version: string;
|
|
59
|
+
/** Human-readable object-type name for catalog/admin surfaces. */
|
|
60
|
+
readonly displayName: string;
|
|
61
|
+
/** Optional longer description of what the object represents. */
|
|
62
|
+
readonly description?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The canonical object's field SHAPE as an opaque JSON Schema (stored as
|
|
65
|
+
* JSON by the registry; validated structurally only — a JSON object — here,
|
|
66
|
+
* exactly like `CapabilityContributionManifest.inputSchema`). Connector
|
|
67
|
+
* mappers and agents validate normalized objects against it.
|
|
68
|
+
*/
|
|
69
|
+
readonly schema: Record<string, unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* The field(s) that form the object's stable natural/identity key (≥1). The
|
|
72
|
+
* CDM registry + connector mappers use these to dedup/upsert a canonical
|
|
73
|
+
* object across sources and runs.
|
|
74
|
+
*/
|
|
75
|
+
readonly naturalKeyFields: readonly string[];
|
|
76
|
+
/** Which schema field is the human-facing title (defaults to the first natural key). */
|
|
77
|
+
readonly titleField?: string;
|
|
78
|
+
/** Optional grouping label for catalog surfaces (e.g. `crm`, `field-service`). */
|
|
79
|
+
readonly category?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const CanonicalObjectTypeContributionManifestSchema: z.ZodType<CanonicalObjectTypeContributionManifest> =
|
|
83
|
+
z
|
|
84
|
+
.object({
|
|
85
|
+
key: CanonicalObjectTypeRefSchema,
|
|
86
|
+
version: CanonicalObjectTypeVersionSchema,
|
|
87
|
+
displayName: z.string().min(1).max(CANONICAL_OBJECT_STRING_MAX),
|
|
88
|
+
description: z.string().max(2000).optional(),
|
|
89
|
+
// Opaque JSON Schema — structural check only (a non-empty object), matching
|
|
90
|
+
// how capability input/output schemas are typed and stored.
|
|
91
|
+
schema: z
|
|
92
|
+
.record(z.string(), z.unknown())
|
|
93
|
+
.refine((s) => Object.keys(s).length > 0, 'schema must be a non-empty JSON Schema object'),
|
|
94
|
+
naturalKeyFields: z
|
|
95
|
+
.array(FieldNameSchema)
|
|
96
|
+
.min(1, 'at least one natural-key field is required')
|
|
97
|
+
.max(NATURAL_KEY_FIELDS_MAX),
|
|
98
|
+
// `titleField` may be any schema property (not necessarily a natural key);
|
|
99
|
+
// the JSON Schema body is opaque here, so the property-existence check for
|
|
100
|
+
// both titleField and naturalKeyFields happens in the receiving service.
|
|
101
|
+
titleField: FieldNameSchema.optional(),
|
|
102
|
+
category: z
|
|
103
|
+
.string()
|
|
104
|
+
.min(1)
|
|
105
|
+
.max(CANONICAL_OBJECT_STRING_MAX)
|
|
106
|
+
.regex(/^[a-z][a-z0-9-]*$/, 'category must be lower-kebab')
|
|
107
|
+
.optional(),
|
|
108
|
+
}) as unknown as z.ZodType<CanonicalObjectTypeContributionManifest>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* Canonical business-object type — the Enterprise Context / CDM plane
|
|
4
|
+
*
|
|
5
|
+
* A `CanonicalObjectTypeRef` names a SYSTEM-AGNOSTIC business object in the
|
|
6
|
+
* shared "Common Data Model" (Account, Contact, Opportunity, Visit, Case, …).
|
|
7
|
+
* It is the counterpart to `XemaObjectKind` (which is the CLOSED, kernel-owned
|
|
8
|
+
* taxonomy of PLATFORM primitives — biome/agent/skill/workflow/…): this ref is
|
|
9
|
+
* the OPEN, biome-declarable taxonomy of BUSINESS-DOMAIN objects.
|
|
10
|
+
*
|
|
11
|
+
* The point of the CDM plane is that AI/agents read a NORMALIZED enterprise
|
|
12
|
+
* context and write NORMALIZED objects, while connectors map those canonical
|
|
13
|
+
* objects to/from the individual systems (IFS, CMS, SharePoint, …). Nothing is
|
|
14
|
+
* connected point-to-point. Canonical object TYPES are declared by a biome via
|
|
15
|
+
* a `ContributionKind.CanonicalObjectType` contribution; connectors then bind
|
|
16
|
+
* their reads/writes to a canonical type through the mapping seams.
|
|
17
|
+
*
|
|
18
|
+
* Keys are lower_snake and open — there is no curated set to shadow. The value
|
|
19
|
+
* is a WIRE CONTRACT (it appears in canonical refs and mapping bindings): never
|
|
20
|
+
* rename a live key without a migration plan.
|
|
21
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
|
|
26
|
+
/** Bound on a canonical-object-type key. */
|
|
27
|
+
const CANONICAL_OBJECT_TYPE_KEY_MAX = 100;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An open, biome-declarable canonical business-object type key. lower_snake,
|
|
31
|
+
* e.g. `account`, `sales_opportunity`, `visit_report`, `service_case`. Unlike
|
|
32
|
+
* `CredentialKindRef` there is no curated vocabulary — the whole registry is
|
|
33
|
+
* contributed.
|
|
34
|
+
*/
|
|
35
|
+
export type CanonicalObjectTypeRef = string;
|
|
36
|
+
|
|
37
|
+
export const CanonicalObjectTypeRefSchema: z.ZodType<CanonicalObjectTypeRef> = z
|
|
38
|
+
.string()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(CANONICAL_OBJECT_TYPE_KEY_MAX)
|
|
41
|
+
.regex(
|
|
42
|
+
/^[a-z][a-z0-9_]*$/,
|
|
43
|
+
'a canonical-object-type key must be lower_snake (e.g. sales_opportunity)',
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/** Semver of a canonical object type's shape — a bump means the schema changed. */
|
|
47
|
+
export const CanonicalObjectTypeVersionSchema = z
|
|
48
|
+
.string()
|
|
49
|
+
.regex(/^\d+\.\d+\.\d+$/, 'version must be semver MAJOR.MINOR.PATCH');
|
package/src/connector/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './lib/connector-adapter-kind';
|
|
|
3
3
|
export * from './lib/connector-http-request';
|
|
4
4
|
export * from './lib/capability';
|
|
5
5
|
export * from './lib/credential-kind';
|
|
6
|
+
export * from './lib/canonical-operation-binding';
|
|
6
7
|
export * from './lib/credential-strategy-contribution';
|
|
7
8
|
export * from './lib/onboarding-manifest';
|
|
8
9
|
export * from './lib/provider-descriptor';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* Canonical operation binding — the connector↔CDM mapping seam (B1b)
|
|
4
|
+
*
|
|
5
|
+
* A connector operation can BIND to a canonical business-object type (declared
|
|
6
|
+
* via `ContributionKind.CanonicalObjectType`) so the gateway maps between the
|
|
7
|
+
* provider's shape and the shared Common Data Model:
|
|
8
|
+
*
|
|
9
|
+
* - direction `read` — the operation FETCHES provider records; the gateway
|
|
10
|
+
* projects each provider record → a canonical object (provider → canonical).
|
|
11
|
+
* - direction `write` — the operation CREATES/UPDATES; the gateway projects
|
|
12
|
+
* the caller's canonical object → the provider payload (canonical → provider).
|
|
13
|
+
*
|
|
14
|
+
* For DECLARATIVE-HTTP operations (no code) the mapping is the declarative
|
|
15
|
+
* `fieldMap`: canonical-field → provider JSON dot-path. For NATIVE code modules
|
|
16
|
+
* the module's `toCanonical`/`fromCanonical` functions take precedence and the
|
|
17
|
+
* `fieldMap` is optional. This is the counterpart to the inbound `EventMapper`
|
|
18
|
+
* (raw event → canonical envelope): here it's raw record ↔ canonical object.
|
|
19
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
CanonicalObjectTypeRefSchema,
|
|
26
|
+
type CanonicalObjectTypeRef,
|
|
27
|
+
} from '../../canonical-object/lib/canonical-object-type';
|
|
28
|
+
|
|
29
|
+
/** Which way a bound operation maps between provider records and canonical objects. */
|
|
30
|
+
export enum CanonicalMappingDirection {
|
|
31
|
+
/** Operation reads provider records → gateway emits canonical objects. */
|
|
32
|
+
Read = 'read',
|
|
33
|
+
/** Operation writes; caller supplies a canonical object → gateway emits provider payload. */
|
|
34
|
+
Write = 'write',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const CanonicalMappingDirectionSchema = z.nativeEnum(CanonicalMappingDirection);
|
|
38
|
+
|
|
39
|
+
/** Cap on the number of mapped fields, keeping the binding small + bounded. */
|
|
40
|
+
const CANONICAL_FIELD_MAP_MAX = 100;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Declarative field mapping: canonical-object field-name → a dot-path into the
|
|
44
|
+
* provider record (read) or the provider payload (write). e.g.
|
|
45
|
+
* `{ "name": "attributes.customer_name", "amount": "value.total" }`.
|
|
46
|
+
* Dot segments address nested objects; bracket/array indexing is out of scope
|
|
47
|
+
* (deliberately — keep the DSL deterministic and small).
|
|
48
|
+
*/
|
|
49
|
+
const CanonicalFieldMapSchema = z
|
|
50
|
+
.record(
|
|
51
|
+
z
|
|
52
|
+
.string()
|
|
53
|
+
.min(1)
|
|
54
|
+
.max(200)
|
|
55
|
+
.regex(/^[A-Za-z][A-Za-z0-9_]*$/, 'canonical field name must be identifier-like'),
|
|
56
|
+
z
|
|
57
|
+
.string()
|
|
58
|
+
.min(1)
|
|
59
|
+
.max(400)
|
|
60
|
+
.regex(
|
|
61
|
+
/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/,
|
|
62
|
+
'provider path must be a dot-path of identifier segments',
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
.refine(
|
|
66
|
+
(m) => Object.keys(m).length <= CANONICAL_FIELD_MAP_MAX,
|
|
67
|
+
`at most ${CANONICAL_FIELD_MAP_MAX} mapped fields`,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Binds a connector operation to a canonical object type + the mapping applied
|
|
72
|
+
* at the gateway seam.
|
|
73
|
+
*/
|
|
74
|
+
export interface CanonicalOperationBinding {
|
|
75
|
+
/** The canonical business-object type this operation reads or writes. */
|
|
76
|
+
readonly objectType: CanonicalObjectTypeRef;
|
|
77
|
+
/** Read (provider → canonical) or write (canonical → provider). */
|
|
78
|
+
readonly direction: CanonicalMappingDirection;
|
|
79
|
+
/**
|
|
80
|
+
* canonical-field → provider dot-path. REQUIRED for declarative-http
|
|
81
|
+
* operations (there is no code); OPTIONAL for native modules whose
|
|
82
|
+
* `toCanonical`/`fromCanonical` map instead.
|
|
83
|
+
*/
|
|
84
|
+
readonly fieldMap?: Readonly<Record<string, string>>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const CanonicalOperationBindingSchema: z.ZodType<CanonicalOperationBinding> =
|
|
88
|
+
z.strictObject({
|
|
89
|
+
objectType: CanonicalObjectTypeRefSchema,
|
|
90
|
+
direction: CanonicalMappingDirectionSchema,
|
|
91
|
+
fieldMap: CanonicalFieldMapSchema.optional(),
|
|
92
|
+
}) as unknown as z.ZodType<CanonicalOperationBinding>;
|
|
93
|
+
|
|
94
|
+
/** Read a dot-path (`a.b.c`) out of a record; `undefined` if any segment is missing. */
|
|
95
|
+
export function getByPath(source: unknown, path: string): unknown {
|
|
96
|
+
let cursor: unknown = source;
|
|
97
|
+
for (const segment of path.split('.')) {
|
|
98
|
+
if (cursor === null || typeof cursor !== 'object') {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
cursor = (cursor as Record<string, unknown>)[segment];
|
|
102
|
+
}
|
|
103
|
+
return cursor;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Set a dot-path (`a.b.c`) on a plain object, creating intermediate objects. */
|
|
107
|
+
export function setByPath(
|
|
108
|
+
target: Record<string, unknown>,
|
|
109
|
+
path: string,
|
|
110
|
+
value: unknown,
|
|
111
|
+
): void {
|
|
112
|
+
const segments = path.split('.');
|
|
113
|
+
let cursor: Record<string, unknown> = target;
|
|
114
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
115
|
+
const key = segments[i]!;
|
|
116
|
+
const next = cursor[key];
|
|
117
|
+
if (next === null || typeof next !== 'object' || Array.isArray(next)) {
|
|
118
|
+
cursor[key] = {};
|
|
119
|
+
}
|
|
120
|
+
cursor = cursor[key] as Record<string, unknown>;
|
|
121
|
+
}
|
|
122
|
+
cursor[segments[segments.length - 1]!] = value;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Project a provider record into a canonical object using a `read` fieldMap.
|
|
127
|
+
* Deterministic + pure; a missing provider path yields an absent canonical
|
|
128
|
+
* field (never throws). Centralized so the gateway + any validator agree.
|
|
129
|
+
*/
|
|
130
|
+
export function projectProviderToCanonical(
|
|
131
|
+
providerRecord: unknown,
|
|
132
|
+
fieldMap: Readonly<Record<string, string>>,
|
|
133
|
+
): Record<string, unknown> {
|
|
134
|
+
const out: Record<string, unknown> = {};
|
|
135
|
+
for (const [canonicalField, providerPath] of Object.entries(fieldMap)) {
|
|
136
|
+
const value = getByPath(providerRecord, providerPath);
|
|
137
|
+
if (value !== undefined) {
|
|
138
|
+
out[canonicalField] = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Project a canonical object into a provider payload using a `write` fieldMap.
|
|
146
|
+
* Deterministic + pure; an absent canonical field is skipped.
|
|
147
|
+
*/
|
|
148
|
+
export function projectCanonicalToProvider(
|
|
149
|
+
canonicalObject: Readonly<Record<string, unknown>>,
|
|
150
|
+
fieldMap: Readonly<Record<string, string>>,
|
|
151
|
+
): Record<string, unknown> {
|
|
152
|
+
const out: Record<string, unknown> = {};
|
|
153
|
+
for (const [canonicalField, providerPath] of Object.entries(fieldMap)) {
|
|
154
|
+
const value = canonicalObject[canonicalField];
|
|
155
|
+
if (value !== undefined) {
|
|
156
|
+
setByPath(out, providerPath, value);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
@@ -22,6 +22,10 @@ import { z } from 'zod';
|
|
|
22
22
|
|
|
23
23
|
import { CapabilityRefSchema, type CapabilityRef } from '../../capability';
|
|
24
24
|
|
|
25
|
+
import {
|
|
26
|
+
CanonicalOperationBindingSchema,
|
|
27
|
+
type CanonicalOperationBinding,
|
|
28
|
+
} from './canonical-operation-binding';
|
|
25
29
|
import {
|
|
26
30
|
CredentialKindRefSchema,
|
|
27
31
|
type CredentialKindRef,
|
|
@@ -91,6 +95,15 @@ export interface ConnectorOperationDescriptor {
|
|
|
91
95
|
* fails fast at the contribution boundary.
|
|
92
96
|
*/
|
|
93
97
|
readonly httpRequest?: ConnectorHttpRequestTemplate;
|
|
98
|
+
/**
|
|
99
|
+
* Optional binding to a canonical business-object type (the CDM seam, B1b).
|
|
100
|
+
* When present, the gateway maps between the provider shape and the canonical
|
|
101
|
+
* object: `read` projects fetched provider records → canonical objects,
|
|
102
|
+
* `write` projects a caller's canonical object → the provider payload. A
|
|
103
|
+
* declarative-http operation with a binding MUST carry a `fieldMap` (there is
|
|
104
|
+
* no code to map); a native operation may omit it (its module maps).
|
|
105
|
+
*/
|
|
106
|
+
readonly canonical?: CanonicalOperationBinding;
|
|
94
107
|
}
|
|
95
108
|
|
|
96
109
|
/**
|
|
@@ -105,6 +118,7 @@ export const ConnectorOperationDescriptorSchema = z
|
|
|
105
118
|
scopes: z.array(z.string()).readonly(),
|
|
106
119
|
requiresConnection: z.boolean(),
|
|
107
120
|
httpRequest: ConnectorHttpRequestTemplateSchema.optional(),
|
|
121
|
+
canonical: CanonicalOperationBindingSchema.optional(),
|
|
108
122
|
})
|
|
109
123
|
.superRefine((op, ctx) => {
|
|
110
124
|
const isDeclarative =
|
|
@@ -125,6 +139,21 @@ export const ConnectorOperationDescriptorSchema = z
|
|
|
125
139
|
message: `httpRequest is only valid for adapterKind="declarative-http" (got "${op.adapterKind}").`,
|
|
126
140
|
});
|
|
127
141
|
}
|
|
142
|
+
// A declarative-http operation bound to a canonical type has no code to map
|
|
143
|
+
// with — it MUST carry a declarative fieldMap.
|
|
144
|
+
if (
|
|
145
|
+
isDeclarative &&
|
|
146
|
+
op.canonical !== undefined &&
|
|
147
|
+
op.canonical.fieldMap === undefined
|
|
148
|
+
) {
|
|
149
|
+
ctx.addIssue({
|
|
150
|
+
code: 'custom',
|
|
151
|
+
path: ['canonical', 'fieldMap'],
|
|
152
|
+
message:
|
|
153
|
+
'A declarative-http operation bound to a canonical type MUST declare ' +
|
|
154
|
+
'canonical.fieldMap (there is no code path to map records).',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
128
157
|
});
|
|
129
158
|
|
|
130
159
|
/**
|
|
@@ -264,6 +264,25 @@ export enum ContributionKind {
|
|
|
264
264
|
* token exchange) is the separate code-bearing tier — NOT expressible here.
|
|
265
265
|
*/
|
|
266
266
|
CredentialStrategy = 'credential-strategy',
|
|
267
|
+
|
|
268
|
+
// -- Enterprise Context / CDM plane ----------------------------------------
|
|
269
|
+
/**
|
|
270
|
+
* Category 1 (biome-host `KindParser`). A CANONICAL BUSINESS-OBJECT TYPE in
|
|
271
|
+
* the shared enterprise Common Data Model — the system-agnostic counterpart
|
|
272
|
+
* to the closed platform `XemaObjectKind`. A biome declares an OPEN, business-
|
|
273
|
+
* domain object type (Account, Opportunity, Visit, Case, …) with a versioned
|
|
274
|
+
* JSON-Schema shape + identity/title fields. The kernel owns this member AND
|
|
275
|
+
* the manifest schema (`CanonicalObjectTypeContributionManifestSchema`,
|
|
276
|
+
* exported from `@xemahq/kernel-contracts/canonical-object`), mirroring the
|
|
277
|
+
* `Capability` / `SearchType` / `CredentialStrategy` kinds: one value-identical
|
|
278
|
+
* wire shape validated fail-fast by BOTH the biome-host parser
|
|
279
|
+
* (`canonical-object-type.parser.ts`) and the owning service — the CDM registry
|
|
280
|
+
* in `connector-gateway-api` (the Enterprise-Context / CDM Adapter). Connectors
|
|
281
|
+
* then bind their reads/writes to a canonical type through the mapping seams so
|
|
282
|
+
* AI reads normalized context and writes normalized objects, never point-to-
|
|
283
|
+
* point. Provenance (`biome.id/version`) is stamped by the parser.
|
|
284
|
+
*/
|
|
285
|
+
CanonicalObjectType = 'canonical-object-type',
|
|
267
286
|
}
|
|
268
287
|
|
|
269
288
|
/**
|