@relkit/provider 0.3.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/binding-normalization.d.ts +15 -0
  4. package/dist/binding-normalization.d.ts.map +1 -0
  5. package/dist/binding-normalization.js +48 -0
  6. package/dist/binding-normalization.js.map +1 -0
  7. package/dist/binding-resolution.d.ts +27 -0
  8. package/dist/binding-resolution.d.ts.map +1 -0
  9. package/dist/binding-resolution.js +65 -0
  10. package/dist/binding-resolution.js.map +1 -0
  11. package/dist/binding-values.d.ts +16 -0
  12. package/dist/binding-values.d.ts.map +1 -0
  13. package/dist/binding-values.js +46 -0
  14. package/dist/binding-values.js.map +1 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +9 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/profile-normalization.d.ts +28 -0
  20. package/dist/profile-normalization.d.ts.map +1 -0
  21. package/dist/profile-normalization.js +64 -0
  22. package/dist/profile-normalization.js.map +1 -0
  23. package/dist/protocol-builders.d.ts +80 -0
  24. package/dist/protocol-builders.d.ts.map +1 -0
  25. package/dist/protocol-builders.js +141 -0
  26. package/dist/protocol-builders.js.map +1 -0
  27. package/dist/protocol-types.d.ts +121 -0
  28. package/dist/protocol-types.d.ts.map +1 -0
  29. package/dist/protocol-types.js +2 -0
  30. package/dist/protocol-types.js.map +1 -0
  31. package/dist/runtime.d.ts +26 -0
  32. package/dist/runtime.d.ts.map +1 -0
  33. package/dist/runtime.js +2 -0
  34. package/dist/runtime.js.map +1 -0
  35. package/dist/source-normalization.d.ts +16 -0
  36. package/dist/source-normalization.d.ts.map +1 -0
  37. package/dist/source-normalization.js +99 -0
  38. package/dist/source-normalization.js.map +1 -0
  39. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rel-kit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @relkit/provider
2
+
3
+ Portable provider authoring and binding protocol for RELKIT.
4
+
5
+ See [@relkit/app](https://github.com/rel-kit/relkit) for supported application APIs.
@@ -0,0 +1,15 @@
1
+ import type { ProviderProfileSelection } from "./profile-normalization.js";
2
+ import type { NormalizedProviderBinding } from "./protocol-types.js";
3
+ export declare class ProviderFeatureMismatchError extends TypeError {
4
+ readonly code: "MISSING_PROVIDER_FEATURE";
5
+ readonly capability: string;
6
+ readonly profile: string;
7
+ readonly descriptorId: string;
8
+ readonly features: readonly string[];
9
+ constructor(capability: string, profile: string, descriptorId: string, features: readonly string[]);
10
+ }
11
+ export declare function normalizeProviderBinding(selection: ProviderProfileSelection, options: {
12
+ readonly descriptorId: string;
13
+ readonly requiredFeatures?: readonly string[];
14
+ }): NormalizedProviderBinding;
15
+ //# sourceMappingURL=binding-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-normalization.d.ts","sourceRoot":"","sources":["../src/binding-normalization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,yBAAyB,EAAmB,MAAM,qBAAqB,CAAC;AAEtF,qBAAa,4BAA6B,SAAQ,SAAS;IACzD,QAAQ,CAAC,IAAI,EAAG,0BAA0B,CAAU;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;gBAGnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,SAAS,MAAM,EAAE;CAW9B;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,wBAAwB,EACnC,OAAO,EAAE;IACP,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/C,GACA,yBAAyB,CAqB3B"}
@@ -0,0 +1,48 @@
1
+ import { deepFreeze, normalizeId, serializeJson } from "@relkit/contracts";
2
+ export class ProviderFeatureMismatchError extends TypeError {
3
+ code = "MISSING_PROVIDER_FEATURE";
4
+ capability;
5
+ profile;
6
+ descriptorId;
7
+ features;
8
+ constructor(capability, profile, descriptorId, features) {
9
+ super(`${capability} logical descriptor "${descriptorId}" requires missing features from profile "${profile}": ${features.join(", ")}`);
10
+ this.name = "ProviderFeatureMismatchError";
11
+ this.capability = capability;
12
+ this.profile = profile;
13
+ this.descriptorId = descriptorId;
14
+ this.features = features;
15
+ }
16
+ }
17
+ export function normalizeProviderBinding(selection, options) {
18
+ const adapter = selection.binding.adapter;
19
+ const supported = new Set(adapter.features.map((feature) => feature.id));
20
+ const required = [...new Set((options.requiredFeatures ?? []).map(normalizeId))].sort();
21
+ const missing = required.filter((feature) => !supported.has(feature));
22
+ if (missing.length > 0)
23
+ throw new ProviderFeatureMismatchError(selection.capability, selection.profile, normalizeId(options.descriptorId), missing);
24
+ return frozen({
25
+ kind: "provider-binding",
26
+ capability: selection.capability,
27
+ profile: selection.profile,
28
+ adapter: projectAdapter(adapter),
29
+ source: selection.binding.source,
30
+ ...(selection.binding.local === undefined ? {} : { local: selection.binding.local }),
31
+ ...(selection.binding.access === undefined ? {} : { access: selection.binding.access }),
32
+ });
33
+ }
34
+ function projectAdapter(adapter) {
35
+ return {
36
+ integrationId: adapter.integration.integrationId,
37
+ adapterId: adapter.adapterId,
38
+ protocolVersion: adapter.protocolVersion,
39
+ behavior: adapter.behavior.value,
40
+ connectionContract: adapter.connectionContract.fields,
41
+ connection: adapter.connection,
42
+ features: adapter.features.map((feature) => feature.id),
43
+ };
44
+ }
45
+ function frozen(value) {
46
+ return deepFreeze(JSON.parse(serializeJson(value)));
47
+ }
48
+ //# sourceMappingURL=binding-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-normalization.js","sourceRoot":"","sources":["../src/binding-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI3E,MAAM,OAAO,4BAA6B,SAAQ,SAAS;IAChD,IAAI,GAAG,0BAAmC,CAAC;IAC3C,UAAU,CAAS;IACnB,OAAO,CAAS;IAChB,YAAY,CAAS;IACrB,QAAQ,CAAoB;IAErC,YACE,UAAkB,EAClB,OAAe,EACf,YAAoB,EACpB,QAA2B;QAE3B,KAAK,CACH,GAAG,UAAU,wBAAwB,YAAY,6CAA6C,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjI,CAAC;QACF,IAAI,CAAC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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpF,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;KACxF,CAA8B,CAAC;AAClC,CAAC;AAED,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO;QACL,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,aAAa;QAChD,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK;QAChC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC,MAAM;QACrD,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAQ,KAAY;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type JsonValue } from "@relkit/contracts";
2
+ import type { ProviderConnectionField, ProviderConnectionValues } from "./protocol-types.js";
3
+ export type ProviderBindingResolutionCode = "CONFLICTING_CONNECTION_VALUE" | "MISSING_CONNECTION_VALUE" | "UNKNOWN_CONNECTION_OUTPUT";
4
+ export declare class ProviderBindingResolutionError extends TypeError {
5
+ readonly code: ProviderBindingResolutionCode;
6
+ readonly bindingId: string;
7
+ readonly field: string;
8
+ constructor(code: ProviderBindingResolutionCode, bindingId: string, field: string, reason: string);
9
+ }
10
+ export interface ResolveProviderConnectionOptions {
11
+ readonly profile: string;
12
+ readonly bindingId?: string;
13
+ readonly local?: Readonly<Record<string, JsonValue>>;
14
+ readonly infrastructure?: Readonly<Record<string, JsonValue>>;
15
+ readonly values?: Readonly<Record<string, JsonValue>>;
16
+ }
17
+ export interface ProviderConnectionDescriptor {
18
+ readonly capability: Readonly<{
19
+ readonly id: string;
20
+ }>;
21
+ readonly connectionContract: Readonly<{
22
+ readonly fields: Readonly<Record<string, ProviderConnectionField>>;
23
+ }>;
24
+ readonly connection: ProviderConnectionValues;
25
+ }
26
+ export declare function resolveProviderConnection(adapter: ProviderConnectionDescriptor, options: ResolveProviderConnectionOptions): Readonly<Record<string, JsonValue>>;
27
+ //# sourceMappingURL=binding-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-resolution.d.ts","sourceRoot":"","sources":["../src/binding-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE7F,MAAM,MAAM,6BAA6B,GACvC,8BAA8B,GAAG,0BAA0B,GAAG,2BAA2B,CAAC;AAE5F,qBAAa,8BAA+B,SAAQ,SAAS;IAC3D,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAGrB,IAAI,EAAE,6BAA6B,EACnC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;CAQjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC;QACpC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;KACpE,CAAC,CAAC;IACH,QAAQ,CAAC,UAAU,EAAE,wBAAwB,CAAC;CAC/C;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,4BAA4B,EACrC,OAAO,EAAE,gCAAgC,GACxC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAUrC"}
@@ -0,0 +1,65 @@
1
+ import { deepFreeze, normalizeId, serializeJson } from "@relkit/contracts";
2
+ import { isBindingValueRef } from "./binding-values.js";
3
+ export class ProviderBindingResolutionError extends TypeError {
4
+ code;
5
+ bindingId;
6
+ field;
7
+ constructor(code, bindingId, field, reason) {
8
+ super(`${bindingId} connection field "${field}" ${reason}`);
9
+ this.name = "ProviderBindingResolutionError";
10
+ this.code = code;
11
+ this.bindingId = bindingId;
12
+ this.field = field;
13
+ }
14
+ }
15
+ export function resolveProviderConnection(adapter, options) {
16
+ const bindingId = options.bindingId ?? `${adapter.capability.id}.${normalizeId(options.profile)}`;
17
+ assertDeclaredOutputs(bindingId, adapter, "local", options.local);
18
+ assertDeclaredOutputs(bindingId, adapter, "infrastructure", options.infrastructure);
19
+ const result = {};
20
+ for (const [name, field] of Object.entries(adapter.connectionContract.fields)) {
21
+ const resolved = resolveField(bindingId, name, field, adapter, options);
22
+ if (resolved !== undefined)
23
+ result[name] = resolved;
24
+ }
25
+ return deepFreeze(JSON.parse(serializeJson(result)));
26
+ }
27
+ function resolveField(bindingId, name, field, adapter, options) {
28
+ const local = own(options.local, name);
29
+ const infrastructure = own(options.infrastructure, name);
30
+ const authored = own(adapter.connection, name);
31
+ if ((local || infrastructure) && authored && field.authoredValue === "fixed")
32
+ throw new ProviderBindingResolutionError("CONFLICTING_CONNECTION_VALUE", bindingId, name, `conflicts with ${local ? "local" : "infrastructure"} output`);
33
+ if (local)
34
+ return options.local[name];
35
+ if (infrastructure)
36
+ return options.infrastructure[name];
37
+ if (authored) {
38
+ const value = adapter.connection[name];
39
+ if (!isBindingValueRef(value))
40
+ return value;
41
+ if (own(options.values, value.name))
42
+ return options.values[value.name];
43
+ if (own(field, "default"))
44
+ return field.default;
45
+ if (field.required)
46
+ throw new ProviderBindingResolutionError("MISSING_CONNECTION_VALUE", bindingId, name, `requires binding value "${value.name}"`);
47
+ return undefined;
48
+ }
49
+ if (own(field, "default"))
50
+ return field.default;
51
+ if (field.required)
52
+ throw new ProviderBindingResolutionError("MISSING_CONNECTION_VALUE", bindingId, name, "is required");
53
+ return undefined;
54
+ }
55
+ function assertDeclaredOutputs(bindingId, adapter, source, outputs) {
56
+ if (outputs === undefined)
57
+ return;
58
+ for (const name of Object.keys(outputs))
59
+ if (!own(adapter.connectionContract.fields, name))
60
+ throw new ProviderBindingResolutionError("UNKNOWN_CONNECTION_OUTPUT", bindingId, name, `is not declared for ${source} output`);
61
+ }
62
+ function own(value, key) {
63
+ return value !== undefined && Object.prototype.hasOwnProperty.call(value, key);
64
+ }
65
+ //# sourceMappingURL=binding-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-resolution.js","sourceRoot":"","sources":["../src/binding-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WA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,KAAK,CAAC,QAAQ;YAChB,MAAM,IAAI,8BAA8B,CACtC,0BAA0B,EAC1B,SAAS,EACT,IAAI,EACJ,2BAA2B,KAAK,CAAC,IAAI,GAAG,CACzC,CAAC;QACJ,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAChD,IAAI,KAAK,CAAC,QAAQ;QAChB,MAAM,IAAI,8BAA8B,CACtC,0BAA0B,EAC1B,SAAS,EACT,IAAI,EACJ,aAAa,CACd,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAC5B,SAAiB,EACjB,OAAqC,EACrC,MAAkC,EAClC,OAAwD;IAExD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO;IAClC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;YAC/C,MAAM,IAAI,8BAA8B,CACtC,2BAA2B,EAC3B,SAAS,EACT,IAAI,EACJ,uBAAuB,MAAM,SAAS,CACvC,CAAC;AACR,CAAC;AAED,SAAS,GAAG,CAAC,KAAyB,EAAE,GAAgB;IACtD,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { BindingValueRef, BindingValueType } from "./protocol-types.js";
2
+ /**
3
+ * Creates a named value reference scoped to one provider binding.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { createBindingValueRef } from "@relkit/provider";
8
+ * const cacheUrl = createBindingValueRef("CACHE_URL", "secret-string");
9
+ * ```
10
+ * @category Provider protocol
11
+ * @since 0.2.0
12
+ */
13
+ export declare function createBindingValueRef<const Name extends string, Value = unknown, const Type extends BindingValueType = BindingValueType>(name: Name, type: Type): BindingValueRef<Name, Value, Type>;
14
+ /** Returns whether a value is an exact binding-local value reference. */
15
+ export declare function isBindingValueRef(value: unknown): value is BindingValueRef;
16
+ //# sourceMappingURL=binding-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-values.d.ts","sourceRoot":"","sources":["../src/binding-values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAY7E;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,GAAG,OAAO,EACf,KAAK,CAAC,IAAI,SAAS,gBAAgB,GAAG,gBAAgB,EACtD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAQ5D;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAS1E"}
@@ -0,0 +1,46 @@
1
+ import { deepFreeze, isStableId, normalizeId, serializeJson } from "@relkit/contracts";
2
+ const bindingValueTypes = [
3
+ "string",
4
+ "number",
5
+ "boolean",
6
+ "port",
7
+ "url",
8
+ "json",
9
+ "secret-string",
10
+ ];
11
+ /**
12
+ * Creates a named value reference scoped to one provider binding.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { createBindingValueRef } from "@relkit/provider";
17
+ * const cacheUrl = createBindingValueRef("CACHE_URL", "secret-string");
18
+ * ```
19
+ * @category Provider protocol
20
+ * @since 0.2.0
21
+ */
22
+ export function createBindingValueRef(name, type) {
23
+ const normalized = normalizeId(name);
24
+ return frozen({
25
+ kind: "binding-value-ref",
26
+ name: normalized,
27
+ type,
28
+ sensitive: type === "secret-string",
29
+ });
30
+ }
31
+ /** Returns whether a value is an exact binding-local value reference. */
32
+ export function isBindingValueRef(value) {
33
+ return (isRecord(value) &&
34
+ Reflect.ownKeys(value).length === 4 &&
35
+ value.kind === "binding-value-ref" &&
36
+ isStableId(value.name) &&
37
+ bindingValueTypes.includes(value.type) &&
38
+ value.sensitive === (value.type === "secret-string"));
39
+ }
40
+ function frozen(value) {
41
+ return deepFreeze(JSON.parse(serializeJson(value)));
42
+ }
43
+ function isRecord(value) {
44
+ return value !== null && typeof value === "object" && !Array.isArray(value);
45
+ }
46
+ //# sourceMappingURL=binding-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-values.js","sourceRoot":"","sources":["../src/binding-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,iBAAiB,GAAgC;IACrD,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,KAAK;IACL,MAAM;IACN,eAAe;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAInC,IAAU,EAAE,IAAU;IACtB,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAoB,CAAC;IACxD,OAAO,MAAM,CAAC;QACZ,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,SAAS,EAAE,IAAI,KAAK,eAAe;KACpC,CAAuC,CAAC;AAC3C,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC;QACnC,KAAK,CAAC,IAAI,KAAK,mBAAmB;QAClC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;QACtB,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAwB,CAAC;QAC1D,KAAK,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,CACrD,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAQ,KAAY;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from "./binding-resolution.js";
2
+ export * from "./binding-normalization.js";
3
+ export * from "./binding-values.js";
4
+ export * from "./profile-normalization.js";
5
+ export * from "./protocol-builders.js";
6
+ export * from "./protocol-types.js";
7
+ export * from "./runtime.js";
8
+ export * from "./source-normalization.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./binding-resolution.js";
2
+ export * from "./binding-normalization.js";
3
+ export * from "./binding-values.js";
4
+ export * from "./profile-normalization.js";
5
+ export * from "./protocol-builders.js";
6
+ export * from "./protocol-types.js";
7
+ export * from "./runtime.js";
8
+ export * from "./source-normalization.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { NormalizedProviderSource, ProviderAdapter, ProviderCapability, ProviderSourceInput } from "./protocol-types.js";
2
+ export type ProviderInput<Binding> = Binding | Readonly<Record<string, Binding>>;
3
+ export interface NormalizedProviderProfiles<Adapter extends ProviderAdapter = ProviderAdapter> {
4
+ readonly kind: "normalized-provider-profiles";
5
+ readonly capability: string;
6
+ readonly profiles: Readonly<Record<string, NormalizedProviderSource<Adapter>>>;
7
+ }
8
+ export type ProviderProfileSelectionSource = "descriptor" | "default" | "sole";
9
+ export interface ProviderProfileSelection<Adapter extends ProviderAdapter = ProviderAdapter> {
10
+ readonly capability: string;
11
+ readonly profile: string;
12
+ readonly source: ProviderProfileSelectionSource;
13
+ readonly binding: NormalizedProviderSource<Adapter>;
14
+ }
15
+ export declare class ProviderProfileSelectionError extends TypeError {
16
+ readonly code: "AMBIGUOUS_PROVIDER_PROFILE" | "UNKNOWN_PROVIDER_PROFILE";
17
+ readonly capability: string;
18
+ readonly descriptorId: string;
19
+ readonly profiles: readonly string[];
20
+ constructor(code: ProviderProfileSelectionError["code"], capability: string, descriptorId: string, profiles: readonly string[], reason: string);
21
+ }
22
+ export declare function normalizeProviderProfiles<Adapter extends ProviderAdapter>(capability: ProviderCapability, input: ProviderInput<ProviderSourceInput<Adapter>>): NormalizedProviderProfiles<Adapter>;
23
+ export declare function selectProviderProfile<Adapter extends ProviderAdapter>(normalized: NormalizedProviderProfiles<Adapter>, options: {
24
+ readonly descriptorId: string;
25
+ readonly profile?: string;
26
+ readonly defaultProfile?: string;
27
+ }): ProviderProfileSelection<Adapter>;
28
+ //# sourceMappingURL=profile-normalization.d.ts.map
@@ -0,0 +1 @@
1
+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AM,EACpB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,MAAM,EAAE,MAAM;CAWjB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,eAAe,EACvE,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,GACjD,0BAA0B,CAAC,OAAO,CAAC,CAqBrC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,eAAe,EACnE,UAAU,EAAE,0BAA0B,CAAC,OAAO,CAAC,EAC/C,OAAO,EAAE;IACP,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,GACA,wBAAwB,CAAC,OAAO,CAAC,CA6BnC"}
@@ -0,0 +1,64 @@
1
+ import { deepFreeze, normalizeId, serializeJson } from "@relkit/contracts";
2
+ import { normalizeProviderSource } from "./source-normalization.js";
3
+ export class ProviderProfileSelectionError extends TypeError {
4
+ code;
5
+ capability;
6
+ descriptorId;
7
+ profiles;
8
+ constructor(code, capability, descriptorId, profiles, reason) {
9
+ super(`${capability} logical descriptor "${descriptorId}" ${reason}; available profiles: ${profiles.join(", ")}`);
10
+ this.name = "ProviderProfileSelectionError";
11
+ this.code = code;
12
+ this.capability = capability;
13
+ this.descriptorId = descriptorId;
14
+ this.profiles = profiles;
15
+ }
16
+ }
17
+ export function normalizeProviderProfiles(capability, input) {
18
+ const entries = isDirectInput(input) ? [["default", input]] : Object.entries(input);
19
+ if (entries.length === 0)
20
+ throw new TypeError(`${capability.id} provider profiles must not be empty`);
21
+ const profiles = {};
22
+ for (const [name, source] of entries.sort(([left], [right]) => left.localeCompare(right))) {
23
+ const profile = normalizeId(name);
24
+ if (profiles[profile] !== undefined)
25
+ throw new TypeError(`Duplicate ${capability.id} provider profile "${profile}"`);
26
+ const normalized = normalizeProviderSource(source);
27
+ if (normalized.adapter.capability.id !== capability.id)
28
+ throw new TypeError(`${capability.id} provider profile "${profile}" received ${normalized.adapter.capability.id}.${normalized.adapter.adapterId}`);
29
+ profiles[profile] = normalized;
30
+ }
31
+ return frozen({
32
+ kind: "normalized-provider-profiles",
33
+ capability: capability.id,
34
+ profiles,
35
+ });
36
+ }
37
+ export function selectProviderProfile(normalized, options) {
38
+ const profiles = Object.keys(normalized.profiles);
39
+ const selected = options.profile ?? options.defaultProfile ?? (profiles.length === 1 ? profiles[0] : undefined);
40
+ const source = options.profile !== undefined
41
+ ? "descriptor"
42
+ : options.defaultProfile !== undefined
43
+ ? "default"
44
+ : "sole";
45
+ if (selected === undefined)
46
+ throw new ProviderProfileSelectionError("AMBIGUOUS_PROVIDER_PROFILE", normalized.capability, normalizeId(options.descriptorId), profiles, "requires an explicit profile");
47
+ const profile = normalizeId(selected);
48
+ const binding = normalized.profiles[profile];
49
+ if (binding === undefined)
50
+ throw new ProviderProfileSelectionError("UNKNOWN_PROVIDER_PROFILE", normalized.capability, normalizeId(options.descriptorId), profiles, `selected unknown profile "${profile}"`);
51
+ return frozen({ capability: normalized.capability, profile, source, binding });
52
+ }
53
+ function isDirectInput(value) {
54
+ if (!isRecord(value) || typeof value.kind !== "string")
55
+ return false;
56
+ return ["provider-adapter", "provider-local-source", "provider-infrastructure-source"].includes(value.kind);
57
+ }
58
+ function frozen(value) {
59
+ return deepFreeze(JSON.parse(serializeJson(value)));
60
+ }
61
+ function isRecord(value) {
62
+ return value !== null && typeof value === "object" && !Array.isArray(value);
63
+ }
64
+ //# sourceMappingURL=profile-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-normalization.js","sourceRoot":"","sources":["../src/profile-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAyBp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B,CAC/B,CAAC;IACJ,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,SAAS;QACvB,MAAM,IAAI,6BAA6B,CACrC,0BAA0B,EAC1B,UAAU,CAAC,UAAU,EACrB,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EACjC,QAAQ,EACR,6BAA6B,OAAO,GAAG,CACxC,CAAC;IACJ,OAAO,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACrE,OAAO,CAAC,kBAAkB,EAAE,uBAAuB,EAAE,gCAAgC,CAAC,CAAC,QAAQ,CAC7F,KAAK,CAAC,IAAI,CACX,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAQ,KAAY;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { type JsonValue } from "@relkit/contracts";
2
+ import { type IntegrationReference, type ProviderAccess, type ProviderAdapter, type ProviderBehavior, type ProviderCapability, type ProviderConnectionContract, type ProviderConnectionFieldInput, type ProviderConnectionValues, type ProviderFeature, type ProviderLocalRecipeReference } from "./protocol-types.js";
3
+ /**
4
+ * Defines a stable provider capability identity.
5
+ * @category Provider protocol
6
+ * @since 0.2.0
7
+ */
8
+ export declare function defineProviderCapability<const Id extends string>(id: Id): ProviderCapability<Id>;
9
+ /**
10
+ * Defines one feature supported by adapters for a capability.
11
+ * @category Provider protocol
12
+ * @since 0.2.0
13
+ */
14
+ export declare function defineProviderFeature<const Capability extends ProviderCapability, const Id extends string>(capability: Capability, id: Id): ProviderFeature<Capability["id"], Id>;
15
+ /**
16
+ * Defines the fields that local, infrastructure, or runtime values may materialize.
17
+ * @category Provider protocol
18
+ * @since 0.2.0
19
+ */
20
+ export declare function defineConnectionContract(fields: Readonly<Record<string, ProviderConnectionFieldInput>>): ProviderConnectionContract;
21
+ /**
22
+ * Keeps adapter behavior separate from connection materialization.
23
+ * @category Provider protocol
24
+ * @since 0.2.0
25
+ */
26
+ export declare function defineProviderBehavior<const Value extends JsonValue>(value: Value): ProviderBehavior<Value>;
27
+ /**
28
+ * Defines explicit binding or infrastructure access metadata.
29
+ * @category Provider protocol
30
+ * @since 0.2.0
31
+ */
32
+ export declare function defineProviderAccess<const Value extends JsonValue>(value: Value): ProviderAccess<Value>;
33
+ /**
34
+ * Defines a static integration identity without accepting an import path.
35
+ * @category Provider protocol
36
+ * @since 0.2.0
37
+ */
38
+ export declare function defineIntegrationReference<const Id extends string>(integrationId: Id): IntegrationReference<Id>;
39
+ /**
40
+ * Defines versioned local-recipe provenance for an adapter.
41
+ * @category Provider protocol
42
+ * @since 0.2.0
43
+ */
44
+ export declare function defineLocalRecipeReference(integration: IntegrationReference, recipeId: string, recipeVersion: number): ProviderLocalRecipeReference;
45
+ /**
46
+ * Defines a pure adapter descriptor for an integration package.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import {
51
+ * defineConnectionContract,
52
+ * defineIntegrationReference,
53
+ * defineProviderAdapter,
54
+ * defineProviderBehavior,
55
+ * defineProviderCapability,
56
+ * } from "@relkit/provider";
57
+ * const cache = defineProviderCapability("cache");
58
+ * const redis = defineProviderAdapter({
59
+ * integration: defineIntegrationReference("redis"),
60
+ * capability: cache,
61
+ * adapterId: "redis",
62
+ * connectionContract: defineConnectionContract({ url: { sensitive: true } }),
63
+ * connection: { url: "redis://localhost:6379" },
64
+ * behavior: defineProviderBehavior({}),
65
+ * });
66
+ * ```
67
+ * @category Provider protocol
68
+ * @since 0.2.0
69
+ */
70
+ export declare function defineProviderAdapter<const Capability extends ProviderCapability, const AdapterId extends string, const Connection extends ProviderConnectionValues, const Behavior extends ProviderBehavior>(options: {
71
+ readonly integration: IntegrationReference;
72
+ readonly capability: Capability;
73
+ readonly adapterId: AdapterId;
74
+ readonly connectionContract: ProviderConnectionContract;
75
+ readonly connection: Connection;
76
+ readonly behavior: Behavior;
77
+ readonly features?: readonly ProviderFeature<Capability["id"]>[];
78
+ readonly localRecipe?: ProviderLocalRecipeReference;
79
+ }): ProviderAdapter<Capability, AdapterId, Connection, Behavior>;
80
+ //# sourceMappingURL=protocol-builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-builders.d.ts","sourceRoot":"","sources":["../src/protocol-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAE/B,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,4BAA4B,EAClC,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,CAAC,UAAU,SAAS,kBAAkB,EAC3C,KAAK,CAAC,EAAE,SAAS,M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AU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;IACjE,QAAQ,CAAC,WAAW,CAAC,EAAE,4BAA4B,CAAC;CACrD,GAAG,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAuB/D"}
@@ -0,0 +1,141 @@
1
+ import { deepFreeze, normalizeId, serializeJson } from "@relkit/contracts";
2
+ import { PROVIDER_PROTOCOL_VERSION, } from "./protocol-types.js";
3
+ /**
4
+ * Defines a stable provider capability identity.
5
+ * @category Provider protocol
6
+ * @since 0.2.0
7
+ */
8
+ export function defineProviderCapability(id) {
9
+ return frozen({ kind: "provider-capability", id: stable(id) });
10
+ }
11
+ /**
12
+ * Defines one feature supported by adapters for a capability.
13
+ * @category Provider protocol
14
+ * @since 0.2.0
15
+ */
16
+ export function defineProviderFeature(capability, id) {
17
+ return frozen({
18
+ kind: "provider-feature",
19
+ capability: capability.id,
20
+ id: stable(id),
21
+ });
22
+ }
23
+ /**
24
+ * Defines the fields that local, infrastructure, or runtime values may materialize.
25
+ * @category Provider protocol
26
+ * @since 0.2.0
27
+ */
28
+ export function defineConnectionContract(fields) {
29
+ const normalized = {};
30
+ for (const [name, field] of Object.entries(fields).sort(([left], [right]) => left.localeCompare(right))) {
31
+ const key = stable(name);
32
+ if (normalized[key] !== undefined)
33
+ throw new TypeError(`Duplicate connection field "${key}"`);
34
+ normalized[key] = {
35
+ required: field.required ?? true,
36
+ sensitive: field.sensitive ?? false,
37
+ authoredValue: field.authoredValue ?? "fixed",
38
+ ...(field.default === undefined ? {} : { default: field.default }),
39
+ };
40
+ }
41
+ return frozen({
42
+ kind: "provider-connection-contract",
43
+ fields: normalized,
44
+ });
45
+ }
46
+ /**
47
+ * Keeps adapter behavior separate from connection materialization.
48
+ * @category Provider protocol
49
+ * @since 0.2.0
50
+ */
51
+ export function defineProviderBehavior(value) {
52
+ return frozen({ kind: "provider-behavior", value });
53
+ }
54
+ /**
55
+ * Defines explicit binding or infrastructure access metadata.
56
+ * @category Provider protocol
57
+ * @since 0.2.0
58
+ */
59
+ export function defineProviderAccess(value) {
60
+ return frozen({ kind: "provider-access", value });
61
+ }
62
+ /**
63
+ * Defines a static integration identity without accepting an import path.
64
+ * @category Provider protocol
65
+ * @since 0.2.0
66
+ */
67
+ export function defineIntegrationReference(integrationId) {
68
+ return frozen({
69
+ kind: "integration-reference",
70
+ integrationId: stable(integrationId),
71
+ });
72
+ }
73
+ /**
74
+ * Defines versioned local-recipe provenance for an adapter.
75
+ * @category Provider protocol
76
+ * @since 0.2.0
77
+ */
78
+ export function defineLocalRecipeReference(integration, recipeId, recipeVersion) {
79
+ if (!Number.isSafeInteger(recipeVersion) || recipeVersion < 1)
80
+ throw new TypeError("Local recipe version must be a positive integer");
81
+ return frozen({
82
+ integrationId: integration.integrationId,
83
+ recipeId: stable(recipeId),
84
+ recipeVersion,
85
+ });
86
+ }
87
+ /**
88
+ * Defines a pure adapter descriptor for an integration package.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * import {
93
+ * defineConnectionContract,
94
+ * defineIntegrationReference,
95
+ * defineProviderAdapter,
96
+ * defineProviderBehavior,
97
+ * defineProviderCapability,
98
+ * } from "@relkit/provider";
99
+ * const cache = defineProviderCapability("cache");
100
+ * const redis = defineProviderAdapter({
101
+ * integration: defineIntegrationReference("redis"),
102
+ * capability: cache,
103
+ * adapterId: "redis",
104
+ * connectionContract: defineConnectionContract({ url: { sensitive: true } }),
105
+ * connection: { url: "redis://localhost:6379" },
106
+ * behavior: defineProviderBehavior({}),
107
+ * });
108
+ * ```
109
+ * @category Provider protocol
110
+ * @since 0.2.0
111
+ */
112
+ export function defineProviderAdapter(options) {
113
+ const fields = new Set(Object.keys(options.connectionContract.fields));
114
+ for (const name of Object.keys(options.connection))
115
+ if (!fields.has(name))
116
+ throw new TypeError(`Unknown connection field "${name}"`);
117
+ const features = [...(options.features ?? [])].sort((left, right) => left.id.localeCompare(right.id));
118
+ if (features.some((feature) => feature.capability !== options.capability.id))
119
+ throw new TypeError(`Provider feature capability must be "${options.capability.id}"`);
120
+ if (new Set(features.map((feature) => feature.id)).size !== features.length)
121
+ throw new TypeError("Duplicate provider feature");
122
+ return frozen({
123
+ kind: "provider-adapter",
124
+ protocolVersion: PROVIDER_PROTOCOL_VERSION,
125
+ integration: options.integration,
126
+ capability: options.capability,
127
+ adapterId: stable(options.adapterId),
128
+ connectionContract: options.connectionContract,
129
+ connection: options.connection,
130
+ behavior: options.behavior,
131
+ features,
132
+ ...(options.localRecipe === undefined ? {} : { localRecipe: options.localRecipe }),
133
+ });
134
+ }
135
+ function stable(value) {
136
+ return normalizeId(value);
137
+ }
138
+ function frozen(value) {
139
+ return deepFreeze(JSON.parse(serializeJson(value)));
140
+ }
141
+ //# sourceMappingURL=protocol-builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-builders.js","sourceRoot":"","sources":["../src/protocol-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EACL,yBAAyB,GAY1B,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAA0B,EAAM;IACtE,OAAO,MAAM,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAA2B,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAGnC,UAAsB,EAAE,EAAM;IAC9B,OAAO,MAAM,CAAC;QACZ,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE,UAAU,CAAC,EAAE;QACzB,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;KACf,CAA0C,CAAC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AAC,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,SAAS,CAAC,wCAAwC,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC;IACxF,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;QACzE,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;QACZ,IAAI,EAAE,kBAAkB;QACxB,eAAe,EAAE,yBAAyB;QAC1C,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;QACpC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ;QACR,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;KACnF,CAA4E,CAAC;AAChF,CAAC;AAED,SAAS,MAAM,CAA6B,KAAY;IACtD,OAAO,WAAW,CAAC,KAAK,CAAqB,CAAC;AAChD,CAAC;AAED,SAAS,MAAM,CAAQ,KAAY;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,121 @@
1
+ import type { JsonValue } from "@relkit/contracts";
2
+ declare const providerProtocolType: unique symbol;
3
+ type ProviderProtocolType<Name extends string> = {
4
+ readonly [providerProtocolType]: Name;
5
+ };
6
+ export declare const PROVIDER_PROTOCOL_VERSION: 1;
7
+ export type ProviderProtocolVersion = typeof PROVIDER_PROTOCOL_VERSION;
8
+ export type BindingValueType = "string" | "number" | "boolean" | "port" | "url" | "json" | "secret-string";
9
+ export type BindingValueRef<Name extends string = string, Value = unknown, Type extends BindingValueType = BindingValueType> = Readonly<{
10
+ kind: "binding-value-ref";
11
+ name: Name;
12
+ type: Type;
13
+ sensitive: Type extends "secret-string" ? true : false;
14
+ __value?: Value;
15
+ }> & ProviderProtocolType<"binding-value-ref">;
16
+ export type ProviderCapability<Id extends string = string> = Readonly<{
17
+ kind: "provider-capability";
18
+ id: Id;
19
+ }> & ProviderProtocolType<"capability">;
20
+ export type ProviderFeature<Capability extends string = string, Id extends string = string> = Readonly<{
21
+ kind: "provider-feature";
22
+ capability: Capability;
23
+ id: Id;
24
+ }> & ProviderProtocolType<"feature">;
25
+ export type ProviderConnectionValueMode = "fixed" | "fallback";
26
+ export interface ProviderConnectionFieldInput {
27
+ readonly required?: boolean;
28
+ readonly sensitive?: boolean;
29
+ readonly authoredValue?: ProviderConnectionValueMode;
30
+ readonly default?: JsonValue;
31
+ }
32
+ export interface ProviderConnectionField {
33
+ readonly required: boolean;
34
+ readonly sensitive: boolean;
35
+ readonly authoredValue: ProviderConnectionValueMode;
36
+ readonly default?: JsonValue;
37
+ }
38
+ export type ProviderConnectionFields = Readonly<Record<string, ProviderConnectionField>>;
39
+ export type ProviderConnectionContract<Fields extends ProviderConnectionFields = ProviderConnectionFields> = Readonly<{
40
+ kind: "provider-connection-contract";
41
+ fields: Fields;
42
+ }> & ProviderProtocolType<"connection-contract">;
43
+ export type ProviderBehavior<Value extends JsonValue = JsonValue> = Readonly<{
44
+ kind: "provider-behavior";
45
+ value: Value;
46
+ }> & ProviderProtocolType<"behavior">;
47
+ export type ProviderAccess<Value extends JsonValue = JsonValue> = Readonly<{
48
+ kind: "provider-access";
49
+ value: Value;
50
+ }> & ProviderProtocolType<"access">;
51
+ export type IntegrationReference<Id extends string = string> = Readonly<{
52
+ kind: "integration-reference";
53
+ integrationId: Id;
54
+ }> & ProviderProtocolType<"integration-reference">;
55
+ export type ProviderConnectionValue = JsonValue | BindingValueRef;
56
+ export type ProviderConnectionValues = Readonly<Record<string, ProviderConnectionValue>>;
57
+ export type ProviderAdapter<Capability extends ProviderCapability = ProviderCapability, AdapterId extends string = string, Connection extends ProviderConnectionValues = ProviderConnectionValues, Behavior extends ProviderBehavior = ProviderBehavior> = Readonly<{
58
+ kind: "provider-adapter";
59
+ protocolVersion: ProviderProtocolVersion;
60
+ integration: IntegrationReference;
61
+ capability: Capability;
62
+ adapterId: AdapterId;
63
+ connectionContract: ProviderConnectionContract;
64
+ connection: Connection;
65
+ behavior: Behavior;
66
+ features: readonly ProviderFeature<Capability["id"]>[];
67
+ localRecipe?: ProviderLocalRecipeReference;
68
+ }> & ProviderProtocolType<"adapter">;
69
+ export type LocalProviderSource<Adapter extends ProviderAdapter = ProviderAdapter> = Readonly<{
70
+ kind: "provider-local-source";
71
+ adapter: Adapter;
72
+ }> & ProviderProtocolType<"local-source">;
73
+ export type InfrastructureProviderSource<Adapter extends ProviderAdapter = ProviderAdapter> = Readonly<{
74
+ kind: "provider-infrastructure-source";
75
+ adapter: Adapter;
76
+ integration: IntegrationReference;
77
+ options: JsonValue;
78
+ access?: ProviderAccess;
79
+ }> & ProviderProtocolType<"infrastructure-source">;
80
+ export type ProviderSourceInput<Adapter extends ProviderAdapter = ProviderAdapter> = Adapter | LocalProviderSource<Adapter> | InfrastructureProviderSource<Adapter>;
81
+ export type ProviderBindingSource = Readonly<{
82
+ kind: "connected";
83
+ }> | Readonly<{
84
+ kind: "local-only";
85
+ }> | Readonly<{
86
+ kind: "infrastructure";
87
+ integrationId: string;
88
+ options: JsonValue;
89
+ }>;
90
+ export interface ProviderLocalRecipeReference {
91
+ readonly integrationId: string;
92
+ readonly recipeId: string;
93
+ readonly recipeVersion: number;
94
+ }
95
+ export type NormalizedProviderSource<Adapter extends ProviderAdapter = ProviderAdapter> = Readonly<{
96
+ kind: "normalized-provider-source";
97
+ adapter: Adapter;
98
+ source: ProviderBindingSource;
99
+ local?: ProviderLocalRecipeReference;
100
+ access?: JsonValue;
101
+ }> & ProviderProtocolType<"normalized-source">;
102
+ export interface NormalizedProviderAdapter {
103
+ readonly integrationId: string;
104
+ readonly adapterId: string;
105
+ readonly protocolVersion: ProviderProtocolVersion;
106
+ readonly behavior: JsonValue;
107
+ readonly connectionContract: ProviderConnectionFields;
108
+ readonly connection: ProviderConnectionValues;
109
+ readonly features: readonly string[];
110
+ }
111
+ export type NormalizedProviderBinding = Readonly<{
112
+ kind: "provider-binding";
113
+ capability: string;
114
+ profile: string;
115
+ adapter: NormalizedProviderAdapter;
116
+ source: ProviderBindingSource;
117
+ local?: ProviderLocalRecipeReference;
118
+ access?: JsonValue;
119
+ }> & ProviderProtocolType<"normalized-binding">;
120
+ export {};
121
+ //# sourceMappingURL=protocol-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-types.d.ts","sourceRoot":"","sources":["../src/protocol-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,CAAC,MAAM,oBAAoB,EAAE,OAAO,MAAM,CAAC;AAElD,KAAK,oBAAoB,CAAC,IAAI,SAAS,MAAM,IAAI;IAC/C,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAG,CAAU,CAAC;AACpD,MAAM,MAAM,uBAAuB,GAAG,OAAO,yBAAyB,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAC1B,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,eAAe,CAAC;AAE9E,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,KAAK,GAAG,OAAO,EACf,IAAI,SAAS,gBAAgB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AAE,SAAS,CAAC;CACpB,CAAC,GACA,oBAAoB,CAAC,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const PROVIDER_PROTOCOL_VERSION = 1;
2
+ //# sourceMappingURL=protocol-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-types.js","sourceRoot":"","sources":["../src/protocol-types.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAU,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { JsonValue, MaybePromise, RuntimeIntegrationRegistrationMetadata } from "@relkit/contracts";
2
+ export interface RuntimeProviderContext {
3
+ readonly generationId: string;
4
+ readonly bindingId: string;
5
+ readonly capability: string;
6
+ readonly profile: string;
7
+ readonly behavior: JsonValue;
8
+ readonly connection: Readonly<Record<string, JsonValue>>;
9
+ readonly signal?: AbortSignal;
10
+ }
11
+ export interface RuntimeProviderGeneration {
12
+ readonly value: unknown;
13
+ readonly ready?: () => MaybePromise<void>;
14
+ readonly readiness?: () => MaybePromise<void>;
15
+ readonly release?: () => MaybePromise<void>;
16
+ readonly dispose?: () => MaybePromise<void>;
17
+ }
18
+ export interface RuntimeProviderRegistration extends RuntimeIntegrationRegistrationMetadata {
19
+ readonly create: (context: RuntimeProviderContext) => MaybePromise<RuntimeProviderGeneration>;
20
+ }
21
+ export interface RuntimeProviderIntegration<IntegrationId extends string = string> {
22
+ readonly kind: "runtime-integration";
23
+ readonly integrationId: IntegrationId;
24
+ readonly registrations: readonly RuntimeProviderRegistration[];
25
+ }
26
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,sCAAsC,EACvC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC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{ type JsonValue } from "@relkit/contracts";
2
+ import type { InfrastructureProviderSource, IntegrationReference, LocalProviderSource, NormalizedProviderSource, ProviderAccess, ProviderAdapter, ProviderSourceInput } from "./protocol-types.js";
3
+ /**
4
+ * Adds an adapter's declared local recipe without starting it.
5
+ * @category Provider protocol
6
+ * @since 0.2.0
7
+ */
8
+ export declare function defineLocalProviderSource<const Adapter extends ProviderAdapter>(adapter: Adapter): LocalProviderSource<Adapter>;
9
+ /**
10
+ * Adds an infrastructure release source and explicit access metadata.
11
+ * @category Provider protocol
12
+ * @since 0.2.0
13
+ */
14
+ export declare function defineInfrastructureProviderSource<const Adapter extends ProviderAdapter>(adapter: Adapter, integration: IntegrationReference, options: JsonValue, access?: ProviderAccess): InfrastructureProviderSource<Adapter>;
15
+ export declare function normalizeProviderSource<const Adapter extends ProviderAdapter>(input: ProviderSourceInput<Adapter>): NormalizedProviderSource<Adapter>;
16
+ //# sourceMappingURL=source-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-normalization.d.ts","sourceRoot":"","sources":["../src/source-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,eAAe,EAEf,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,OAAO,SAAS,eAAe,EAC7E,OAAO,EAAE,OAAO,GACf,mBAAmB,CAAC,OAAO,CAAC,CAK9B;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,CAAC,OAAO,SAAS,eAAe,EACtF,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,SAAS,EAClB,MAAM,CAAC,EAAE,cAAc,GACtB,4BAA4B,CAAC,OAAO,CAAC,CAWvC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,OAAO,SAAS,eAAe,EAC3E,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAClC,wBAAwB,CAAC,OAAO,CAAC,CA2BnC"}
@@ -0,0 +1,99 @@
1
+ import { deepFreeze, serializeJson } from "@relkit/contracts";
2
+ /**
3
+ * Adds an adapter's declared local recipe without starting it.
4
+ * @category Provider protocol
5
+ * @since 0.2.0
6
+ */
7
+ export function defineLocalProviderSource(adapter) {
8
+ assertAdapter(adapter);
9
+ if (adapter.localRecipe === undefined)
10
+ throw new TypeError(`${label(adapter)} does not declare a local recipe`);
11
+ return frozen({ kind: "provider-local-source", adapter });
12
+ }
13
+ /**
14
+ * Adds an infrastructure release source and explicit access metadata.
15
+ * @category Provider protocol
16
+ * @since 0.2.0
17
+ */
18
+ export function defineInfrastructureProviderSource(adapter, integration, options, access) {
19
+ assertAdapter(adapter);
20
+ if (adapter.localRecipe === undefined)
21
+ throw new TypeError(`${label(adapter)} does not declare a default local recipe`);
22
+ return frozen({
23
+ kind: "provider-infrastructure-source",
24
+ adapter,
25
+ integration,
26
+ options,
27
+ ...(access === undefined ? {} : { access }),
28
+ });
29
+ }
30
+ export function normalizeProviderSource(input) {
31
+ if (isRecord(input) && input.kind === "provider-adapter") {
32
+ assertAdapter(input);
33
+ assertConnected(input);
34
+ return normalized(input, { kind: "connected" });
35
+ }
36
+ if (isRecord(input) && isRecord(input.adapter))
37
+ assertAdapter(input.adapter);
38
+ if (!isRecord(input) || !isAdapter(input.adapter))
39
+ throw new TypeError("Provider source wrappers cannot be nested");
40
+ if (input.kind === "provider-local-source") {
41
+ const source = isConfigured(input.adapter)
42
+ ? { kind: "connected" }
43
+ : { kind: "local-only" };
44
+ return normalized(input.adapter, source, input.adapter.localRecipe);
45
+ }
46
+ if (input.kind === "provider-infrastructure-source")
47
+ return normalized(input.adapter, {
48
+ kind: "infrastructure",
49
+ integrationId: input.integration.integrationId,
50
+ options: input.options,
51
+ }, input.adapter.localRecipe, input.access?.value);
52
+ throw new TypeError("Invalid provider source descriptor");
53
+ }
54
+ function normalized(adapter, source, local, access) {
55
+ return frozen({
56
+ kind: "normalized-provider-source",
57
+ adapter,
58
+ source,
59
+ ...(local === undefined ? {} : { local }),
60
+ ...(access === undefined ? {} : { access }),
61
+ });
62
+ }
63
+ function assertConnected(adapter) {
64
+ const missing = Object.entries(adapter.connectionContract.fields)
65
+ .filter(([name, field]) => field.required &&
66
+ !Object.prototype.hasOwnProperty.call(adapter.connection, name) &&
67
+ !Object.prototype.hasOwnProperty.call(field, "default"))
68
+ .map(([name]) => name);
69
+ if (missing.length > 0)
70
+ throw new TypeError(`${label(adapter)} is missing connection fields: ${missing.join(", ")}`);
71
+ }
72
+ function isConfigured(adapter) {
73
+ try {
74
+ assertConnected(adapter);
75
+ return true;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
81
+ function assertAdapter(value) {
82
+ if (isRecord(value) && value.kind === "provider-adapter" && value.protocolVersion !== 1)
83
+ throw new TypeError(`Provider protocol version ${String(value.protocolVersion)} is unsupported; rewrite the app with current integration constructors.`);
84
+ if (!isAdapter(value))
85
+ throw new TypeError("Provider source wrappers cannot be nested");
86
+ }
87
+ function isAdapter(value) {
88
+ return isRecord(value) && value.kind === "provider-adapter" && value.protocolVersion === 1;
89
+ }
90
+ function label(adapter) {
91
+ return `${adapter.capability.id}.${adapter.adapterId}`;
92
+ }
93
+ function frozen(value) {
94
+ return deepFreeze(JSON.parse(serializeJson(value)));
95
+ }
96
+ function isRecord(value) {
97
+ return value !== null && typeof value === "object" && !Array.isArray(value);
98
+ }
99
+ //# sourceMappingURL=source-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-normalization.js","sourceRoot":"","sources":["../src/source-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAY9E;;;;GAIG;AACH,MAAM,UAAU,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AAC,CAAC;AAC7F,CAAC;AAED,SAAS,KAAK,CAAC,OAAwB;IACrC,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;AACzD,CAAC;AAED,SAAS,MAAM,CAAQ,KAAY;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@relkit/provider",
3
+ "version": "0.3.0",
4
+ "description": "Portable provider authoring and binding protocol for RELKIT.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rel-kit/relkit.git",
9
+ "directory": "packages/provider"
10
+ },
11
+ "homepage": "https://github.com/rel-kit/relkit#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/rel-kit/relkit/issues"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "engines": {
22
+ "bun": ">=1.3.10"
23
+ },
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "@relkit/contracts": "0.3.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -b",
36
+ "check": "tsc -b --pretty false",
37
+ "typecheck": "tsc -b --pretty false"
38
+ }
39
+ }