@getstrata/starter 2.0.9 → 2.1.0

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
@@ -3191,9 +3191,9 @@ function renderPackageJson(projectName, options = {}) {
3191
3191
  "@getstrata/cli": "workspace:*",
3192
3192
  "@getstrata/core": "workspace:*"
3193
3193
  } : {
3194
- "@getstrata/bootstrap": "^2.0.9",
3195
- "@getstrata/cli": "^2.0.9",
3196
- "@getstrata/core": "^2.0.9"
3194
+ "@getstrata/bootstrap": "^2.1.0",
3195
+ "@getstrata/cli": "^2.1.0",
3196
+ "@getstrata/core": "^2.1.0"
3197
3197
  };
3198
3198
  coreDeps.eta = "^4.6.0";
3199
3199
  if (options.layers?.database === "mysql") {
@@ -4047,12 +4047,6 @@ const notesTable = defineTable<NoteRecord, "id">({
4047
4047
  defaultOrderBy: { column: "id", direction: "ASC" },
4048
4048
  });
4049
4049
 
4050
- class NoteRepository extends BaseRepository<NoteRecord, "id"> {
4051
- constructor() {
4052
- super(notesTable);
4053
- }
4054
- }
4055
-
4056
4050
  class Note extends Model<NoteRecord, "id"> {
4057
4051
  static $fillable = ${fillable} as const;
4058
4052
  // created_at uses the table default. Sending a JS Date from $timestamps
@@ -4060,7 +4054,7 @@ class Note extends Model<NoteRecord, "id"> {
4060
4054
  static $timestamps = false;
4061
4055
  }
4062
4056
 
4063
- registerModelRepository(Note, new NoteRepository());
4057
+ registerModelRepository(Note, new BaseRepository(notesTable));
4064
4058
 
4065
4059
  export type { NoteRecord };
4066
4060
  export { Note };
@@ -4120,12 +4114,6 @@ const usersTable = defineTable<UserRecord, "id">({
4120
4114
  defaultOrderBy: { column: "id", direction: "ASC" },
4121
4115
  });
4122
4116
 
4123
- class UserRepository extends BaseRepository<UserRecord, "id"> {
4124
- constructor() {
4125
- super(usersTable);
4126
- }
4127
- }
4128
-
4129
4117
  class User extends Model<UserRecord, "id"> {
4130
4118
  static $fillable = ${fillableLiteral} as const;
4131
4119
  static $hidden = ${hiddenLiteral} as const;
@@ -4134,7 +4122,7 @@ class User extends Model<UserRecord, "id"> {
4134
4122
  static $timestamps = false;
4135
4123
  }
4136
4124
 
4137
- registerModelRepository(User, new UserRepository());
4125
+ registerModelRepository(User, new BaseRepository(usersTable));
4138
4126
 
4139
4127
  export type { UserRecord };
4140
4128
  export { User };
@@ -4163,12 +4151,6 @@ const apiTokensTable = defineTable<ApiTokenRecord, "id">({
4163
4151
  defaultOrderBy: { column: "id", direction: "ASC" },
4164
4152
  });
4165
4153
 
4166
- class ApiTokenRepository extends BaseRepository<ApiTokenRecord, "id"> {
4167
- constructor() {
4168
- super(apiTokensTable);
4169
- }
4170
- }
4171
-
4172
4154
  class ApiToken extends Model<ApiTokenRecord, "id"> {
4173
4155
  static $fillable = ["user_id", "name", "token_hash", "abilities", "expires_at", "last_used_at"] as const;
4174
4156
  // created_at uses the table default. Sending a JS Date from $timestamps
@@ -4176,7 +4158,7 @@ class ApiToken extends Model<ApiTokenRecord, "id"> {
4176
4158
  static $timestamps = false;
4177
4159
  }
4178
4160
 
4179
- registerModelRepository(ApiToken, new ApiTokenRepository());
4161
+ registerModelRepository(ApiToken, new BaseRepository(apiTokensTable));
4180
4162
 
4181
4163
  export type { ApiTokenRecord };
4182
4164
  export { ApiToken };
@@ -4203,18 +4185,12 @@ const authOneTimeTokensTable = defineTable<AuthOneTimeTokenRecord, "id">({
4203
4185
  defaultOrderBy: { column: "id", direction: "ASC" },
4204
4186
  });
4205
4187
 
4206
- class AuthOneTimeTokenRepository extends BaseRepository<AuthOneTimeTokenRecord, "id"> {
4207
- constructor() {
4208
- super(authOneTimeTokensTable);
4209
- }
4210
- }
4211
-
4212
4188
  class AuthOneTimeToken extends Model<AuthOneTimeTokenRecord, "id"> {
4213
4189
  static $fillable = ["purpose", "user_id", "token_hash", "expires_at", "consumed_at"] as const;
4214
4190
  static $timestamps = false;
4215
4191
  }
4216
4192
 
4217
- registerModelRepository(AuthOneTimeToken, new AuthOneTimeTokenRepository());
4193
+ registerModelRepository(AuthOneTimeToken, new BaseRepository(authOneTimeTokensTable));
4218
4194
 
4219
4195
  export type { AuthOneTimeTokenRecord };
4220
4196
  export { AuthOneTimeToken };
@@ -4224,7 +4200,6 @@ function renderModelsRegister(layers) {
4224
4200
  const lines = [
4225
4201
  "// Side-effect imports run registerModelRepository() in each model file.",
4226
4202
  "// registerModelClass() is only for a string alias that is neither constructor.name nor $morphClass.",
4227
- 'import { registerModelClass } from "@getstrata/core/database/model";',
4228
4203
  'import "./Note.ts";'
4229
4204
  ];
4230
4205
  if (authNeedsUsers(layers.auth)) {
@@ -4235,9 +4210,9 @@ function renderModelsRegister(layers) {
4235
4210
  lines.push('import "./ApiToken.ts";');
4236
4211
  }
4237
4212
  lines.push("");
4238
- lines.push("// Example after you add a Product model with belongsTo('Category'):");
4239
- lines.push('// registerModelClass("Category", Category);');
4240
- lines.push("void registerModelClass;");
4213
+ lines.push("// Optional alias when a relation uses belongsTo('CategoryAlias'):");
4214
+ lines.push('// import { registerModelClass } from "@getstrata/core/database/model";');
4215
+ lines.push('// registerModelClass("CategoryAlias", Category);');
4241
4216
  lines.push("");
4242
4217
  return `${lines.join(`
4243
4218
  `)}
@@ -4613,10 +4588,9 @@ import "./preload.ts";
4613
4588
  import { runProviderPhase } from "@getstrata/bootstrap/context";
4614
4589
  import {
4615
4590
  type AppContext,
4616
- type AppDependencies,
4617
4591
  type AppRouteMap,
4618
4592
  assertAppDependenciesComplete,
4619
- type ConfigStore,
4593
+ ConfigStore,
4620
4594
  type MutableAppDependencies,
4621
4595
  type ProviderContext,
4622
4596
  ServiceContainer,
@@ -4649,34 +4623,9 @@ export interface BootstrappedApp {
4649
4623
  config: ReturnType<typeof loadConfig>;
4650
4624
  }
4651
4625
 
4652
- class AppConfigStore {
4653
- private readonly values = new Map<string, unknown>();
4654
-
4655
- set<T>(key: string, value: T): T {
4656
- this.values.set(key, value);
4657
- return value;
4658
- }
4659
-
4660
- get<T>(key: string): T | undefined {
4661
- return this.values.get(key) as T | undefined;
4662
- }
4663
-
4664
- require<T>(key: string): T {
4665
- const value = this.get<T>(key);
4666
- if (value === undefined) {
4667
- throw new Error(\`Missing required config value "\${key}".\`);
4668
- }
4669
- return value;
4670
- }
4671
-
4672
- has(key: string): boolean {
4673
- return this.values.has(key);
4674
- }
4675
- }
4676
-
4677
4626
  function createAppContext(): AppContext {
4678
4627
  const container = new ServiceContainer();
4679
- const config = new AppConfigStore() as unknown as ConfigStore;
4628
+ const config = new ConfigStore();
4680
4629
  const dependencies: MutableAppDependencies = { container };
4681
4630
  const context: ProviderContext = { container, config, dependencies };
4682
4631
 
@@ -4689,8 +4638,8 @@ function createAppContext(): AppContext {
4689
4638
 
4690
4639
  assertAppDependenciesComplete(dependencies);
4691
4640
 
4692
- const appContext = { container, config, dependencies: dependencies as AppDependencies };
4693
- setActiveApplicationContext(appContext as never);
4641
+ const appContext: AppContext = { container, config, dependencies };
4642
+ setActiveApplicationContext(appContext);
4694
4643
  return appContext;
4695
4644
  }
4696
4645
 
@@ -12,9 +12,9 @@
12
12
  "check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@getstrata/bootstrap": "^2.0.9",
16
- "@getstrata/cli": "^2.0.9",
17
- "@getstrata/core": "^2.0.9",
15
+ "@getstrata/bootstrap": "^2.1.0",
16
+ "@getstrata/cli": "^2.1.0",
17
+ "@getstrata/core": "^2.1.0",
18
18
  "eta": "^4.6.0"
19
19
  },
20
20
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/starter",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "description": "Interactive create-strata wizard. Choose each layer; one database engine.",
5
5
  "type": "module",
6
6
  "license": "MIT",