@lo1/sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/dist/config/hooks.d.ts +30 -0
- package/dist/config/hooks.d.ts.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/proxy.d.ts +53 -0
- package/dist/config/proxy.d.ts.map +1 -0
- package/dist/config/service.d.ts +98 -0
- package/dist/config/service.d.ts.map +1 -0
- package/dist/config/workspace.d.ts +282 -0
- package/dist/config/workspace.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4064 -0
- package/dist/plugin.d.ts +110 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/schema/generate.d.ts +2 -0
- package/dist/schema/generate.d.ts.map +1 -0
- package/package.json +36 -0
- package/schemas/lo1.v1.schema.json +224 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ServiceConfig } from "./config/index";
|
|
2
|
+
export interface Logger {
|
|
3
|
+
info(message: string, ...args: unknown[]): void;
|
|
4
|
+
warn(message: string, ...args: unknown[]): void;
|
|
5
|
+
error(message: string, ...args: unknown[]): void;
|
|
6
|
+
debug(message: string, ...args: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginContext {
|
|
9
|
+
workspaceDir: string;
|
|
10
|
+
workspaceName: string;
|
|
11
|
+
logger: Logger;
|
|
12
|
+
}
|
|
13
|
+
export type PluginFactory = (context: PluginContext) => Plugin | Promise<Plugin>;
|
|
14
|
+
export interface Plugin {
|
|
15
|
+
/** Plugin identifier — matches service `type` in manifest. */
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Inspects all services of this plugin's type and returns
|
|
19
|
+
* compose service definitions for shared infrastructure.
|
|
20
|
+
* Called once with ALL services of this type — the plugin deduplicates internally.
|
|
21
|
+
*/
|
|
22
|
+
contributeCompose?(input: ComposeInput): Promise<ComposeContribution>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates infrastructure resources (tables, buckets, schemas)
|
|
25
|
+
* after the compose stack is healthy. Called once per service of this type.
|
|
26
|
+
*/
|
|
27
|
+
provisionInfra?(input: ProvisionInput): Promise<ProvisionResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Applies seed data to provisioned infrastructure.
|
|
30
|
+
* Called once per service of this type, after provisionInfra.
|
|
31
|
+
*/
|
|
32
|
+
seedData?(input: SeedInput): Promise<SeedResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the container configuration for running a service.
|
|
35
|
+
* Only called for services in container/dev mode (not host process mode).
|
|
36
|
+
*/
|
|
37
|
+
configureContainer?(input: ContainerInput): Promise<ContainerConfig>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets up file watchers that trigger rebuilds/restarts.
|
|
40
|
+
* Returns an async iterable that yields restart signals. Optional.
|
|
41
|
+
*/
|
|
42
|
+
watchForChanges?(input: WatchInput): AsyncIterable<RestartSignal>;
|
|
43
|
+
}
|
|
44
|
+
export interface ComposeInput {
|
|
45
|
+
services: Record<string, ServiceConfig>;
|
|
46
|
+
workspaceDir: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ComposeServiceDef {
|
|
49
|
+
image: string;
|
|
50
|
+
ports?: string[];
|
|
51
|
+
environment?: Record<string, string>;
|
|
52
|
+
volumes?: string[];
|
|
53
|
+
command?: string[];
|
|
54
|
+
healthcheck?: {
|
|
55
|
+
test: string[];
|
|
56
|
+
interval?: string;
|
|
57
|
+
timeout?: string;
|
|
58
|
+
retries?: number;
|
|
59
|
+
start_period?: string;
|
|
60
|
+
};
|
|
61
|
+
depends_on?: Record<string, {
|
|
62
|
+
condition: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
export interface ComposeContribution {
|
|
66
|
+
services: Record<string, ComposeServiceDef>;
|
|
67
|
+
envVars: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
export interface ProvisionInput {
|
|
70
|
+
serviceName: string;
|
|
71
|
+
servicePath: string;
|
|
72
|
+
endpoints: Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
export interface ProvisionResult {
|
|
75
|
+
created: string[];
|
|
76
|
+
skipped: string[];
|
|
77
|
+
}
|
|
78
|
+
export interface SeedInput {
|
|
79
|
+
serviceName: string;
|
|
80
|
+
servicePath: string;
|
|
81
|
+
mode: "run" | "test";
|
|
82
|
+
endpoints: Record<string, string>;
|
|
83
|
+
}
|
|
84
|
+
export interface SeedResult {
|
|
85
|
+
applied: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface ContainerInput {
|
|
88
|
+
serviceName: string;
|
|
89
|
+
servicePath: string;
|
|
90
|
+
servicePort: string;
|
|
91
|
+
mode: "dev" | "container";
|
|
92
|
+
networkName: string;
|
|
93
|
+
endpoints: Record<string, string>;
|
|
94
|
+
}
|
|
95
|
+
export interface ContainerConfig {
|
|
96
|
+
image: string;
|
|
97
|
+
cmd: string[];
|
|
98
|
+
envVars: Record<string, string>;
|
|
99
|
+
binds: string[];
|
|
100
|
+
workingDir: string;
|
|
101
|
+
}
|
|
102
|
+
export interface WatchInput {
|
|
103
|
+
serviceName: string;
|
|
104
|
+
servicePath: string;
|
|
105
|
+
}
|
|
106
|
+
export interface RestartSignal {
|
|
107
|
+
reason: string;
|
|
108
|
+
changedFiles?: string[];
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO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WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,KAAK,GAAG,WAAW,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/schema/generate.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lo1/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Plugin SDK for lo1 — types, config schemas, and utilities for plugin authors",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./schemas/lo1.v1.schema.json": "./schemas/lo1.v1.schema.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"schemas"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "bun run build:ts && bun run build:schema",
|
|
21
|
+
"build:ts": "bun build ./src/index.ts --outdir ./dist --target node && tsc --emitDeclarationOnly --outDir ./dist",
|
|
22
|
+
"build:schema": "bun run ./src/schema/generate.ts",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"test": "bun test"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"zod": "^3.23.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/bun": "latest",
|
|
32
|
+
"zod-to-json-schema": "^3.23.0",
|
|
33
|
+
"ajv": "^8.17.0",
|
|
34
|
+
"ajv-formats": "^3.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://lo1.dev/schemas/lo1.v1.schema.json",
|
|
4
|
+
"$ref": "#/definitions/lo1.v1",
|
|
5
|
+
"definitions": {
|
|
6
|
+
"lo1.v1": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"version": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"const": "1"
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"plugins": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"additionalProperties": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"repositories": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"url": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"path": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"branch": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": [
|
|
38
|
+
"url",
|
|
39
|
+
"path"
|
|
40
|
+
],
|
|
41
|
+
"additionalProperties": false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"proxy": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {
|
|
47
|
+
"enabled": {
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"default": true
|
|
50
|
+
},
|
|
51
|
+
"port": {
|
|
52
|
+
"type": "number",
|
|
53
|
+
"default": 80
|
|
54
|
+
},
|
|
55
|
+
"tld": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"default": "local"
|
|
58
|
+
},
|
|
59
|
+
"tls": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"enabled": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"default": false
|
|
65
|
+
},
|
|
66
|
+
"port": {
|
|
67
|
+
"type": "number",
|
|
68
|
+
"default": 443
|
|
69
|
+
},
|
|
70
|
+
"certDir": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"default": ".lo1/certs"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"additionalProperties": false
|
|
79
|
+
},
|
|
80
|
+
"services": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"additionalProperties": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"properties": {
|
|
85
|
+
"type": {
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"path": {
|
|
89
|
+
"type": "string"
|
|
90
|
+
},
|
|
91
|
+
"port": {
|
|
92
|
+
"type": "number"
|
|
93
|
+
},
|
|
94
|
+
"hostPort": {
|
|
95
|
+
"type": "number"
|
|
96
|
+
},
|
|
97
|
+
"mode": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"enum": [
|
|
100
|
+
"dev",
|
|
101
|
+
"container",
|
|
102
|
+
"skip"
|
|
103
|
+
],
|
|
104
|
+
"default": "dev"
|
|
105
|
+
},
|
|
106
|
+
"command": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"containerImage": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
"plugin": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"additionalProperties": {}
|
|
115
|
+
},
|
|
116
|
+
"compose": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
},
|
|
119
|
+
"env": {
|
|
120
|
+
"type": "object",
|
|
121
|
+
"additionalProperties": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"proxy": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"domain": {
|
|
129
|
+
"type": "string"
|
|
130
|
+
},
|
|
131
|
+
"pathPrefix": {
|
|
132
|
+
"type": "string"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"additionalProperties": false
|
|
136
|
+
},
|
|
137
|
+
"hooks": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"properties": {
|
|
140
|
+
"preStart": {
|
|
141
|
+
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
"postStart": {
|
|
144
|
+
"type": "string"
|
|
145
|
+
},
|
|
146
|
+
"preStop": {
|
|
147
|
+
"type": "string"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"additionalProperties": false
|
|
151
|
+
},
|
|
152
|
+
"dependsOn": {
|
|
153
|
+
"type": "array",
|
|
154
|
+
"items": {
|
|
155
|
+
"type": "string"
|
|
156
|
+
},
|
|
157
|
+
"default": []
|
|
158
|
+
},
|
|
159
|
+
"initTask": {
|
|
160
|
+
"type": "boolean",
|
|
161
|
+
"default": false
|
|
162
|
+
},
|
|
163
|
+
"readinessProbe": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"format": "uri"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"required": [
|
|
169
|
+
"type",
|
|
170
|
+
"path"
|
|
171
|
+
],
|
|
172
|
+
"additionalProperties": false
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"extraCompose": {
|
|
176
|
+
"anyOf": [
|
|
177
|
+
{
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"type": "object",
|
|
182
|
+
"properties": {
|
|
183
|
+
"file": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
},
|
|
186
|
+
"initTaskServices": {
|
|
187
|
+
"type": "array",
|
|
188
|
+
"items": {
|
|
189
|
+
"type": "string"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"required": [
|
|
194
|
+
"file"
|
|
195
|
+
],
|
|
196
|
+
"additionalProperties": false
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"hooks": {
|
|
201
|
+
"type": "object",
|
|
202
|
+
"properties": {
|
|
203
|
+
"postInfrastructure": {
|
|
204
|
+
"type": "string"
|
|
205
|
+
},
|
|
206
|
+
"postSetup": {
|
|
207
|
+
"type": "string"
|
|
208
|
+
},
|
|
209
|
+
"preStop": {
|
|
210
|
+
"type": "string"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"additionalProperties": false
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"required": [
|
|
217
|
+
"version",
|
|
218
|
+
"name",
|
|
219
|
+
"services"
|
|
220
|
+
],
|
|
221
|
+
"additionalProperties": false
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|