@lukoweb/apitogo 0.1.51 → 0.1.54
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 +467 -197
- package/dist/declarations/config/apitogo-config-core.d.ts +35 -0
- package/dist/declarations/config/apitogo-config-loader.d.ts +2 -7
- package/dist/declarations/config/apitogo-config-loader.node.d.ts +4 -0
- package/dist/declarations/config/build-apitogo-config.d.ts +5 -4
- package/dist/declarations/config/loader.d.ts +2 -0
- package/dist/declarations/config/local-manifest.d.ts +22 -8
- package/dist/declarations/config/validators/ModulesSchema.d.ts +38 -0
- package/dist/declarations/config/validators/ZudokuConfig.d.ts +43 -2
- package/dist/declarations/index.d.ts +1 -1
- package/dist/declarations/lib/authentication/providers/dev-portal-auth-pages.d.ts +15 -0
- package/dist/declarations/lib/authentication/providers/dev-portal-constants.d.ts +19 -1
- package/dist/declarations/lib/authentication/providers/dev-portal-utils.d.ts +5 -1
- package/dist/declarations/lib/authentication/providers/dev-portal.d.ts +5 -0
- package/dist/declarations/lib/core/plugins.d.ts +1 -0
- package/dist/flat-config.d.ts +53 -24
- package/docs/configuration/authentication.md +11 -9
- package/docs/configuration/manifest.md +75 -74
- package/package.json +1 -1
- package/src/config/apitogo-config-core.ts +601 -0
- package/src/config/apitogo-config-loader.node.ts +88 -0
- package/src/config/apitogo-config-loader.ts +6 -224
- package/src/config/build-apitogo-config.ts +26 -17
- package/src/config/loader.ts +23 -2
- package/src/config/local-manifest.ts +58 -59
- package/src/config/resolve-modules.ts +16 -13
- package/src/config/validators/ModulesSchema.ts +17 -0
- package/src/config/validators/ZudokuConfig.ts +25 -1
- package/src/index.ts +3 -2
- package/src/lib/authentication/providers/dev-portal-auth-pages.tsx +439 -0
- package/src/lib/authentication/providers/dev-portal-constants.ts +15 -1
- package/src/lib/authentication/providers/dev-portal-utils.ts +124 -4
- package/src/lib/authentication/providers/dev-portal.tsx +41 -6
- package/src/lib/core/plugins.ts +1 -0
- package/src/vite/dev-portal-env.ts +12 -4
- package/src/vite/plugin-config.ts +20 -3
- package/src/vite/plugin-local-manifest.ts +15 -0
package/dist/cli/cli.js
CHANGED
|
@@ -174,18 +174,7 @@ var init_invariant = __esm({
|
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
// src/config/
|
|
178
|
-
import { stat } from "node:fs/promises";
|
|
179
|
-
var fileExists;
|
|
180
|
-
var init_file_exists = __esm({
|
|
181
|
-
"src/config/file-exists.ts"() {
|
|
182
|
-
fileExists = (path39) => stat(path39).then(() => true).catch(() => false);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
// src/config/apitogo-config-loader.ts
|
|
187
|
-
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
188
|
-
import path2 from "node:path";
|
|
177
|
+
// src/config/apitogo-config-core.ts
|
|
189
178
|
function parseEnvValue(raw) {
|
|
190
179
|
if (raw === void 0) {
|
|
191
180
|
return raw;
|
|
@@ -234,8 +223,12 @@ function setNestedValue(target, pathParts, value) {
|
|
|
234
223
|
}
|
|
235
224
|
current[leafKey] = value;
|
|
236
225
|
}
|
|
226
|
+
function stripRuntimeConfigFields(config2) {
|
|
227
|
+
const { plugins: _plugins, ...jsonOnly } = config2;
|
|
228
|
+
return jsonOnly;
|
|
229
|
+
}
|
|
237
230
|
function applyEnvOverrides(config2, env = process.env) {
|
|
238
|
-
const result = structuredClone(config2);
|
|
231
|
+
const result = structuredClone(stripRuntimeConfigFields(config2));
|
|
239
232
|
for (const [key, value] of Object.entries(env)) {
|
|
240
233
|
if (!key.startsWith(ENV_PREFIX) || value === void 0) {
|
|
241
234
|
continue;
|
|
@@ -248,40 +241,296 @@ function applyEnvOverrides(config2, env = process.env) {
|
|
|
248
241
|
}
|
|
249
242
|
return result;
|
|
250
243
|
}
|
|
251
|
-
function
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
244
|
+
function asRecord(value) {
|
|
245
|
+
return value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
246
|
+
}
|
|
247
|
+
function readSiteTitle(config2) {
|
|
248
|
+
const site = asRecord(config2.site);
|
|
249
|
+
const branding = asRecord(config2.branding);
|
|
250
|
+
const siteTitle = site?.title;
|
|
251
|
+
const brandingTitle = branding?.title;
|
|
252
|
+
const legacySiteName = config2.siteName;
|
|
253
|
+
if (typeof siteTitle === "string" && siteTitle.trim()) {
|
|
254
|
+
return siteTitle.trim();
|
|
257
255
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
if (typeof brandingTitle === "string" && brandingTitle.trim()) {
|
|
257
|
+
return brandingTitle.trim();
|
|
258
|
+
}
|
|
259
|
+
if (typeof legacySiteName === "string" && legacySiteName.trim()) {
|
|
260
|
+
return legacySiteName.trim();
|
|
261
|
+
}
|
|
262
|
+
return void 0;
|
|
261
263
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
function readLogoUrl(config2) {
|
|
265
|
+
const site = asRecord(config2.site);
|
|
266
|
+
const logo = asRecord(site?.logo);
|
|
267
|
+
const src = asRecord(logo?.src);
|
|
268
|
+
const branding = asRecord(config2.branding);
|
|
269
|
+
const fromSite = typeof src?.light === "string" && src.light || typeof src?.dark === "string" && src.dark || typeof logo?.logoUrl === "string" && logo.logoUrl || typeof site?.logoUrl === "string" && site.logoUrl;
|
|
270
|
+
if (fromSite) {
|
|
271
|
+
return fromSite;
|
|
272
|
+
}
|
|
273
|
+
return typeof branding?.logoUrl === "string" ? branding.logoUrl : void 0;
|
|
274
|
+
}
|
|
275
|
+
function firstApiInput(config2) {
|
|
276
|
+
const apis = config2.apis;
|
|
277
|
+
const list = Array.isArray(apis) ? apis : apis ? [apis] : [];
|
|
278
|
+
for (const entry of list) {
|
|
279
|
+
const api = asRecord(entry);
|
|
280
|
+
if (typeof api?.input === "string" && api.input.trim()) {
|
|
281
|
+
return api.input.trim();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return void 0;
|
|
285
|
+
}
|
|
286
|
+
function mergeAuthenticationGateway(config2) {
|
|
287
|
+
const authentication = asRecord(config2.authentication);
|
|
288
|
+
if (!authentication) {
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
const authGateway = asRecord(authentication.gateway);
|
|
292
|
+
const rootGateway = asRecord(config2.gateway);
|
|
293
|
+
if (!authGateway && !rootGateway) {
|
|
294
|
+
return authentication;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
...authentication,
|
|
298
|
+
gateway: {
|
|
299
|
+
...rootGateway,
|
|
300
|
+
...authGateway
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function ensureModules(config2) {
|
|
305
|
+
const modules = asRecord(config2.modules) ?? {};
|
|
306
|
+
config2.modules = modules;
|
|
307
|
+
return modules;
|
|
308
|
+
}
|
|
309
|
+
function mergePlansBySku(existing, patch) {
|
|
310
|
+
const bySku = /* @__PURE__ */ new Map();
|
|
311
|
+
for (const plan of existing) {
|
|
312
|
+
if (typeof plan.sku === "string") {
|
|
313
|
+
bySku.set(plan.sku, plan);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (const plan of patch) {
|
|
317
|
+
if (typeof plan.sku !== "string") {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
const prior = bySku.get(plan.sku);
|
|
321
|
+
bySku.set(plan.sku, prior ? { ...prior, ...plan } : plan);
|
|
265
322
|
}
|
|
323
|
+
return Array.from(bySku.values());
|
|
324
|
+
}
|
|
325
|
+
function readPlanCatalogItems(config2) {
|
|
326
|
+
const normalized = normalizeApitogoConfig(config2);
|
|
327
|
+
const items = asRecord(
|
|
328
|
+
asRecord(asRecord(normalized.modules)?.userPanel)?.plans
|
|
329
|
+
)?.items;
|
|
330
|
+
return Array.isArray(items) ? items : [];
|
|
331
|
+
}
|
|
332
|
+
function migratePlanCatalog(normalized) {
|
|
333
|
+
const modules = ensureModules(normalized);
|
|
334
|
+
const userPanel = asRecord(modules.userPanel) ?? {};
|
|
335
|
+
const plansModule = asRecord(userPanel.plans) ?? {};
|
|
336
|
+
const rootList = Array.isArray(normalized.plans) ? normalized.plans : [];
|
|
337
|
+
const existingItems = Array.isArray(plansModule.items) ? plansModule.items : [];
|
|
338
|
+
if (rootList.length) {
|
|
339
|
+
plansModule.items = mergePlansBySku(existingItems, rootList);
|
|
340
|
+
if (plansModule.enabled === void 0) {
|
|
341
|
+
plansModule.enabled = true;
|
|
342
|
+
}
|
|
343
|
+
userPanel.plans = plansModule;
|
|
344
|
+
modules.userPanel = userPanel;
|
|
345
|
+
}
|
|
346
|
+
delete normalized.plans;
|
|
347
|
+
}
|
|
348
|
+
function normalizeApitogoConfig(config2) {
|
|
349
|
+
const normalized = structuredClone(stripRuntimeConfigFields(config2));
|
|
350
|
+
const title = readSiteTitle(normalized);
|
|
351
|
+
const logoUrl = readLogoUrl(normalized);
|
|
352
|
+
const site = asRecord(normalized.site) ?? {};
|
|
353
|
+
if (title) {
|
|
354
|
+
site.title = title;
|
|
355
|
+
}
|
|
356
|
+
if (logoUrl && !asRecord(site.logo)?.src) {
|
|
357
|
+
site.logo = {
|
|
358
|
+
...asRecord(site.logo) ?? {},
|
|
359
|
+
src: { light: logoUrl, dark: logoUrl }
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
normalized.site = site;
|
|
363
|
+
const authentication = mergeAuthenticationGateway(normalized);
|
|
364
|
+
if (authentication) {
|
|
365
|
+
normalized.authentication = authentication;
|
|
366
|
+
}
|
|
367
|
+
delete normalized.gateway;
|
|
368
|
+
const modules = ensureModules(normalized);
|
|
369
|
+
const legacyDocs = asRecord(normalized.docs);
|
|
370
|
+
const moduleDocs = asRecord(modules.docs) ?? {};
|
|
371
|
+
if (legacyDocs) {
|
|
372
|
+
modules.docs = { ...legacyDocs, ...moduleDocs };
|
|
373
|
+
}
|
|
374
|
+
delete normalized.docs;
|
|
375
|
+
const legacyApiKeys = asRecord(normalized.apiKeys);
|
|
376
|
+
const userPanel = asRecord(modules.userPanel) ?? {};
|
|
377
|
+
const apiKeys = asRecord(userPanel.apiKeys) ?? {};
|
|
378
|
+
if (legacyApiKeys?.enabled === true && apiKeys.enabled === void 0) {
|
|
379
|
+
userPanel.apiKeys = { ...apiKeys, enabled: true };
|
|
380
|
+
modules.userPanel = userPanel;
|
|
381
|
+
}
|
|
382
|
+
delete normalized.apiKeys;
|
|
383
|
+
const apiInput = firstApiInput(normalized);
|
|
384
|
+
if (apiInput) {
|
|
385
|
+
const backend = asRecord(normalized.backend) ?? {};
|
|
386
|
+
if (!backend.openApiPath) {
|
|
387
|
+
backend.openApiPath = apiInput;
|
|
388
|
+
}
|
|
389
|
+
normalized.backend = backend;
|
|
390
|
+
}
|
|
391
|
+
delete normalized.siteName;
|
|
392
|
+
delete normalized.branding;
|
|
393
|
+
delete normalized.projectName;
|
|
394
|
+
migratePlanCatalog(normalized);
|
|
395
|
+
syncBillingEnabled(normalized);
|
|
396
|
+
syncAuthentication(normalized);
|
|
397
|
+
return normalized;
|
|
398
|
+
}
|
|
399
|
+
function isBillingEnabled(config2) {
|
|
400
|
+
const normalized = normalizeApitogoConfig(config2);
|
|
401
|
+
const plans = asRecord(
|
|
402
|
+
asRecord(asRecord(normalized.modules)?.userPanel)?.plans
|
|
403
|
+
);
|
|
404
|
+
return plans?.enabled === true;
|
|
405
|
+
}
|
|
406
|
+
function isUserPanelEnabled(normalized) {
|
|
407
|
+
const modules = asRecord(normalized.modules);
|
|
408
|
+
const userPanel = asRecord(modules?.userPanel);
|
|
409
|
+
if (userPanel?.enabled === true) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
const dashboard = asRecord(userPanel?.dashboard);
|
|
413
|
+
const userManagement = asRecord(userPanel?.userManagement);
|
|
414
|
+
const apiKeys = asRecord(userPanel?.apiKeys);
|
|
415
|
+
const plans = asRecord(userPanel?.plans);
|
|
416
|
+
return dashboard?.enabled === true || userManagement?.enabled === true || apiKeys?.enabled === true || plans?.enabled === true;
|
|
417
|
+
}
|
|
418
|
+
function syncAuthentication(normalized) {
|
|
419
|
+
const userPanelEnabled = isUserPanelEnabled(normalized);
|
|
420
|
+
const authentication = asRecord(normalized.authentication);
|
|
421
|
+
if (!userPanelEnabled && !authentication) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const auth = authentication ?? {};
|
|
425
|
+
auth.enabled = userPanelEnabled;
|
|
426
|
+
auth.type = "dev-portal";
|
|
427
|
+
if (userPanelEnabled) {
|
|
428
|
+
const native = asRecord(auth.native) ?? {};
|
|
429
|
+
if (native.enabled === void 0) {
|
|
430
|
+
native.enabled = true;
|
|
431
|
+
}
|
|
432
|
+
auth.native = native;
|
|
433
|
+
if (!Array.isArray(auth.providers)) {
|
|
434
|
+
auth.providers = [];
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
normalized.authentication = auth;
|
|
438
|
+
}
|
|
439
|
+
function stripAuthenticationSecrets(authentication) {
|
|
440
|
+
const {
|
|
441
|
+
gateway: _gateway,
|
|
442
|
+
oidc: _oidc,
|
|
443
|
+
stripe: _stripe,
|
|
444
|
+
type: _type,
|
|
445
|
+
email,
|
|
446
|
+
providers,
|
|
447
|
+
...authPublic
|
|
448
|
+
} = authentication;
|
|
449
|
+
const emailRecord = asRecord(email);
|
|
450
|
+
if (emailRecord) {
|
|
451
|
+
const { connectionString: _connectionString, ...emailPublic } = emailRecord;
|
|
452
|
+
authPublic.email = emailPublic;
|
|
453
|
+
}
|
|
454
|
+
if (Array.isArray(providers)) {
|
|
455
|
+
authPublic.providers = providers.map((entry) => {
|
|
456
|
+
const provider = asRecord(entry) ?? {};
|
|
457
|
+
const { clientSecret: _clientSecret, ...providerPublic } = provider;
|
|
458
|
+
return providerPublic;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return authPublic;
|
|
462
|
+
}
|
|
463
|
+
function syncBillingEnabled(normalized) {
|
|
464
|
+
const legacyPricing = asRecord(normalized.pricing);
|
|
465
|
+
const modules = ensureModules(normalized);
|
|
466
|
+
const userPanel = asRecord(modules.userPanel) ?? {};
|
|
467
|
+
const plans = asRecord(userPanel.plans) ?? {};
|
|
468
|
+
const enabled = plans.enabled === true || legacyPricing?.enabled === true;
|
|
469
|
+
if (enabled) {
|
|
470
|
+
userPanel.plans = { ...plans, enabled: true };
|
|
471
|
+
modules.userPanel = userPanel;
|
|
472
|
+
}
|
|
473
|
+
delete normalized.pricing;
|
|
474
|
+
}
|
|
475
|
+
function deriveManifestFields(config2) {
|
|
476
|
+
const normalized = normalizeApitogoConfig(config2);
|
|
266
477
|
const manifest = {};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
478
|
+
const title = readSiteTitle(normalized);
|
|
479
|
+
if (title) {
|
|
480
|
+
manifest.siteName = title;
|
|
481
|
+
const logoUrl = readLogoUrl(normalized);
|
|
482
|
+
manifest.branding = logoUrl ? { title, logoUrl } : { title };
|
|
483
|
+
}
|
|
484
|
+
for (const key of DERIVED_MANIFEST_KEYS) {
|
|
485
|
+
if (key === "siteName" || key === "branding") {
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (key === "authentication") {
|
|
489
|
+
const authentication2 = asRecord(normalized.authentication);
|
|
490
|
+
if (authentication2) {
|
|
491
|
+
manifest.authentication = stripAuthenticationSecrets(authentication2);
|
|
492
|
+
}
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (key === "gateway") {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (key === "pricing") {
|
|
499
|
+
if (isBillingEnabled(config2)) {
|
|
500
|
+
manifest.pricing = { enabled: true };
|
|
501
|
+
}
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
if (key === "plans") {
|
|
505
|
+
const items = readPlanCatalogItems(normalized);
|
|
506
|
+
if (items.length) {
|
|
507
|
+
manifest.plans = items;
|
|
508
|
+
}
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (normalized[key] !== void 0) {
|
|
512
|
+
manifest[key] = normalized[key];
|
|
270
513
|
}
|
|
271
514
|
}
|
|
272
|
-
const authentication =
|
|
273
|
-
if (authentication
|
|
274
|
-
|
|
275
|
-
manifest.authentication = enabled === void 0 ? void 0 : { enabled };
|
|
515
|
+
const authentication = asRecord(normalized.authentication);
|
|
516
|
+
if (authentication?.gateway) {
|
|
517
|
+
manifest.gateway = authentication.gateway;
|
|
276
518
|
}
|
|
519
|
+
return manifest;
|
|
520
|
+
}
|
|
521
|
+
function extractManifest(config2) {
|
|
522
|
+
if (!config2 || typeof config2 !== "object") {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
const manifest = deriveManifestFields(config2);
|
|
277
526
|
return Object.keys(manifest).length > 0 ? manifest : null;
|
|
278
527
|
}
|
|
279
|
-
var APITOGO_CONFIG_FILENAME, ENV_PREFIX,
|
|
280
|
-
var
|
|
281
|
-
"src/config/apitogo-config-
|
|
528
|
+
var APITOGO_CONFIG_FILENAME, ENV_PREFIX, DERIVED_MANIFEST_KEYS;
|
|
529
|
+
var init_apitogo_config_core = __esm({
|
|
530
|
+
"src/config/apitogo-config-core.ts"() {
|
|
282
531
|
APITOGO_CONFIG_FILENAME = "apitogo.config.json";
|
|
283
532
|
ENV_PREFIX = "APITOGO_CONFIG_";
|
|
284
|
-
|
|
533
|
+
DERIVED_MANIFEST_KEYS = [
|
|
285
534
|
"siteName",
|
|
286
535
|
"branding",
|
|
287
536
|
"pricing",
|
|
@@ -289,14 +538,49 @@ var init_apitogo_config_loader = __esm({
|
|
|
289
538
|
"plans",
|
|
290
539
|
"backend",
|
|
291
540
|
"gateway",
|
|
292
|
-
"projectId"
|
|
293
|
-
"projectName"
|
|
541
|
+
"projectId"
|
|
294
542
|
];
|
|
295
543
|
}
|
|
296
544
|
});
|
|
297
545
|
|
|
546
|
+
// src/config/apitogo-config-loader.node.ts
|
|
547
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
548
|
+
import path2 from "node:path";
|
|
549
|
+
function loadApitogoConfig(rootDir = process.cwd()) {
|
|
550
|
+
const configPath = path2.join(path2.resolve(rootDir), APITOGO_CONFIG_FILENAME);
|
|
551
|
+
if (!existsSync(configPath)) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
`Missing ${APITOGO_CONFIG_FILENAME} in ${path2.resolve(rootDir)}`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
const raw = readFileSync2(configPath, "utf8");
|
|
557
|
+
const parsed = JSON.parse(raw);
|
|
558
|
+
return normalizeApitogoConfig(applyEnvOverrides(parsed, process.env));
|
|
559
|
+
}
|
|
560
|
+
var init_apitogo_config_loader_node = __esm({
|
|
561
|
+
"src/config/apitogo-config-loader.node.ts"() {
|
|
562
|
+
init_apitogo_config_core();
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// src/config/apitogo-config-loader.ts
|
|
567
|
+
var init_apitogo_config_loader = __esm({
|
|
568
|
+
"src/config/apitogo-config-loader.ts"() {
|
|
569
|
+
init_apitogo_config_core();
|
|
570
|
+
init_apitogo_config_loader_node();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// src/config/file-exists.ts
|
|
575
|
+
import { stat } from "node:fs/promises";
|
|
576
|
+
var fileExists;
|
|
577
|
+
var init_file_exists = __esm({
|
|
578
|
+
"src/config/file-exists.ts"() {
|
|
579
|
+
fileExists = (path39) => stat(path39).then(() => true).catch(() => false);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
298
583
|
// src/config/local-manifest.ts
|
|
299
|
-
import { access, readFile } from "node:fs/promises";
|
|
300
584
|
import path3 from "node:path";
|
|
301
585
|
import { z as z3 } from "zod";
|
|
302
586
|
function isPricingEnabled(manifest) {
|
|
@@ -335,7 +619,6 @@ function plansToPreviewCatalog(plans) {
|
|
|
335
619
|
plans: plans.map((plan) => ({
|
|
336
620
|
sku: plan.sku,
|
|
337
621
|
displayName: plan.displayName,
|
|
338
|
-
isFree: plan.isFree,
|
|
339
622
|
priceAmount: plan.priceAmount ?? 0,
|
|
340
623
|
priceCurrency: plan.priceCurrency ?? "usd",
|
|
341
624
|
billingPeriod: normalizeBillingPeriod(plan.billingPeriod),
|
|
@@ -347,48 +630,6 @@ function plansToPreviewCatalog(plans) {
|
|
|
347
630
|
function resolveManifestEnv(viteMode) {
|
|
348
631
|
return viteMode === "production" ? "production" : "development";
|
|
349
632
|
}
|
|
350
|
-
function mergePlansBySku(existing, patch) {
|
|
351
|
-
const bySku = /* @__PURE__ */ new Map();
|
|
352
|
-
for (const plan of existing ?? []) {
|
|
353
|
-
bySku.set(plan.sku, plan);
|
|
354
|
-
}
|
|
355
|
-
for (const plan of patch) {
|
|
356
|
-
const prior = bySku.get(plan.sku);
|
|
357
|
-
bySku.set(plan.sku, prior ? { ...prior, ...plan } : plan);
|
|
358
|
-
}
|
|
359
|
-
return Array.from(bySku.values());
|
|
360
|
-
}
|
|
361
|
-
function mergeManifest(base, override) {
|
|
362
|
-
const merged = { ...base, ...override };
|
|
363
|
-
if (override.branding) {
|
|
364
|
-
merged.branding = { ...base.branding, ...override.branding };
|
|
365
|
-
}
|
|
366
|
-
if (override.pricing) {
|
|
367
|
-
merged.pricing = { ...base.pricing, ...override.pricing };
|
|
368
|
-
}
|
|
369
|
-
if (override.authentication) {
|
|
370
|
-
merged.authentication = {
|
|
371
|
-
...base.authentication,
|
|
372
|
-
...override.authentication
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
if (override.backend) {
|
|
376
|
-
merged.backend = { ...base.backend, ...override.backend };
|
|
377
|
-
}
|
|
378
|
-
if (override.gateway) {
|
|
379
|
-
merged.gateway = { ...base.gateway, ...override.gateway };
|
|
380
|
-
}
|
|
381
|
-
if (override.plans) {
|
|
382
|
-
merged.plans = mergePlansBySku(base.plans, override.plans);
|
|
383
|
-
}
|
|
384
|
-
return merged;
|
|
385
|
-
}
|
|
386
|
-
function manifestFilePath(rootDir, filename) {
|
|
387
|
-
return path3.join(
|
|
388
|
-
path3.resolve(rootDir),
|
|
389
|
-
filename ?? DEV_PORTAL_MANIFEST_FILENAME
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
633
|
function manifestPathsForEnv(rootDir, _env) {
|
|
393
634
|
const resolvedRoot = path3.resolve(rootDir);
|
|
394
635
|
const configPath = path3.join(resolvedRoot, APITOGO_CONFIG_FILENAME);
|
|
@@ -398,35 +639,6 @@ function manifestPathsForEnv(rootDir, _env) {
|
|
|
398
639
|
watchPaths: [configPath]
|
|
399
640
|
};
|
|
400
641
|
}
|
|
401
|
-
function parseLocalManifestJson(raw) {
|
|
402
|
-
try {
|
|
403
|
-
const parsed = JSON.parse(raw);
|
|
404
|
-
const result = DevPortalLocalManifestSchema.safeParse(parsed);
|
|
405
|
-
if (!result.success) {
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
return result.data;
|
|
409
|
-
} catch {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
async function fileExists2(filePath) {
|
|
414
|
-
try {
|
|
415
|
-
await access(filePath);
|
|
416
|
-
return true;
|
|
417
|
-
} catch {
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
async function readManifestFile(rootDir, filename) {
|
|
422
|
-
const filePath = manifestFilePath(rootDir, filename);
|
|
423
|
-
try {
|
|
424
|
-
const raw = await readFile(filePath, "utf8");
|
|
425
|
-
return parseLocalManifestJson(raw);
|
|
426
|
-
} catch {
|
|
427
|
-
return null;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
642
|
function parseManifestRecord(manifest) {
|
|
431
643
|
if (!manifest) {
|
|
432
644
|
return null;
|
|
@@ -434,65 +646,36 @@ function parseManifestRecord(manifest) {
|
|
|
434
646
|
const result = DevPortalLocalManifestSchema.safeParse(manifest);
|
|
435
647
|
return result.success ? result.data : null;
|
|
436
648
|
}
|
|
437
|
-
async function readEffectiveManifest(rootDir,
|
|
649
|
+
async function readEffectiveManifest(rootDir, _env) {
|
|
438
650
|
try {
|
|
439
651
|
const config2 = loadApitogoConfig(rootDir);
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
async function readLegacyEffectiveManifest(rootDir, env) {
|
|
446
|
-
const resolvedRoot = path3.resolve(rootDir);
|
|
447
|
-
const basePath = path3.join(resolvedRoot, APITOGO_MANIFEST_BASE_FILENAME);
|
|
448
|
-
const overridePath = path3.join(resolvedRoot, APITOGO_MANIFEST_ENV_FILES[env]);
|
|
449
|
-
const hasBase = await fileExists2(basePath);
|
|
450
|
-
const hasOverride = await fileExists2(overridePath);
|
|
451
|
-
if (!hasBase) {
|
|
452
|
-
const legacy = await readManifestFile(
|
|
453
|
-
rootDir,
|
|
454
|
-
APITOGO_MANIFEST_ENV_FILES.development
|
|
455
|
-
);
|
|
456
|
-
if (legacy) {
|
|
457
|
-
return legacy;
|
|
652
|
+
const manifest = parseManifestRecord(extractManifest(config2));
|
|
653
|
+
if (!manifest) {
|
|
654
|
+
return null;
|
|
458
655
|
}
|
|
459
|
-
if (
|
|
460
|
-
|
|
656
|
+
if (!manifest.plans?.length) {
|
|
657
|
+
const items = readPlanCatalogItems(config2);
|
|
658
|
+
if (items.length) {
|
|
659
|
+
manifest.plans = items;
|
|
660
|
+
}
|
|
461
661
|
}
|
|
662
|
+
return {
|
|
663
|
+
...manifest,
|
|
664
|
+
pricing: { ...manifest.pricing, enabled: isBillingEnabled(config2) }
|
|
665
|
+
};
|
|
666
|
+
} catch {
|
|
462
667
|
return null;
|
|
463
668
|
}
|
|
464
|
-
const base = await readManifestFile(rootDir, APITOGO_MANIFEST_BASE_FILENAME);
|
|
465
|
-
if (!base) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
if (!hasOverride) {
|
|
469
|
-
return base;
|
|
470
|
-
}
|
|
471
|
-
const override = await readManifestFile(
|
|
472
|
-
rootDir,
|
|
473
|
-
APITOGO_MANIFEST_ENV_FILES[env]
|
|
474
|
-
);
|
|
475
|
-
if (!override) {
|
|
476
|
-
return base;
|
|
477
|
-
}
|
|
478
|
-
return mergeManifest(base, override);
|
|
479
669
|
}
|
|
480
|
-
var
|
|
670
|
+
var BillingPeriodSchema, ManifestPlanInputSchema, DevPortalLocalManifestSchema;
|
|
481
671
|
var init_local_manifest = __esm({
|
|
482
672
|
"src/config/local-manifest.ts"() {
|
|
483
673
|
init_apitogo_config_loader();
|
|
484
|
-
DEV_PORTAL_MANIFEST_FILENAME = "apitogo.local.json";
|
|
485
|
-
APITOGO_MANIFEST_BASE_FILENAME = "apitogo.json";
|
|
486
|
-
APITOGO_MANIFEST_ENV_FILES = {
|
|
487
|
-
development: "apitogo.local.json",
|
|
488
|
-
production: "apitogo.prod.json"
|
|
489
|
-
};
|
|
490
674
|
BillingPeriodSchema = z3.enum(["month", "year", "monthly", "annual"]);
|
|
491
675
|
ManifestPlanInputSchema = z3.object({
|
|
492
676
|
sku: z3.string().min(1),
|
|
493
677
|
displayName: z3.string().min(1),
|
|
494
|
-
|
|
495
|
-
priceAmount: z3.number().optional(),
|
|
678
|
+
priceAmount: z3.number().default(0),
|
|
496
679
|
priceCurrency: z3.string().optional(),
|
|
497
680
|
billingPeriod: BillingPeriodSchema.optional(),
|
|
498
681
|
limitsJson: z3.string().optional(),
|
|
@@ -508,7 +691,24 @@ var init_local_manifest = __esm({
|
|
|
508
691
|
enabled: z3.boolean().optional()
|
|
509
692
|
}).optional(),
|
|
510
693
|
authentication: z3.object({
|
|
511
|
-
enabled: z3.boolean().optional()
|
|
694
|
+
enabled: z3.boolean().optional(),
|
|
695
|
+
apiBaseUrl: z3.string().optional(),
|
|
696
|
+
native: z3.object({
|
|
697
|
+
enabled: z3.boolean().optional()
|
|
698
|
+
}).optional(),
|
|
699
|
+
email: z3.object({
|
|
700
|
+
provider: z3.string().optional(),
|
|
701
|
+
from: z3.string().optional()
|
|
702
|
+
}).optional(),
|
|
703
|
+
providers: z3.array(
|
|
704
|
+
z3.object({
|
|
705
|
+
id: z3.string().min(1),
|
|
706
|
+
displayName: z3.string().optional(),
|
|
707
|
+
authority: z3.string().optional(),
|
|
708
|
+
clientId: z3.string().optional(),
|
|
709
|
+
scopes: z3.string().optional()
|
|
710
|
+
})
|
|
711
|
+
).optional()
|
|
512
712
|
}).optional(),
|
|
513
713
|
plans: z3.array(ManifestPlanInputSchema).optional(),
|
|
514
714
|
backend: z3.object({
|
|
@@ -527,15 +727,14 @@ var init_local_manifest = __esm({
|
|
|
527
727
|
limitsJson: z3.string().optional(),
|
|
528
728
|
publicHealthActionKey: z3.string().optional()
|
|
529
729
|
}).optional(),
|
|
530
|
-
projectId: z3.string().optional()
|
|
531
|
-
projectName: z3.string().optional()
|
|
730
|
+
projectId: z3.string().optional()
|
|
532
731
|
});
|
|
533
732
|
}
|
|
534
733
|
});
|
|
535
734
|
|
|
536
735
|
// src/config/validators/ModulesSchema.ts
|
|
537
736
|
import { z as z4 } from "zod";
|
|
538
|
-
var ModuleToggleSchema, DocsModuleSchema, LandingLinkSchema, LandingFeatureSchema, LandingHeroSchema, LandingContentSchema, DashboardContentSchema, ProfileContentSchema, PlanTierSchema, PlansContentSchema, SubmodulePageFields, LandingModuleSchema, UserManagementModuleSchema, ApiKeysModuleSchema, PlansModuleSchema, DashboardModuleSchema, UserPanelModuleSchema, ModulesSchema;
|
|
737
|
+
var ModuleToggleSchema, DocsModuleSchema, LandingLinkSchema, LandingFeatureSchema, LandingHeroSchema, LandingContentSchema, DashboardContentSchema, ProfileContentSchema, PlanTierSchema, PlansContentSchema, SubmodulePageFields, LandingModuleSchema, UserManagementModuleSchema, ApiKeysModuleSchema, PlanCatalogItemSchema, PlansModuleSchema, DashboardModuleSchema, UserPanelModuleSchema, ModulesSchema;
|
|
539
738
|
var init_ModulesSchema = __esm({
|
|
540
739
|
"src/config/validators/ModulesSchema.ts"() {
|
|
541
740
|
ModuleToggleSchema = z4.object({
|
|
@@ -635,12 +834,24 @@ var init_ModulesSchema = __esm({
|
|
|
635
834
|
ApiKeysModuleSchema = ModuleToggleSchema.extend({
|
|
636
835
|
path: z4.string().default("settings/api-keys").describe("Route path for API key management.")
|
|
637
836
|
});
|
|
837
|
+
PlanCatalogItemSchema = z4.object({
|
|
838
|
+
sku: z4.string(),
|
|
839
|
+
displayName: z4.string(),
|
|
840
|
+
priceAmount: z4.number().default(0),
|
|
841
|
+
priceCurrency: z4.string().optional(),
|
|
842
|
+
billingPeriod: z4.string().optional(),
|
|
843
|
+
limitsJson: z4.string().optional(),
|
|
844
|
+
includedActionKeys: z4.array(z4.string()).optional()
|
|
845
|
+
});
|
|
638
846
|
PlansModuleSchema = ModuleToggleSchema.extend({
|
|
639
847
|
path: z4.string().default("plans").describe("Route path for plans and subscription management."),
|
|
640
848
|
page: SubmodulePageFields.page,
|
|
641
849
|
component: SubmodulePageFields.component,
|
|
642
850
|
content: PlansContentSchema.describe(
|
|
643
851
|
"Default plans page content when no custom component is provided."
|
|
852
|
+
),
|
|
853
|
+
items: z4.array(PlanCatalogItemSchema).optional().describe(
|
|
854
|
+
"Gateway plan catalog for /pricing preview and publish (canonical storage)."
|
|
644
855
|
)
|
|
645
856
|
});
|
|
646
857
|
DashboardModuleSchema = ModuleToggleSchema.extend({
|
|
@@ -757,17 +968,18 @@ var init_resolve_modules = __esm({
|
|
|
757
968
|
const plansConfig = userPanelModule?.plans;
|
|
758
969
|
const dashboardEnabled = dashboardConfig?.enabled ?? (explicit ? false : false);
|
|
759
970
|
const userManagementEnabled = explicit ? userManagementConfig?.enabled ?? !!config2.authentication : !!config2.authentication;
|
|
760
|
-
const apiKeysEnabled = explicit ? apiKeysModuleConfig?.enabled ??
|
|
761
|
-
const
|
|
971
|
+
const apiKeysEnabled = explicit ? apiKeysModuleConfig?.enabled ?? false : false;
|
|
972
|
+
const billingEnabled = config2.__meta?.pricingEnabled === true || plansConfig?.enabled === true;
|
|
973
|
+
const plansEnabled = billingEnabled;
|
|
762
974
|
const userPanelEnabled = userPanelModule?.enabled ?? (dashboardEnabled || userManagementEnabled || apiKeysEnabled || plansEnabled);
|
|
763
975
|
const basePath = userPanelModule?.basePath ?? "/account";
|
|
764
976
|
return {
|
|
765
977
|
docs: {
|
|
766
978
|
enabled: docsEnabled,
|
|
767
|
-
files: docsModule?.files
|
|
768
|
-
publishMarkdown: docsModule?.publishMarkdown
|
|
769
|
-
defaultOptions: docsModule?.defaultOptions
|
|
770
|
-
llms: docsModule?.llms
|
|
979
|
+
files: docsModule?.files,
|
|
980
|
+
publishMarkdown: docsModule?.publishMarkdown,
|
|
981
|
+
defaultOptions: docsModule?.defaultOptions,
|
|
982
|
+
llms: docsModule?.llms
|
|
771
983
|
},
|
|
772
984
|
landing: {
|
|
773
985
|
enabled: landingEnabled,
|
|
@@ -807,7 +1019,8 @@ var init_resolve_modules = __esm({
|
|
|
807
1019
|
plans: {
|
|
808
1020
|
enabled: plansEnabled,
|
|
809
1021
|
path: joinPanelPath(basePath, plansConfig?.path ?? "plans"),
|
|
810
|
-
content: resolvePlansContent(plansConfig?.content)
|
|
1022
|
+
content: resolvePlansContent(plansConfig?.content),
|
|
1023
|
+
items: plansConfig?.items
|
|
811
1024
|
}
|
|
812
1025
|
}
|
|
813
1026
|
};
|
|
@@ -3948,8 +4161,26 @@ var init_ZudokuConfig = __esm({
|
|
|
3948
4161
|
redirectToAfterSignOut: z9.string().optional()
|
|
3949
4162
|
}),
|
|
3950
4163
|
z9.object({
|
|
3951
|
-
type: z9.literal("dev-portal"),
|
|
4164
|
+
type: z9.literal("dev-portal").optional().default("dev-portal"),
|
|
3952
4165
|
apiBaseUrl: z9.string().optional(),
|
|
4166
|
+
native: z9.object({
|
|
4167
|
+
enabled: z9.boolean().optional()
|
|
4168
|
+
}).optional(),
|
|
4169
|
+
email: z9.object({
|
|
4170
|
+
provider: z9.string().optional(),
|
|
4171
|
+
from: z9.string().optional(),
|
|
4172
|
+
connectionString: z9.string().optional()
|
|
4173
|
+
}).optional(),
|
|
4174
|
+
providers: z9.array(
|
|
4175
|
+
z9.object({
|
|
4176
|
+
id: z9.string().min(1),
|
|
4177
|
+
displayName: z9.string().optional(),
|
|
4178
|
+
authority: z9.string().optional(),
|
|
4179
|
+
clientId: z9.string().optional(),
|
|
4180
|
+
clientSecret: z9.string().optional(),
|
|
4181
|
+
scopes: z9.string().optional()
|
|
4182
|
+
})
|
|
4183
|
+
).optional(),
|
|
3953
4184
|
redirectToAfterSignUp: z9.string().optional(),
|
|
3954
4185
|
redirectToAfterSignIn: z9.string().optional(),
|
|
3955
4186
|
redirectToAfterSignOut: z9.string().optional()
|
|
@@ -4245,12 +4476,18 @@ async function loadZudokuConfig(configEnv, rootDir) {
|
|
|
4245
4476
|
const loadedConfig = await loadZudokuConfigWithMeta(rootDir);
|
|
4246
4477
|
const manifestEnv = resolveManifestEnv(configEnv.mode);
|
|
4247
4478
|
const manifest = await readEffectiveManifest(rootDir, manifestEnv);
|
|
4479
|
+
const previewCatalog = manifestToPreviewCatalog(manifest);
|
|
4480
|
+
const jsonConfig = loadApitogoConfig(rootDir);
|
|
4481
|
+
const previewPlans = previewCatalog.plans.length ? previewCatalog.plans : plansToPreviewCatalog(
|
|
4482
|
+
readPlanCatalogItems(jsonConfig)
|
|
4483
|
+
).plans;
|
|
4248
4484
|
const configWithManifestMeta = {
|
|
4249
4485
|
...loadedConfig,
|
|
4250
4486
|
__meta: {
|
|
4251
4487
|
...loadedConfig.__meta,
|
|
4252
|
-
pricingEnabled:
|
|
4253
|
-
authenticationEnabled: isAuthenticationEnabled(manifest)
|
|
4488
|
+
pricingEnabled: isBillingEnabled(jsonConfig),
|
|
4489
|
+
authenticationEnabled: isAuthenticationEnabled(manifest),
|
|
4490
|
+
previewPlans
|
|
4254
4491
|
}
|
|
4255
4492
|
};
|
|
4256
4493
|
const transformedConfig = applyAuthenticationHeaderNav(
|
|
@@ -4258,6 +4495,10 @@ async function loadZudokuConfig(configEnv, rootDir) {
|
|
|
4258
4495
|
);
|
|
4259
4496
|
config = {
|
|
4260
4497
|
...transformedConfig,
|
|
4498
|
+
__meta: {
|
|
4499
|
+
...transformedConfig.__meta,
|
|
4500
|
+
...configWithManifestMeta.__meta
|
|
4501
|
+
},
|
|
4261
4502
|
__resolvedModules: resolveModulesConfig(transformedConfig)
|
|
4262
4503
|
};
|
|
4263
4504
|
if (!process.env.APITOGO_JSON_ONLY) {
|
|
@@ -4285,6 +4526,7 @@ var init_loader = __esm({
|
|
|
4285
4526
|
init_auth_header_nav();
|
|
4286
4527
|
init_transform_config();
|
|
4287
4528
|
init_invariant();
|
|
4529
|
+
init_apitogo_config_loader();
|
|
4288
4530
|
init_file_exists();
|
|
4289
4531
|
init_local_manifest();
|
|
4290
4532
|
init_resolve_modules();
|
|
@@ -4411,7 +4653,7 @@ import yargs from "yargs/yargs";
|
|
|
4411
4653
|
import path30 from "node:path";
|
|
4412
4654
|
|
|
4413
4655
|
// src/vite/build.ts
|
|
4414
|
-
import { mkdir as mkdir5, readFile as
|
|
4656
|
+
import { mkdir as mkdir5, readFile as readFile3, rename, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
|
|
4415
4657
|
import path28 from "node:path";
|
|
4416
4658
|
import { build as esbuild } from "esbuild";
|
|
4417
4659
|
import { build as viteBuild, mergeConfig as mergeConfig3 } from "vite";
|
|
@@ -4559,7 +4801,7 @@ import {
|
|
|
4559
4801
|
// package.json
|
|
4560
4802
|
var package_default = {
|
|
4561
4803
|
name: "@lukoweb/apitogo",
|
|
4562
|
-
version: "0.1.
|
|
4804
|
+
version: "0.1.54",
|
|
4563
4805
|
type: "module",
|
|
4564
4806
|
sideEffects: [
|
|
4565
4807
|
"**/*.css",
|
|
@@ -4966,12 +5208,14 @@ init_joinUrl();
|
|
|
4966
5208
|
|
|
4967
5209
|
// src/vite/dev-portal-env.ts
|
|
4968
5210
|
import { loadEnv as loadEnv2 } from "vite";
|
|
5211
|
+
var AUTHENTICATION_API_BASE_URL_ENV = "VITE_APITOGO_AUTHENTICATION_API_BASE_URL";
|
|
5212
|
+
var LEGACY_DEV_PORTAL_API_URL_ENV = "VITE_APITOGO_DEV_PORTAL_API_URL";
|
|
4969
5213
|
async function loadDevPortalViteDefines(rootDir, mode) {
|
|
4970
5214
|
const env = loadEnv2(mode, rootDir, "VITE_");
|
|
4971
5215
|
const defines = {};
|
|
4972
|
-
const apiUrl = env
|
|
5216
|
+
const apiUrl = env[AUTHENTICATION_API_BASE_URL_ENV]?.trim() || env[LEGACY_DEV_PORTAL_API_URL_ENV]?.trim();
|
|
4973
5217
|
if (apiUrl) {
|
|
4974
|
-
defines
|
|
5218
|
+
defines[AUTHENTICATION_API_BASE_URL_ENV] = JSON.stringify(apiUrl);
|
|
4975
5219
|
}
|
|
4976
5220
|
return defines;
|
|
4977
5221
|
}
|
|
@@ -6613,7 +6857,7 @@ import { mdxFromMarkdown } from "mdast-util-mdx";
|
|
|
6613
6857
|
import { mdxjs } from "micromark-extension-mdxjs";
|
|
6614
6858
|
|
|
6615
6859
|
// src/lib/util/readFrontmatter.ts
|
|
6616
|
-
import { readFile
|
|
6860
|
+
import { readFile } from "node:fs/promises";
|
|
6617
6861
|
import matter from "gray-matter";
|
|
6618
6862
|
import { parse, stringify as stringify2 } from "yaml";
|
|
6619
6863
|
var yaml = {
|
|
@@ -6621,7 +6865,7 @@ var yaml = {
|
|
|
6621
6865
|
stringify: (obj) => stringify2(obj)
|
|
6622
6866
|
};
|
|
6623
6867
|
var readFrontmatter = async (filePath) => {
|
|
6624
|
-
const content = await
|
|
6868
|
+
const content = await readFile(filePath, "utf-8");
|
|
6625
6869
|
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
6626
6870
|
return matter(normalizedContent, { engines: { yaml } });
|
|
6627
6871
|
};
|
|
@@ -7237,17 +7481,33 @@ var viteConfigPlugin = () => {
|
|
|
7237
7481
|
configResolved(resolvedConfig) {
|
|
7238
7482
|
viteConfig = resolvedConfig;
|
|
7239
7483
|
},
|
|
7240
|
-
load(id) {
|
|
7484
|
+
async load(id) {
|
|
7241
7485
|
if (id !== resolvedVirtualModuleId3) return;
|
|
7242
7486
|
const configPath = getCurrentConfig().__meta.configPath;
|
|
7243
7487
|
if (!configPath) {
|
|
7244
7488
|
return `export default {};`;
|
|
7245
7489
|
}
|
|
7490
|
+
const { config: loadedConfig } = await loadZudokuConfig(
|
|
7491
|
+
{
|
|
7492
|
+
mode: viteConfig.mode,
|
|
7493
|
+
command: viteConfig.command
|
|
7494
|
+
},
|
|
7495
|
+
viteConfig.root
|
|
7496
|
+
);
|
|
7497
|
+
const clientMeta = {
|
|
7498
|
+
rootDir: loadedConfig.__meta.rootDir,
|
|
7499
|
+
pricingEnabled: loadedConfig.__meta.pricingEnabled,
|
|
7500
|
+
authenticationEnabled: loadedConfig.__meta.authenticationEnabled,
|
|
7501
|
+
previewPlans: loadedConfig.__meta.previewPlans
|
|
7502
|
+
};
|
|
7246
7503
|
return `
|
|
7247
7504
|
import rawConfig from "${normalizePath(configPath)}";
|
|
7248
7505
|
import { runPluginTransformConfig } from "@lukoweb/apitogo/plugins";
|
|
7249
7506
|
|
|
7250
|
-
const config = await runPluginTransformConfig(
|
|
7507
|
+
const config = await runPluginTransformConfig({
|
|
7508
|
+
...rawConfig,
|
|
7509
|
+
__meta: ${JSON.stringify(clientMeta)},
|
|
7510
|
+
});
|
|
7251
7511
|
export default config;
|
|
7252
7512
|
`;
|
|
7253
7513
|
},
|
|
@@ -7522,6 +7782,7 @@ var viteDocsPlugin = () => {
|
|
|
7522
7782
|
var plugin_docs_default = viteDocsPlugin;
|
|
7523
7783
|
|
|
7524
7784
|
// src/vite/plugin-local-manifest.ts
|
|
7785
|
+
init_apitogo_config_loader();
|
|
7525
7786
|
init_local_manifest();
|
|
7526
7787
|
import path17 from "node:path";
|
|
7527
7788
|
var APITOGO_LOCAL_MANIFEST_VIRTUAL_ID = "virtual:apitogo-local-manifest";
|
|
@@ -7536,6 +7797,15 @@ var viteLocalManifestPlugin = () => {
|
|
|
7536
7797
|
try {
|
|
7537
7798
|
const manifest = await readEffectiveManifest(rootDir, env);
|
|
7538
7799
|
catalog = manifestToPreviewCatalog(manifest);
|
|
7800
|
+
if (!catalog.plans.length) {
|
|
7801
|
+
const config2 = loadApitogoConfig(rootDir);
|
|
7802
|
+
catalog = {
|
|
7803
|
+
...catalog,
|
|
7804
|
+
...plansToPreviewCatalog(
|
|
7805
|
+
readPlanCatalogItems(config2)
|
|
7806
|
+
)
|
|
7807
|
+
};
|
|
7808
|
+
}
|
|
7539
7809
|
} catch {
|
|
7540
7810
|
}
|
|
7541
7811
|
return `export default ${JSON.stringify(catalog)};`;
|
|
@@ -8766,7 +9036,7 @@ async function writeOutput(dir, {
|
|
|
8766
9036
|
// src/vite/prerender/prerender.ts
|
|
8767
9037
|
init_logger();
|
|
8768
9038
|
init_file_exists();
|
|
8769
|
-
import { readFile as
|
|
9039
|
+
import { readFile as readFile2, rm } from "node:fs/promises";
|
|
8770
9040
|
import os from "node:os";
|
|
8771
9041
|
import path27 from "node:path";
|
|
8772
9042
|
import { pathToFileURL } from "node:url";
|
|
@@ -9042,7 +9312,7 @@ var prerender = async ({
|
|
|
9042
9312
|
);
|
|
9043
9313
|
let markdownFileInfos = [];
|
|
9044
9314
|
if (await fileExists(markdownInfoPath)) {
|
|
9045
|
-
const markdownInfoContent = await
|
|
9315
|
+
const markdownInfoContent = await readFile2(markdownInfoPath, "utf-8");
|
|
9046
9316
|
markdownFileInfos = JSON.parse(markdownInfoContent);
|
|
9047
9317
|
}
|
|
9048
9318
|
if (llmsConfig.llmsTxt || llmsConfig.llmsTxtFull) {
|
|
@@ -9193,7 +9463,7 @@ var bundleSSREntry = async (options) => {
|
|
|
9193
9463
|
const { dir, adapter, serverOutDir, serverConfigFilename, html, basePath } = options;
|
|
9194
9464
|
const tempEntryPath = path28.join(dir, "__ssr-entry.ts");
|
|
9195
9465
|
const packageRoot = getZudokuRootDir();
|
|
9196
|
-
const templateContent = await
|
|
9466
|
+
const templateContent = await readFile3(
|
|
9197
9467
|
path28.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
9198
9468
|
"utf-8"
|
|
9199
9469
|
);
|
|
@@ -9470,7 +9740,7 @@ var build_default = {
|
|
|
9470
9740
|
|
|
9471
9741
|
// src/cli/configure-github-workflow/handler.ts
|
|
9472
9742
|
import { constants } from "node:fs";
|
|
9473
|
-
import { access
|
|
9743
|
+
import { access, mkdir as mkdir6, writeFile as writeFile6 } from "node:fs/promises";
|
|
9474
9744
|
import path31 from "node:path";
|
|
9475
9745
|
var APITOGO_DEPLOY_WORKFLOW_YAML = `name: Build and Deploy
|
|
9476
9746
|
|
|
@@ -9587,7 +9857,7 @@ async function configureGithubWorkflow(argv) {
|
|
|
9587
9857
|
const workflowPath = path31.join(workflowDir, "apitogo-deploy.yml");
|
|
9588
9858
|
try {
|
|
9589
9859
|
try {
|
|
9590
|
-
await
|
|
9860
|
+
await access(workflowPath, constants.F_OK);
|
|
9591
9861
|
if (!argv.force) {
|
|
9592
9862
|
await printCriticalFailureToConsoleAndExit(
|
|
9593
9863
|
`Workflow file already exists: ${workflowPath}. Pass --force to overwrite.`
|
|
@@ -9656,14 +9926,14 @@ function applyJsonOnlyDeployQuietMode() {
|
|
|
9656
9926
|
}
|
|
9657
9927
|
|
|
9658
9928
|
// src/cli/deploy/handler.ts
|
|
9659
|
-
import { access as
|
|
9929
|
+
import { access as access2, readFile as readFile4 } from "node:fs/promises";
|
|
9660
9930
|
import path32 from "node:path";
|
|
9661
9931
|
import { create as createTar } from "tar";
|
|
9662
9932
|
var DEPLOY_ENDPOINT = "https://deploy-server-dotnet2-b3fkcaaraydbckfe.canadacentral-01.azurewebsites.net/deploy";
|
|
9663
9933
|
var ARCHIVE_NAME = "dist.tgz";
|
|
9664
9934
|
var createDeploymentArchive = async (dir) => {
|
|
9665
9935
|
const distDir = path32.join(dir, "dist");
|
|
9666
|
-
await
|
|
9936
|
+
await access2(distDir);
|
|
9667
9937
|
const archivePath = path32.join(dir, ARCHIVE_NAME);
|
|
9668
9938
|
await createTar(
|
|
9669
9939
|
{
|
|
@@ -9694,7 +9964,7 @@ async function deploy(argv) {
|
|
|
9694
9964
|
`Uploading ${path32.basename(archivePath)} to ${env}...`
|
|
9695
9965
|
);
|
|
9696
9966
|
}
|
|
9697
|
-
const archiveBuffer = await
|
|
9967
|
+
const archiveBuffer = await readFile4(archivePath);
|
|
9698
9968
|
const formData = new FormData();
|
|
9699
9969
|
formData.append(
|
|
9700
9970
|
"file",
|
|
@@ -10181,14 +10451,14 @@ var dev_default = {
|
|
|
10181
10451
|
|
|
10182
10452
|
// src/cli/make-config/handler.ts
|
|
10183
10453
|
import { constants as constants3 } from "node:fs";
|
|
10184
|
-
import { access as
|
|
10454
|
+
import { access as access4, mkdir as mkdir7, readFile as readFile6, writeFile as writeFile8 } from "node:fs/promises";
|
|
10185
10455
|
import path37 from "node:path";
|
|
10186
10456
|
import { glob as glob5 } from "glob";
|
|
10187
10457
|
|
|
10188
10458
|
// src/cli/make-config/scaffold-project.ts
|
|
10189
10459
|
init_package_json();
|
|
10190
10460
|
import { constants as constants2 } from "node:fs";
|
|
10191
|
-
import { access as
|
|
10461
|
+
import { access as access3, readFile as readFile5, writeFile as writeFile7 } from "node:fs/promises";
|
|
10192
10462
|
import path36 from "node:path";
|
|
10193
10463
|
import { glob as glob4 } from "glob";
|
|
10194
10464
|
var OPENAPI_GLOBS = [
|
|
@@ -10263,7 +10533,7 @@ async function findOpenApiSpecPath(dir) {
|
|
|
10263
10533
|
for (const rel of OPENAPI_GLOBS) {
|
|
10264
10534
|
const full = path36.join(dir, rel);
|
|
10265
10535
|
try {
|
|
10266
|
-
await
|
|
10536
|
+
await access3(full, constants2.R_OK);
|
|
10267
10537
|
return toPosix(rel);
|
|
10268
10538
|
} catch {
|
|
10269
10539
|
}
|
|
@@ -10289,7 +10559,7 @@ async function ensurePackageJson(dir) {
|
|
|
10289
10559
|
preview: "apitogo preview"
|
|
10290
10560
|
};
|
|
10291
10561
|
try {
|
|
10292
|
-
await
|
|
10562
|
+
await access3(pkgPath, constants2.R_OK);
|
|
10293
10563
|
} catch (err) {
|
|
10294
10564
|
const code = err.code;
|
|
10295
10565
|
if (code !== "ENOENT") throw err;
|
|
@@ -10311,7 +10581,7 @@ async function ensurePackageJson(dir) {
|
|
|
10311
10581
|
`, "utf8");
|
|
10312
10582
|
return true;
|
|
10313
10583
|
}
|
|
10314
|
-
const raw = await
|
|
10584
|
+
const raw = await readFile5(pkgPath, "utf8");
|
|
10315
10585
|
let pkg;
|
|
10316
10586
|
try {
|
|
10317
10587
|
pkg = JSON.parse(raw);
|
|
@@ -10341,7 +10611,7 @@ async function ensurePackageJson(dir) {
|
|
|
10341
10611
|
async function ensureTsconfigJson(dir) {
|
|
10342
10612
|
const tsPath = path36.join(dir, "tsconfig.json");
|
|
10343
10613
|
try {
|
|
10344
|
-
await
|
|
10614
|
+
await access3(tsPath, constants2.R_OK);
|
|
10345
10615
|
return false;
|
|
10346
10616
|
} catch {
|
|
10347
10617
|
const tsconfig = {
|
|
@@ -10673,7 +10943,7 @@ var ensureApitogoDeployWorkflow = async (dir) => {
|
|
|
10673
10943
|
"apitogo-deploy.yml"
|
|
10674
10944
|
);
|
|
10675
10945
|
try {
|
|
10676
|
-
await
|
|
10946
|
+
await access4(workflowPath, constants3.F_OK);
|
|
10677
10947
|
return false;
|
|
10678
10948
|
} catch {
|
|
10679
10949
|
}
|
|
@@ -10685,7 +10955,7 @@ var findExistingConfigPath = async (dir) => {
|
|
|
10685
10955
|
for (const filename of CONFIG_FILENAMES) {
|
|
10686
10956
|
const fullPath = path37.join(dir, filename);
|
|
10687
10957
|
try {
|
|
10688
|
-
await
|
|
10958
|
+
await readFile6(fullPath, "utf8");
|
|
10689
10959
|
return fullPath;
|
|
10690
10960
|
} catch {
|
|
10691
10961
|
}
|
|
@@ -10732,7 +11002,7 @@ async function makeConfig(argv) {
|
|
|
10732
11002
|
if (routePaths.length === 0) {
|
|
10733
11003
|
throw new Error(`No .md or .mdx files found under '${pagesDir}'.`);
|
|
10734
11004
|
}
|
|
10735
|
-
let originalConfig = await
|
|
11005
|
+
let originalConfig = await readFile6(configPath, "utf8");
|
|
10736
11006
|
if (!createdNew && openApiSpecPath) {
|
|
10737
11007
|
originalConfig = insertApisIfMissing(
|
|
10738
11008
|
originalConfig,
|
|
@@ -10896,7 +11166,7 @@ var remove_default = {
|
|
|
10896
11166
|
|
|
10897
11167
|
// src/cli/common/outdated.ts
|
|
10898
11168
|
import { existsSync as existsSync3, mkdirSync } from "node:fs";
|
|
10899
|
-
import { readFile as
|
|
11169
|
+
import { readFile as readFile7, writeFile as writeFile9 } from "node:fs/promises";
|
|
10900
11170
|
import { join } from "node:path";
|
|
10901
11171
|
import colors10 from "picocolors";
|
|
10902
11172
|
import { gt } from "semver";
|
|
@@ -11026,7 +11296,7 @@ async function getVersionCheckInfo() {
|
|
|
11026
11296
|
let versionCheckInfo;
|
|
11027
11297
|
if (existsSync3(versionCheckPath)) {
|
|
11028
11298
|
try {
|
|
11029
|
-
versionCheckInfo = await
|
|
11299
|
+
versionCheckInfo = await readFile7(versionCheckPath, "utf-8").then(
|
|
11030
11300
|
JSON.parse
|
|
11031
11301
|
);
|
|
11032
11302
|
} catch {
|