@valon-technologies/gestalt 0.0.1-alpha.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/README.md +160 -0
- package/gen/v1/auth_pb.ts +212 -0
- package/gen/v1/cache_pb.ts +357 -0
- package/gen/v1/datastore_pb.ts +922 -0
- package/gen/v1/plugin_pb.ts +772 -0
- package/gen/v1/runtime_pb.ts +216 -0
- package/gen/v1/s3_pb.ts +640 -0
- package/gen/v1/secrets_pb.ts +63 -0
- package/package.json +55 -0
- package/src/api.ts +98 -0
- package/src/auth.ts +103 -0
- package/src/build.ts +181 -0
- package/src/cache.ts +304 -0
- package/src/catalog.ts +188 -0
- package/src/index.ts +182 -0
- package/src/indexeddb.ts +740 -0
- package/src/plugin.ts +402 -0
- package/src/provider.ts +133 -0
- package/src/runtime.ts +871 -0
- package/src/s3.ts +1128 -0
- package/src/schema.ts +219 -0
- package/src/secrets.ts +36 -0
- package/src/target.ts +192 -0
- package/tsconfig.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Gestalt TypeScript SDK
|
|
2
|
+
|
|
3
|
+
This package provides the TypeScript authoring surface for executable Gestalt
|
|
4
|
+
providers.
|
|
5
|
+
|
|
6
|
+
It is intended for source providers discovered through `package.json` and for
|
|
7
|
+
packaged providers built from that same source tree.
|
|
8
|
+
|
|
9
|
+
## Provider target
|
|
10
|
+
|
|
11
|
+
Point the package at the provider module with a top-level `gestalt.provider`
|
|
12
|
+
property in `package.json`:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"name": "my-provider",
|
|
17
|
+
"version": "0.0.1-alpha.1",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@valon-technologies/gestalt": "0.0.1-alpha.1"
|
|
20
|
+
},
|
|
21
|
+
"gestalt": {
|
|
22
|
+
"provider": {
|
|
23
|
+
"kind": "plugin",
|
|
24
|
+
"target": "./provider.ts#provider"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The target is a relative file path with an optional export suffix. The runtime
|
|
31
|
+
accepts:
|
|
32
|
+
|
|
33
|
+
- `gestalt.provider` as `{ "kind": "...", "target": "./file.ts#export" }`
|
|
34
|
+
- `gestalt.provider` as a string like `"plugin:./provider.ts#provider"` or `"cache:./cache.ts#provider"`
|
|
35
|
+
- legacy integration-only `gestalt.plugin`
|
|
36
|
+
|
|
37
|
+
Use `"plugin"` as the kind token for executable integration providers. The
|
|
38
|
+
older `"integration"` spelling is still accepted for compatibility.
|
|
39
|
+
|
|
40
|
+
If the export suffix is omitted, the runtime looks for `provider`, then
|
|
41
|
+
`plugin`, then the default export.
|
|
42
|
+
|
|
43
|
+
## Authoring
|
|
44
|
+
|
|
45
|
+
Use explicit runtime schemas to define plugin operation inputs and outputs:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import {
|
|
49
|
+
defineIntegrationProvider,
|
|
50
|
+
ok,
|
|
51
|
+
operation,
|
|
52
|
+
response,
|
|
53
|
+
s,
|
|
54
|
+
} from "@valon-technologies/gestalt";
|
|
55
|
+
|
|
56
|
+
export const provider = defineIntegrationProvider({
|
|
57
|
+
displayName: "Example Provider",
|
|
58
|
+
description: "A provider implemented with the Gestalt TypeScript SDK",
|
|
59
|
+
configure(name, config) {
|
|
60
|
+
console.log("configured", name, config);
|
|
61
|
+
},
|
|
62
|
+
sessionCatalog(request) {
|
|
63
|
+
return {
|
|
64
|
+
name: "example-session",
|
|
65
|
+
operations: [
|
|
66
|
+
{
|
|
67
|
+
id: "session-ping",
|
|
68
|
+
method: "GET",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
operations: [
|
|
74
|
+
operation({
|
|
75
|
+
id: "greet",
|
|
76
|
+
method: "GET",
|
|
77
|
+
readOnly: true,
|
|
78
|
+
input: s.object({
|
|
79
|
+
name: s.string({ description: "Name to greet", default: "World" }),
|
|
80
|
+
excited: s.optional(s.boolean()),
|
|
81
|
+
}),
|
|
82
|
+
output: s.object({
|
|
83
|
+
message: s.string(),
|
|
84
|
+
}),
|
|
85
|
+
async handler(input) {
|
|
86
|
+
return ok({
|
|
87
|
+
message: `Hello, ${input.name}${input.excited ? "!" : "."}`,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `ok(body)` for normal responses and `response(status, body)` when a handler
|
|
96
|
+
needs to set a non-200 status. Plain objects with `status` and `body` fields
|
|
97
|
+
are treated as user data.
|
|
98
|
+
|
|
99
|
+
Auth providers, cache providers, and secrets providers use dedicated helpers:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import {
|
|
103
|
+
Cache,
|
|
104
|
+
defineAuthProvider,
|
|
105
|
+
defineCacheProvider,
|
|
106
|
+
defineSecretsProvider,
|
|
107
|
+
} from "@valon-technologies/gestalt";
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Runtime and build entrypoints
|
|
111
|
+
|
|
112
|
+
Source-mode runtime:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
gestalt-ts-runtime ROOT plugin:./provider.ts#provider
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Release build:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
gestalt-ts-build ROOT cache:./cache.ts#provider OUTPUT PROVIDER_NAME GOOS GOARCH
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The build entrypoint compiles a standalone executable with Bun and bundles the
|
|
125
|
+
provider source into the result.
|
|
126
|
+
|
|
127
|
+
## Regenerating protobuf code
|
|
128
|
+
|
|
129
|
+
From the repo root:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
buf generate --template sdk/proto/buf.typescript.gen.yaml sdk/proto
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Local checks
|
|
136
|
+
|
|
137
|
+
From `sdk/typescript`:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
export PATH="$HOME/.bun/bin:$PATH"
|
|
141
|
+
bun install
|
|
142
|
+
bun run build:proto
|
|
143
|
+
bun run check
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Publishing
|
|
147
|
+
|
|
148
|
+
The SDK is published to npm as `@valon-technologies/gestalt`.
|
|
149
|
+
|
|
150
|
+
Release tags stay aligned with the repo's SDK tag convention:
|
|
151
|
+
|
|
152
|
+
- `sdk/typescript/v0.0.1`
|
|
153
|
+
- `sdk/typescript/v0.0.1-alpha.1`
|
|
154
|
+
- `sdk/typescript/v0.0.1-beta.1`
|
|
155
|
+
- `sdk/typescript/v0.0.1-rc.1`
|
|
156
|
+
|
|
157
|
+
The release workflow uses Bun for installation and validation, then publishes
|
|
158
|
+
with npm Trusted Publishing from GitHub Actions. Stable releases use the
|
|
159
|
+
default `latest` dist-tag; prereleases are published under `alpha`, `beta`, or
|
|
160
|
+
`rc`.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
|
|
2
|
+
// @generated from file v1/auth.proto (package gestalt.provider.v1, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
|
6
|
+
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
|
7
|
+
import type { EmptySchema } from "@bufbuild/protobuf/wkt";
|
|
8
|
+
import { file_google_protobuf_empty } from "@bufbuild/protobuf/wkt";
|
|
9
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Describes the file v1/auth.proto.
|
|
13
|
+
*/
|
|
14
|
+
export const file_v1_auth: GenFile = /*@__PURE__*/
|
|
15
|
+
fileD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sKE3Nlc3Npb25fdHRsX3NlY29uZHMYASABKAMynQMKDEF1dGhQcm92aWRlchJdCgpCZWdpbkxvZ2luEiYuZ2VzdGFsdC5wcm92aWRlci52MS5CZWdpbkxvZ2luUmVxdWVzdBonLmdlc3RhbHQucHJvdmlkZXIudjEuQmVnaW5Mb2dpblJlc3BvbnNlEmIKDUNvbXBsZXRlTG9naW4SKS5nZXN0YWx0LnByb3ZpZGVyLnYxLkNvbXBsZXRlTG9naW5SZXF1ZXN0GiYuZ2VzdGFsdC5wcm92aWRlci52MS5BdXRoZW50aWNhdGVkVXNlchJyChVWYWxpZGF0ZUV4dGVybmFsVG9rZW4SMS5nZXN0YWx0LnByb3ZpZGVyLnYxLlZhbGlkYXRlRXh0ZXJuYWxUb2tlblJlcXVlc3QaJi5nZXN0YWx0LnByb3ZpZGVyLnYxLkF1dGhlbnRpY2F0ZWRVc2VyElYKEkdldFNlc3Npb25TZXR0aW5ncxIWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eRooLmdlc3RhbHQucHJvdmlkZXIudjEuQXV0aFNlc3Npb25TZXR0aW5nc0I7WjlnaXRodWIuY29tL3ZhbG9uLXRlY2hub2xvZ2llcy9nZXN0YWx0L3Nkay9nby9nZW4vdjE7cHJvdG9iBnByb3RvMw", [file_google_protobuf_empty]);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @generated from message gestalt.provider.v1.AuthenticatedUser
|
|
19
|
+
*/
|
|
20
|
+
export type AuthenticatedUser = Message<"gestalt.provider.v1.AuthenticatedUser"> & {
|
|
21
|
+
/**
|
|
22
|
+
* @generated from field: string subject = 1;
|
|
23
|
+
*/
|
|
24
|
+
subject: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @generated from field: string email = 2;
|
|
28
|
+
*/
|
|
29
|
+
email: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @generated from field: bool email_verified = 3;
|
|
33
|
+
*/
|
|
34
|
+
emailVerified: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @generated from field: string display_name = 4;
|
|
38
|
+
*/
|
|
39
|
+
displayName: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @generated from field: string avatar_url = 5;
|
|
43
|
+
*/
|
|
44
|
+
avatarUrl: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @generated from field: map<string, string> claims = 6;
|
|
48
|
+
*/
|
|
49
|
+
claims: { [key: string]: string };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Describes the message gestalt.provider.v1.AuthenticatedUser.
|
|
54
|
+
* Use `create(AuthenticatedUserSchema)` to create a new message.
|
|
55
|
+
*/
|
|
56
|
+
export const AuthenticatedUserSchema: GenMessage<AuthenticatedUser> = /*@__PURE__*/
|
|
57
|
+
messageDesc(file_v1_auth, 0);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @generated from message gestalt.provider.v1.BeginLoginRequest
|
|
61
|
+
*/
|
|
62
|
+
export type BeginLoginRequest = Message<"gestalt.provider.v1.BeginLoginRequest"> & {
|
|
63
|
+
/**
|
|
64
|
+
* @generated from field: string callback_url = 1;
|
|
65
|
+
*/
|
|
66
|
+
callbackUrl: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @generated from field: string host_state = 2;
|
|
70
|
+
*/
|
|
71
|
+
hostState: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @generated from field: repeated string scopes = 3;
|
|
75
|
+
*/
|
|
76
|
+
scopes: string[];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @generated from field: map<string, string> options = 4;
|
|
80
|
+
*/
|
|
81
|
+
options: { [key: string]: string };
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Describes the message gestalt.provider.v1.BeginLoginRequest.
|
|
86
|
+
* Use `create(BeginLoginRequestSchema)` to create a new message.
|
|
87
|
+
*/
|
|
88
|
+
export const BeginLoginRequestSchema: GenMessage<BeginLoginRequest> = /*@__PURE__*/
|
|
89
|
+
messageDesc(file_v1_auth, 1);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @generated from message gestalt.provider.v1.BeginLoginResponse
|
|
93
|
+
*/
|
|
94
|
+
export type BeginLoginResponse = Message<"gestalt.provider.v1.BeginLoginResponse"> & {
|
|
95
|
+
/**
|
|
96
|
+
* @generated from field: string authorization_url = 1;
|
|
97
|
+
*/
|
|
98
|
+
authorizationUrl: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @generated from field: bytes provider_state = 2;
|
|
102
|
+
*/
|
|
103
|
+
providerState: Uint8Array;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Describes the message gestalt.provider.v1.BeginLoginResponse.
|
|
108
|
+
* Use `create(BeginLoginResponseSchema)` to create a new message.
|
|
109
|
+
*/
|
|
110
|
+
export const BeginLoginResponseSchema: GenMessage<BeginLoginResponse> = /*@__PURE__*/
|
|
111
|
+
messageDesc(file_v1_auth, 2);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @generated from message gestalt.provider.v1.CompleteLoginRequest
|
|
115
|
+
*/
|
|
116
|
+
export type CompleteLoginRequest = Message<"gestalt.provider.v1.CompleteLoginRequest"> & {
|
|
117
|
+
/**
|
|
118
|
+
* @generated from field: map<string, string> query = 1;
|
|
119
|
+
*/
|
|
120
|
+
query: { [key: string]: string };
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @generated from field: bytes provider_state = 2;
|
|
124
|
+
*/
|
|
125
|
+
providerState: Uint8Array;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @generated from field: string callback_url = 3;
|
|
129
|
+
*/
|
|
130
|
+
callbackUrl: string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Describes the message gestalt.provider.v1.CompleteLoginRequest.
|
|
135
|
+
* Use `create(CompleteLoginRequestSchema)` to create a new message.
|
|
136
|
+
*/
|
|
137
|
+
export const CompleteLoginRequestSchema: GenMessage<CompleteLoginRequest> = /*@__PURE__*/
|
|
138
|
+
messageDesc(file_v1_auth, 3);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @generated from message gestalt.provider.v1.ValidateExternalTokenRequest
|
|
142
|
+
*/
|
|
143
|
+
export type ValidateExternalTokenRequest = Message<"gestalt.provider.v1.ValidateExternalTokenRequest"> & {
|
|
144
|
+
/**
|
|
145
|
+
* @generated from field: string token = 1;
|
|
146
|
+
*/
|
|
147
|
+
token: string;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Describes the message gestalt.provider.v1.ValidateExternalTokenRequest.
|
|
152
|
+
* Use `create(ValidateExternalTokenRequestSchema)` to create a new message.
|
|
153
|
+
*/
|
|
154
|
+
export const ValidateExternalTokenRequestSchema: GenMessage<ValidateExternalTokenRequest> = /*@__PURE__*/
|
|
155
|
+
messageDesc(file_v1_auth, 4);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @generated from message gestalt.provider.v1.AuthSessionSettings
|
|
159
|
+
*/
|
|
160
|
+
export type AuthSessionSettings = Message<"gestalt.provider.v1.AuthSessionSettings"> & {
|
|
161
|
+
/**
|
|
162
|
+
* @generated from field: int64 session_ttl_seconds = 1;
|
|
163
|
+
*/
|
|
164
|
+
sessionTtlSeconds: bigint;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Describes the message gestalt.provider.v1.AuthSessionSettings.
|
|
169
|
+
* Use `create(AuthSessionSettingsSchema)` to create a new message.
|
|
170
|
+
*/
|
|
171
|
+
export const AuthSessionSettingsSchema: GenMessage<AuthSessionSettings> = /*@__PURE__*/
|
|
172
|
+
messageDesc(file_v1_auth, 5);
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @generated from service gestalt.provider.v1.AuthProvider
|
|
176
|
+
*/
|
|
177
|
+
export const AuthProvider: GenService<{
|
|
178
|
+
/**
|
|
179
|
+
* @generated from rpc gestalt.provider.v1.AuthProvider.BeginLogin
|
|
180
|
+
*/
|
|
181
|
+
beginLogin: {
|
|
182
|
+
methodKind: "unary";
|
|
183
|
+
input: typeof BeginLoginRequestSchema;
|
|
184
|
+
output: typeof BeginLoginResponseSchema;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* @generated from rpc gestalt.provider.v1.AuthProvider.CompleteLogin
|
|
188
|
+
*/
|
|
189
|
+
completeLogin: {
|
|
190
|
+
methodKind: "unary";
|
|
191
|
+
input: typeof CompleteLoginRequestSchema;
|
|
192
|
+
output: typeof AuthenticatedUserSchema;
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* @generated from rpc gestalt.provider.v1.AuthProvider.ValidateExternalToken
|
|
196
|
+
*/
|
|
197
|
+
validateExternalToken: {
|
|
198
|
+
methodKind: "unary";
|
|
199
|
+
input: typeof ValidateExternalTokenRequestSchema;
|
|
200
|
+
output: typeof AuthenticatedUserSchema;
|
|
201
|
+
},
|
|
202
|
+
/**
|
|
203
|
+
* @generated from rpc gestalt.provider.v1.AuthProvider.GetSessionSettings
|
|
204
|
+
*/
|
|
205
|
+
getSessionSettings: {
|
|
206
|
+
methodKind: "unary";
|
|
207
|
+
input: typeof EmptySchema;
|
|
208
|
+
output: typeof AuthSessionSettingsSchema;
|
|
209
|
+
},
|
|
210
|
+
}> = /*@__PURE__*/
|
|
211
|
+
serviceDesc(file_v1_auth, 0);
|
|
212
|
+
|