@valon-technologies/gestalt 0.0.1-alpha.1 → 0.0.1-alpha.11
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/README.md +8 -26
- package/gen/v1/{auth_pb.ts → authentication_pb.ts} +51 -17
- package/gen/v1/authorization_pb.ts +857 -0
- package/gen/v1/cache_pb.ts +32 -0
- package/gen/v1/datastore_pb.ts +62 -0
- package/gen/v1/plugin_pb.ts +279 -18
- package/gen/v1/runtime_pb.ts +27 -3
- package/gen/v1/s3_pb.ts +39 -0
- package/gen/v1/secrets_pb.ts +6 -0
- package/gen/v1/workflow_pb.ts +1372 -0
- package/package.json +12 -10
- package/src/api.ts +56 -0
- package/src/auth.ts +67 -16
- package/src/build.ts +37 -21
- package/src/cache.ts +32 -0
- package/src/catalog.ts +27 -0
- package/src/index.ts +105 -18
- package/src/indexeddb.ts +166 -0
- package/src/invoker.ts +160 -0
- package/src/manifest-metadata.ts +101 -0
- package/src/plugin.ts +255 -38
- package/src/provider-kind.ts +107 -0
- package/src/provider.ts +32 -1
- package/src/runtime.ts +245 -219
- package/src/s3.ts +135 -20
- package/src/schema.ts +46 -0
- package/src/secrets.ts +12 -0
- package/src/target.ts +58 -60
- package/src/workflow-manager.ts +131 -0
- package/src/workflow.ts +479 -0
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ProviderKind } from "./provider.ts";
|
|
2
|
+
|
|
3
|
+
type ProviderKindDefinition = {
|
|
4
|
+
readonly tokens: readonly string[];
|
|
5
|
+
readonly formatToken: string;
|
|
6
|
+
readonly defaultExportNames: readonly string[];
|
|
7
|
+
readonly label: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const PROVIDER_KIND_DEFINITIONS = {
|
|
11
|
+
integration: {
|
|
12
|
+
tokens: ["plugin"],
|
|
13
|
+
formatToken: "plugin",
|
|
14
|
+
defaultExportNames: ["provider", "plugin"],
|
|
15
|
+
label: "plugin provider",
|
|
16
|
+
},
|
|
17
|
+
authentication: {
|
|
18
|
+
tokens: ["authentication"],
|
|
19
|
+
formatToken: "authentication",
|
|
20
|
+
defaultExportNames: ["authentication", "provider"],
|
|
21
|
+
label: "authentication provider",
|
|
22
|
+
},
|
|
23
|
+
cache: {
|
|
24
|
+
tokens: ["cache"],
|
|
25
|
+
formatToken: "cache",
|
|
26
|
+
defaultExportNames: ["cache", "provider"],
|
|
27
|
+
label: "cache provider",
|
|
28
|
+
},
|
|
29
|
+
secrets: {
|
|
30
|
+
tokens: ["secrets"],
|
|
31
|
+
formatToken: "secrets",
|
|
32
|
+
defaultExportNames: ["secrets", "provider"],
|
|
33
|
+
label: "secrets provider",
|
|
34
|
+
},
|
|
35
|
+
s3: {
|
|
36
|
+
tokens: ["s3"],
|
|
37
|
+
formatToken: "s3",
|
|
38
|
+
defaultExportNames: ["s3", "provider"],
|
|
39
|
+
label: "s3 provider",
|
|
40
|
+
},
|
|
41
|
+
workflow: {
|
|
42
|
+
tokens: ["workflow"],
|
|
43
|
+
formatToken: "workflow",
|
|
44
|
+
defaultExportNames: ["workflow", "provider"],
|
|
45
|
+
label: "workflow provider",
|
|
46
|
+
},
|
|
47
|
+
telemetry: {
|
|
48
|
+
tokens: ["telemetry"],
|
|
49
|
+
formatToken: "telemetry",
|
|
50
|
+
defaultExportNames: ["telemetry", "provider"],
|
|
51
|
+
label: "telemetry provider",
|
|
52
|
+
},
|
|
53
|
+
} satisfies Record<ProviderKind, ProviderKindDefinition>;
|
|
54
|
+
|
|
55
|
+
const EXTERNAL_PROVIDER_KIND_TOKEN_SET = new Set<string>(
|
|
56
|
+
Object.values(PROVIDER_KIND_DEFINITIONS).flatMap(
|
|
57
|
+
(definition) => definition.tokens,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const EXTERNAL_PROVIDER_KIND_MAP = new Map<string, ProviderKind>(
|
|
62
|
+
Object.entries(PROVIDER_KIND_DEFINITIONS).flatMap(([kind, definition]) =>
|
|
63
|
+
definition.tokens.map(
|
|
64
|
+
(token) => [token, kind as ProviderKind] as const,
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export function isExternalProviderKindToken(value: string): boolean {
|
|
70
|
+
return EXTERNAL_PROVIDER_KIND_TOKEN_SET.has(value.trim().toLowerCase());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function parseExternalProviderKind(value: string): ProviderKind {
|
|
74
|
+
const normalized = value.trim().toLowerCase();
|
|
75
|
+
const kind = EXTERNAL_PROVIDER_KIND_MAP.get(normalized);
|
|
76
|
+
if (!kind) {
|
|
77
|
+
throw new Error(`unsupported provider kind ${JSON.stringify(value)}`);
|
|
78
|
+
}
|
|
79
|
+
return kind;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function formatExternalProviderKind(kind: ProviderKind): string {
|
|
83
|
+
return PROVIDER_KIND_DEFINITIONS[kind].formatToken;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function providerKindLabel(kind: ProviderKind): string {
|
|
87
|
+
return PROVIDER_KIND_DEFINITIONS[kind].label;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function defaultProviderExportNames(
|
|
91
|
+
kind: ProviderKind,
|
|
92
|
+
): readonly string[] {
|
|
93
|
+
return PROVIDER_KIND_DEFINITIONS[kind].defaultExportNames;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function resolveDefaultProviderExport(
|
|
97
|
+
module: Record<string, unknown>,
|
|
98
|
+
kind: ProviderKind,
|
|
99
|
+
): unknown {
|
|
100
|
+
for (const exportName of defaultProviderExportNames(kind)) {
|
|
101
|
+
const candidate = Reflect.get(module, exportName);
|
|
102
|
+
if (candidate !== undefined && candidate !== null) {
|
|
103
|
+
return candidate;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Reflect.get(module, "default");
|
|
107
|
+
}
|
package/src/provider.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { MaybePromise } from "./api.ts";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Provider kinds supported by the TypeScript SDK runtime.
|
|
5
|
+
*/
|
|
3
6
|
export type ProviderKind =
|
|
4
7
|
| "integration"
|
|
5
|
-
| "
|
|
8
|
+
| "authentication"
|
|
6
9
|
| "cache"
|
|
7
10
|
| "secrets"
|
|
8
11
|
| "s3"
|
|
12
|
+
| "workflow"
|
|
9
13
|
| "telemetry";
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Runtime metadata reported to the Gestalt host during startup.
|
|
17
|
+
*/
|
|
11
18
|
export type ProviderMetadata = {
|
|
12
19
|
kind?: ProviderKind;
|
|
13
20
|
name?: string;
|
|
@@ -16,17 +23,32 @@ export type ProviderMetadata = {
|
|
|
16
23
|
version?: string;
|
|
17
24
|
};
|
|
18
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Optional configuration hook invoked after the host starts the provider.
|
|
28
|
+
*/
|
|
19
29
|
export type ConfigureHandler = (
|
|
20
30
|
name: string,
|
|
21
31
|
config: Record<string, unknown>,
|
|
22
32
|
) => MaybePromise<void>;
|
|
23
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Optional readiness probe invoked by the Gestalt host.
|
|
36
|
+
*/
|
|
24
37
|
export type HealthCheckHandler = () => MaybePromise<void>;
|
|
25
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Optional callback that returns non-fatal runtime warnings.
|
|
41
|
+
*/
|
|
26
42
|
export type WarningsHandler = () => MaybePromise<string[]>;
|
|
27
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Optional shutdown hook invoked when the provider process exits.
|
|
46
|
+
*/
|
|
28
47
|
export type CloseHandler = () => MaybePromise<void>;
|
|
29
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Shared runtime metadata and lifecycle hooks for authored providers.
|
|
51
|
+
*/
|
|
30
52
|
export interface RuntimeProviderOptions {
|
|
31
53
|
name?: string;
|
|
32
54
|
displayName?: string;
|
|
@@ -38,6 +60,9 @@ export interface RuntimeProviderOptions {
|
|
|
38
60
|
close?: CloseHandler;
|
|
39
61
|
}
|
|
40
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Base class shared by all TypeScript SDK provider implementations.
|
|
65
|
+
*/
|
|
41
66
|
export abstract class RuntimeProvider {
|
|
42
67
|
abstract readonly kind: ProviderKind;
|
|
43
68
|
|
|
@@ -116,6 +141,9 @@ export abstract class RuntimeProvider {
|
|
|
116
141
|
}
|
|
117
142
|
}
|
|
118
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Runtime type guard for values that implement the provider base contract.
|
|
146
|
+
*/
|
|
119
147
|
export function isRuntimeProvider(value: unknown): value is RuntimeProvider {
|
|
120
148
|
return (
|
|
121
149
|
value instanceof RuntimeProvider ||
|
|
@@ -127,6 +155,9 @@ export function isRuntimeProvider(value: unknown): value is RuntimeProvider {
|
|
|
127
155
|
);
|
|
128
156
|
}
|
|
129
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Normalizes package and provider names into Gestalt's slug format.
|
|
160
|
+
*/
|
|
130
161
|
export function slugName(value: string): string {
|
|
131
162
|
const normalized = value.trim().replace(/^@[^/]+\//, "");
|
|
132
163
|
return normalized.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|