create-strata 2.2.57 → 2.2.59

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.js CHANGED
@@ -3480,6 +3480,8 @@ function renderCliRegisterTs(layers) {
3480
3480
  const commands: StrataCommandMap = {${layers && authNeedsUsers(layers.auth) ? `
3481
3481
  "auth:provision-admin": async () => (await import("./initialAdmin.ts")).initialAdminCommand,` : ""}
3482
3482
  "make:module": async () => (await import("@getstrata/cli/scaffold")).makeModuleCommand,
3483
+ "make:model": async () => (await import("@getstrata/cli/scaffold")).makeModelCommand,
3484
+ "make:view": async () => (await import("@getstrata/cli/scaffold")).makeViewCommand,
3483
3485
  "make:policy": async () => (await import("@getstrata/cli/scaffold")).makePolicyCommand,
3484
3486
  "make:job": async () => (await import("@getstrata/cli/scaffold")).makeJobCommand,
3485
3487
  "make:listener": async () => (await import("@getstrata/cli/scaffold")).makeListenerCommand,
@@ -4072,6 +4074,10 @@ Until \`frontend/dist\` exists, \`${layers.spaPrefix}\` answers 503. Use \`bun r
4072
4074
  The app uses the database named in \`DATABASE_URL\` and creates it on first migrate when the connection user may. Set \`APP_DATABASE_URL\` only when migrations and the app should target a different database than \`DATABASE_URL\`.${usesComposePostgres(layers) ? ` \`.env.example\` points \`DATABASE_URL\` at \`${GENERATED_POSTGRES_APP_ROLE}\` (\`NOSUPERUSER\` \`NOBYPASSRLS\`), including \`--no-docker\`. \`db/ensure-postgres-app-role.sql\` is repeatable on an existing volume; Compose init still runs on first empty volume. The \`postgres\` superuser is for CREATE ROLE / GRANT / migrate and Adminer.` : ""}
4073
4075
  `}
4074
4076
  ${renderOpenApiReadme()}
4077
+ ## Migration status
4078
+
4079
+ Run \`bun run src/db/status.ts\` to inspect existing migration history. Status does not initialize missing history or repair runtime grants; missing history/read access fails with the database error. Initialize a new database with the explicit migrate command first. Migrate, fresh and rollback remain administrative mutations.${layers.database === "postgres" ? " Status needs only CONNECT, schema USAGE and SELECT on framework_migrations through its configured migration connection; it does not need schema CREATE or grant authority. The generated status call opts out of the migration helper's privilege repair, while mutation callers retain that repair." : ""} Package upgrades do not rewrite these generated application files.
4080
+
4075
4081
  ## Deploy
4076
4082
 
4077
4083
  Bun >=1.4.4 is required. \`.bun-version\` and Docker stages pin the tested 1.4.4 runtime; upgrade pins deliberately and rerun checks before deployment. Runtime and TypeScript requirements use >=1.4.4, accepting future 1.4.x patches; the bun-types override keeps transitive shims above the same minimum. Refresh and commit root/frontend lockfiles when upgrading. Updating framework packages does not rewrite an existing app Dockerfile, runtime pin or manifest.
@@ -4142,11 +4148,15 @@ function postgresAppRolePrivilegeSql(options) {
4142
4148
  const role = assertSafeSqlIdentifier(options.role ?? POSTGRES_APP_ROLE, "role name");
4143
4149
  return `GRANT CONNECT ON DATABASE ${database} TO ${role};
4144
4150
  GRANT USAGE ON SCHEMA public TO ${role};
4145
- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ${role};
4146
- GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO ${role};
4151
+ REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM ${role};
4152
+ GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO ${role};
4153
+ REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM ${role};
4154
+ GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO ${role};
4147
4155
  GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO ${role};
4148
- ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO ${role};
4149
- ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO ${role};
4156
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON TABLES FROM ${role};
4157
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO ${role};
4158
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON SEQUENCES FROM ${role};
4159
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO ${role};
4150
4160
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT EXECUTE ON FUNCTIONS TO ${role};
4151
4161
  `;
4152
4162
  }
@@ -4478,9 +4488,9 @@ function renderPackageJson(projectName, options = {}) {
4478
4488
  "@getstrata/cli": "workspace:*",
4479
4489
  "@getstrata/core": "workspace:*"
4480
4490
  } : {
4481
- "@getstrata/bootstrap": "^2.2.57",
4482
- "@getstrata/cli": "^2.2.57",
4483
- "@getstrata/core": "^2.2.57"
4491
+ "@getstrata/bootstrap": "^2.2.59",
4492
+ "@getstrata/cli": "^2.2.59",
4493
+ "@getstrata/core": "^2.2.59"
4484
4494
  };
4485
4495
  coreDeps.eta = "^4.6.0";
4486
4496
  if (options.layers?.database === "mysql") {
@@ -4803,6 +4813,7 @@ export async function loadStarterMigrations() {
4803
4813
 
4804
4814
  export async function withMigrationDatabase<T>(
4805
4815
  fn: (db: MigrationDatabase) => Promise<T>,
4816
+ options: { grantRuntimePrivileges?: boolean } = {},
4806
4817
  ): Promise<T> {
4807
4818
  const runtimeUrl = process.env.DATABASE_URL ?? "";
4808
4819
  const admin = await openPostgresAdminConnection({
@@ -4811,9 +4822,11 @@ export async function withMigrationDatabase<T>(
4811
4822
  });
4812
4823
  try {
4813
4824
  const result = await fn(admin);
4814
- await grantPostgresAppRolePrivileges(admin, {
4815
- database: postgresDatabaseNameFromUrl(runtimeUrl),
4816
- });
4825
+ if (options.grantRuntimePrivileges !== false) {
4826
+ await grantPostgresAppRolePrivileges(admin, {
4827
+ database: postgresDatabaseNameFromUrl(runtimeUrl),
4828
+ });
4829
+ }
4817
4830
  return result;
4818
4831
  } finally {
4819
4832
  await admin.close?.();
@@ -5016,7 +5029,7 @@ import { loadStarterMigrations, withMigrationDatabase } from "./migrationRuntime
5016
5029
  export async function status() {
5017
5030
  ${ensureCall(layers, false)} const rows = await withMigrationDatabase(async (db) => {
5018
5031
  return getMigrationStatus(db, await loadStarterMigrations());
5019
- });
5032
+ }${layers.database === "postgres" ? ", { grantRuntimePrivileges: false }" : ""});
5020
5033
  console.log("Migrations:");
5021
5034
  for (const row of rows) {
5022
5035
  const batch = row.batch == null ? "" : \` (batch \${row.batch})\`;
@@ -12,9 +12,9 @@
12
12
  "check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@getstrata/bootstrap": "^2.2.57",
16
- "@getstrata/cli": "^2.2.57",
17
- "@getstrata/core": "^2.2.57",
15
+ "@getstrata/bootstrap": "^2.2.59",
16
+ "@getstrata/cli": "^2.2.59",
17
+ "@getstrata/core": "^2.2.59",
18
18
  "eta": "^4.6.0"
19
19
  },
20
20
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-strata",
3
- "version": "2.2.57",
3
+ "version": "2.2.59",
4
4
  "description": "Create a new Strata app. Interactive wizard; choose each layer; one database engine.",
5
5
  "type": "module",
6
6
  "license": "MIT",