@stacksjs/config 0.64.6 → 0.65.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/src/defaults.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { commandsPath, userDatabasePath } from '@stacksjs/path'
2
1
  import type { StacksOptions } from '@stacksjs/types'
2
+ import { commandsPath, userDatabasePath } from '@stacksjs/path'
3
3
 
4
4
  // import { userConfig as overrides } from './overrides'
5
5
 
6
- export default {
6
+ const config: StacksOptions = {
7
7
  ai: {
8
8
  deploy: false,
9
9
  models: [
@@ -187,50 +187,50 @@ export default {
187
187
 
188
188
  errors: {
189
189
  messages: {
190
- string: 'The {{ field }} field must be a string',
191
- email: 'The {{ field }} field must be a valid email address',
192
- regex: 'The {{ field }} field format is invalid',
193
- url: 'The {{ field }} field must be a valid URL',
194
- activeUrl: 'The {{ field }} field must be a valid URL',
195
- alpha: 'The {{ field }} field must contain only letters',
196
- alphaNumeric: 'The {{ field }} field must contain only letters and numbers',
197
- minLength: 'The {{ field }} field must have at least {{ min }} characters',
198
- maxLength: 'The {{ field }} field must not be greater than {{ max }} characters',
199
- fixedLength: 'The {{ field }} field must be {{ size }} characters long',
200
- confirmed: 'The {{ field }} field and {{ otherField }} field must be the same',
201
- endsWith: 'The {{ field }} field must end with {{ substring }}',
202
- startsWith: 'The {{ field }} field must start with {{ substring }}',
203
- sameAs: 'The {{ field }} field and {{ otherField }} field must be the same',
204
- notSameAs: 'The {{ field }} field and {{ otherField }} field must be different',
205
- in: 'The selected {{ field }} is invalid',
206
- notIn: 'The selected {{ field }} is invalid',
207
- ipAddress: 'The {{ field }} field must be a valid IP address',
208
- uuid: 'The {{ field }} field must be a valid UUID',
209
- ascii: 'The {{ field }} field must only contain ASCII characters',
210
- creditCard: 'The {{ field }} field must be a valid {{ providersList }} card number',
211
- hexCode: 'The {{ field }} field must be a valid hex color code',
212
- iban: 'The {{ field }} field must be a valid IBAN number',
213
- jwt: 'The {{ field }} field must be a valid JWT token',
214
- coordinates: 'The {{ field }} field must contain latitude and longitude coordinates',
215
- mobile: 'The {{ field }} field must be a valid mobile phone number',
216
- passport: 'The {{ field }} field must be a valid passport number',
217
- postalCode: 'The {{ field }} field must be a valid postal code',
190
+ 'string': 'The {{ field }} field must be a string',
191
+ 'email': 'The {{ field }} field must be a valid email address',
192
+ 'regex': 'The {{ field }} field format is invalid',
193
+ 'url': 'The {{ field }} field must be a valid URL',
194
+ 'activeUrl': 'The {{ field }} field must be a valid URL',
195
+ 'alpha': 'The {{ field }} field must contain only letters',
196
+ 'alphaNumeric': 'The {{ field }} field must contain only letters and numbers',
197
+ 'minLength': 'The {{ field }} field must have at least {{ min }} characters',
198
+ 'maxLength': 'The {{ field }} field must not be greater than {{ max }} characters',
199
+ 'fixedLength': 'The {{ field }} field must be {{ size }} characters long',
200
+ 'confirmed': 'The {{ field }} field and {{ otherField }} field must be the same',
201
+ 'endsWith': 'The {{ field }} field must end with {{ substring }}',
202
+ 'startsWith': 'The {{ field }} field must start with {{ substring }}',
203
+ 'sameAs': 'The {{ field }} field and {{ otherField }} field must be the same',
204
+ 'notSameAs': 'The {{ field }} field and {{ otherField }} field must be different',
205
+ 'in': 'The selected {{ field }} is invalid',
206
+ 'notIn': 'The selected {{ field }} is invalid',
207
+ 'ipAddress': 'The {{ field }} field must be a valid IP address',
208
+ 'uuid': 'The {{ field }} field must be a valid UUID',
209
+ 'ascii': 'The {{ field }} field must only contain ASCII characters',
210
+ 'creditCard': 'The {{ field }} field must be a valid {{ providersList }} card number',
211
+ 'hexCode': 'The {{ field }} field must be a valid hex color code',
212
+ 'iban': 'The {{ field }} field must be a valid IBAN number',
213
+ 'jwt': 'The {{ field }} field must be a valid JWT token',
214
+ 'coordinates': 'The {{ field }} field must contain latitude and longitude coordinates',
215
+ 'mobile': 'The {{ field }} field must be a valid mobile phone number',
216
+ 'passport': 'The {{ field }} field must be a valid passport number',
217
+ 'postalCode': 'The {{ field }} field must be a valid postal code',
218
218
 
219
219
  // boolean
220
- boolean: 'The value must be a boolean',
220
+ 'boolean': 'The value must be a boolean',
221
221
 
222
222
  // number
223
- number: 'The {{ field }} field must be a number',
224
- min: 'The {{ field }} field must be at least {{ min }}',
225
- max: 'The {{ field }} field must not be greater than {{ max }}',
226
- range: 'The {{ field }} field must be between {{ min }} and {{ max }}',
227
- positive: 'The {{ field }} field must be positive',
228
- negative: 'The {{ field }} field must be negative',
229
- decimal: 'The {{ field }} field must have {{ digits }} decimal places',
230
- withoutDecimals: 'The {{ field }} field must not have decimal places',
223
+ 'number': 'The {{ field }} field must be a number',
224
+ 'min': 'The {{ field }} field must be at least {{ min }}',
225
+ 'max': 'The {{ field }} field must not be greater than {{ max }}',
226
+ 'range': 'The {{ field }} field must be between {{ min }} and {{ max }}',
227
+ 'positive': 'The {{ field }} field must be positive',
228
+ 'negative': 'The {{ field }} field must be negative',
229
+ 'decimal': 'The {{ field }} field must have {{ digits }} decimal places',
230
+ 'withoutDecimals': 'The {{ field }} field must not have decimal places',
231
231
 
232
232
  // date
233
- date: 'The {{ field }} field must be a datetime value',
233
+ 'date': 'The {{ field }} field must be a datetime value',
234
234
  'date.equals': 'The {{ field }} field must be a date equal to {{ expectedValue }}',
235
235
  'date.after': 'The {{ field }} field must be a date after {{ expectedValue }}',
236
236
  'date.before': 'The {{ field }} field must be a date before {{ expectedValue }}',
@@ -241,38 +241,38 @@ export default {
241
241
  'date.afterField': 'The {{ field }} field must be a date after {{ otherField }}',
242
242
 
243
243
  // accepted
244
- accepted: 'The {{ field }} field must be accepted',
244
+ 'accepted': 'The {{ field }} field must be accepted',
245
245
 
246
246
  // enum
247
- enum: 'The selected {{ field }} is invalid',
247
+ 'enum': 'The selected {{ field }} is invalid',
248
248
 
249
249
  // literal
250
- literal: 'The {{ field }} field must be {{ expectedValue }}',
250
+ 'literal': 'The {{ field }} field must be {{ expectedValue }}',
251
251
 
252
252
  // object
253
- object: 'The {{ field }} field must be an object',
253
+ 'object': 'The {{ field }} field must be an object',
254
254
 
255
255
  // record
256
- record: 'The {{ field }} field must be an object',
256
+ 'record': 'The {{ field }} field must be an object',
257
257
  'record.minLength': 'The {{ field }} field must have at least {{ min }} items',
258
258
  'record.maxLength': 'The {{ field }} field must not have more than {{ max }} items',
259
259
  'record.fixedLength': 'The {{ field }} field must contain {{ size }} items',
260
260
 
261
261
  // array
262
- array: 'The {{ field }} field must be an array',
262
+ 'array': 'The {{ field }} field must be an array',
263
263
  'array.minLength': 'The {{ field }} field must have at least {{ min }} items',
264
264
  'array.maxLength': 'The {{ field }} field must not have more than {{ max }} items',
265
265
  'array.fixedLength': 'The {{ field }} field must contain {{ size }} items',
266
- notEmpty: 'The {{ field }} field must not be empty',
267
- distinct: 'The {{ field }} field has duplicate values',
266
+ 'notEmpty': 'The {{ field }} field must not be empty',
267
+ 'distinct': 'The {{ field }} field has duplicate values',
268
268
 
269
269
  // tuple
270
- tuple: 'The {{ field }} field must be an array',
270
+ 'tuple': 'The {{ field }} field must be an array',
271
271
 
272
272
  // union
273
- union: 'Invalid value provided for {{ field }} field',
274
- unionGroup: 'Invalid value provided for {{ field }} field',
275
- unionOfTypes: 'Invalid value provided for {{ field }} field',
273
+ 'union': 'Invalid value provided for {{ field }} field',
274
+ 'unionGroup': 'Invalid value provided for {{ field }} field',
275
+ 'unionOfTypes': 'Invalid value provided for {{ field }} field',
276
276
  },
277
277
  },
278
278
 
@@ -613,4 +613,6 @@ export default {
613
613
  },
614
614
  },
615
615
  },
616
- } satisfies StacksOptions
616
+ }
617
+
618
+ export default config
package/src/helpers.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { createLocalTunnel } from '@stacksjs/tunnel'
2
1
  import type {
3
2
  AppConfig,
4
3
  CacheConfig,
@@ -25,6 +24,7 @@ import type {
25
24
  StorageConfig,
26
25
  UiConfig,
27
26
  } from '@stacksjs/types'
27
+ import { createLocalTunnel } from '@stacksjs/tunnel'
28
28
  import { config } from '.'
29
29
 
30
30
  export type LocalUrlType =
@@ -44,218 +44,185 @@ export async function localUrl({
44
44
  localhost = false,
45
45
  https = undefined as boolean | undefined,
46
46
  network = undefined as boolean | undefined,
47
- } = {}) {
48
- // Ensure url starts with http:// or https://
49
- // if (!url.startsWith('http://') && !url.startsWith('https://'))
50
- // url = 'https://' + url
51
- let url
47
+ }: {
48
+ domain?: string
49
+ type?: LocalUrlType
50
+ network?: boolean
51
+ localhost?: boolean
52
+ https?: boolean
53
+ } = {}): Promise<string> {
54
+ let url = domain.replace(/\.[^.]+$/, '.localhost')
52
55
 
53
56
  switch (type) {
54
57
  case 'frontend':
55
- if (network) return await createLocalTunnel(config.ports?.frontend || 3000)
56
-
57
- if (localhost) return `http://localhost:${config.ports?.frontend}`
58
-
59
- url = domain.replace(/\.[^\.]+$/, '.localhost')
60
-
61
- if (https) return `https://${url}`
62
-
63
- return url
58
+ if (network)
59
+ return await createLocalTunnel(config.ports?.frontend || 3000)
60
+ if (localhost)
61
+ return `http://localhost:${config.ports?.frontend}`
62
+ break
64
63
  case 'backend':
65
- if (network) return await createLocalTunnel(config.ports?.backend || 3001)
66
-
67
- if (localhost) return `http://localhost:${config.ports?.backend}`
68
-
69
- url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
70
-
71
- if (https) return `https://${url}`
72
-
73
- return url
74
- case 'api':
75
- if (network) return await createLocalTunnel(config.ports?.backend || 3001)
76
-
77
- if (localhost) return `http://localhost:${config.ports?.backend}`
78
-
79
- url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
80
-
81
- if (https) return `https://${url}`
82
-
83
- return url
64
+ if (network)
65
+ return await createLocalTunnel(config.ports?.backend || 3001)
66
+ if (localhost)
67
+ return `http://localhost:${config.ports?.backend}`
68
+ url = `api.${url}`
69
+ break
84
70
  case 'admin':
85
- if (network) return await createLocalTunnel(config.ports?.admin || 3002)
86
-
87
- if (localhost) return `http://localhost:${config.ports?.admin}`
88
-
89
- url = domain.replace(/\.[^\.]+$/, '.localhost/admin/')
90
-
91
- if (https) return `https://${url}`
92
-
93
- return url
71
+ if (network)
72
+ return await createLocalTunnel(config.ports?.admin || 3002)
73
+ if (localhost)
74
+ return `http://localhost:${config.ports?.admin}`
75
+ url = `admin.${url}`
76
+ break
94
77
  case 'library':
95
- if (network) return await createLocalTunnel(config.ports?.library || 3003)
96
-
97
- if (localhost) return `http://localhost:${config.ports?.library}`
98
-
99
- url = domain.replace(/\.[^\.]+$/, '.localhost/libs/')
100
-
101
- if (https) return `https://${url}`
102
-
103
- return url
78
+ if (network)
79
+ return await createLocalTunnel(config.ports?.library || 3003)
80
+ if (localhost)
81
+ return `http://localhost:${config.ports?.library}`
82
+ url = `libs.${url}`
83
+ break
104
84
  case 'email':
105
- if (network) return await createLocalTunnel(config.ports?.email || 3005)
106
-
107
- if (localhost) return `http://localhost:${config.ports?.email}`
108
-
109
- url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
110
-
111
- if (https) return `https://${url}`
112
-
113
- return url
85
+ if (network)
86
+ return await createLocalTunnel(config.ports?.email || 3005)
87
+ if (localhost)
88
+ return `http://localhost:${config.ports?.email}`
89
+ url = `email.${url}`
90
+ break
114
91
  case 'desktop':
115
- if (network) return await createLocalTunnel(config.ports?.desktop || 3004)
116
-
117
- if (localhost) return `http://localhost:${config.ports?.email}`
118
-
119
- url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
120
-
121
- if (https) return `https://${url}`
122
-
123
- return url
92
+ if (network)
93
+ return await createLocalTunnel(config.ports?.desktop || 3004)
94
+ if (localhost)
95
+ return `http://localhost:${config.ports?.desktop}`
96
+ url = `desktop.${url}`
97
+ break
124
98
  case 'docs':
125
- if (network) return await createLocalTunnel(config.ports?.desktop || 3006)
126
-
127
- if (localhost) return `http://localhost:${config.ports?.docs}`
128
-
129
- url = domain.replace(/\.[^\.]+$/, '.localhost/docs/')
130
-
131
- if (https) return `https://${url}`
132
-
133
- return url
99
+ if (network)
100
+ return await createLocalTunnel(config.ports?.docs || 3006)
101
+ if (localhost)
102
+ return `http://localhost:${config.ports?.docs}`
103
+ url = `docs.${url}`
104
+ break
134
105
  case 'inspect':
135
- if (network) return await createLocalTunnel(config.ports?.desktop || 3007)
136
-
137
- if (localhost) return `http://localhost:${config.ports?.inspect}`
138
-
139
- url = domain.replace(/\.[^\.]+$/, '.localhost/__inspect/')
140
-
141
- if (https) return `https://${url}`
142
-
143
- return url
106
+ if (network)
107
+ return await createLocalTunnel(config.ports?.inspect || 3007)
108
+ if (localhost)
109
+ return `http://localhost:${config.ports?.inspect}`
110
+ url = `inspect.${url}`
111
+ break
144
112
  default:
145
- if (localhost) return `http://localhost:${config.ports?.frontend}`
146
-
147
- url = domain.replace(/\.[^\.]+$/, '.localhost')
148
-
149
- if (https) return `https://${url}`
150
-
151
- return url
113
+ if (localhost)
114
+ return `http://localhost:${config.ports?.frontend}`
152
115
  }
116
+
117
+ if (https)
118
+ return `https://${url}`
119
+ return `http://${url}`
153
120
  }
154
121
 
155
- export function defineStacksConfig(config: StacksConfig) {
122
+ export function defineStacksConfig(config: StacksConfig): StacksConfig {
156
123
  return config
157
124
  }
158
125
 
159
- export function defineApp(config: AppConfig) {
126
+ export function defineApp(config: AppConfig): AppConfig {
160
127
  return config
161
128
  }
162
129
 
163
- export function defineCache(config: CacheConfig) {
130
+ export function defineCache(config: CacheConfig): CacheConfig {
164
131
  return config
165
132
  }
166
133
 
167
- export function defineCdn(config: CdnConfig) {
134
+ export function defineCdn(config: CdnConfig): CdnConfig {
168
135
  return config
169
136
  }
170
137
 
171
- export function defineChat(config: ChatConfig) {
138
+ export function defineChat(config: ChatConfig): ChatConfig {
172
139
  return config
173
140
  }
174
141
 
175
- export function defineCli(config: CliConfig) {
142
+ export function defineCli(config: CliConfig): CliConfig {
176
143
  return config
177
144
  }
178
145
 
179
- export function defineJob(config: JobConfig) {
146
+ export function defineJob(config: JobConfig): JobConfig {
180
147
  return config
181
148
  }
182
149
 
183
- export function defineCronJob(config: JobConfig) {
150
+ export function defineCronJob(config: JobConfig): JobConfig {
184
151
  return config
185
152
  }
186
153
 
187
- export function defineDatabase(config: DatabaseConfig) {
154
+ export function defineDatabase(config: DatabaseConfig): DatabaseConfig {
188
155
  return config
189
156
  }
190
157
 
191
- export function defineDependencies(config: DependenciesConfig) {
158
+ export function defineDependencies(config: DependenciesConfig): DependenciesConfig {
192
159
  return config
193
160
  }
194
161
 
195
- export function defineDns(config: DnsConfig) {
162
+ export function defineDns(config: DnsConfig): DnsConfig {
196
163
  return config
197
164
  }
198
165
 
199
- export function defineEmailConfig(config: EmailConfig) {
166
+ export function defineEmailConfig(config: EmailConfig): EmailConfig {
200
167
  return config
201
168
  }
202
169
 
203
- export function defineEmail(config: EmailConfig) {
170
+ export function defineEmail(config: EmailConfig): EmailConfig {
204
171
  return config
205
172
  }
206
173
 
207
- export function defineGit(config: GitConfig) {
174
+ export function defineGit(config: GitConfig): GitConfig {
208
175
  return config
209
176
  }
210
177
 
211
- export function defineHashing(config: HashingConfig) {
178
+ export function defineHashing(config: HashingConfig): HashingConfig {
212
179
  return config
213
180
  }
214
181
 
215
- export function defineLibrary(config: LibraryConfig) {
182
+ export function defineLibrary(config: LibraryConfig): LibraryConfig {
216
183
  return config
217
184
  }
218
185
 
219
- export function defineNotification(config: NotificationConfig) {
186
+ export function defineNotification(config: NotificationConfig): NotificationConfig {
220
187
  return config
221
188
  }
222
189
 
223
- export function definePayment(config: PaymentConfig) {
190
+ export function definePayment(config: PaymentConfig): PaymentConfig {
224
191
  return config
225
192
  }
226
193
 
227
- export function defineQueue(config: QueueConfig) {
194
+ export function defineQueue(config: QueueConfig): QueueConfig {
228
195
  return config
229
196
  }
230
197
 
231
- export function defineSearchEngine(config: SearchEngineConfig) {
198
+ export function defineSearchEngine(config: SearchEngineConfig): SearchEngineConfig {
232
199
  return config
233
200
  }
234
201
 
235
- export function defineSecurity(config: SecurityConfig) {
202
+ export function defineSecurity(config: SecurityConfig): SecurityConfig {
236
203
  return config
237
204
  }
238
205
 
239
- export function defineServices(config: ServicesConfig) {
206
+ export function defineServices(config: ServicesConfig): ServicesConfig {
240
207
  return config
241
208
  }
242
209
 
243
- export function defineSms(config: any) {
210
+ export function defineSms(config: any): any {
244
211
  return config
245
212
  }
246
213
 
247
- export function defineStorage(config: StorageConfig) {
214
+ export function defineStorage(config: StorageConfig): StorageConfig {
248
215
  return config
249
216
  }
250
217
 
251
- export function defineUi(config: UiConfig) {
218
+ export function defineUi(config: UiConfig): UiConfig {
252
219
  return config
253
220
  }
254
221
 
255
- export function defineModel(config: Model) {
222
+ export function defineModel(config: Model): Model {
256
223
  return config
257
224
  }
258
225
 
259
- export function defineEvents(config: Events) {
226
+ export function defineEvents(config: Events): Events {
260
227
  return config
261
228
  }
package/src/overrides.ts CHANGED
@@ -25,8 +25,7 @@ import team from '~/config/team'
25
25
  import ui from '~/config/ui'
26
26
  // import docs from '~/docs/config'
27
27
 
28
- // this "user config" will override the default config options
29
- export default {
28
+ const config: StacksConfig = {
30
29
  ai,
31
30
  analytics,
32
31
  app,
@@ -52,4 +51,6 @@ export default {
52
51
  storage,
53
52
  team,
54
53
  ui,
55
- } satisfies StacksConfig
54
+ }
55
+
56
+ export default config