Skip to content

Commit 578d3fb

Browse files
committed
chore: wip
1 parent 6c4af2d commit 578d3fb

File tree

10 files changed

+137
-167
lines changed

10 files changed

+137
-167
lines changed

.stacks/core/ai/build.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineBuildConfig({
44
alias,
55

66
entries: [
7+
'./src/drivers/openai',
78
'./src/index',
89
],
910

.stacks/core/ai/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"import": "./dist/index.mjs"
3030
},
3131
"./openai": {
32-
"types": "./dist/drivers/openai.d.ts",
33-
"import": "./dist/drivers/openai.mjs"
32+
"types": "./dist/openai.d.ts",
33+
"import": "./dist/openai.mjs"
3434
}
3535
},
3636
"module": "dist/index.mjs",

.stacks/core/objects/build.config.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ export default defineBuildConfig({
44
alias,
55

66
entries: [
7-
{
8-
builder: 'mkdist',
9-
input: './src/',
10-
outDir: './dist/',
11-
format: 'esm',
12-
},
7+
'./src/index',
138
],
149

10+
externals: [
11+
'@stacksjs/collections',
12+
'@stacksjs/types',
13+
'@stacksjs/utils',
14+
'@stacksjs/validation',
15+
],
16+
17+
rollup: {
18+
inlineDependencies: true,
19+
},
20+
1521
clean: true,
1622
declaration: true,
1723
})

.stacks/core/objects/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"dependencies": {
4747
"@stacksjs/collections": "workspace:*",
4848
"@stacksjs/types": "workspace:*",
49-
"@stacksjs/utils": "workspace:*"
49+
"@stacksjs/utils": "workspace:*",
50+
"@stacksjs/validation": "workspace:*"
5051
},
5152
"devDependencies": {
5253
"@stacksjs/development": "workspace:*"

.stacks/core/strings/src/is.ts

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getTypeName, toString } from '@stacksjs/utils'
21
import type { HashAlgorithm } from '@stacksjs/types'
32
import v from 'validator'
43

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './is'
12
export * from './rules'
23
export * from './validate'
34
export * from './types'

.stacks/core/validation/src/is.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { getTypeName, toString } from '@stacksjs/utils'
2+
3+
export function isDef<T = any>(val?: T): val is T {
4+
return typeof val !== 'undefined'
5+
}
6+
7+
export function isBoolean(val: any): val is boolean {
8+
return typeof val === 'boolean'
9+
}
10+
11+
export function isFunction<T extends Function>(val: any): val is T {
12+
return typeof val === 'function'
13+
}
14+
15+
export function isNumber(val: any): val is number {
16+
return typeof val === 'number'
17+
}
18+
19+
export function isString(val: unknown): val is string {
20+
return typeof val === 'string'
21+
}
22+
23+
export function isObject(val: any): val is object {
24+
return toString(val) === '[object Object]'
25+
}
26+
27+
export function isWindow(val: any): boolean {
28+
return typeof window !== 'undefined' && toString(val) === '[object Window]'
29+
}
30+
31+
export const isBrowser = typeof window !== 'undefined'
32+
33+
export const isServer = typeof document === 'undefined' // https://remix.run/docs/en/v1/pages/gotchas#typeof-window-checks
34+
35+
export function isMap(val: any): val is Map<any, any> {
36+
return toString(val) === '[object Map]'
37+
}
38+
39+
export function isSet(val: any): val is Set<any> {
40+
return toString(val) === '[object Set]'
41+
}
42+
43+
export function isPromise<T = any>(val: any): val is Promise<T> {
44+
return toString(val) === '[object Promise]'
45+
}
46+
47+
export function isUndefined(v: any) {
48+
return getTypeName(v) === 'undefined'
49+
}
50+
51+
export function isNull(v: any) {
52+
return getTypeName(v) === 'null'
53+
}
54+
55+
export function isSymbol(v: any) {
56+
return getTypeName(v) === 'symbol'
57+
}
58+
59+
export function isDate(v: any) {
60+
return getTypeName(v) === 'date'
61+
}
62+
63+
export function isRegExp(v: any) {
64+
return getTypeName(v) === 'regexp'
65+
}
66+
67+
export function isArray(v: any) {
68+
return getTypeName(v) === 'array'
69+
}
70+
71+
export function isPrimitive(v: any) {
72+
const type = getTypeName(v)
73+
return type === 'null' || type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean' || type === 'symbol'
74+
}
75+
76+
export function isInteger(v: any) {
77+
return isNumber(v) && Number.isInteger(v)
78+
}
79+
80+
export function isFloat(v: any) {
81+
return isNumber(v) && !Number.isInteger(v)
82+
}
83+
84+
export function isPositive(v: any) {
85+
return isNumber(v) && v > 0
86+
}
87+
88+
export function isNegative(v: any) {
89+
return isNumber(v) && v < 0
90+
}
91+
92+
export function isEven(v: any) {
93+
return isNumber(v) && v % 2 === 0
94+
}
95+
96+
export function isOdd(v: any) {
97+
return isNumber(v) && v % 2 !== 0
98+
}
99+
100+
export function isEvenOrOdd(v: any) {
101+
return isNumber(v) && (v % 2 === 0 ? 'even' : 'odd')
102+
}
103+
104+
export function isPositiveOrNegative(v: any) {
105+
return isNumber(v) && (v > 0 ? 'positive' : 'negative')
106+
}
107+
108+
export function isIntegerOrFloat(v: any) {
109+
return isNumber(v) && (Number.isInteger(v) ? 'integer' : 'float')
110+
}

.stacks/core/validation/src/types/env.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import process from 'node:process'
2+
import type { VineObject } from '@vinejs/vine'
23
import validator from '@vinejs/vine'
34
import type { Infer } from '@vinejs/vine/build/src/types'
45
import { loadEnv } from 'vite'
@@ -116,12 +117,12 @@ const envSchema = validator.object({
116117
MICROSOFT_TEAMS_APPLICATION_ID: validator.string().optional(),
117118
MICROSOFT_TEAMS_CLIENT_ID: validator.string().optional(),
118119
MICROSOFT_TEAMS_SECRET: validator.string().optional(),
119-
})
120+
}) as VineObject<any, any, any>
120121

121122
const frontendEnvSchema = validator.object({
122123
FRONTEND_APP_ENV: validator.enum(['local', 'development', 'staging', 'production']).optional(),
123124
FRONTEND_APP_URL: validator.string().optional(),
124-
})
125+
}) as VineObject<any, any, any>
125126

126127
export type Env = Infer<typeof envSchema>
127128
export type EnvKeys = keyof Env

config/email.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineEmailConfig } from 'stacks/core/utils/src'
2-
import { env } from '@stacksjs/validation'
2+
import { env } from 'stacks/core/validation/src'
33
import app from './app'
44

55
/**

pnpm-lock.yaml

Lines changed: 5 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)