@beignet/cli 0.0.23 → 0.0.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/make.js CHANGED
@@ -4668,7 +4668,7 @@ export type List${names.pluralPascal}Input = z.infer<
4668
4668
  }
4669
4669
  function listUseCaseFile(names, config, options) {
4670
4670
  const filePath = path.join(resourceUseCaseDir(names, config), `list-${names.pluralKebab}.ts`);
4671
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4671
+ return `import "@beignet/core/server-only";
4672
4672
  import { normalizeCursorPage } from "@beignet/core/pagination";
4673
4673
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
4674
4674
  import {
@@ -4699,7 +4699,7 @@ ${options.tenant ? `\t\t\ttenantId,\n` : ""} });
4699
4699
  }
4700
4700
  function createUseCaseFile(names, config, options) {
4701
4701
  const filePath = path.join(resourceUseCaseDir(names, config), `create-${names.singularKebab}.ts`);
4702
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4702
+ return `import "@beignet/core/server-only";
4703
4703
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
4704
4704
  import {
4705
4705
  Create${names.singularPascal}InputSchema,
@@ -4722,7 +4722,7 @@ ${options.events ? `\n\t\tawait ctx.ports.eventBus.publish(${names.singularPasca
4722
4722
  }
4723
4723
  function getUseCaseFile(names, config, options) {
4724
4724
  const filePath = path.join(resourceUseCaseDir(names, config), `get-${names.singularKebab}.ts`);
4725
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4725
+ return `import "@beignet/core/server-only";
4726
4726
  import { appError } from "${relativeModule(filePath, resourceSharedErrorsPath(config))}";
4727
4727
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
4728
4728
  import {
@@ -4748,7 +4748,7 @@ ${options.tenant ? `\t\tconst tenantId = ctx.tenant?.id;\n\t\tif (!tenantId) {\n
4748
4748
  }
4749
4749
  function updateUseCaseFile(names, config, options) {
4750
4750
  const filePath = path.join(resourceUseCaseDir(names, config), `update-${names.singularKebab}.ts`);
4751
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4751
+ return `import "@beignet/core/server-only";
4752
4752
  import { appError } from "${relativeModule(filePath, resourceSharedErrorsPath(config))}";
4753
4753
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
4754
4754
  ${options.events ? `import { ${names.singularPascal}Updated } from "../domain/events";\n` : ""}import {
@@ -4788,7 +4788,7 @@ ${options.events ? `\n\t\tawait ctx.ports.eventBus.publish(${names.singularPasca
4788
4788
  }
4789
4789
  function deleteUseCaseFile(names, config, options) {
4790
4790
  const filePath = path.join(resourceUseCaseDir(names, config), `delete-${names.singularKebab}.ts`);
4791
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4791
+ return `import "@beignet/core/server-only";
4792
4792
  import { z } from "zod";
4793
4793
  import { appError } from "${relativeModule(filePath, resourceSharedErrorsPath(config))}";
4794
4794
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
@@ -4881,7 +4881,7 @@ function inMemoryRepositoryFile(names, config, mode, options) {
4881
4881
  ${names.pluralCamel}.set(id, { ...existing, deletedAt: now, updatedAt: now });
4882
4882
  return true;`
4883
4883
  : `${options.tenant ? `\t\t\tconst existing = ${names.pluralCamel}.get(id);\n\t\t\tif (existing?.tenantId !== filter.tenantId) return false;\n` : ""} return ${names.pluralCamel}.delete(id);`;
4884
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
4884
+ return `import "@beignet/core/server-only";
4885
4885
  import { cursorPageResult } from "@beignet/core/pagination";
4886
4886
  import type { ${names.singularPascal}Repository } from "${aliasModule(repositoryPortPath)}";
4887
4887
  import { encode${names.singularPascal}Cursor } from "${aliasModule(resourceSchemaFilePath(names, config))}";
@@ -5239,7 +5239,7 @@ ${options.softDelete ? `\t\t\tconst now = new Date().toISOString();\n\t\t\tconst
5239
5239
  return affectedRows(result) > 0;
5240
5240
  },
5241
5241
  `;
5242
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
5242
+ return `import "@beignet/core/server-only";
5243
5243
  import { cursorPageResult } from "@beignet/core/pagination";
5244
5244
  import type { ${dialect.dbTypeName} } from "@beignet/provider-db-drizzle/${dialect.subpath}";
5245
5245
  import { ${drizzleImports.join(", ")} } from "drizzle-orm";
@@ -5460,7 +5460,7 @@ export const ${names.pluralCamel}Contracts = [list${names.pluralPascal}];
5460
5460
  `;
5461
5461
  }
5462
5462
  function standaloneUseCaseFile(names, config, filePath) {
5463
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
5463
+ return `import "@beignet/core/server-only";
5464
5464
  import { z } from "zod";
5465
5465
  import { useCase } from "${relativeModule(filePath, config.paths.useCaseBuilder)}";
5466
5466
 
@@ -7372,7 +7372,7 @@ function routeGroupFile(names, config, mode, _options) {
7372
7372
  const routeFilePath = path.join(config.paths.features, names.pluralKebab, "routes.ts");
7373
7373
  const contractsPath = resourceContractFilePath(names, config);
7374
7374
  const useCasesPath = resourceUseCaseIndexPath(names, config);
7375
- return `import type { beignetServerOnly } from "@beignet/core/server-only";
7375
+ return `import "@beignet/core/server-only";
7376
7376
  import { defineRouteGroup } from "@beignet/next";
7377
7377
  import type { AppContext } from "${relativeModule(routeFilePath, config.paths.appContext)}";
7378
7378
  import {
@@ -7396,11 +7396,11 @@ ${mode === "resource" ? ` { contract: get${names.singularPascal}, useCase: get$
7396
7396
  function testFile(names, config, mode, options) {
7397
7397
  const repositoryPath = path.join(path.dirname(config.paths.infrastructurePorts), names.pluralKebab, `in-memory-${names.singularKebab}-repository.ts`);
7398
7398
  const serverContextPath = path.join(path.dirname(config.paths.server), "context.ts");
7399
- const requestTarget = options.tenant ? "requester" : "app";
7399
+ const requestTarget = "app";
7400
7400
  return `import { describe, expect, it } from "bun:test";
7401
7401
  import { createUseCaseTester } from "@beignet/core/application";
7402
7402
  ${mode === "resource" ? `import { isAppError } from "@beignet/core/errors";\n` : ""}import { defineRoutes } from "@beignet/web";
7403
- import { createTestApp${options.tenant ? ", createTestRequester" : ""} } from "@beignet/web/testing";
7403
+ import { createTestApp } from "@beignet/web/testing";
7404
7404
  import { createInMemoryDevtools } from "@beignet/devtools";
7405
7405
  import { createTestContextFactory, createTestPorts } from "@beignet/core/testing";
7406
7406
  import { ${options.auth ? "createTestUserActor" : "createTestAnonymousActor"}${options.tenant ? ", createTestTenant" : ""} } from "@beignet/core/ports/testing";
@@ -7448,13 +7448,15 @@ ${options.tenant ? `\t\t\t{\n\t\t\t\tid: "00000000-0000-4000-8000-000000000104",
7448
7448
  base: appPorts,
7449
7449
  overrides: {
7450
7450
  ${names.pluralCamel},
7451
- ${options.auth
7451
+ ${options.auth || options.tenant
7452
7452
  ? `\t\t\t\tauth: {
7453
7453
  getSession: async () => ({
7454
- user: { id: "user_test", name: "Test User" },
7454
+ user: { id: "user_test", name: "Test User"${options.tenant ? `, tenantId: "tenant_test"` : ""} },
7455
+ ${options.tenant ? `\t\t\t\t\t\tsession: { tenantId: "tenant_test" },\n` : ""}
7455
7456
  }),
7456
7457
  },
7457
- gate: appPorts.gate,\n`
7458
+ ${options.auth ? `\t\t\t\tgate: appPorts.gate,\n` : ""}
7459
+ `
7458
7460
  : `\t\t\t\tauth: {
7459
7461
  getSession: async () => null,
7460
7462
  },\n`} devtools: createInMemoryDevtools(),
@@ -7601,7 +7603,6 @@ ${mode === "resource"
7601
7603
  routes: defineRoutes<AppContext>([${names.singularCamel}Routes]),
7602
7604
  context: appContext,
7603
7605
  });
7604
- ${options.tenant ? `\t\tconst requester = createTestRequester(app, {\n\t\t\theaders: { "x-tenant-id": "tenant_test" },\n\t\t});\n` : ""}
7605
7606
  const createdViaRoute = await ${requestTarget}.request(create${names.singularPascal}, {
7606
7607
  body: { name: "Second ${names.singularPascal}" },
7607
7608
  });