Skip to content

Commit 86a9bcf

Browse files
committed
chore: wip
1 parent 1f955fe commit 86a9bcf

File tree

11 files changed

+266
-321
lines changed

11 files changed

+266
-321
lines changed

.stacks/auto-imports.d.ts

Lines changed: 147 additions & 174 deletions
Large diffs are not rendered by default.

.stacks/core/build/src/stacks.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,15 @@ function autoImports(options?: AutoImportsOptions) {
9595
p.aiPath('src'),
9696
p.arraysPath('src'),
9797
p.authPath('src'),
98-
p.authPath('src'),
9998
p.cachePath('src'),
10099
p.chatPath('src'),
101-
p.collectionsPath('src'),
102100
p.databasePath('src'),
103101
p.desktopPath('src'),
104-
p.emailPath('src'),
102+
p.emailPath('src/index'),
105103
p.errorHandlingPath('src'),
106104
p.eventsPath('src'),
107105
p.healthPath('src'),
108-
p.lintPath('src'),
106+
p.lintPath('src/index'),
109107
p.loggingPath('src'),
110108
p.notificationsPath('src'),
111109
p.objectsPath('src'),
@@ -121,7 +119,6 @@ function autoImports(options?: AutoImportsOptions) {
121119
p.storagePath('src'),
122120
p.stringsPath('src'),
123121
p.tablesPath('src'),
124-
p.stringsPath('src'),
125122
p.testingPath('src'),
126123
p.uiPath('src'),
127124
p.utilsPath('src'),

.stacks/core/email/src/tailwind.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { notification } from '@stacksjs/config'
33
const email = notification.email
44

55
export const config = {
6-
...email.build,
6+
...email?.build,
77
theme: {
88
screens: {
99
sm: '480px',

.stacks/core/lint/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import eslint from 'eslint'
22

3-
export default eslint
3+
export { eslint }

.stacks/core/search-engine/src/index.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,4 @@ export function calculatePagination() {
6464
}
6565

6666
// it needs these exports
67-
// currentPage, filterName, filters, goToNextPage, goToPage, goToPrevPage, hits, index, lastPageNumber, perPage, query, results, search, searchFilters, searchParams, setTotalHits, sort, sorts, totalPages
68-
69-
export default {
70-
useSearchEngine,
71-
client,
72-
search,
73-
calculatePagination,
74-
currentPage,
75-
totalPages,
76-
filterName,
77-
filters,
78-
goToNextPage,
79-
goToPage,
80-
goToPrevPage,
81-
hits,
82-
index,
83-
searchFilters,
84-
searchParams,
85-
setTotalHits,
86-
sort,
87-
sorts,
88-
}
67+
// currentPage, filterName, filters, goToNextPage, goToPage, goToPrevPage, hits, index, lastPageNumber, perPage, query, results, search, searchFilters, searchParams, setTotalHits, sort, sorts, totalPages

.stacks/core/strings/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './case'
22
export * from './utils'
33
export * from './pluralize'
4-
export * from './validation'

.stacks/core/utils/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export * from './equal'
77
export * from './function'
88
export * from './guards'
99
export * from './helpers'
10-
export * from './is'
1110
export * from './p'
1211
export type { SingletonPromiseReturn, ControlledPromise } from './promise'
1312
export { createSingletonPromise, createPromiseLock, createControlledPromise, sleep } from './promise'

.stacks/core/utils/src/is.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

.stacks/core/validation/src/index.ts

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,2 @@
1-
import { z as validate, z } from 'zod'
2-
3-
export const envVariables = validate.object({
4-
APP_NAME: validate.string().default('Stacks').optional(),
5-
APP_ENV: validate.string().default('local').optional(),
6-
APP_KEY: validate.string(),
7-
APP_URL: validate.string().url().default('http://localhost:3333'),
8-
APP_DEBUG: validate.boolean().default(true),
9-
DB_CONNECTION: validate.string().default('mysql').optional(),
10-
DB_DATABASE: validate.string().default('stacks').optional(),
11-
DB_USERNAME: validate.string().default('root').optional(),
12-
DB_PASSWORD: validate.string().optional(),
13-
SEARCH_ENGINE_DRIVER: validate.string().optional(),
14-
MEILISEARCH_HOST: validate.string().optional().default('http://127.0.0.1:7700'),
15-
MEILISEARCH_KEY: validate.string().optional(),
16-
})
17-
18-
export type StacksEnv = validate.infer<typeof envVariables>
19-
20-
export enum Type {
21-
String = 'String',
22-
Number = 'Number',
23-
Boolean = 'Boolean',
24-
Date = 'Date',
25-
Object = 'Object',
26-
Array = 'Array',
27-
}
28-
29-
export { validate, z }
1+
export * from './is'
2+
export * from './validate'

.stacks/core/strings/src/validation.ts renamed to .stacks/core/validation/src/is.ts

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getTypeName, toString } from '@stacksjs/utils'
12
import validator from 'validator'
23
import type { HashAlgorithm } from '@stacksjs/types'
34

@@ -41,10 +42,6 @@ export function isNumeric(number: string) {
4142
return validator.isNumeric(number)
4243
}
4344

44-
export function isBoolean(boolean: string) {
45-
return validator.isBoolean(boolean)
46-
}
47-
4845
export function isHexColor(color: string) {
4946
return validator.isHexColor(color)
5047
}
@@ -180,3 +177,85 @@ export function isISO31661Alpha2(iso31661Alpha2: string) {
180177
export function isISO31661Alpha3(iso31661Alpha3: string) {
181178
return validator.isISO31661Alpha3(iso31661Alpha3)
182179
}
180+
181+
export function isDef<T = any>(val?: T): val is T {
182+
return typeof val !== 'undefined'
183+
}
184+
export function isBoolean(val: any): val is boolean {
185+
return typeof val === 'boolean'
186+
}
187+
export function isFunction<T extends Function>(val: any): val is T {
188+
return typeof val === 'function'
189+
}
190+
export function isNumber(val: any): val is number {
191+
return typeof val === 'number'
192+
}
193+
export function isString(val: unknown): val is string {
194+
return typeof val === 'string'
195+
}
196+
export function isObject(val: any): val is object {
197+
return toString(val) === '[object Object]'
198+
}
199+
export function isWindow(val: any): boolean {
200+
return typeof window !== 'undefined' && toString(val) === '[object Window]'
201+
}
202+
export const isBrowser = typeof window !== 'undefined'
203+
export const isServer = typeof document === 'undefined' // https://remix.run/docs/en/v1/pages/gotchas#typeof-window-checks
204+
export function isMap(val: any): val is Map<any, any> {
205+
return toString(val) === '[object Map]'
206+
}
207+
export function isSet(val: any): val is Set<any> {
208+
return toString(val) === '[object Set]'
209+
}
210+
export function isPromise<T = any>(val: any): val is Promise<T> {
211+
return toString(val) === '[object Promise]'
212+
}
213+
export function isUndefined(v: any) {
214+
return getTypeName(v) === 'undefined'
215+
}
216+
export function isNull(v: any) {
217+
return getTypeName(v) === 'null'
218+
}
219+
export function isSymbol(v: any) {
220+
return getTypeName(v) === 'symbol'
221+
}
222+
export function isDate(v: any) {
223+
return getTypeName(v) === 'date'
224+
}
225+
export function isRegExp(v: any) {
226+
return getTypeName(v) === 'regexp'
227+
}
228+
export function isArray(v: any) {
229+
return getTypeName(v) === 'array'
230+
}
231+
export function isPrimitive(v: any) {
232+
const type = getTypeName(v)
233+
return type === 'null' || type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean' || type === 'symbol'
234+
}
235+
export function isInteger(v: any) {
236+
return isNumber(v) && Number.isInteger(v)
237+
}
238+
export function isFloat(v: any) {
239+
return isNumber(v) && !Number.isInteger(v)
240+
}
241+
export function isPositive(v: any) {
242+
return isNumber(v) && v > 0
243+
}
244+
export function isNegative(v: any) {
245+
return isNumber(v) && v < 0
246+
}
247+
export function isEven(v: any) {
248+
return isNumber(v) && v % 2 === 0
249+
}
250+
export function isOdd(v: any) {
251+
return isNumber(v) && v % 2 !== 0
252+
}
253+
export function isEvenOrOdd(v: any) {
254+
return isNumber(v) && (v % 2 === 0 ? 'even' : 'odd')
255+
}
256+
export function isPositiveOrNegative(v: any) {
257+
return isNumber(v) && (v > 0 ? 'positive' : 'negative')
258+
}
259+
export function isIntegerOrFloat(v: any) {
260+
return isNumber(v) && (Number.isInteger(v) ? 'integer' : 'float')
261+
}

0 commit comments

Comments
 (0)