@geekmidas/cli 10.0.0-alpha.23 → 10.0.0-alpha.24
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/index.cjs +121 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +121 -63
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-B5PSuLym.mjs → openapi-Co2Tv7zh.mjs} +13 -3
- package/dist/openapi-Co2Tv7zh.mjs.map +1 -0
- package/dist/{openapi-CN69hrf0.cjs → openapi-DeMqoLuJ.cjs} +13 -3
- package/dist/openapi-DeMqoLuJ.cjs.map +1 -0
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.mjs +1 -1
- package/package.json +12 -12
- package/dist/openapi-B5PSuLym.mjs.map +0 -1
- package/dist/openapi-CN69hrf0.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const require_workspace = require("./workspace-CRD9YinV.cjs");
|
|
|
7
7
|
const require_credentials = require("./credentials-COrSpZfF.cjs");
|
|
8
8
|
const require_generator = require("./generator-Wdfp0jCS.cjs");
|
|
9
9
|
const require_storage = require("./storage-DgypfSD6.cjs");
|
|
10
|
-
const require_openapi = require("./openapi-
|
|
10
|
+
const require_openapi = require("./openapi-DeMqoLuJ.cjs");
|
|
11
11
|
const require_emit = require("./emit-BdoPFjZf.cjs");
|
|
12
12
|
const require_reconcile = require("./reconcile-hx_vBvux.cjs");
|
|
13
13
|
const require_transfer = require("./transfer-BZbyaV3I.cjs");
|
|
@@ -44,7 +44,7 @@ prompts = require_rolldown_runtime.__toESM(prompts, 1);
|
|
|
44
44
|
let _geekmidas_envkit = require("@geekmidas/envkit");
|
|
45
45
|
let _geekmidas_services = require("@geekmidas/services");
|
|
46
46
|
//#region package.json
|
|
47
|
-
var version = "10.0.0-alpha.
|
|
47
|
+
var version = "10.0.0-alpha.24";
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/auth/credentials.ts
|
|
50
50
|
/**
|
|
@@ -329,6 +329,76 @@ function maskToken(token) {
|
|
|
329
329
|
return `${token.slice(0, 4)}...${token.slice(-4)}`;
|
|
330
330
|
}
|
|
331
331
|
//#endregion
|
|
332
|
+
//#region src/build/owners.ts
|
|
333
|
+
/**
|
|
334
|
+
* What a generated entry imports its runtime from, read off the discovered
|
|
335
|
+
* constructs: the surface it serves, every construct a runnable can be built
|
|
336
|
+
* from, and the database Studio browses.
|
|
337
|
+
*
|
|
338
|
+
* `gkm build` and `gkm dev` both write entries that import the surface for its
|
|
339
|
+
* logger and environment parser, so both ask here. A dev server that skipped it
|
|
340
|
+
* had nothing to import them from.
|
|
341
|
+
*/
|
|
342
|
+
function ownersContext(options) {
|
|
343
|
+
const { declared, sources, workspaceRoot, appRoot, studio } = options;
|
|
344
|
+
const surfaces = restApis(declared);
|
|
345
|
+
const primary = servedSurface(declared, workspaceRoot, appRoot) ?? surfaces.find((d) => d.endpoints.length === 0) ?? surfaces[0];
|
|
346
|
+
const browsable = Object.entries(declared).find(([, d]) => d.kind === "database");
|
|
347
|
+
const browsableSource = browsable ? sources[browsable[0]] : void 0;
|
|
348
|
+
const owners = {};
|
|
349
|
+
for (const [id, declaration] of Object.entries(declared)) {
|
|
350
|
+
if (declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
|
|
351
|
+
const source = sources[id];
|
|
352
|
+
if (!source) continue;
|
|
353
|
+
owners[id] = {
|
|
354
|
+
specifier: source.file,
|
|
355
|
+
exportName: source.exportName
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const primarySource = primary ? sources[primary.id] : void 0;
|
|
359
|
+
return {
|
|
360
|
+
owners,
|
|
361
|
+
...primary ? { surface: {
|
|
362
|
+
id: primary.id,
|
|
363
|
+
trustedOriginsKey: (0, _geekmidas_manifest.provideKey)(primary.id, "trustedOrigins"),
|
|
364
|
+
...primary.cors ? { cors: primary.cors } : {},
|
|
365
|
+
...primarySource ? { module: {
|
|
366
|
+
specifier: primarySource.file,
|
|
367
|
+
exportName: primarySource.exportName
|
|
368
|
+
} } : {}
|
|
369
|
+
} } : {},
|
|
370
|
+
studio: studio && browsableSource ? {
|
|
371
|
+
...studio,
|
|
372
|
+
database: {
|
|
373
|
+
specifier: browsableSource.file,
|
|
374
|
+
exportName: browsableSource.exportName
|
|
375
|
+
}
|
|
376
|
+
} : studio
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The endpoints one surface serves.
|
|
381
|
+
*
|
|
382
|
+
* One glob finds every surface's endpoints, wherever their files live. A build
|
|
383
|
+
* keeps the ones built from the surface it serves; one built from no surface at
|
|
384
|
+
* all has nowhere else to go.
|
|
385
|
+
*/
|
|
386
|
+
function servedBy(endpoints, surface) {
|
|
387
|
+
if (!surface) return endpoints;
|
|
388
|
+
return endpoints.filter(({ construct }) => !construct.surface || construct.surface.id === surface.id);
|
|
389
|
+
}
|
|
390
|
+
function restApis(declared) {
|
|
391
|
+
return Object.values(declared).filter((d) => d.kind === "rest-api");
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The surface whose declared `path` is the directory being built — asked of
|
|
395
|
+
* every surface, because a workspace has several and each app's build serves
|
|
396
|
+
* exactly one.
|
|
397
|
+
*/
|
|
398
|
+
function servedSurface(declared, workspaceRoot, appRoot) {
|
|
399
|
+
return restApis(declared).find((d) => (0, node_path.resolve)(workspaceRoot, d.path) === (0, node_path.resolve)(appRoot));
|
|
400
|
+
}
|
|
401
|
+
//#endregion
|
|
332
402
|
//#region src/build/providerResolver.ts
|
|
333
403
|
/**
|
|
334
404
|
* Resolves provider configuration from the new simplified system
|
|
@@ -1365,12 +1435,13 @@ async function devCommand(options) {
|
|
|
1365
1435
|
if (hooks) logger$11.log(`🪝 Server hooks enabled from ${config.hooks?.server}`);
|
|
1366
1436
|
const enableOpenApi = require_openapi.resolveOpenApiConfig(config).enabled || resolved.enableOpenApi;
|
|
1367
1437
|
if (enableOpenApi) logger$11.log(`📄 OpenAPI output: ${require_openapi.OPENAPI_OUTPUT_PATH}`);
|
|
1438
|
+
const workspaceRoot = workspace?.root ?? secretsRoot;
|
|
1368
1439
|
const buildContext = {
|
|
1369
1440
|
telescope,
|
|
1370
1441
|
studio,
|
|
1371
1442
|
hooks
|
|
1372
1443
|
};
|
|
1373
|
-
await buildServer(config, buildContext, resolved.providers[0], enableOpenApi, appRoot);
|
|
1444
|
+
await buildServer(config, buildContext, resolved.providers[0], enableOpenApi, appRoot, workspaceRoot);
|
|
1374
1445
|
if (enableOpenApi) await require_openapi.generateOpenApiFrom(config.constructs, { openapi: config.openapi });
|
|
1375
1446
|
const runtime = config.runtime ?? "node";
|
|
1376
1447
|
let secretsJsonPath;
|
|
@@ -1435,7 +1506,7 @@ async function devCommand(options) {
|
|
|
1435
1506
|
rebuildTimeout = setTimeout(async () => {
|
|
1436
1507
|
try {
|
|
1437
1508
|
logger$11.log("🔄 Rebuilding...");
|
|
1438
|
-
await buildServer(config, buildContext, resolved.providers[0], enableOpenApi, appRoot, true);
|
|
1509
|
+
await buildServer(config, buildContext, resolved.providers[0], enableOpenApi, appRoot, workspaceRoot, true);
|
|
1439
1510
|
if (enableOpenApi) await require_openapi.generateOpenApiFrom(config.constructs, {
|
|
1440
1511
|
openapi: config.openapi,
|
|
1441
1512
|
silent: true,
|
|
@@ -1821,24 +1892,34 @@ async function workspaceDevCommand(workspace, options) {
|
|
|
1821
1892
|
* guarded rather than unconditional: a project with no `constructs` glob has
|
|
1822
1893
|
* not adopted the model, and there is nothing to import.
|
|
1823
1894
|
*/
|
|
1824
|
-
async function declaredConstructs(config, appRoot) {
|
|
1895
|
+
async function declaredConstructs(config, appRoot, sources) {
|
|
1825
1896
|
const patterns = typeof config?.constructs === "string" || Array.isArray(config?.constructs) ? config.constructs : void 0;
|
|
1826
1897
|
if (!patterns) return {};
|
|
1827
1898
|
try {
|
|
1828
1899
|
return await require_discover.discover({
|
|
1829
1900
|
patterns: (Array.isArray(patterns) ? patterns : [patterns]).map((p) => (0, node_path.isAbsolute)(p) ? p : (0, node_path.join)(appRoot, p)),
|
|
1830
|
-
cwd: appRoot
|
|
1901
|
+
cwd: appRoot,
|
|
1902
|
+
sources
|
|
1831
1903
|
});
|
|
1832
1904
|
} catch {
|
|
1833
1905
|
return {};
|
|
1834
1906
|
}
|
|
1835
1907
|
}
|
|
1836
|
-
async function buildServer(config, context, provider, enableOpenApi, appRoot
|
|
1908
|
+
async function buildServer(config, context, provider, enableOpenApi, appRoot, workspaceRoot, bustCache = false) {
|
|
1909
|
+
const sources = {};
|
|
1910
|
+
const declared = await declaredConstructs(config, appRoot, sources);
|
|
1837
1911
|
context = {
|
|
1838
1912
|
...context,
|
|
1913
|
+
...ownersContext({
|
|
1914
|
+
declared,
|
|
1915
|
+
sources,
|
|
1916
|
+
workspaceRoot,
|
|
1917
|
+
appRoot,
|
|
1918
|
+
studio: context.studio
|
|
1919
|
+
}),
|
|
1839
1920
|
storageDrivers: driversFor({
|
|
1840
1921
|
appRoot,
|
|
1841
|
-
cache: cacheBackendsIn(
|
|
1922
|
+
cache: cacheBackendsIn(declared, require_credentials.cacheBackendFor(require_credentials.providerOf(config ?? {})))
|
|
1842
1923
|
})
|
|
1843
1924
|
};
|
|
1844
1925
|
const endpointGenerator = new require_openapi.EndpointGenerator();
|
|
@@ -1847,7 +1928,7 @@ async function buildServer(config, context, provider, enableOpenApi, appRoot = p
|
|
|
1847
1928
|
const subscriberGenerator = new SubscriberGenerator();
|
|
1848
1929
|
const queueGenerator = new QueueGenerator();
|
|
1849
1930
|
const topicGenerator = new TopicGenerator();
|
|
1850
|
-
const [
|
|
1931
|
+
const [loadedEndpoints, allFunctions, allCrons, allSubscribers, allQueues, allTopics] = await Promise.all([
|
|
1851
1932
|
endpointGenerator.load(config.constructs, appRoot, bustCache),
|
|
1852
1933
|
config.functions ? functionGenerator.load(config.functions, appRoot, bustCache) : [],
|
|
1853
1934
|
config.crons ? cronGenerator.load(config.crons, appRoot, bustCache) : [],
|
|
@@ -1855,6 +1936,7 @@ async function buildServer(config, context, provider, enableOpenApi, appRoot = p
|
|
|
1855
1936
|
config.queues ? queueGenerator.load(config.queues, appRoot, bustCache) : [],
|
|
1856
1937
|
config.topics ? topicGenerator.load(config.topics, appRoot, bustCache) : []
|
|
1857
1938
|
]);
|
|
1939
|
+
const allEndpoints = servedBy(loadedEndpoints, context.surface);
|
|
1858
1940
|
const outputDir = (0, node_path.join)(appRoot, ".gkm", provider);
|
|
1859
1941
|
await (0, node_fs_promises.mkdir)(outputDir, { recursive: true });
|
|
1860
1942
|
await Promise.all([
|
|
@@ -2486,41 +2568,16 @@ async function buildCommand(options) {
|
|
|
2486
2568
|
cwd: process.cwd(),
|
|
2487
2569
|
sources: constructSources
|
|
2488
2570
|
}) : {};
|
|
2489
|
-
const
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
for (const [id, declaration] of Object.entries(declared)) {
|
|
2497
|
-
if (declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
|
|
2498
|
-
const source = constructSources[id];
|
|
2499
|
-
if (!source) continue;
|
|
2500
|
-
owners[id] = {
|
|
2501
|
-
specifier: source.file,
|
|
2502
|
-
exportName: source.exportName
|
|
2503
|
-
};
|
|
2504
|
-
}
|
|
2571
|
+
const derived = ownersContext({
|
|
2572
|
+
declared,
|
|
2573
|
+
sources: constructSources,
|
|
2574
|
+
workspaceRoot: loadedConfig.workspace.root,
|
|
2575
|
+
appRoot: process.cwd(),
|
|
2576
|
+
studio
|
|
2577
|
+
});
|
|
2505
2578
|
const buildContext = {
|
|
2506
|
-
|
|
2507
|
-
...primary ? { surface: {
|
|
2508
|
-
id: primary.id,
|
|
2509
|
-
trustedOriginsKey: (0, _geekmidas_manifest.provideKey)(primary.id, "trustedOrigins"),
|
|
2510
|
-
...primary.cors ? { cors: primary.cors } : {},
|
|
2511
|
-
...constructSources[primary.id] ? { module: {
|
|
2512
|
-
specifier: constructSources[primary.id].file,
|
|
2513
|
-
exportName: constructSources[primary.id].exportName
|
|
2514
|
-
} } : {}
|
|
2515
|
-
} } : {},
|
|
2579
|
+
...derived,
|
|
2516
2580
|
telescope,
|
|
2517
|
-
studio: studio && browsableSource ? {
|
|
2518
|
-
...studio,
|
|
2519
|
-
database: {
|
|
2520
|
-
specifier: browsableSource.file,
|
|
2521
|
-
exportName: browsableSource.exportName
|
|
2522
|
-
}
|
|
2523
|
-
} : studio,
|
|
2524
2581
|
hooks,
|
|
2525
2582
|
production,
|
|
2526
2583
|
constructGlobs,
|
|
@@ -2547,7 +2604,7 @@ async function buildCommand(options) {
|
|
|
2547
2604
|
queueGenerator.load(code),
|
|
2548
2605
|
topicGenerator.load(code)
|
|
2549
2606
|
]);
|
|
2550
|
-
const allEndpoints =
|
|
2607
|
+
const allEndpoints = servedBy(loadedEndpoints, derived.surface);
|
|
2551
2608
|
logger$9.log(`Found ${allEndpoints.length} endpoints`);
|
|
2552
2609
|
logger$9.log(`Found ${allFunctions.length} functions`);
|
|
2553
2610
|
logger$9.log(`Found ${allCrons.length} crons`);
|
|
@@ -2555,6 +2612,7 @@ async function buildCommand(options) {
|
|
|
2555
2612
|
logger$9.log(`Found ${allQueues.length} queues`);
|
|
2556
2613
|
logger$9.log(`Found ${allTopics.length} topics`);
|
|
2557
2614
|
if (allEndpoints.length === 0 && allFunctions.length === 0 && allCrons.length === 0 && allSubscribers.length === 0 && allQueues.length === 0 && allTopics.length === 0) {
|
|
2615
|
+
const served = servedSurface(declared, loadedConfig.workspace.root, process.cwd());
|
|
2558
2616
|
const selfServing = served && served.endpoints.length > 0 && constructSources[served.id] !== void 0 ? [served.id, served] : void 0;
|
|
2559
2617
|
if (selfServing) {
|
|
2560
2618
|
const [id] = selfServing;
|
|
@@ -8420,26 +8478,26 @@ function loadPackageJson() {
|
|
|
8420
8478
|
* Run: pnpm --filter @geekmidas/cli sync-versions
|
|
8421
8479
|
*/
|
|
8422
8480
|
const GEEKMIDAS_VERSIONS = {
|
|
8423
|
-
"@geekmidas/audit": "~10.0.0-alpha.
|
|
8424
|
-
"@geekmidas/auth": "~10.0.0-alpha.
|
|
8425
|
-
"@geekmidas/cache": "~10.0.0-alpha.
|
|
8426
|
-
"@geekmidas/client": "~10.0.0-alpha.
|
|
8427
|
-
"@geekmidas/cloud": "~10.0.0-alpha.
|
|
8428
|
-
"@geekmidas/constructs": "~10.0.0-alpha.
|
|
8429
|
-
"@geekmidas/db": "~10.0.0-alpha.
|
|
8430
|
-
"@geekmidas/emailkit": "~10.0.0-alpha.
|
|
8431
|
-
"@geekmidas/envkit": "~10.0.0-alpha.
|
|
8432
|
-
"@geekmidas/errors": "~10.0.0-alpha.
|
|
8433
|
-
"@geekmidas/events": "~10.0.0-alpha.
|
|
8434
|
-
"@geekmidas/logger": "~10.0.0-alpha.
|
|
8435
|
-
"@geekmidas/manifest": "~10.0.0-alpha.
|
|
8436
|
-
"@geekmidas/rate-limit": "~10.0.0-alpha.
|
|
8437
|
-
"@geekmidas/schema": "~10.0.0-alpha.
|
|
8438
|
-
"@geekmidas/services": "~10.0.0-alpha.
|
|
8439
|
-
"@geekmidas/storage": "~10.0.0-alpha.
|
|
8440
|
-
"@geekmidas/studio": "~10.0.0-alpha.
|
|
8441
|
-
"@geekmidas/telescope": "~10.0.0-alpha.
|
|
8442
|
-
"@geekmidas/testkit": "~10.0.0-alpha.
|
|
8481
|
+
"@geekmidas/audit": "~10.0.0-alpha.24",
|
|
8482
|
+
"@geekmidas/auth": "~10.0.0-alpha.24",
|
|
8483
|
+
"@geekmidas/cache": "~10.0.0-alpha.24",
|
|
8484
|
+
"@geekmidas/client": "~10.0.0-alpha.24",
|
|
8485
|
+
"@geekmidas/cloud": "~10.0.0-alpha.24",
|
|
8486
|
+
"@geekmidas/constructs": "~10.0.0-alpha.24",
|
|
8487
|
+
"@geekmidas/db": "~10.0.0-alpha.24",
|
|
8488
|
+
"@geekmidas/emailkit": "~10.0.0-alpha.24",
|
|
8489
|
+
"@geekmidas/envkit": "~10.0.0-alpha.24",
|
|
8490
|
+
"@geekmidas/errors": "~10.0.0-alpha.24",
|
|
8491
|
+
"@geekmidas/events": "~10.0.0-alpha.24",
|
|
8492
|
+
"@geekmidas/logger": "~10.0.0-alpha.24",
|
|
8493
|
+
"@geekmidas/manifest": "~10.0.0-alpha.24",
|
|
8494
|
+
"@geekmidas/rate-limit": "~10.0.0-alpha.24",
|
|
8495
|
+
"@geekmidas/schema": "~10.0.0-alpha.24",
|
|
8496
|
+
"@geekmidas/services": "~10.0.0-alpha.24",
|
|
8497
|
+
"@geekmidas/storage": "~10.0.0-alpha.24",
|
|
8498
|
+
"@geekmidas/studio": "~10.0.0-alpha.24",
|
|
8499
|
+
"@geekmidas/telescope": "~10.0.0-alpha.24",
|
|
8500
|
+
"@geekmidas/testkit": "~10.0.0-alpha.24",
|
|
8443
8501
|
"@geekmidas/cli": `~${loadPackageJson().version}`
|
|
8444
8502
|
};
|
|
8445
8503
|
//#endregion
|