@lunora/codegen 1.0.0-alpha.26 → 1.0.0-alpha.28

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.mjs CHANGED
@@ -19,11 +19,11 @@ export { default as discoverSchema } from './packem_shared/discoverSchema-KYq55q
19
19
  export { SHAPES_FILENAME, discoverShapes } from './packem_shared/SHAPES_FILENAME-ChV7MqgE.mjs';
20
20
  export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-Da8BKXcI.mjs';
21
21
  export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-CCisG0Vy.mjs';
22
- export { GENERATED_HEADER, emitApi, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-CYaSI_qY.mjs';
23
- export { emitApp } from './packem_shared/emitApp-C38fHt_1.mjs';
24
- export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-BlpXQe2K.mjs';
25
- export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-CRe5l79E.mjs';
26
- export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-cgOjZTVY.mjs';
22
+ export { GENERATED_HEADER, emitApi, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-Bq7mlUUg.mjs';
23
+ export { emitApp } from './packem_shared/emitApp-YuSwauCv.mjs';
24
+ export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-DLAW4ldJ.mjs';
25
+ export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-CPz5aJ8A.mjs';
26
+ export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-BSBSVXEv.mjs';
27
27
  export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs';
28
28
  export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
29
29
  export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
@@ -2056,6 +2056,7 @@ const emitShard = ({
2056
2056
  const studioFeaturesData = studioFeatures ?? {
2057
2057
  analytics: false,
2058
2058
  auth: false,
2059
+ containers: false,
2059
2060
  flags: false,
2060
2061
  kv: false,
2061
2062
  mail: false,
@@ -1,4 +1,4 @@
1
- import { GENERATED_HEADER } from './GENERATED_HEADER-CYaSI_qY.mjs';
1
+ import { GENERATED_HEADER } from './GENERATED_HEADER-Bq7mlUUg.mjs';
2
2
  import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
3
3
  import { argsObjectSchema, LUNORA_ERROR_CODES } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
4
4
 
@@ -24,10 +24,10 @@ import { discoverShapes } from './SHAPES_FILENAME-ChV7MqgE.mjs';
24
24
  import discoverStorageRulesMetadata from './discoverStorageRulesMetadata-Da8BKXcI.mjs';
25
25
  import { e as enclosingExportName$1 } from './discover-ast-CT6BgBr4.mjs';
26
26
  import { discoverWorkflows } from './WORKFLOWS_FILENAME-CCisG0Vy.mjs';
27
- import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitCollections, emitContainers, emitWorkflows, emitQueues, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-CYaSI_qY.mjs';
28
- import { emitApp } from './emitApp-C38fHt_1.mjs';
29
- import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-BlpXQe2K.mjs';
30
- import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-CRe5l79E.mjs';
27
+ import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitCollections, emitContainers, emitWorkflows, emitQueues, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-Bq7mlUUg.mjs';
28
+ import { emitApp } from './emitApp-YuSwauCv.mjs';
29
+ import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-DLAW4ldJ.mjs';
30
+ import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-CPz5aJ8A.mjs';
31
31
  import { buildSchemaSnapshot, serializeSchemaSnapshot } from './SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs';
32
32
 
33
33
  const HTTP_VERBS = /* @__PURE__ */ new Set(["delete", "get", "head", "options", "patch", "post", "put"]);
@@ -252,6 +252,10 @@ const PROBES = {
252
252
  ai: { contextProperty: "ai", moduleSpecifier: "@lunora/ai" },
253
253
  analytics: { contextProperty: "analytics", moduleSpecifier: "@lunora/bindings/analytics" },
254
254
  browser: { contextProperty: "browser", moduleSpecifier: "@lunora/browser" },
255
+ // `lunora/containers.ts` imports `defineContainer` from `@lunora/container`,
256
+ // and handlers reach live instances via `ctx.containers` — either signals the
257
+ // app wires containers, so the studio should show the Containers page.
258
+ container: { contextProperty: "containers", moduleSpecifier: "@lunora/container" },
255
259
  flags: { contextProperty: "flags", moduleSpecifier: "@lunora/flags" },
256
260
  hyperdrive: { contextProperty: "sql", moduleSpecifier: "@lunora/hyperdrive" },
257
261
  images: { contextProperty: "images", moduleSpecifier: "@lunora/bindings/images" },
@@ -268,20 +272,28 @@ const PROBES = {
268
272
  vectors: { contextProperty: "vectors", moduleSpecifier: "@lunora/bindings/vectors" },
269
273
  workflows: { contextProperty: "workflows", moduleSpecifier: "@lunora/workflow" }
270
274
  };
271
- const readsContextProperty = (sourceFile, property) => {
275
+ const contextPropertiesRead = (sourceFile) => {
272
276
  const reachesContext = (receiver) => Node.isIdentifier(receiver) && receiver.getText() === "ctx";
273
- const directAccess = sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression).some((access) => access.getName() === property && reachesContext(access.getExpression()));
274
- if (directAccess) {
275
- return true;
277
+ const names = /* @__PURE__ */ new Set();
278
+ for (const access of sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {
279
+ if (reachesContext(access.getExpression())) {
280
+ names.add(access.getName());
281
+ }
276
282
  }
277
- return sourceFile.getDescendantsOfKind(SyntaxKind.VariableDeclaration).some((declaration) => {
283
+ for (const declaration of sourceFile.getDescendantsOfKind(SyntaxKind.VariableDeclaration)) {
278
284
  const initializer = declaration.getInitializer();
279
285
  const nameNode = declaration.getNameNode();
280
286
  if (initializer === void 0 || !reachesContext(initializer) || !Node.isObjectBindingPattern(nameNode)) {
281
- return false;
287
+ continue;
282
288
  }
283
- return nameNode.getElements().some((element) => element.getPropertyNameNode()?.getText() === property || element.getName() === property);
284
- });
289
+ for (const element of nameNode.getElements()) {
290
+ const name = element.getPropertyNameNode()?.getText() ?? element.getName();
291
+ if (name) {
292
+ names.add(name);
293
+ }
294
+ }
295
+ }
296
+ return names;
285
297
  };
286
298
  const discoverFeatureUsage = (project, lunoraDirectory) => {
287
299
  const usage = {
@@ -289,6 +301,7 @@ const discoverFeatureUsage = (project, lunoraDirectory) => {
289
301
  ai: false,
290
302
  analytics: false,
291
303
  browser: false,
304
+ container: false,
292
305
  flags: false,
293
306
  hyperdrive: false,
294
307
  images: false,
@@ -306,6 +319,7 @@ const discoverFeatureUsage = (project, lunoraDirectory) => {
306
319
  for (const filePath of listLunoraSourceFiles(lunoraDirectory)) {
307
320
  const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPath(filePath);
308
321
  const importSpecifiers = new Set(sourceFile.getImportDeclarations().map((declaration) => declaration.getModuleSpecifierValue()));
322
+ const contextProperties = contextPropertiesRead(sourceFile);
309
323
  for (const key of keys) {
310
324
  if (usage[key]) {
311
325
  continue;
@@ -315,7 +329,7 @@ const discoverFeatureUsage = (project, lunoraDirectory) => {
315
329
  usage[key] = true;
316
330
  continue;
317
331
  }
318
- if (probe.contextProperty !== void 0 && readsContextProperty(sourceFile, probe.contextProperty)) {
332
+ if (probe.contextProperty !== void 0 && contextProperties.has(probe.contextProperty)) {
319
333
  usage[key] = true;
320
334
  }
321
335
  }
@@ -329,6 +343,7 @@ const buildStudioFeatures = (usage, signals) => {
329
343
  return {
330
344
  analytics: usage.analytics || signals.dependencies.has("@lunora/bindings/analytics"),
331
345
  auth: signals.dependencies.has("@lunora/auth"),
346
+ containers: usage.container || signals.containerCount > 0 || signals.dependencies.has("@lunora/container"),
332
347
  flags: usage.flags || signals.dependencies.has("@lunora/flags"),
333
348
  kv: usage.kv || signals.dependencies.has("@lunora/bindings/kv"),
334
349
  mail: usage.mail || signals.dependencies.has("@lunora/mail"),
@@ -938,6 +953,7 @@ const runCodegen = (options) => {
938
953
  const hasR2sql = featureUsage.r2sql;
939
954
  const dependencies = discoverPackageDependencies(options.projectRoot);
940
955
  const studioFeatures = buildStudioFeatures(featureUsage, {
956
+ containerCount: containers.length,
941
957
  cronCount: crons.length,
942
958
  dependencies,
943
959
  queueCount: queues.length,
@@ -1,4 +1,4 @@
1
- import { GENERATED_HEADER } from './GENERATED_HEADER-CYaSI_qY.mjs';
1
+ import { GENERATED_HEADER } from './GENERATED_HEADER-Bq7mlUUg.mjs';
2
2
  import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
3
3
  import { LUNORA_ERROR_CODES, objectSchema, argsObjectSchema, validatorIrToJsonSchema } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { GENERATED_HEADER } from './GENERATED_HEADER-CYaSI_qY.mjs';
1
+ import { GENERATED_HEADER } from './GENERATED_HEADER-Bq7mlUUg.mjs';
2
2
 
3
3
  const LONG_TAIL = [
4
4
  ["hasAi", "ai", "ai", "Override the Workers AI binding backing `ctx.ai` (defaults to `env.AI`)."],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/codegen",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.28",
4
4
  "description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,7 +46,7 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/advisor": "1.0.0-alpha.14",
49
+ "@lunora/advisor": "1.0.0-alpha.15",
50
50
  "@lunora/container": "1.0.0-alpha.5",
51
51
  "@lunora/queue": "1.0.0-alpha.2",
52
52
  "@lunora/scheduler": "1.0.0-alpha.4",