@vibesdotdev/connector-base 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SPEC.md +23 -0
- package/dist/connector.plugin.d.ts +10 -0
- package/dist/connector.plugin.d.ts.map +1 -0
- package/dist/connector.plugin.js +26 -0
- package/dist/connector.plugin.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver.d.ts +45 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +85 -0
- package/dist/resolver.js.map +1 -0
- package/dist/schemas.d.ts +90 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +67 -0
- package/dist/schemas.js.map +1 -0
- package/package.json +67 -0
- package/src/connector.plugin.ts +37 -0
- package/src/index.ts +30 -0
- package/src/resolver.ts +144 -0
- package/src/schemas.ts +79 -0
package/SPEC.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Connector Base
|
|
2
|
+
|
|
3
|
+
## Ownership
|
|
4
|
+
|
|
5
|
+
- **Owns:** Base schemas, interfaces, and resolution utilities for connector packages.
|
|
6
|
+
- **Does not own:** Provider-specific implementations (AWS, Azure, GCP).
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
The `connector-base` package defines the runtime `connector/substrate` and `connector/sub-connector` kinds.
|
|
11
|
+
Substrate packages (`connector-aws`, `connector-azure`, etc.) register descriptors against these kinds and provide concrete service clients (S3, SecretsManager, Blob Storage, etc.).
|
|
12
|
+
|
|
13
|
+
## Public Entrypoints
|
|
14
|
+
|
|
15
|
+
- `src/index.ts` — types, schemas, and resolution utilities
|
|
16
|
+
- `src/connector.plugin.ts` — runtime plugin for kind registration
|
|
17
|
+
- `src/schemas.ts` — `ConnectorSubstrateDescriptorSchema`, `SubConnectorDescriptorSchema`, `CredentialReferenceSchema`, `AwsCredentialsSchema`
|
|
18
|
+
- `src/resolver.ts` — `resolveCredentialReference`, `resolveAwsCredentials`, `resolveConfigValue`
|
|
19
|
+
|
|
20
|
+
## Hard Rules
|
|
21
|
+
|
|
22
|
+
- No provider-specific imports.
|
|
23
|
+
- Must not depend on `@vibesdotdev/secrets` at runtime — accepts `MinimalSecretsStore` shape injected by callers.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Plugin
|
|
3
|
+
*
|
|
4
|
+
* Registers the connector/substrate and connector/sub-connector runtime kinds.
|
|
5
|
+
* Individual provider packages (connector-aws, connector-azure, …) register
|
|
6
|
+
* concrete descriptors against these kinds.
|
|
7
|
+
*/
|
|
8
|
+
export declare const connectorBasePlugin: import("@vibesdotdev/runtime").RuntimePlugin;
|
|
9
|
+
export default connectorBasePlugin;
|
|
10
|
+
//# sourceMappingURL=connector.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.plugin.d.ts","sourceRoot":"","sources":["../src/connector.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,eAAO,MAAM,mBAAmB,8CAoB9B,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Plugin
|
|
3
|
+
*
|
|
4
|
+
* Registers the connector/substrate and connector/sub-connector runtime kinds.
|
|
5
|
+
* Individual provider packages (connector-aws, connector-azure, …) register
|
|
6
|
+
* concrete descriptors against these kinds.
|
|
7
|
+
*/
|
|
8
|
+
import { createRuntimePlugin, createRuntimeKind } from '@vibesdotdev/runtime';
|
|
9
|
+
import { ConnectorSubstrateDescriptorSchema, SubConnectorDescriptorSchema, } from "./schemas.js";
|
|
10
|
+
export const connectorBasePlugin = createRuntimePlugin({
|
|
11
|
+
id: '@vibesdotdev/connector-base',
|
|
12
|
+
name: 'Connector Base',
|
|
13
|
+
description: 'Base connector/substrate and connector/sub-connector kinds for platform integrations.',
|
|
14
|
+
onRegister: async (runtime) => {
|
|
15
|
+
runtime.registerKind(createRuntimeKind({
|
|
16
|
+
id: 'connector/substrate',
|
|
17
|
+
descriptorSchema: ConnectorSubstrateDescriptorSchema,
|
|
18
|
+
}));
|
|
19
|
+
runtime.registerKind(createRuntimeKind({
|
|
20
|
+
id: 'connector/sub-connector',
|
|
21
|
+
descriptorSchema: SubConnectorDescriptorSchema,
|
|
22
|
+
}));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
export default connectorBasePlugin;
|
|
26
|
+
//# sourceMappingURL=connector.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.plugin.js","sourceRoot":"","sources":["../src/connector.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACN,kCAAkC,EAClC,4BAA4B,GAC5B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;IACtD,EAAE,EAAE,6BAA6B;IACjC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,uFAAuF;IAEpG,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7B,OAAO,CAAC,YAAY,CACnB,iBAAiB,CAAC;YACjB,EAAE,EAAE,qBAAqB;YACzB,gBAAgB,EAAE,kCAAkC;SACpD,CAAC,CACF,CAAC;QAEF,OAAO,CAAC,YAAY,CACnB,iBAAiB,CAAC;YACjB,EAAE,EAAE,yBAAyB;YAC7B,gBAAgB,EAAE,4BAA4B;SAC9C,CAAC,CACF,CAAC;IACH,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Base contracts, schemas, and interfaces for platform connector packages.
|
|
5
|
+
* Owned by packages/connector-base.
|
|
6
|
+
*
|
|
7
|
+
* Does NOT contain provider-specific implementations.
|
|
8
|
+
* Use @vibesdotdev/connector-aws for AWS sub-connectors,
|
|
9
|
+
* @vibesdotdev/connector-azure for Azure, etc.
|
|
10
|
+
*/
|
|
11
|
+
export { ConnectorSubstrateDescriptorSchema, SubConnectorDescriptorSchema, CredentialReferenceSchema, AwsCredentialsSchema, type ConnectorSubstrateDescriptor, type SubConnectorDescriptor, type CredentialReference, type AwsCredentials, } from './schemas.ts';
|
|
12
|
+
export { resolveCredentialReference, resolveAwsCredentials, resolveConfigValue, type ResolutionOptions, } from './resolver.ts';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACN,kCAAkC,EAClC,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,iBAAiB,GACtB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Base contracts, schemas, and interfaces for platform connector packages.
|
|
5
|
+
* Owned by packages/connector-base.
|
|
6
|
+
*
|
|
7
|
+
* Does NOT contain provider-specific implementations.
|
|
8
|
+
* Use @vibesdotdev/connector-aws for AWS sub-connectors,
|
|
9
|
+
* @vibesdotdev/connector-azure for Azure, etc.
|
|
10
|
+
*/
|
|
11
|
+
// Descriptor schemas
|
|
12
|
+
export { ConnectorSubstrateDescriptorSchema, SubConnectorDescriptorSchema, CredentialReferenceSchema, AwsCredentialsSchema, } from "./schemas.js";
|
|
13
|
+
// Resolvers (credential resolution, config hydration)
|
|
14
|
+
export { resolveCredentialReference, resolveAwsCredentials, resolveConfigValue, } from "./resolver.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,qBAAqB;AACrB,OAAO,EACN,kCAAkC,EAClC,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,GAKpB,MAAM,cAAc,CAAC;AAEtB,sDAAsD;AACtD,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,GAElB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential and Config Resolution for Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Provides generic reference-resolution utilities used by all
|
|
6
|
+
* connector-{provider} packages. Avoids hard dependency on
|
|
7
|
+
* @vibesdotdev/secrets by accepting an injected store shape.
|
|
8
|
+
*/
|
|
9
|
+
import type { CredentialReference, AwsCredentials } from './schemas.ts';
|
|
10
|
+
export interface MinimalSecretsStore {
|
|
11
|
+
get(scope: string, key: string): Promise<string | undefined>;
|
|
12
|
+
}
|
|
13
|
+
export interface ResolutionOptions {
|
|
14
|
+
/** Active environment tier — dev / staging / prod */
|
|
15
|
+
environment: string;
|
|
16
|
+
/** Optional secrets store for source: 'secret' refs */
|
|
17
|
+
secretsStore?: MinimalSecretsStore;
|
|
18
|
+
/** Optional env reader (defaults to process.env) */
|
|
19
|
+
envReader?: Record<string, string | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export declare class ConnectorResolutionError extends Error {
|
|
22
|
+
readonly field: string;
|
|
23
|
+
readonly ref: CredentialReference;
|
|
24
|
+
readonly cause?: unknown | undefined;
|
|
25
|
+
constructor(message: string, field: string, ref: CredentialReference, cause?: unknown | undefined);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a single credential reference to its string value.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveCredentialReference(field: string, ref: CredentialReference, opts: ResolutionOptions): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve an AWS credentials block where each field may be a string or
|
|
33
|
+
* a CredentialReference.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveAwsCredentials(creds: AwsCredentials, opts: ResolutionOptions): Promise<{
|
|
36
|
+
accessKeyId: string;
|
|
37
|
+
secretAccessKey: string;
|
|
38
|
+
sessionToken?: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve an arbitrary config value that may be a bare string or a
|
|
42
|
+
* CredentialReference.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveConfigValue(value: string | CredentialReference, field: string, opts: ResolutionOptions): Promise<string>;
|
|
45
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMxE,MAAM,WAAW,mBAAmB;IACnC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,iBAAiB;IACjC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/C;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAGjD,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,GAAG,EAAE,mBAAmB;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;gBAHxB,OAAO,EAAE,MAAM,EACN,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,mBAAmB,EACxB,KAAK,CAAC,EAAE,OAAO,YAAA;CAKzB;AAMD;;GAEG;AACH,wBAAsB,0BAA0B,CAC/C,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,MAAM,CAAC,CAkDjB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBlF;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,KAAK,EAAE,MAAM,GAAG,mBAAmB,EACnC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
package/dist/resolver.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential and Config Resolution for Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Provides generic reference-resolution utilities used by all
|
|
6
|
+
* connector-{provider} packages. Avoids hard dependency on
|
|
7
|
+
* @vibesdotdev/secrets by accepting an injected store shape.
|
|
8
|
+
*/
|
|
9
|
+
export class ConnectorResolutionError extends Error {
|
|
10
|
+
field;
|
|
11
|
+
ref;
|
|
12
|
+
cause;
|
|
13
|
+
constructor(message, field, ref, cause) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.field = field;
|
|
16
|
+
this.ref = ref;
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
this.name = 'ConnectorResolutionError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Value resolution
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a single credential reference to its string value.
|
|
26
|
+
*/
|
|
27
|
+
export async function resolveCredentialReference(field, ref, opts) {
|
|
28
|
+
if (ref.source === 'env') {
|
|
29
|
+
const reader = opts.envReader ?? process.env;
|
|
30
|
+
const value = reader[ref.key];
|
|
31
|
+
if (value === undefined || value === '') {
|
|
32
|
+
throw new ConnectorResolutionError(`Environment variable "${ref.key}" required by field "${field}" is not set.`, field, ref);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
if (ref.source === 'secret') {
|
|
37
|
+
if (!opts.secretsStore) {
|
|
38
|
+
throw new ConnectorResolutionError(`Secrets store unavailable — cannot resolve { source: 'secret', key: '${ref.key}' } for field "${field}".`, field, ref);
|
|
39
|
+
}
|
|
40
|
+
const scope = ref.scope ?? opts.environment;
|
|
41
|
+
let value;
|
|
42
|
+
try {
|
|
43
|
+
value = await opts.secretsStore.get(scope, ref.key);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
throw new ConnectorResolutionError(`Secrets store lookup failed for "${field}" (key "${ref.key}", scope "${scope}"): ${err instanceof Error ? err.message : String(err)}`, field, ref, err);
|
|
47
|
+
}
|
|
48
|
+
if (value === undefined || value === '') {
|
|
49
|
+
throw new ConnectorResolutionError(`Secret "${ref.key}" (scope "${scope}") required by field "${field}" not found.`, field, ref);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
// Should not reach here — schemas guard inline.
|
|
54
|
+
throw new ConnectorResolutionError(`Unsupported credential source "${ref.source}" for field "${field}".`, field, ref);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve an AWS credentials block where each field may be a string or
|
|
58
|
+
* a CredentialReference.
|
|
59
|
+
*/
|
|
60
|
+
export async function resolveAwsCredentials(creds, opts) {
|
|
61
|
+
const accessKeyId = typeof creds.accessKeyId === 'string'
|
|
62
|
+
? creds.accessKeyId
|
|
63
|
+
: await resolveCredentialReference('accessKeyId', creds.accessKeyId, opts);
|
|
64
|
+
const secretAccessKey = typeof creds.secretAccessKey === 'string'
|
|
65
|
+
? creds.secretAccessKey
|
|
66
|
+
: await resolveCredentialReference('secretAccessKey', creds.secretAccessKey, opts);
|
|
67
|
+
let sessionToken;
|
|
68
|
+
if (creds.sessionToken !== undefined) {
|
|
69
|
+
sessionToken =
|
|
70
|
+
typeof creds.sessionToken === 'string'
|
|
71
|
+
? creds.sessionToken
|
|
72
|
+
: await resolveCredentialReference('sessionToken', creds.sessionToken, opts);
|
|
73
|
+
}
|
|
74
|
+
return { accessKeyId, secretAccessKey, sessionToken };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve an arbitrary config value that may be a bare string or a
|
|
78
|
+
* CredentialReference.
|
|
79
|
+
*/
|
|
80
|
+
export async function resolveConfigValue(value, field, opts) {
|
|
81
|
+
if (typeof value === 'string')
|
|
82
|
+
return value;
|
|
83
|
+
return resolveCredentialReference(field, value, opts);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAGxC;IACA;IACA;IAJV,YACC,OAAe,EACN,KAAa,EACb,GAAwB,EACxB,KAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAqB;QACxB,UAAK,GAA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AC;IAChF,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,KAAmC,EACnC,KAAa,EACb,IAAuB;IAEvB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Schemas
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Descriptor schemas for connector/substrate kind and sub-connector variants.
|
|
6
|
+
*/
|
|
7
|
+
import * as z from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Credential reference for secret store / env lookup.
|
|
10
|
+
* Mirrored from credential-reference.ts to avoid cross-deps.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CredentialReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
|
+
source: z.ZodLiteral<"secret">;
|
|
14
|
+
key: z.ZodString;
|
|
15
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
16
|
+
store: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
+
source: z.ZodLiteral<"env">;
|
|
19
|
+
key: z.ZodString;
|
|
20
|
+
}, z.core.$strip>], "source">;
|
|
21
|
+
export type CredentialReference = z.infer<typeof CredentialReferenceSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* AWS-style credentials block (used by S3, SecretsManager, etc).
|
|
24
|
+
*/
|
|
25
|
+
export declare const AwsCredentialsSchema: z.ZodObject<{
|
|
26
|
+
accessKeyId: z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
source: z.ZodLiteral<"secret">;
|
|
28
|
+
key: z.ZodString;
|
|
29
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
30
|
+
store: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
+
source: z.ZodLiteral<"env">;
|
|
33
|
+
key: z.ZodString;
|
|
34
|
+
}, z.core.$strip>], "source">]>;
|
|
35
|
+
secretAccessKey: z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
36
|
+
source: z.ZodLiteral<"secret">;
|
|
37
|
+
key: z.ZodString;
|
|
38
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
39
|
+
store: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
source: z.ZodLiteral<"env">;
|
|
42
|
+
key: z.ZodString;
|
|
43
|
+
}, z.core.$strip>], "source">]>;
|
|
44
|
+
sessionToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
+
source: z.ZodLiteral<"secret">;
|
|
46
|
+
key: z.ZodString;
|
|
47
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
48
|
+
store: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
50
|
+
source: z.ZodLiteral<"env">;
|
|
51
|
+
key: z.ZodString;
|
|
52
|
+
}, z.core.$strip>], "source">]>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type AwsCredentials = z.infer<typeof AwsCredentialsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Base descriptor schema for connector/substrate runtime kind.
|
|
57
|
+
*
|
|
58
|
+
* A substrate is a platform-level integration that provides one or more
|
|
59
|
+
* sub-connectors (e.g., S3, SecretsManager, CloudFront).
|
|
60
|
+
*/
|
|
61
|
+
export declare const ConnectorSubstrateDescriptorSchema: z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
kind: z.ZodLiteral<"connector/substrate">;
|
|
64
|
+
name: z.ZodOptional<z.ZodString>;
|
|
65
|
+
description: z.ZodOptional<z.ZodString>;
|
|
66
|
+
provider: z.ZodString;
|
|
67
|
+
subConnectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
hardware: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
69
|
+
consumer: "consumer";
|
|
70
|
+
cloud: "cloud";
|
|
71
|
+
server: "server";
|
|
72
|
+
}>>>;
|
|
73
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type ConnectorSubstrateDescriptor = z.infer<typeof ConnectorSubstrateDescriptorSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Descriptor for a sub-connector within a substrate.
|
|
78
|
+
* Sub-connectors are the actual service clients (e.g., S3, SecretsManager).
|
|
79
|
+
*/
|
|
80
|
+
export declare const SubConnectorDescriptorSchema: z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
kind: z.ZodLiteral<"connector/sub-connector">;
|
|
83
|
+
name: z.ZodOptional<z.ZodString>;
|
|
84
|
+
description: z.ZodOptional<z.ZodString>;
|
|
85
|
+
substrateId: z.ZodString;
|
|
86
|
+
service: z.ZodString;
|
|
87
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export type SubConnectorDescriptor = z.infer<typeof SubConnectorDescriptorSchema>;
|
|
90
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;6BAWpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;iBAY7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;iBAWvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Schemas
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Descriptor schemas for connector/substrate kind and sub-connector variants.
|
|
6
|
+
*/
|
|
7
|
+
import * as z from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Credential reference for secret store / env lookup.
|
|
10
|
+
* Mirrored from credential-reference.ts to avoid cross-deps.
|
|
11
|
+
*/
|
|
12
|
+
export const CredentialReferenceSchema = z.discriminatedUnion('source', [
|
|
13
|
+
z.object({
|
|
14
|
+
source: z.literal('secret'),
|
|
15
|
+
key: z.string(),
|
|
16
|
+
scope: z.string().optional(),
|
|
17
|
+
store: z.string().optional(),
|
|
18
|
+
}),
|
|
19
|
+
z.object({
|
|
20
|
+
source: z.literal('env'),
|
|
21
|
+
key: z.string(),
|
|
22
|
+
}),
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* AWS-style credentials block (used by S3, SecretsManager, etc).
|
|
26
|
+
*/
|
|
27
|
+
export const AwsCredentialsSchema = z.object({
|
|
28
|
+
accessKeyId: z.union([z.string(), CredentialReferenceSchema]),
|
|
29
|
+
secretAccessKey: z.union([z.string(), CredentialReferenceSchema]),
|
|
30
|
+
sessionToken: z.union([z.string(), CredentialReferenceSchema]).optional(),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Base descriptor schema for connector/substrate runtime kind.
|
|
34
|
+
*
|
|
35
|
+
* A substrate is a platform-level integration that provides one or more
|
|
36
|
+
* sub-connectors (e.g., S3, SecretsManager, CloudFront).
|
|
37
|
+
*/
|
|
38
|
+
export const ConnectorSubstrateDescriptorSchema = z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
kind: z.literal('connector/substrate'),
|
|
41
|
+
name: z.string().optional(),
|
|
42
|
+
description: z.string().optional(),
|
|
43
|
+
provider: z.string(),
|
|
44
|
+
/** Sub-connectors provided by this substrate */
|
|
45
|
+
subConnectors: z.array(z.string()).optional(),
|
|
46
|
+
/** Hardware targets (consumer, cloud) */
|
|
47
|
+
hardware: z.array(z.enum(['consumer', 'cloud', 'server'])).optional(),
|
|
48
|
+
/** Whether this substrate is currently enabled */
|
|
49
|
+
enabled: z.boolean().default(true),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Descriptor for a sub-connector within a substrate.
|
|
53
|
+
* Sub-connectors are the actual service clients (e.g., S3, SecretsManager).
|
|
54
|
+
*/
|
|
55
|
+
export const SubConnectorDescriptorSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
kind: z.literal('connector/sub-connector'),
|
|
58
|
+
name: z.string().optional(),
|
|
59
|
+
description: z.string().optional(),
|
|
60
|
+
/** Parent substrate ID */
|
|
61
|
+
substrateId: z.string(),
|
|
62
|
+
/** Service type identifier */
|
|
63
|
+
service: z.string(),
|
|
64
|
+
/** Whether this sub-connector is currently enabled */
|
|
65
|
+
enabled: z.boolean().default(true),
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
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tC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,gDAAgD;IAChD,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC7C,yCAAyC;IACzC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrE,kDAAkD;IAClD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAClC,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,0BAA0B;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,8BAA8B;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,sDAAsD;IACtD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAClC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibesdotdev/connector-base",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Base connector runtime kind and contracts for platform integrations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"bun": "./src/index.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./plugin": {
|
|
20
|
+
"types": "./dist/connector.plugin.d.ts",
|
|
21
|
+
"bun": "./src/connector.plugin.ts",
|
|
22
|
+
"import": "./dist/connector.plugin.js",
|
|
23
|
+
"default": "./dist/connector.plugin.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@vibesdotdev/runtime": "0.0.1",
|
|
28
|
+
"zod": "^3.23.8"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"check": "bun --bun tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"build": "tsc -p tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/vibesdotdev/monorepo.git",
|
|
37
|
+
"directory": "packages/connector-base"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"src",
|
|
43
|
+
"bin",
|
|
44
|
+
"README.md",
|
|
45
|
+
"SPEC.md",
|
|
46
|
+
"LICENSE",
|
|
47
|
+
"!src/**/__tests__/**",
|
|
48
|
+
"!src/**/__stubs__/**",
|
|
49
|
+
"!src/**/*.test.ts",
|
|
50
|
+
"!src/**/*.test.tsx",
|
|
51
|
+
"!src/**/*.spec.ts",
|
|
52
|
+
"!src/**/*.spec.tsx",
|
|
53
|
+
"!dist/**/__tests__/**",
|
|
54
|
+
"!dist/**/__stubs__/**",
|
|
55
|
+
"!dist/**/*.test.js",
|
|
56
|
+
"!dist/**/*.test.js.map",
|
|
57
|
+
"!dist/**/*.test.d.ts",
|
|
58
|
+
"!dist/**/*.test.d.ts.map",
|
|
59
|
+
"!dist/**/*.spec.js",
|
|
60
|
+
"!dist/**/*.spec.js.map",
|
|
61
|
+
"!dist/**/*.spec.d.ts",
|
|
62
|
+
"!dist/**/*.spec.d.ts.map"
|
|
63
|
+
],
|
|
64
|
+
"vibes": {
|
|
65
|
+
"visibility": "public-framework"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Plugin
|
|
3
|
+
*
|
|
4
|
+
* Registers the connector/substrate and connector/sub-connector runtime kinds.
|
|
5
|
+
* Individual provider packages (connector-aws, connector-azure, …) register
|
|
6
|
+
* concrete descriptors against these kinds.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createRuntimePlugin, createRuntimeKind } from '@vibesdotdev/runtime';
|
|
10
|
+
import {
|
|
11
|
+
ConnectorSubstrateDescriptorSchema,
|
|
12
|
+
SubConnectorDescriptorSchema,
|
|
13
|
+
} from './schemas.ts';
|
|
14
|
+
|
|
15
|
+
export const connectorBasePlugin = createRuntimePlugin({
|
|
16
|
+
id: '@vibesdotdev/connector-base',
|
|
17
|
+
name: 'Connector Base',
|
|
18
|
+
description: 'Base connector/substrate and connector/sub-connector kinds for platform integrations.',
|
|
19
|
+
|
|
20
|
+
onRegister: async (runtime) => {
|
|
21
|
+
runtime.registerKind(
|
|
22
|
+
createRuntimeKind({
|
|
23
|
+
id: 'connector/substrate',
|
|
24
|
+
descriptorSchema: ConnectorSubstrateDescriptorSchema,
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
runtime.registerKind(
|
|
29
|
+
createRuntimeKind({
|
|
30
|
+
id: 'connector/sub-connector',
|
|
31
|
+
descriptorSchema: SubConnectorDescriptorSchema,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default connectorBasePlugin;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Base contracts, schemas, and interfaces for platform connector packages.
|
|
5
|
+
* Owned by packages/connector-base.
|
|
6
|
+
*
|
|
7
|
+
* Does NOT contain provider-specific implementations.
|
|
8
|
+
* Use @vibesdotdev/connector-aws for AWS sub-connectors,
|
|
9
|
+
* @vibesdotdev/connector-azure for Azure, etc.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Descriptor schemas
|
|
13
|
+
export {
|
|
14
|
+
ConnectorSubstrateDescriptorSchema,
|
|
15
|
+
SubConnectorDescriptorSchema,
|
|
16
|
+
CredentialReferenceSchema,
|
|
17
|
+
AwsCredentialsSchema,
|
|
18
|
+
type ConnectorSubstrateDescriptor,
|
|
19
|
+
type SubConnectorDescriptor,
|
|
20
|
+
type CredentialReference,
|
|
21
|
+
type AwsCredentials,
|
|
22
|
+
} from './schemas.ts';
|
|
23
|
+
|
|
24
|
+
// Resolvers (credential resolution, config hydration)
|
|
25
|
+
export {
|
|
26
|
+
resolveCredentialReference,
|
|
27
|
+
resolveAwsCredentials,
|
|
28
|
+
resolveConfigValue,
|
|
29
|
+
type ResolutionOptions,
|
|
30
|
+
} from './resolver.ts';
|
package/src/resolver.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential and Config Resolution for Connector Base
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Provides generic reference-resolution utilities used by all
|
|
6
|
+
* connector-{provider} packages. Avoids hard dependency on
|
|
7
|
+
* @vibesdotdev/secrets by accepting an injected store shape.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { CredentialReference, AwsCredentials } from './schemas.ts';
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Minimal store interface — avoids pulling in @vibesdotdev/secrets
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export interface MinimalSecretsStore {
|
|
17
|
+
get(scope: string, key: string): Promise<string | undefined>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ResolutionOptions {
|
|
21
|
+
/** Active environment tier — dev / staging / prod */
|
|
22
|
+
environment: string;
|
|
23
|
+
/** Optional secrets store for source: 'secret' refs */
|
|
24
|
+
secretsStore?: MinimalSecretsStore;
|
|
25
|
+
/** Optional env reader (defaults to process.env) */
|
|
26
|
+
envReader?: Record<string, string | undefined>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ConnectorResolutionError extends Error {
|
|
30
|
+
constructor(
|
|
31
|
+
message: string,
|
|
32
|
+
readonly field: string,
|
|
33
|
+
readonly ref: CredentialReference,
|
|
34
|
+
readonly cause?: unknown
|
|
35
|
+
) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = 'ConnectorResolutionError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Value resolution
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a single credential reference to its string value.
|
|
47
|
+
*/
|
|
48
|
+
export async function resolveCredentialReference(
|
|
49
|
+
field: string,
|
|
50
|
+
ref: CredentialReference,
|
|
51
|
+
opts: ResolutionOptions
|
|
52
|
+
): Promise<string> {
|
|
53
|
+
if (ref.source === 'env') {
|
|
54
|
+
const reader = opts.envReader ?? (process.env as Record<string, string | undefined>);
|
|
55
|
+
const value = reader[ref.key];
|
|
56
|
+
if (value === undefined || value === '') {
|
|
57
|
+
throw new ConnectorResolutionError(
|
|
58
|
+
`Environment variable "${ref.key}" required by field "${field}" is not set.`,
|
|
59
|
+
field,
|
|
60
|
+
ref
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (ref.source === 'secret') {
|
|
67
|
+
if (!opts.secretsStore) {
|
|
68
|
+
throw new ConnectorResolutionError(
|
|
69
|
+
`Secrets store unavailable — cannot resolve { source: 'secret', key: '${ref.key}' } for field "${field}".`,
|
|
70
|
+
field,
|
|
71
|
+
ref
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const scope = ref.scope ?? opts.environment;
|
|
75
|
+
let value: string | undefined;
|
|
76
|
+
try {
|
|
77
|
+
value = await opts.secretsStore.get(scope, ref.key);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
throw new ConnectorResolutionError(
|
|
80
|
+
`Secrets store lookup failed for "${field}" (key "${ref.key}", scope "${scope}"): ${err instanceof Error ? err.message : String(err)}`,
|
|
81
|
+
field,
|
|
82
|
+
ref,
|
|
83
|
+
err
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (value === undefined || value === '') {
|
|
87
|
+
throw new ConnectorResolutionError(
|
|
88
|
+
`Secret "${ref.key}" (scope "${scope}") required by field "${field}" not found.`,
|
|
89
|
+
field,
|
|
90
|
+
ref
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Should not reach here — schemas guard inline.
|
|
97
|
+
throw new ConnectorResolutionError(
|
|
98
|
+
`Unsupported credential source "${(ref as CredentialReference).source}" for field "${field}".`,
|
|
99
|
+
field,
|
|
100
|
+
ref
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Resolve an AWS credentials block where each field may be a string or
|
|
106
|
+
* a CredentialReference.
|
|
107
|
+
*/
|
|
108
|
+
export async function resolveAwsCredentials(
|
|
109
|
+
creds: AwsCredentials,
|
|
110
|
+
opts: ResolutionOptions
|
|
111
|
+
): Promise<{ accessKeyId: string; secretAccessKey: string; sessionToken?: string }> {
|
|
112
|
+
const accessKeyId =
|
|
113
|
+
typeof creds.accessKeyId === 'string'
|
|
114
|
+
? creds.accessKeyId
|
|
115
|
+
: await resolveCredentialReference('accessKeyId', creds.accessKeyId, opts);
|
|
116
|
+
|
|
117
|
+
const secretAccessKey =
|
|
118
|
+
typeof creds.secretAccessKey === 'string'
|
|
119
|
+
? creds.secretAccessKey
|
|
120
|
+
: await resolveCredentialReference('secretAccessKey', creds.secretAccessKey, opts);
|
|
121
|
+
|
|
122
|
+
let sessionToken: string | undefined;
|
|
123
|
+
if (creds.sessionToken !== undefined) {
|
|
124
|
+
sessionToken =
|
|
125
|
+
typeof creds.sessionToken === 'string'
|
|
126
|
+
? creds.sessionToken
|
|
127
|
+
: await resolveCredentialReference('sessionToken', creds.sessionToken, opts);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { accessKeyId, secretAccessKey, sessionToken };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Resolve an arbitrary config value that may be a bare string or a
|
|
135
|
+
* CredentialReference.
|
|
136
|
+
*/
|
|
137
|
+
export async function resolveConfigValue(
|
|
138
|
+
value: string | CredentialReference,
|
|
139
|
+
field: string,
|
|
140
|
+
opts: ResolutionOptions
|
|
141
|
+
): Promise<string> {
|
|
142
|
+
if (typeof value === 'string') return value;
|
|
143
|
+
return resolveCredentialReference(field, value, opts);
|
|
144
|
+
}
|
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector Base Schemas
|
|
3
|
+
*
|
|
4
|
+
* Owned by packages/connector-base.
|
|
5
|
+
* Descriptor schemas for connector/substrate kind and sub-connector variants.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as z from 'zod';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Credential reference for secret store / env lookup.
|
|
12
|
+
* Mirrored from credential-reference.ts to avoid cross-deps.
|
|
13
|
+
*/
|
|
14
|
+
export const CredentialReferenceSchema = z.discriminatedUnion('source', [
|
|
15
|
+
z.object({
|
|
16
|
+
source: z.literal('secret'),
|
|
17
|
+
key: z.string(),
|
|
18
|
+
scope: z.string().optional(),
|
|
19
|
+
store: z.string().optional(),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
source: z.literal('env'),
|
|
23
|
+
key: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export type CredentialReference = z.infer<typeof CredentialReferenceSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* AWS-style credentials block (used by S3, SecretsManager, etc).
|
|
31
|
+
*/
|
|
32
|
+
export const AwsCredentialsSchema = z.object({
|
|
33
|
+
accessKeyId: z.union([z.string(), CredentialReferenceSchema]),
|
|
34
|
+
secretAccessKey: z.union([z.string(), CredentialReferenceSchema]),
|
|
35
|
+
sessionToken: z.union([z.string(), CredentialReferenceSchema]).optional(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type AwsCredentials = z.infer<typeof AwsCredentialsSchema>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Base descriptor schema for connector/substrate runtime kind.
|
|
42
|
+
*
|
|
43
|
+
* A substrate is a platform-level integration that provides one or more
|
|
44
|
+
* sub-connectors (e.g., S3, SecretsManager, CloudFront).
|
|
45
|
+
*/
|
|
46
|
+
export const ConnectorSubstrateDescriptorSchema = z.object({
|
|
47
|
+
id: z.string(),
|
|
48
|
+
kind: z.literal('connector/substrate'),
|
|
49
|
+
name: z.string().optional(),
|
|
50
|
+
description: z.string().optional(),
|
|
51
|
+
provider: z.string(),
|
|
52
|
+
/** Sub-connectors provided by this substrate */
|
|
53
|
+
subConnectors: z.array(z.string()).optional(),
|
|
54
|
+
/** Hardware targets (consumer, cloud) */
|
|
55
|
+
hardware: z.array(z.enum(['consumer', 'cloud', 'server'])).optional(),
|
|
56
|
+
/** Whether this substrate is currently enabled */
|
|
57
|
+
enabled: z.boolean().default(true),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export type ConnectorSubstrateDescriptor = z.infer<typeof ConnectorSubstrateDescriptorSchema>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Descriptor for a sub-connector within a substrate.
|
|
64
|
+
* Sub-connectors are the actual service clients (e.g., S3, SecretsManager).
|
|
65
|
+
*/
|
|
66
|
+
export const SubConnectorDescriptorSchema = z.object({
|
|
67
|
+
id: z.string(),
|
|
68
|
+
kind: z.literal('connector/sub-connector'),
|
|
69
|
+
name: z.string().optional(),
|
|
70
|
+
description: z.string().optional(),
|
|
71
|
+
/** Parent substrate ID */
|
|
72
|
+
substrateId: z.string(),
|
|
73
|
+
/** Service type identifier */
|
|
74
|
+
service: z.string(),
|
|
75
|
+
/** Whether this sub-connector is currently enabled */
|
|
76
|
+
enabled: z.boolean().default(true),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export type SubConnectorDescriptor = z.infer<typeof SubConnectorDescriptorSchema>;
|