zerotal 1.7.2 → 1.7.4

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.
Files changed (2) hide show
  1. package/api-surface.md +59 -22
  2. package/package.json +12 -12
package/api-surface.md CHANGED
@@ -316,6 +316,7 @@ class HttpContext = {
316
316
  new <TParams extends Record<string, unknown> = Record<string, string>>(request: Request, container: ScopedResolver): HttpContext<TParams>
317
317
  static fake: (url?: string, init?: RequestInit, container?: ScopedResolver) => HttpContext
318
318
  static tryGet: () => HttpContext | undefined
319
+ __: (key: string, replacements?: Replacements, locale?: string) => string
319
320
  _afterResponseCallbacks: (() => Promise<void>)[]
320
321
  _pageResolver?: (pageName: string) => number | undefined
321
322
  _primeBody: (data: Record<string, unknown>) => void
@@ -368,7 +369,6 @@ class HttpContext = {
368
369
  string: (key: string, fallback?: string) => string | undefined
369
370
  subdomain: (name: string) => string | null
370
371
  subdomains: Record<string, string>
371
- t: (key: string, replacements?: Replacements, locale?: string) => string
372
372
  took: number
373
373
  user?: UserModel | undefined
374
374
  view: { (markup: ViewMarkup, status?: number): void; <P extends Record<string, unknown> = Record<string, never>>(component: (ctx: HttpContext, props: P) => ViewMarkup | Promise<ViewMarkup>, props?: P | undefined, status?: number): void | Promise<void>;}
@@ -1101,6 +1101,7 @@ interface WebhookOptions = {
1101
1101
  interface WebSocketHandlers = {
1102
1102
  close?: (ws: unknown, code: number, reason: string) => void
1103
1103
  drain?: (ws: unknown) => void
1104
+ idleTimeout?: number
1104
1105
  message: (ws: unknown, message: string | Uint8Array) => void
1105
1106
  open?: (ws: unknown) => void
1106
1107
  }
@@ -1111,7 +1112,7 @@ type AppScopeInstaller = () => () => void
1111
1112
 
1112
1113
  type ArgDef = { name: string; required?: boolean; default?: string;}
1113
1114
 
1114
- type BindingToken = keyof ContainerBindings | ClassToken<T> | AbstractToken<T>
1115
+ type BindingToken = ClassToken<T> | AbstractToken<T> | keyof ContainerBindings
1115
1116
 
1116
1117
  type ClassRef = abstract new (...args: never[]) => unknown
1117
1118
 
@@ -1139,7 +1140,7 @@ type FileRouteResolver = (ctx: FileRouteContext) => boolean
1139
1140
 
1140
1141
  type FileRoutingConfig = { [x: string]: FileRoutingEntry;}
1141
1142
 
1142
- type FileRoutingEntry = string | { dir: string; prefix?: string; middleware?: MiddlewareInput;}
1143
+ type FileRoutingEntry = string | { dir: string; prefix?: string; middleware?: MiddlewareInput }
1143
1144
 
1144
1145
  type FlagDef = { name: string; short?: string; type: 'string' | 'boolean' | 'number'; description?: string; default?: unknown;}
1145
1146
 
@@ -1177,7 +1178,7 @@ type RouteTarget = string
1177
1178
 
1178
1179
  type RoutingConfig = { [x: string]: RoutingEntry;}
1179
1180
 
1180
- type RoutingEntry = string | { file: string; prefix?: string; middleware?: MiddlewareInput;}
1181
+ type RoutingEntry = string | { file: string; prefix?: string; middleware?: MiddlewareInput }
1181
1182
 
1182
1183
  type SameSite = 'Strict' | 'Lax' | 'None'
1183
1184
 
@@ -3105,7 +3106,7 @@ type ResponseInterceptor = (ctx: ResponseContext) => ResponseContext | Promise<R
3105
3106
 
3106
3107
  type ResponseOf = `${Method} ${Path}` extends keyof Routes ? Routes[`${Method} ${Path}`] extends { response: infer R;} ? R : unknown : unknown
3107
3108
 
3108
- type SocketState = 'error' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting'
3109
+ type SocketState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error'
3109
3110
 
3110
3111
  type TokenSource = string | (() => string | null | undefined | Promise<string | null | undefined>)
3111
3112
 
@@ -4098,7 +4099,7 @@ interface RegisteredConfigValidator = {
4098
4099
  validate: ConfigValidator
4099
4100
  }
4100
4101
 
4101
- type AssetLoaderKind = 'text' | 'file' | 'json' | 'dataurl' | 'base64' | 'toml'
4102
+ type AssetLoaderKind = 'file' | 'dataurl' | 'base64' | 'text' | 'json' | 'toml'
4102
4103
 
4103
4104
  type ConfigIssueLevel = 'error' | 'warning'
4104
4105
 
@@ -4315,7 +4316,7 @@ const t = { readonly string: () => Def<string | undefined>; readonly numbe
4315
4316
 
4316
4317
  type EnvOutput = { readonly [K in keyof S]: InferDef<S[K]>; }
4317
4318
 
4318
- type FieldType = 'string' | 'number' | 'boolean' | 'url' | 'enum' | 'port'
4319
+ type FieldType = 'string' | 'number' | 'boolean' | 'enum' | 'url' | 'port'
4319
4320
 
4320
4321
  type InferDef = D extends Def<infer T> ? T : never
4321
4322
 
@@ -4665,7 +4666,7 @@ interface WebContext = {
4665
4666
  view: (markup: string | { toString(): string;}, status?: number) => void
4666
4667
  }
4667
4668
 
4668
- type AnsiColor = 'cyan' | 'yellow' | 'green' | 'blue' | 'red' | 'dim'
4669
+ type AnsiColor = 'red' | 'green' | 'yellow' | 'blue' | 'cyan' | 'dim'
4669
4670
 
4670
4671
  type Channel = 'web' | 'json' | 'cli'
4671
4672
 
@@ -4926,11 +4927,11 @@ interface LoggingConfigShape = {
4926
4927
  slowQueryMs?: number
4927
4928
  }
4928
4929
 
4929
- type ChannelConfig = { driver: 'console'; level?: LogLevel; format?: 'json' | 'pretty';} | { driver: 'single'; level?: LogLevel; path: string;} | { driver: 'daily'; level?: LogLevel; path: string; days?: number;} | { driver: 'stack'; level?: LogLevel; channels: string[];} | { driver: 'null';}
4930
+ type ChannelConfig = { driver: 'console'; level?: LogLevel; format?: 'json' | 'pretty' } | { driver: 'single'; level?: LogLevel; path: string } | { driver: 'daily'; level?: LogLevel; path: string; days?: number } | { driver: 'stack'; level?: LogLevel; channels: string[] } | { driver: 'null' }
4930
4931
 
4931
- type LogLevel = 'error' | 'info' | 'warn' | 'debug' | 'fatal'
4932
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal'
4932
4933
 
4933
- type TableData = Record<string, unknown> | readonly Record<string, unknown>[]
4934
+ type TableData = Record<string, unknown> | ReadonlyArray<Record<string, unknown>>
4934
4935
 
4935
4936
  ## ./media `(./src/media.ts)`
4936
4937
 
@@ -5378,7 +5379,7 @@ interface ResponsiveImageSet = {
5378
5379
  placeholder?: string
5379
5380
  }
5380
5381
 
5381
- type ConversionFit = 'fill' | 'inside' | 'cover'
5382
+ type ConversionFit = 'inside' | 'fill' | 'cover'
5382
5383
 
5383
5384
  type ConversionFormat = SafeConversionFormat | 'avif' | 'heic'
5384
5385
 
@@ -5386,7 +5387,7 @@ type ConversionMap = { [x: string]: ConversionDefinition;}
5386
5387
 
5387
5388
  type MediaCollections = { [x: string]: CollectionDefinition | (() => CollectionDefinition);}
5388
5389
 
5389
- type MediaSource = ArrayBuffer | Blob | UploadedFile | File | Uint8Array<ArrayBufferLike>
5390
+ type MediaSource = UploadedFile | File | Blob | Uint8Array | ArrayBuffer
5390
5391
 
5391
5392
  type SafeConversionFormat = 'jpeg' | 'png' | 'webp'
5392
5393
 
@@ -5529,7 +5530,7 @@ class Blueprint = {
5529
5530
  bigInteger: (name: string) => ColumnBuilder
5530
5531
  binary: (name: string) => ColumnBuilder
5531
5532
  boolean: (name: string) => ColumnBuilder
5532
- char: (name: string, _length?: number) => ColumnBuilder
5533
+ char: (name: string, length?: number) => ColumnBuilder
5533
5534
  date: (name: string) => ColumnBuilder
5534
5535
  dateTime: (name: string) => ColumnBuilder
5535
5536
  datetime: (name: string) => ColumnBuilder
@@ -5566,7 +5567,7 @@ class Blueprint = {
5566
5567
  smallInteger: (name: string) => ColumnBuilder
5567
5568
  softDeletes: (column?: string) => void
5568
5569
  spatialIndex: (columns: string | string[], name?: string) => Blueprint
5569
- string: (name: string, _length?: number) => ColumnBuilder
5570
+ string: (name: string, length?: number) => ColumnBuilder
5570
5571
  text: (name: string) => ColumnBuilder
5571
5572
  time: (name: string) => ColumnBuilder
5572
5573
  timestamp: (name: string) => ColumnBuilder
@@ -5595,7 +5596,7 @@ class Cast = {
5595
5596
  }
5596
5597
 
5597
5598
  class ColumnBuilder = {
5598
- new <Locked extends string = never>(name: string, _sqlType: string, isPrimary?: boolean, isAutoIncrement?: boolean): ColumnBuilder<Locked>
5599
+ new <Locked extends string = never>(name: string, _sqlType: string, isPrimary?: boolean, isAutoIncrement?: boolean, _isBoolean?: boolean, _stringLength?: number | undefined): ColumnBuilder<Locked>
5599
5600
  after: (_column: string) => ColumnBuilder<Locked>
5600
5601
  alter: () => ColumnBuilder<Locked>
5601
5602
  before: (_column: string) => ColumnBuilder<Locked>
@@ -5979,12 +5980,15 @@ class MysqlDialect = {
5979
5980
  advisoryLockSql: (key: number) => DialectQuery
5980
5981
  advisoryUnlockSql: (key: number) => DialectQuery
5981
5982
  autoIncrementColumn: (column: string) => string
5983
+ booleanLiteral: (value: boolean) => string
5982
5984
  dateExpr: (part: DatePart, column: string) => string
5983
5985
  hasColumnSql: (table: string, column: string) => DialectQuery
5984
5986
  hasTableSql: (table: string) => DialectQuery
5987
+ readonly booleanType: 'INTEGER'
5985
5988
  readonly name: 'mysql'
5986
5989
  readonly supportsAdvisoryLocks: true
5987
5990
  readonly supportsTransactionalDdl: false
5991
+ stringType: (length: number) => string
5988
5992
  }
5989
5993
 
5990
5994
  class NPlusOneDetected = {
@@ -6018,12 +6022,15 @@ class PostgresDialect = {
6018
6022
  advisoryLockSql: (key: number) => DialectQuery
6019
6023
  advisoryUnlockSql: (key: number) => DialectQuery
6020
6024
  autoIncrementColumn: (column: string) => string
6025
+ booleanLiteral: (value: boolean) => string
6021
6026
  dateExpr: (part: DatePart, column: string) => string
6022
6027
  hasColumnSql: (table: string, column: string) => DialectQuery
6023
6028
  hasTableSql: (table: string) => DialectQuery
6029
+ readonly booleanType: 'BOOLEAN'
6024
6030
  readonly name: 'postgres'
6025
6031
  readonly supportsAdvisoryLocks: true
6026
6032
  readonly supportsTransactionalDdl: true
6033
+ stringType: () => string
6027
6034
  }
6028
6035
 
6029
6036
  class QueryBuilder = {
@@ -6155,12 +6162,15 @@ class SqliteDialect = {
6155
6162
  advisoryLockSql: () => DialectQuery | null
6156
6163
  advisoryUnlockSql: () => DialectQuery | null
6157
6164
  autoIncrementColumn: (column: string) => string
6165
+ booleanLiteral: (value: boolean) => string
6158
6166
  dateExpr: (part: DatePart, column: string) => string
6159
6167
  hasColumnSql: (table: string, column: string) => DialectQuery
6160
6168
  hasTableSql: (table: string) => DialectQuery
6169
+ readonly booleanType: 'INTEGER'
6161
6170
  readonly name: 'sqlite'
6162
6171
  readonly supportsAdvisoryLocks: false
6163
6172
  readonly supportsTransactionalDdl: true
6173
+ stringType: () => string
6164
6174
  }
6165
6175
 
6166
6176
  class StateError = {
@@ -6673,12 +6683,15 @@ interface SqlDialect = {
6673
6683
  advisoryLockSql: (key: number) => DialectQuery | null
6674
6684
  advisoryUnlockSql: (key: number) => DialectQuery | null
6675
6685
  autoIncrementColumn: (column: string) => string
6686
+ booleanLiteral: (value: boolean) => string
6676
6687
  dateExpr: (part: DatePart, column: string) => string
6677
6688
  hasColumnSql: (table: string, column: string) => DialectQuery
6678
6689
  hasTableSql: (table: string) => DialectQuery
6690
+ readonly booleanType: string
6679
6691
  readonly name: DialectName
6680
6692
  readonly supportsAdvisoryLocks: boolean
6681
6693
  readonly supportsTransactionalDdl: boolean
6694
+ stringType: (length: number) => string
6682
6695
  }
6683
6696
 
6684
6697
  interface SQLInstance = {
@@ -6720,13 +6733,13 @@ type ClassRef = abstract new (...args: never[]) => unknown
6720
6733
 
6721
6734
  type Columns = { [K in keyof T & string]: K extends `_${string}` ? never : T[K] extends (...args: any[]) => any ? never : K; }[keyof T & string]
6722
6735
 
6723
- type ColumnShorthand = 'string' | 'number' | 'boolean' | 'text' | 'date' | 'datetime' | 'array' | 'integer' | 'json' | 'float' | 'encrypted' | 'encrypted:json'
6736
+ type ColumnShorthand = 'string' | 'text' | 'integer' | 'number' | 'float' | 'boolean' | 'datetime' | 'date' | 'json' | 'array' | 'encrypted' | 'encrypted:json'
6724
6737
 
6725
6738
  type Constructor = new (...args: any[]) => T
6726
6739
 
6727
6740
  type ContextConnectionResolver = (ModelClass?: typeof BaseModel) => SQLInstance | null
6728
6741
 
6729
- type DatePart = 'date' | 'time' | 'year' | 'month' | 'day'
6742
+ type DatePart = 'date' | 'time' | 'day' | 'month' | 'year'
6730
6743
 
6731
6744
  type DialectName = 'sqlite' | 'postgres' | 'mysql'
6732
6745
 
@@ -7061,26 +7074,49 @@ interface WorkerPoolOptions = {
7061
7074
  size: number
7062
7075
  }
7063
7076
 
7064
- type BatchStatus = 'failed' | 'pending' | 'complete'
7077
+ type BatchStatus = 'pending' | 'complete' | 'failed'
7065
7078
 
7066
7079
  type JobStatus = 'dispatched' | 'completed' | 'failed' | 'retried'
7067
7080
 
7068
7081
  type SerializedJob = { className: string; payload: Record<string, unknown>;}
7069
7082
 
7070
- type WorkerResult = { success: true;} | { success: false; error: string;}
7083
+ type WorkerResult = { success: true } | { success: false; error: string }
7071
7084
 
7072
7085
  ## ./routes `(./src/routes.ts)`
7073
7086
 
7074
7087
  const route = RouteBuilder
7075
7088
 
7089
+ function action = <N extends RouteTarget>(name: N, params?: RouteParamValues | undefined, query?: RouteQuery | undefined) => RouteAction
7090
+
7091
+ function defineRouteMethods = (table: Readonly<Record<string, string>>) => void
7092
+
7076
7093
  function defineRoutes = (table: RouteTable) => void
7077
7094
 
7078
7095
  function hasRoute = (name: string) => boolean
7079
7096
 
7080
7097
  function resetRoutes = () => void
7081
7098
 
7099
+ function routeMethod = (name: string) => string | undefined
7100
+
7101
+ interface RouteAction = {
7102
+ method: string
7103
+ url: string
7104
+ }
7105
+
7106
+ interface RouteMethodRegistry = {}
7107
+
7108
+ type MethodedRouteName = never
7109
+
7110
+ type RouteArgs = [params?: RouteParamValues, query?: RouteQuery]
7111
+
7112
+ type RouteParamValues = { [x: string]: RouteParamValue | readonly RouteParamValue[];}
7113
+
7114
+ type RouteQuery = { [x: string]: string | number | boolean | readonly (string | number | boolean)[] | null | undefined;}
7115
+
7082
7116
  type RouteTable = Readonly<Record<string, string>> | ReadonlyMap<string, string>
7083
7117
 
7118
+ type RouteTarget = string
7119
+
7084
7120
  ## ./scheduler `(./src/scheduler.ts)`
7085
7121
 
7086
7122
  class CronExpression = {
@@ -7350,7 +7386,7 @@ interface RedactGraphOptions = {
7350
7386
  tooDeep: string
7351
7387
  }
7352
7388
 
7353
- type HashAlgorithm = 'bcrypt' | 'argon2id' | 'argon2i' | 'argon2d'
7389
+ type HashAlgorithm = 'argon2id' | 'argon2i' | 'argon2d' | 'bcrypt'
7354
7390
 
7355
7391
  ## ./session `(./src/session.ts)`
7356
7392
 
@@ -8030,7 +8066,7 @@ type FakeFile = { create(name: string, content?: string | Uint8Array, type?:
8030
8066
 
8031
8067
  type SessionDecoder = (response: Response) => Promise<Record<string, unknown> | null>
8032
8068
 
8033
- type TestFormValue = string | number | boolean | Blob | File | TestFileInput | null | undefined
8069
+ type TestFormValue = string | number | boolean | null | undefined | TestFileInput | File | Blob
8034
8070
 
8035
8071
  ## ./validator `(./src/validator.ts)`
8036
8072
 
@@ -8159,6 +8195,7 @@ class FormRequest = {
8159
8195
  static macro: (name: string, fn: (this: FormRequest, ...args: unknown[]) => unknown) => void
8160
8196
  static validate: <T extends FormRequest>(this: new () => T) => Promise<Infer<ExtractDefs<ReturnType<T['rules']>>>>
8161
8197
  authorize: () => boolean | Promise<boolean>
8198
+ prepareForValidation: (body: Record<string, unknown>) => Record<string, unknown>
8162
8199
  rules: (_r: RuleBuilder) => Record<string, FieldRule>
8163
8200
  }
8164
8201
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerotal",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "license": "MIT",
5
5
  "maturity": "stable",
6
6
  "private": false,
@@ -61,17 +61,17 @@
61
61
  "typecheck": "tsc --noEmit"
62
62
  },
63
63
  "dependencies": {
64
- "@zerotal/auth": "1.7.2",
65
- "@zerotal/cache": "1.7.2",
66
- "@zerotal/client": "1.7.2",
67
- "@zerotal/core": "1.7.2",
68
- "@zerotal/media": "1.7.2",
69
- "@zerotal/orm": "1.7.2",
70
- "@zerotal/queue": "1.7.2",
71
- "@zerotal/scheduler": "1.7.2",
72
- "@zerotal/session": "1.7.2",
73
- "@zerotal/testing": "1.7.2",
74
- "@zerotal/validator": "1.7.2"
64
+ "@zerotal/auth": "1.7.4",
65
+ "@zerotal/cache": "1.7.4",
66
+ "@zerotal/client": "1.7.4",
67
+ "@zerotal/core": "1.7.4",
68
+ "@zerotal/media": "1.7.4",
69
+ "@zerotal/orm": "1.7.4",
70
+ "@zerotal/queue": "1.7.4",
71
+ "@zerotal/scheduler": "1.7.4",
72
+ "@zerotal/session": "1.7.4",
73
+ "@zerotal/testing": "1.7.4",
74
+ "@zerotal/validator": "1.7.4"
75
75
  },
76
76
  "devDependencies": {
77
77
  "typescript": "^5.8.0"