@intentic/state-resolver 1.0.2
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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/emit/emit-github.d.ts +4 -0
- package/dist/emit/emit-github.d.ts.map +1 -0
- package/dist/emit/emit-github.js +92 -0
- package/dist/emit/emit-github.js.map +1 -0
- package/dist/emit/emit-gitlab.d.ts +4 -0
- package/dist/emit/emit-gitlab.d.ts.map +1 -0
- package/dist/emit/emit-gitlab.js +100 -0
- package/dist/emit/emit-gitlab.js.map +1 -0
- package/dist/emit/emit.d.ts +7 -0
- package/dist/emit/emit.d.ts.map +1 -0
- package/dist/emit/emit.js +222 -0
- package/dist/emit/emit.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/catalog.d.ts +13 -0
- package/dist/lib/catalog.d.ts.map +1 -0
- package/dist/lib/catalog.js +32 -0
- package/dist/lib/catalog.js.map +1 -0
- package/dist/lib/ids.d.ts +34 -0
- package/dist/lib/ids.d.ts.map +1 -0
- package/dist/lib/ids.js +43 -0
- package/dist/lib/ids.js.map +1 -0
- package/dist/lib/images.d.ts +28 -0
- package/dist/lib/images.d.ts.map +1 -0
- package/dist/lib/images.js +28 -0
- package/dist/lib/images.js.map +1 -0
- package/dist/lib/ssh.d.ts +3 -0
- package/dist/lib/ssh.d.ts.map +1 -0
- package/dist/lib/ssh.js +8 -0
- package/dist/lib/ssh.js.map +1 -0
- package/dist/lib/zone.d.ts +4 -0
- package/dist/lib/zone.d.ts.map +1 -0
- package/dist/lib/zone.js +33 -0
- package/dist/lib/zone.js.map +1 -0
- package/dist/resolvers/app-github.d.ts +9 -0
- package/dist/resolvers/app-github.d.ts.map +1 -0
- package/dist/resolvers/app-github.js +64 -0
- package/dist/resolvers/app-github.js.map +1 -0
- package/dist/resolvers/app-gitlab.d.ts +9 -0
- package/dist/resolvers/app-gitlab.d.ts.map +1 -0
- package/dist/resolvers/app-gitlab.js +76 -0
- package/dist/resolvers/app-gitlab.js.map +1 -0
- package/dist/resolvers/app.d.ts +13 -0
- package/dist/resolvers/app.d.ts.map +1 -0
- package/dist/resolvers/app.js +108 -0
- package/dist/resolvers/app.js.map +1 -0
- package/dist/resolvers/backing.d.ts +11 -0
- package/dist/resolvers/backing.d.ts.map +1 -0
- package/dist/resolvers/backing.js +142 -0
- package/dist/resolvers/backing.js.map +1 -0
- package/dist/resolvers/backup.d.ts +6 -0
- package/dist/resolvers/backup.d.ts.map +1 -0
- package/dist/resolvers/backup.js +26 -0
- package/dist/resolvers/backup.js.map +1 -0
- package/dist/resolvers/identity.d.ts +5 -0
- package/dist/resolvers/identity.d.ts.map +1 -0
- package/dist/resolvers/identity.js +112 -0
- package/dist/resolvers/identity.js.map +1 -0
- package/dist/resolvers/platform.d.ts +20 -0
- package/dist/resolvers/platform.d.ts.map +1 -0
- package/dist/resolvers/platform.js +77 -0
- package/dist/resolvers/platform.js.map +1 -0
- package/dist/resolvers/route.d.ts +12 -0
- package/dist/resolvers/route.d.ts.map +1 -0
- package/dist/resolvers/route.js +17 -0
- package/dist/resolvers/route.js.map +1 -0
- package/dist/resolvers/service.d.ts +13 -0
- package/dist/resolvers/service.d.ts.map +1 -0
- package/dist/resolvers/service.js +88 -0
- package/dist/resolvers/service.js.map +1 -0
- package/dist/resolvers/workspace.d.ts +14 -0
- package/dist/resolvers/workspace.d.ts.map +1 -0
- package/dist/resolvers/workspace.js +46 -0
- package/dist/resolvers/workspace.js.map +1 -0
- package/dist/state.d.ts +5 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +20 -0
- package/dist/state.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artur Kurowski
|
|
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,27 @@
|
|
|
1
|
+
# @intentic/state-resolver
|
|
2
|
+
|
|
3
|
+
The **state resolver**: turns an `IntentSet` into the desired state — a `DesiredStateGraph`. It assigns each need its catalog option and compiles the emitted nodes into one graph. Depends on [`@intentic/graph`](../graph), [`@intentic/need-resolver`](../need-resolver) (needs), and [`@intentic/resources`](../resources) (the vocabulary it emits); consumed by [`@intentic/sdk`](../sdk).
|
|
4
|
+
|
|
5
|
+
## Responsibilities
|
|
6
|
+
|
|
7
|
+
- Resolve needs to concrete catalog options (Forgejo for git+registry, Komodo for control, Cloudflare for domain, GitHub/GHCR as the alternative stack).
|
|
8
|
+
- Emit the `ResolvedNode`s for each assignment and `compile` them into a single dependency-ordered graph (`resolveState`).
|
|
9
|
+
- Derive the control-plane platform and the application-plane support stack (repos, CI, deployments, tunnel, routes, workspace sandbox).
|
|
10
|
+
- It does **not** talk to infra or reconcile — it only produces the serializable artifact.
|
|
11
|
+
|
|
12
|
+
## Key files
|
|
13
|
+
|
|
14
|
+
- [src/state.ts](src/state.ts) — `resolveState`: intent → `DesiredStateGraph`.
|
|
15
|
+
- [src/catalog.ts](src/catalog.ts) — `defaultCatalog`, `Catalog`/`Option` (what satisfies each capability).
|
|
16
|
+
- [src/emit.ts](src/emit.ts) — `emit` + `Assignment` (build the nodes for one assignment); `emit-github.ts` for the GitHub stack.
|
|
17
|
+
- [src/platform.ts](src/platform.ts) / [src/app.ts](src/app.ts) / [src/route.ts](src/route.ts) / [src/workspace.ts](src/workspace.ts) — per-area node derivation (control plane, app plane, DNS routes, dev workspace sandbox).
|
|
18
|
+
- [src/ids.ts](src/ids.ts) / [src/identity.ts](src/identity.ts) — id helpers, `adminUsername`.
|
|
19
|
+
|
|
20
|
+
## How it fits
|
|
21
|
+
|
|
22
|
+
Stage 2 of the pipeline: `need-resolver` produces `Need`s, this maps each to an `Option` and emits `@intentic/resources` nodes, then `graph.compile` orders them. The `sdk`'s `defineStack` runs this end-to-end; `cli resolve` writes the result to `desired-state.json`.
|
|
23
|
+
|
|
24
|
+
## Conventions & gotchas
|
|
25
|
+
|
|
26
|
+
- Adding a resource kind means emitting it here **and** registering its type/outputs in `resources` and a provider in `providers`.
|
|
27
|
+
- Emitter changes are snapshot-tested ([src/emit.test.ts](src/emit.test.ts), [src/state.test.ts](src/state.test.ts)) — update fixtures deliberately. See [ARCHITECTURE.md](../../ARCHITECTURE.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-github.d.ts","sourceRoot":"","sources":["../../src/emit/emit-github.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,EAAE,MAAM,MAAM,KAAG,YAAY,EA4GxE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { makeRef } from "@intentic/graph";
|
|
2
|
+
import { tunnelId, tunnelName } from "../lib/ids.js";
|
|
3
|
+
import { IMAGES } from "../lib/images.js";
|
|
4
|
+
import { sshOf } from "../lib/ssh.js";
|
|
5
|
+
import { resolveAppGitHub } from "../resolvers/app-github.js";
|
|
6
|
+
import { resolveService } from "../resolvers/service.js";
|
|
7
|
+
export const emitGitHub = (intent, zone) => {
|
|
8
|
+
if (intent.apps.length === 0 && intent.services.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const cloudflare = intent.cloudflare;
|
|
12
|
+
if (cloudflare === undefined) {
|
|
13
|
+
throw new Error("intent declares apps/services but no Cloudflare; declare it with i.have.cloudflare");
|
|
14
|
+
}
|
|
15
|
+
const github = intent.github;
|
|
16
|
+
if (github === undefined) {
|
|
17
|
+
throw new Error("GitHub emit called but no GitHub declared; this is a resolver bug");
|
|
18
|
+
}
|
|
19
|
+
const apiToken = cloudflare.input.apiToken;
|
|
20
|
+
const hostById = new Map(intent.hosts.map((h) => [h.id, h]));
|
|
21
|
+
const nodes = [];
|
|
22
|
+
for (const host of intent.hosts) {
|
|
23
|
+
nodes.push({
|
|
24
|
+
id: host.id,
|
|
25
|
+
type: "host",
|
|
26
|
+
inputs: { ...sshOf(host.input) },
|
|
27
|
+
explicitDependsOn: [],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
nodes.push({
|
|
31
|
+
id: cloudflare.id,
|
|
32
|
+
type: "cloudflare",
|
|
33
|
+
inputs: { apiToken, zone },
|
|
34
|
+
explicitDependsOn: [],
|
|
35
|
+
});
|
|
36
|
+
nodes.push({
|
|
37
|
+
id: github.id,
|
|
38
|
+
type: "github",
|
|
39
|
+
inputs: {
|
|
40
|
+
token: github.input.token,
|
|
41
|
+
...(github.input.owner !== undefined ? { owner: github.input.owner } : {}),
|
|
42
|
+
},
|
|
43
|
+
explicitDependsOn: [],
|
|
44
|
+
});
|
|
45
|
+
const ingressByHost = new Map();
|
|
46
|
+
const serviceById = new Map(intent.services.map((service) => [service.id, service]));
|
|
47
|
+
for (const app of intent.apps) {
|
|
48
|
+
if (app.observe !== undefined && !serviceById.has(app.observe)) {
|
|
49
|
+
throw new Error(`app "${app.id}" observes unknown service "${app.observe}"; declare it with i.want.service`);
|
|
50
|
+
}
|
|
51
|
+
if (app.observe !== undefined && serviceById.get(app.observe)?.kind !== "signoz") {
|
|
52
|
+
throw new Error(`app "${app.id}" observes "${app.observe}", which is not a signoz service`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const app of intent.apps) {
|
|
56
|
+
const resolved = resolveAppGitHub(app, github.id, apiToken, zone, github.input.token);
|
|
57
|
+
nodes.push(...resolved.nodes);
|
|
58
|
+
const hostIngress = ingressByHost.get(app.on) ?? [];
|
|
59
|
+
hostIngress.push(...resolved.ingress);
|
|
60
|
+
ingressByHost.set(app.on, hostIngress);
|
|
61
|
+
}
|
|
62
|
+
for (const service of intent.services) {
|
|
63
|
+
const host = hostById.get(service.on);
|
|
64
|
+
const resolved = resolveService(service, host.input, zone, apiToken);
|
|
65
|
+
nodes.push(...resolved.nodes);
|
|
66
|
+
const hostIngress = ingressByHost.get(service.on) ?? [];
|
|
67
|
+
hostIngress.push(...resolved.ingress);
|
|
68
|
+
ingressByHost.set(service.on, hostIngress);
|
|
69
|
+
}
|
|
70
|
+
for (const [hostId, ingress] of ingressByHost) {
|
|
71
|
+
if (ingress.length === 0) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const host = hostById.get(hostId);
|
|
75
|
+
nodes.push({
|
|
76
|
+
id: tunnelId(hostId),
|
|
77
|
+
type: "tunnel",
|
|
78
|
+
inputs: {
|
|
79
|
+
name: tunnelName(hostId),
|
|
80
|
+
accountId: makeRef(cloudflare.id, "accountId"),
|
|
81
|
+
apiToken,
|
|
82
|
+
...sshOf(host.input),
|
|
83
|
+
internalIp: makeRef(hostId, "internalIp"),
|
|
84
|
+
ingress,
|
|
85
|
+
image: IMAGES.cloudflared,
|
|
86
|
+
},
|
|
87
|
+
explicitDependsOn: [cloudflare.id, hostId],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return nodes;
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=emit-github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-github.js","sourceRoot":"","sources":["../../src/emit/emit-github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAiB,EAAE,IAAY,EAAkB,EAAE;IAC1E,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;IAC1G,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,MA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AC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-gitlab.d.ts","sourceRoot":"","sources":["../../src/emit/emit-gitlab.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAcxD,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,EAAE,MAAM,MAAM,KAAG,YAAY,EAmHxE,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { makeRef } from "@intentic/graph";
|
|
2
|
+
import { gitlabRegistry, tunnelId, tunnelName } from "../lib/ids.js";
|
|
3
|
+
import { IMAGES } from "../lib/images.js";
|
|
4
|
+
import { sshOf } from "../lib/ssh.js";
|
|
5
|
+
import { resolveAppGitLab } from "../resolvers/app-gitlab.js";
|
|
6
|
+
import { resolveService } from "../resolvers/service.js";
|
|
7
|
+
const DEFAULT_URL = "https://gitlab.com";
|
|
8
|
+
export const emitGitLab = (intent, zone) => {
|
|
9
|
+
if (intent.apps.length === 0 && intent.services.length === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const cloudflare = intent.cloudflare;
|
|
13
|
+
if (cloudflare === undefined) {
|
|
14
|
+
throw new Error("intent declares apps/services but no Cloudflare; declare it with i.have.cloudflare");
|
|
15
|
+
}
|
|
16
|
+
const gitlab = intent.gitlab;
|
|
17
|
+
if (gitlab === undefined) {
|
|
18
|
+
throw new Error("GitLab emit called but no GitLab declared; this is a resolver bug");
|
|
19
|
+
}
|
|
20
|
+
const url = gitlab.input.url ?? DEFAULT_URL;
|
|
21
|
+
const registry = gitlabRegistry(url, gitlab.input.registry);
|
|
22
|
+
const apiToken = cloudflare.input.apiToken;
|
|
23
|
+
const hostById = new Map(intent.hosts.map((h) => [h.id, h]));
|
|
24
|
+
const nodes = [];
|
|
25
|
+
for (const host of intent.hosts) {
|
|
26
|
+
nodes.push({
|
|
27
|
+
id: host.id,
|
|
28
|
+
type: "host",
|
|
29
|
+
inputs: { ...sshOf(host.input) },
|
|
30
|
+
explicitDependsOn: [],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
nodes.push({
|
|
34
|
+
id: cloudflare.id,
|
|
35
|
+
type: "cloudflare",
|
|
36
|
+
inputs: { apiToken, zone },
|
|
37
|
+
explicitDependsOn: [],
|
|
38
|
+
});
|
|
39
|
+
nodes.push({
|
|
40
|
+
id: gitlab.id,
|
|
41
|
+
type: "gitlab",
|
|
42
|
+
inputs: {
|
|
43
|
+
token: gitlab.input.token,
|
|
44
|
+
url,
|
|
45
|
+
...(gitlab.input.owner !== undefined ? { owner: gitlab.input.owner } : {}),
|
|
46
|
+
},
|
|
47
|
+
explicitDependsOn: [],
|
|
48
|
+
});
|
|
49
|
+
const ingressByHost = new Map();
|
|
50
|
+
const serviceById = new Map(intent.services.map((service) => [service.id, service]));
|
|
51
|
+
for (const app of intent.apps) {
|
|
52
|
+
if (app.observe !== undefined && !serviceById.has(app.observe)) {
|
|
53
|
+
throw new Error(`app "${app.id}" observes unknown service "${app.observe}"; declare it with i.want.service`);
|
|
54
|
+
}
|
|
55
|
+
if (app.observe !== undefined && serviceById.get(app.observe)?.kind !== "signoz") {
|
|
56
|
+
throw new Error(`app "${app.id}" observes "${app.observe}", which is not a signoz service`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const app of intent.apps) {
|
|
60
|
+
const host = hostById.get(app.on);
|
|
61
|
+
if (host === undefined) {
|
|
62
|
+
throw new Error(`app "${app.id}" targets undeclared host "${app.on}"; declare it with i.have.host`);
|
|
63
|
+
}
|
|
64
|
+
const resolved = resolveAppGitLab(app, gitlab.id, apiToken, zone, gitlab.input.token, url, registry, host.input);
|
|
65
|
+
nodes.push(...resolved.nodes);
|
|
66
|
+
const hostIngress = ingressByHost.get(app.on) ?? [];
|
|
67
|
+
hostIngress.push(...resolved.ingress);
|
|
68
|
+
ingressByHost.set(app.on, hostIngress);
|
|
69
|
+
}
|
|
70
|
+
for (const service of intent.services) {
|
|
71
|
+
const host = hostById.get(service.on);
|
|
72
|
+
const resolved = resolveService(service, host.input, zone, apiToken);
|
|
73
|
+
nodes.push(...resolved.nodes);
|
|
74
|
+
const hostIngress = ingressByHost.get(service.on) ?? [];
|
|
75
|
+
hostIngress.push(...resolved.ingress);
|
|
76
|
+
ingressByHost.set(service.on, hostIngress);
|
|
77
|
+
}
|
|
78
|
+
for (const [hostId, ingress] of ingressByHost) {
|
|
79
|
+
if (ingress.length === 0) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const host = hostById.get(hostId);
|
|
83
|
+
nodes.push({
|
|
84
|
+
id: tunnelId(hostId),
|
|
85
|
+
type: "tunnel",
|
|
86
|
+
inputs: {
|
|
87
|
+
name: tunnelName(hostId),
|
|
88
|
+
accountId: makeRef(cloudflare.id, "accountId"),
|
|
89
|
+
apiToken,
|
|
90
|
+
...sshOf(host.input),
|
|
91
|
+
internalIp: makeRef(hostId, "internalIp"),
|
|
92
|
+
ingress,
|
|
93
|
+
image: IMAGES.cloudflared,
|
|
94
|
+
},
|
|
95
|
+
explicitDependsOn: [cloudflare.id, hostId],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return nodes;
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=emit-gitlab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-gitlab.js","sourceRoot":"","sources":["../../src/emit/emit-gitlab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAA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ResolvedNode } from "@intentic/resources";
|
|
3
|
+
export interface Assignment {
|
|
4
|
+
readonly byNeed: ReadonlyMap<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare const emit: (intent: IntentSet, assignment: Assignment, zone: string | undefined) => ResolvedNode[];
|
|
7
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/emit/emit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA0B,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiBxD,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;AAuBD,eAAO,MAAM,IAAI,GAAI,QAAQ,SAAS,EAAE,YAAY,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,KAAG,YAAY,EA8QtG,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { generated, makeRef } from "@intentic/graph";
|
|
2
|
+
import { controlPlaneHostId } from "@intentic/need-resolver";
|
|
3
|
+
import { adminUsername, tunnelId, tunnelName } from "../lib/ids.js";
|
|
4
|
+
import { IMAGES } from "../lib/images.js";
|
|
5
|
+
import { sshOf } from "../lib/ssh.js";
|
|
6
|
+
import { resolveApp } from "../resolvers/app.js";
|
|
7
|
+
import { resolveBacking } from "../resolvers/backing.js";
|
|
8
|
+
import { defaultBackupInput, resolveBackup } from "../resolvers/backup.js";
|
|
9
|
+
import { resolveIdentities } from "../resolvers/identity.js";
|
|
10
|
+
import { resolvePlatform } from "../resolvers/platform.js";
|
|
11
|
+
import { resolveService } from "../resolvers/service.js";
|
|
12
|
+
import { resolveWorkspace } from "../resolvers/workspace.js";
|
|
13
|
+
import { emitGitHub } from "./emit-github.js";
|
|
14
|
+
import { emitGitLab } from "./emit-gitlab.js";
|
|
15
|
+
const supportedOptions = new Set(["forgejo", "komodo", "ssh-linux", "cloudflare-tunnel"]);
|
|
16
|
+
const assertHostedStack = (intent, zone, stack) => {
|
|
17
|
+
if (intent.backings.length > 0) {
|
|
18
|
+
throw new Error(`backings (i.want.database/cache/…) are not yet supported on the ${stack} stack; use the Forgejo stack`);
|
|
19
|
+
}
|
|
20
|
+
if (zone === undefined && (intent.apps.length > 0 || intent.services.length > 0)) {
|
|
21
|
+
throw new Error("intent exposes apps/services through Cloudflare but no zone was provided; the CLI discovers it from the API token before resolving");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const emit = (intent, assignment, zone) => {
|
|
25
|
+
const options = new Set(assignment.byNeed.values());
|
|
26
|
+
if (options.has("github")) {
|
|
27
|
+
assertHostedStack(intent, zone, "GitHub");
|
|
28
|
+
return emitGitHub(intent, zone);
|
|
29
|
+
}
|
|
30
|
+
if (options.has("gitlab")) {
|
|
31
|
+
assertHostedStack(intent, zone, "GitLab");
|
|
32
|
+
return emitGitLab(intent, zone);
|
|
33
|
+
}
|
|
34
|
+
for (const optionId of assignment.byNeed.values()) {
|
|
35
|
+
if (!supportedOptions.has(optionId)) {
|
|
36
|
+
throw new Error(`unsupported option "${optionId}"; the emitter only implements ${[...supportedOptions].join("/")}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (intent.apps.length === 0 && intent.services.length === 0 && intent.workspaces.length === 0 && intent.backings.length === 0) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const cloudflare = intent.cloudflare;
|
|
43
|
+
if (cloudflare === undefined) {
|
|
44
|
+
throw new Error("intent declares apps/services/workspaces/backings but no Cloudflare; declare it with i.have.cloudflare");
|
|
45
|
+
}
|
|
46
|
+
if (zone === undefined) {
|
|
47
|
+
throw new Error("intent exposes apps/services through Cloudflare but no zone was provided; the CLI discovers it from the API token before resolving");
|
|
48
|
+
}
|
|
49
|
+
const cpId = controlPlaneHostId(intent);
|
|
50
|
+
if (cpId === undefined) {
|
|
51
|
+
throw new Error("intent declares apps/services/backings but no host; declare one with i.have.host");
|
|
52
|
+
}
|
|
53
|
+
const apiToken = cloudflare.input.apiToken;
|
|
54
|
+
const hostById = new Map(intent.hosts.map((h) => [h.id, h]));
|
|
55
|
+
const serviceById = new Map(intent.services.map((service) => [service.id, service]));
|
|
56
|
+
const backingById = new Map();
|
|
57
|
+
for (const backing of intent.backings) {
|
|
58
|
+
const host = hostById.get(backing.on);
|
|
59
|
+
if (host === undefined) {
|
|
60
|
+
throw new Error(`backing "${backing.id}" targets undeclared host "${backing.on}"; declare it with i.have.host`);
|
|
61
|
+
}
|
|
62
|
+
backingById.set(backing.id, { intent: backing, host: host.input });
|
|
63
|
+
}
|
|
64
|
+
const cpHost = hostById.get(cpId);
|
|
65
|
+
const backupInput = intent.backup?.input ?? defaultBackupInput();
|
|
66
|
+
const nodes = [];
|
|
67
|
+
for (const host of intent.hosts) {
|
|
68
|
+
nodes.push({
|
|
69
|
+
id: host.id,
|
|
70
|
+
type: "host",
|
|
71
|
+
inputs: { ...sshOf(host.input) },
|
|
72
|
+
explicitDependsOn: [],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
nodes.push({
|
|
76
|
+
id: cloudflare.id,
|
|
77
|
+
type: "cloudflare",
|
|
78
|
+
inputs: { apiToken, zone },
|
|
79
|
+
explicitDependsOn: [],
|
|
80
|
+
});
|
|
81
|
+
if (intent.discord !== undefined) {
|
|
82
|
+
const notifiedApps = intent.apps.filter((app) => app.notify === intent.discord.id).map((app) => app.id);
|
|
83
|
+
nodes.push({
|
|
84
|
+
id: intent.discord.id,
|
|
85
|
+
type: "discord",
|
|
86
|
+
inputs: {
|
|
87
|
+
botToken: intent.discord.input.botToken,
|
|
88
|
+
zone,
|
|
89
|
+
apps: notifiedApps,
|
|
90
|
+
},
|
|
91
|
+
explicitDependsOn: [],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (intent.stripe !== undefined) {
|
|
95
|
+
nodes.push({
|
|
96
|
+
id: intent.stripe.id,
|
|
97
|
+
type: "stripe",
|
|
98
|
+
inputs: { apiKey: intent.stripe.input.apiKey },
|
|
99
|
+
explicitDependsOn: [],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const ingressByHost = new Map();
|
|
103
|
+
const serviceIds = new Set(intent.services.map((service) => service.id));
|
|
104
|
+
if (intent.apps.length > 0) {
|
|
105
|
+
const guard = cpHost.input.updatePolicy === "guarded" ? { repo: backupInput.repo, resticImage: IMAGES.backup } : undefined;
|
|
106
|
+
const platform = resolvePlatform(cpId, cloudflare.id, zone, apiToken, cpHost.input, guard);
|
|
107
|
+
nodes.push(...platform.nodes);
|
|
108
|
+
const cpIngress = [...platform.ingress];
|
|
109
|
+
ingressByHost.set(cpId, cpIngress);
|
|
110
|
+
for (const app of intent.apps) {
|
|
111
|
+
if (app.observe !== undefined && !serviceIds.has(app.observe)) {
|
|
112
|
+
throw new Error(`app "${app.id}" observes unknown service "${app.observe}"; declare it with i.want.service`);
|
|
113
|
+
}
|
|
114
|
+
if (app.observe !== undefined && serviceById.get(app.observe)?.kind !== "signoz") {
|
|
115
|
+
throw new Error(`app "${app.id}" observes "${app.observe}", which is not a signoz service`);
|
|
116
|
+
}
|
|
117
|
+
for (const binding of app.use ?? []) {
|
|
118
|
+
const backing = backingById.get(binding.target);
|
|
119
|
+
if (backing === undefined) {
|
|
120
|
+
throw new Error(`app "${app.id}" uses unknown backing "${binding.target}"; declare it with i.want.${binding.capability}`);
|
|
121
|
+
}
|
|
122
|
+
if (backing.intent.capability !== binding.capability) {
|
|
123
|
+
throw new Error(`app "${app.id}" uses "${binding.target}" as ${binding.capability} but it is a ${backing.intent.capability}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const workerHostIds = new Set([...intent.apps.map((a) => a.on), ...intent.services.map((s) => s.on)].filter((id) => id !== cpId));
|
|
128
|
+
for (const hostId of workerHostIds) {
|
|
129
|
+
const host = hostById.get(hostId);
|
|
130
|
+
const peripheryId = `${hostId}-periphery`;
|
|
131
|
+
const serverId = `${hostId}-server`;
|
|
132
|
+
nodes.push({
|
|
133
|
+
id: peripheryId,
|
|
134
|
+
type: "komodo-periphery",
|
|
135
|
+
inputs: {
|
|
136
|
+
...sshOf(host.input),
|
|
137
|
+
coreAddress: makeRef(platform.refs.deploy, "url"),
|
|
138
|
+
serverName: hostId,
|
|
139
|
+
image: IMAGES.komodoPeriphery,
|
|
140
|
+
},
|
|
141
|
+
explicitDependsOn: [hostId, platform.refs.deploy, platform.refs.deployRoute],
|
|
142
|
+
});
|
|
143
|
+
nodes.push({
|
|
144
|
+
id: serverId,
|
|
145
|
+
type: "komodo-server",
|
|
146
|
+
inputs: {
|
|
147
|
+
komodoUrl: makeRef(platform.refs.deploy, "url"),
|
|
148
|
+
adminUser: adminUsername,
|
|
149
|
+
adminPassword: generated("KOMODO_ADMIN_PASSWORD"),
|
|
150
|
+
serverName: hostId,
|
|
151
|
+
},
|
|
152
|
+
explicitDependsOn: [peripheryId, platform.refs.deploy, platform.refs.deployRoute],
|
|
153
|
+
});
|
|
154
|
+
if (!ingressByHost.has(hostId)) {
|
|
155
|
+
ingressByHost.set(hostId, []);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const app of intent.apps) {
|
|
159
|
+
const resolved = resolveApp(app, platform.refs, apiToken, zone, cpId, backingById);
|
|
160
|
+
nodes.push(...resolved.nodes);
|
|
161
|
+
const hostIngress = ingressByHost.get(app.on) ?? [];
|
|
162
|
+
hostIngress.push(...resolved.ingress);
|
|
163
|
+
ingressByHost.set(app.on, hostIngress);
|
|
164
|
+
}
|
|
165
|
+
nodes.push(...resolveIdentities(intent, platform.refs, cpId));
|
|
166
|
+
}
|
|
167
|
+
for (const service of intent.services) {
|
|
168
|
+
const host = hostById.get(service.on);
|
|
169
|
+
const resolved = resolveService(service, host.input, zone, apiToken);
|
|
170
|
+
nodes.push(...resolved.nodes);
|
|
171
|
+
const hostIngress = ingressByHost.get(service.on) ?? [];
|
|
172
|
+
hostIngress.push(...resolved.ingress);
|
|
173
|
+
ingressByHost.set(service.on, hostIngress);
|
|
174
|
+
}
|
|
175
|
+
for (const workspace of intent.workspaces) {
|
|
176
|
+
const host = hostById.get(workspace.on);
|
|
177
|
+
const tools = (workspace.tools ?? []).map((id) => {
|
|
178
|
+
const service = serviceById.get(id);
|
|
179
|
+
return { id: service.id, kind: service.kind, domain: service.domain };
|
|
180
|
+
});
|
|
181
|
+
const resolved = resolveWorkspace(workspace, host.input, zone, apiToken, tools);
|
|
182
|
+
nodes.push(...resolved.nodes);
|
|
183
|
+
const hostIngress = ingressByHost.get(workspace.on) ?? [];
|
|
184
|
+
hostIngress.push(...resolved.ingress);
|
|
185
|
+
ingressByHost.set(workspace.on, hostIngress);
|
|
186
|
+
}
|
|
187
|
+
for (const backing of intent.backings) {
|
|
188
|
+
const host = hostById.get(backing.on);
|
|
189
|
+
const resolved = resolveBacking(backing, host.input, apiToken);
|
|
190
|
+
nodes.push(...resolved.nodes);
|
|
191
|
+
if (resolved.ingress.length > 0) {
|
|
192
|
+
const hostIngress = ingressByHost.get(backing.on) ?? [];
|
|
193
|
+
hostIngress.push(...resolved.ingress);
|
|
194
|
+
ingressByHost.set(backing.on, hostIngress);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (intent.apps.length > 0) {
|
|
198
|
+
const signozService = intent.services.find((service) => service.kind === "signoz");
|
|
199
|
+
nodes.push(resolveBackup(cpId, cpHost.input, backupInput, signozService?.id));
|
|
200
|
+
}
|
|
201
|
+
for (const [hostId, ingress] of ingressByHost) {
|
|
202
|
+
if (ingress.length === 0) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const host = hostById.get(hostId);
|
|
206
|
+
nodes.push({
|
|
207
|
+
id: tunnelId(hostId),
|
|
208
|
+
type: "tunnel",
|
|
209
|
+
inputs: {
|
|
210
|
+
name: tunnelName(hostId),
|
|
211
|
+
accountId: makeRef(cloudflare.id, "accountId"),
|
|
212
|
+
apiToken,
|
|
213
|
+
...sshOf(host.input),
|
|
214
|
+
ingress,
|
|
215
|
+
image: IMAGES.cloudflared,
|
|
216
|
+
},
|
|
217
|
+
explicitDependsOn: [cloudflare.id, hostId],
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return nodes;
|
|
221
|
+
};
|
|
222
|
+
//# sourceMappingURL=emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAU9C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,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AC,EAAE,CAAC;YACvB,SAAS;QACb,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC;YACP,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE;gBACJ,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;gBACxB,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,CAAC;gBAC9C,QAAQ;gBACR,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;gBACpB,OAAO;gBACP,KAAK,EAAE,MAAM,CAAC,WAAW;aAC5B;YACD,iBAAiB,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC;SAC7C,CAAC,CAAC;IACP,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { Assignment } from "./emit/emit.js";
|
|
2
|
+
export { emit } from "./emit/emit.js";
|
|
3
|
+
export { emitGitHub } from "./emit/emit-github.js";
|
|
4
|
+
export { emitGitLab } from "./emit/emit-gitlab.js";
|
|
5
|
+
export type { Catalog, Option } from "./lib/catalog.js";
|
|
6
|
+
export { catalogFor, forgejoCatalog, githubCatalog, gitlabCatalog } from "./lib/catalog.js";
|
|
7
|
+
export { adminUsername, backingPort, bindingId, cacheUser, dbName, deploymentId, deploymentPort, forgejoOrgId, forgejoTeamId, forgejoUserId, ghCiId, gitlabRegistry, glCiId, komodoUserId, orgName, repoId, secretKey, userPasswordKey, } from "./lib/ids.js";
|
|
8
|
+
export { collectDomains, selectZone } from "./lib/zone.js";
|
|
9
|
+
export { resolveApp } from "./resolvers/app.js";
|
|
10
|
+
export { resolveAppGitHub } from "./resolvers/app-github.js";
|
|
11
|
+
export { resolveAppGitLab } from "./resolvers/app-gitlab.js";
|
|
12
|
+
export { bindingEnv, resolveBacking, resolveBinding } from "./resolvers/backing.js";
|
|
13
|
+
export { resolveBackup } from "./resolvers/backup.js";
|
|
14
|
+
export { resolveIdentities } from "./resolvers/identity.js";
|
|
15
|
+
export type { PlatformRefs } from "./resolvers/platform.js";
|
|
16
|
+
export { resolvePlatform } from "./resolvers/platform.js";
|
|
17
|
+
export { resolveService } from "./resolvers/service.js";
|
|
18
|
+
export { resolveState } from "./state.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EACH,aAAa,EACb,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,MAAM,EACN,cAAc,EACd,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,EACT,eAAe,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { emit } from "./emit/emit.js";
|
|
2
|
+
export { emitGitHub } from "./emit/emit-github.js";
|
|
3
|
+
export { emitGitLab } from "./emit/emit-gitlab.js";
|
|
4
|
+
export { catalogFor, forgejoCatalog, githubCatalog, gitlabCatalog } from "./lib/catalog.js";
|
|
5
|
+
export { adminUsername, backingPort, bindingId, cacheUser, dbName, deploymentId, deploymentPort, forgejoOrgId, forgejoTeamId, forgejoUserId, ghCiId, gitlabRegistry, glCiId, komodoUserId, orgName, repoId, secretKey, userPasswordKey, } from "./lib/ids.js";
|
|
6
|
+
export { collectDomains, selectZone } from "./lib/zone.js";
|
|
7
|
+
export { resolveApp } from "./resolvers/app.js";
|
|
8
|
+
export { resolveAppGitHub } from "./resolvers/app-github.js";
|
|
9
|
+
export { resolveAppGitLab } from "./resolvers/app-gitlab.js";
|
|
10
|
+
export { bindingEnv, resolveBacking, resolveBinding } from "./resolvers/backing.js";
|
|
11
|
+
export { resolveBackup } from "./resolvers/backup.js";
|
|
12
|
+
export { resolveIdentities } from "./resolvers/identity.js";
|
|
13
|
+
export { resolvePlatform } from "./resolvers/platform.js";
|
|
14
|
+
export { resolveService } from "./resolvers/service.js";
|
|
15
|
+
export { resolveState } from "./state.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EACH,aAAa,EACb,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,MAAM,EACN,cAAc,EACd,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,EACT,eAAe,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Capability, IntentSet } from "@intentic/need-resolver";
|
|
2
|
+
export interface Option {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly provides: readonly Capability[];
|
|
5
|
+
}
|
|
6
|
+
export interface Catalog {
|
|
7
|
+
optionsFor(capability: Capability): readonly Option[];
|
|
8
|
+
}
|
|
9
|
+
export declare const forgejoCatalog: Catalog;
|
|
10
|
+
export declare const githubCatalog: Catalog;
|
|
11
|
+
export declare const gitlabCatalog: Catalog;
|
|
12
|
+
export declare const catalogFor: (intent: IntentSet) => Catalog;
|
|
13
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/lib/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKrE,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,OAAO;IACpB,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,CAAC;CACzD;AAgCD,eAAO,MAAM,cAAc,EAAE,OAAqC,CAAC;AACnE,eAAO,MAAM,aAAa,EAAE,OAAoC,CAAC;AACjE,eAAO,MAAM,aAAa,EAAE,OAAoC,CAAC;AAKjE,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,KAAG,OAQ9C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const forgejoOptions = [
|
|
2
|
+
{ id: "forgejo", provides: ["source-control", "docker-registry"] },
|
|
3
|
+
{ id: "komodo", provides: ["infra-control"] },
|
|
4
|
+
{ id: "ssh-linux", provides: ["deployment-target"] },
|
|
5
|
+
{ id: "cloudflare-tunnel", provides: ["domain"] },
|
|
6
|
+
];
|
|
7
|
+
const githubOptions = [
|
|
8
|
+
{ id: "github", provides: ["source-control", "docker-registry"] },
|
|
9
|
+
{ id: "github-actions", provides: ["infra-control"] },
|
|
10
|
+
{ id: "ssh-linux", provides: ["deployment-target"] },
|
|
11
|
+
{ id: "cloudflare-tunnel", provides: ["domain"] },
|
|
12
|
+
];
|
|
13
|
+
const gitlabOptions = [
|
|
14
|
+
{ id: "gitlab", provides: ["source-control", "docker-registry"] },
|
|
15
|
+
{ id: "gitlab-ci", provides: ["infra-control"] },
|
|
16
|
+
{ id: "ssh-linux", provides: ["deployment-target"] },
|
|
17
|
+
{ id: "cloudflare-tunnel", provides: ["domain"] },
|
|
18
|
+
];
|
|
19
|
+
const makeCatalog = (options) => Object.freeze({ optionsFor: (capability) => options.filter((option) => option.provides.includes(capability)) });
|
|
20
|
+
export const forgejoCatalog = makeCatalog(forgejoOptions);
|
|
21
|
+
export const githubCatalog = makeCatalog(githubOptions);
|
|
22
|
+
export const gitlabCatalog = makeCatalog(gitlabOptions);
|
|
23
|
+
export const catalogFor = (intent) => {
|
|
24
|
+
if (intent.github !== undefined) {
|
|
25
|
+
return githubCatalog;
|
|
26
|
+
}
|
|
27
|
+
if (intent.gitlab !== undefined) {
|
|
28
|
+
return gitlabCatalog;
|
|
29
|
+
}
|
|
30
|
+
return forgejoCatalog;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=catalog.js.map
|