@lukoweb/apitogo 0.1.148 → 0.2.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/dist/cli/cli.js +5533 -1850
- package/dist/declarations/cli/common/constants.d.ts +0 -1
- package/dist/declarations/cli/platform/client/platform-api.d.ts +8 -0
- package/dist/declarations/cli/platform/config.d.ts +0 -10
- package/package.json +4 -1
- package/src/app/main.tsx +0 -1
- package/src/config/v2/__fixtures__/scenario-a-docs-only.json +6 -0
- package/src/config/v2/__fixtures__/scenario-b-managed-origin.json +14 -0
- package/src/config/v2/__fixtures__/scenario-c-proxy-oidc.json +15 -0
- package/src/config/v2/__fixtures__/scenario-h-full-stack.json +28 -0
- package/src/config/v2/errors.ts +42 -0
- package/src/config/v2/index.ts +105 -0
- package/src/config/v2/init.ts +273 -0
- package/src/config/v2/layout.ts +237 -0
- package/src/config/v2/ledger.ts +219 -0
- package/src/config/v2/load.ts +70 -0
- package/src/config/v2/manifest.ts +293 -0
- package/src/config/v2/parse.ts +214 -0
- package/src/config/v2/paths.ts +54 -0
- package/src/config/v2/portal-profile.ts +88 -0
- package/src/config/v2/resolve.ts +186 -0
- package/src/config/v2/rules.ts +650 -0
- package/src/config/v2/schema.ts +211 -0
- package/src/config/v2/services.ts +644 -0
- package/src/config/v2/workspace.ts +117 -0
- package/src/config/v2/wrapper.ts +397 -0
- package/src/vite/html.ts +0 -2
- package/src/vite/plugin-theme.ts +23 -7
- package/src/app/font.geist.css +0 -73
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { layoutRoot, type StatePaths, statePathsFor } from "./paths.js";
|
|
3
|
+
import type { ConfigV2, Layout } from "./schema.js";
|
|
4
|
+
|
|
5
|
+
export { layoutRoot };
|
|
6
|
+
|
|
7
|
+
/** A path relative to the config file, made absolute. A leading `!` (negated glob) is preserved. */
|
|
8
|
+
function fromConfig(configDir: string, value: string): string {
|
|
9
|
+
return value.startsWith("!")
|
|
10
|
+
? `!${path.resolve(configDir, value.slice(1))}`
|
|
11
|
+
: path.resolve(configDir, value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ResolvedPortal = {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
dir: string;
|
|
17
|
+
name: string;
|
|
18
|
+
docs: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
provider: "apitogo" | "external";
|
|
21
|
+
/** Absolute globs. Empty for an external docs provider. */
|
|
22
|
+
content: string[];
|
|
23
|
+
url?: string;
|
|
24
|
+
};
|
|
25
|
+
console: { enabled: boolean };
|
|
26
|
+
theme: string;
|
|
27
|
+
requireAuth: boolean | { exclude: string[] };
|
|
28
|
+
search: "pagefind" | "inkeep" | "none";
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ResolvedGateway = {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
provider: string;
|
|
34
|
+
origin: NonNullable<ConfigV2["gateway"]>["origin"];
|
|
35
|
+
/** Absolute paths. */
|
|
36
|
+
specs: string[];
|
|
37
|
+
auth?: NonNullable<ConfigV2["gateway"]>["auth"];
|
|
38
|
+
policies: NonNullable<NonNullable<ConfigV2["gateway"]>["policies"]>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ResolvedIdentity = {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
provider: "apitogo" | "oidc";
|
|
44
|
+
native: boolean;
|
|
45
|
+
connections: NonNullable<NonNullable<ConfigV2["identity"]>["connections"]>;
|
|
46
|
+
clients: NonNullable<NonNullable<ConfigV2["identity"]>["clients"]>;
|
|
47
|
+
issuer?: string;
|
|
48
|
+
clientId?: string;
|
|
49
|
+
providerOptions: NonNullable<
|
|
50
|
+
NonNullable<ConfigV2["identity"]>["providerOptions"]
|
|
51
|
+
>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type ResolvedPlans = {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
/** Absolute path of the plan catalog. */
|
|
57
|
+
file: string;
|
|
58
|
+
billing: {
|
|
59
|
+
provider: "stripe" | "none";
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
webhookSecret?: string;
|
|
62
|
+
successUrl?: string;
|
|
63
|
+
cancelUrl?: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type ResolvedConfigV2 = {
|
|
68
|
+
configPath: string;
|
|
69
|
+
configDir: string;
|
|
70
|
+
layout: Layout;
|
|
71
|
+
/** `<root>` of the layout: where `portal/`, `plans.json` and `apis/` live by default. */
|
|
72
|
+
root: string;
|
|
73
|
+
/** Default folder for OpenAPI files created by `init`. */
|
|
74
|
+
apisDir: string;
|
|
75
|
+
/** Generated and observed state (`state.json`, `generated/`, `build/`), ignored by git on its own. */
|
|
76
|
+
state: StatePaths;
|
|
77
|
+
project: { id?: string; name: string };
|
|
78
|
+
portal?: ResolvedPortal;
|
|
79
|
+
gateway?: ResolvedGateway;
|
|
80
|
+
identity?: ResolvedIdentity;
|
|
81
|
+
plans?: ResolvedPlans;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Applies the documented defaults and makes every path absolute. Defaults for `portal.dir`, `plans.file`
|
|
86
|
+
* and the spec folder derive from `<root>`, so a standalone config can omit them. A section that is present
|
|
87
|
+
* without `enabled` is enabled.
|
|
88
|
+
*/
|
|
89
|
+
export function resolveConfigV2(
|
|
90
|
+
config: ConfigV2,
|
|
91
|
+
configPath: string,
|
|
92
|
+
): ResolvedConfigV2 {
|
|
93
|
+
const absoluteConfigPath = path.resolve(configPath);
|
|
94
|
+
const configDir = path.dirname(absoluteConfigPath);
|
|
95
|
+
const layout = config.layout ?? "standalone";
|
|
96
|
+
const root = layoutRoot(configDir, layout);
|
|
97
|
+
const projectName = config.project?.name ?? path.basename(configDir);
|
|
98
|
+
|
|
99
|
+
const resolved: ResolvedConfigV2 = {
|
|
100
|
+
configPath: absoluteConfigPath,
|
|
101
|
+
configDir,
|
|
102
|
+
layout,
|
|
103
|
+
root,
|
|
104
|
+
apisDir: path.join(root, "apis"),
|
|
105
|
+
state: statePathsFor(configDir, layout),
|
|
106
|
+
project: { id: config.project?.id, name: projectName },
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const { portal, gateway, identity, plans } = config;
|
|
110
|
+
|
|
111
|
+
if (portal) {
|
|
112
|
+
const dir = portal.dir
|
|
113
|
+
? path.resolve(configDir, portal.dir)
|
|
114
|
+
: path.join(root, "portal");
|
|
115
|
+
const provider = portal.docs?.provider ?? "apitogo";
|
|
116
|
+
resolved.portal = {
|
|
117
|
+
enabled: portal.enabled ?? true,
|
|
118
|
+
dir,
|
|
119
|
+
name: portal.name ?? projectName,
|
|
120
|
+
docs: {
|
|
121
|
+
enabled: portal.docs?.enabled ?? true,
|
|
122
|
+
provider,
|
|
123
|
+
content:
|
|
124
|
+
provider === "external"
|
|
125
|
+
? []
|
|
126
|
+
: portal.docs?.content
|
|
127
|
+
? portal.docs.content.map((glob) => fromConfig(configDir, glob))
|
|
128
|
+
: [path.join(dir, "pages", "**", "*.{md,mdx}")],
|
|
129
|
+
url: portal.docs?.url,
|
|
130
|
+
},
|
|
131
|
+
console: { enabled: portal.console?.enabled ?? true },
|
|
132
|
+
theme: portal.theme
|
|
133
|
+
? path.resolve(configDir, portal.theme)
|
|
134
|
+
: path.join(dir, "theme.json"),
|
|
135
|
+
requireAuth: portal.requireAuth ?? false,
|
|
136
|
+
search: provider === "external" ? "none" : (portal.search ?? "pagefind"),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (gateway) {
|
|
141
|
+
resolved.gateway = {
|
|
142
|
+
enabled: gateway.enabled ?? true,
|
|
143
|
+
provider: gateway.provider ?? "apitogo",
|
|
144
|
+
origin: {
|
|
145
|
+
...gateway.origin,
|
|
146
|
+
source: gateway.origin.source
|
|
147
|
+
? path.resolve(configDir, gateway.origin.source)
|
|
148
|
+
: undefined,
|
|
149
|
+
},
|
|
150
|
+
specs: gateway.specs.map((spec) => path.resolve(configDir, spec)),
|
|
151
|
+
auth: gateway.auth,
|
|
152
|
+
policies: gateway.policies ?? {},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (identity) {
|
|
157
|
+
resolved.identity = {
|
|
158
|
+
enabled: identity.enabled ?? true,
|
|
159
|
+
provider: identity.provider ?? "apitogo",
|
|
160
|
+
native: identity.native ?? true,
|
|
161
|
+
connections: identity.connections ?? [],
|
|
162
|
+
clients: identity.clients ?? [],
|
|
163
|
+
issuer: identity.issuer,
|
|
164
|
+
clientId: identity.clientId,
|
|
165
|
+
providerOptions: identity.providerOptions ?? {},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (plans) {
|
|
170
|
+
resolved.plans = {
|
|
171
|
+
enabled: plans.enabled ?? true,
|
|
172
|
+
file: plans.file
|
|
173
|
+
? path.resolve(configDir, plans.file)
|
|
174
|
+
: path.join(root, "plans.json"),
|
|
175
|
+
billing: {
|
|
176
|
+
provider: plans.billing?.provider ?? "stripe",
|
|
177
|
+
apiKey: plans.billing?.apiKey,
|
|
178
|
+
webhookSecret: plans.billing?.webhookSecret,
|
|
179
|
+
successUrl: plans.billing?.successUrl,
|
|
180
|
+
cancelUrl: plans.billing?.cancelUrl,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return resolved;
|
|
186
|
+
}
|