@xrystal/core 3.44.0 → 3.45.1
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/README.md +6 -8
- package/package.json +2 -2
- package/x/bin/commands/doctor.mjs +9 -8
- package/x/bin/commands/project.mjs +1 -1
- package/x/bin/commands/release.mjs +2 -2
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +1 -0
- package/x/bin/helpers/.generated/tmp-schema.mjs +1 -0
- package/x/bin/helpers/cli-help.mjs +5 -4
- package/x/bin/helpers/cli-identity.mjs +6 -0
- package/x/bin/helpers/package-defaults.mjs +100 -5
- package/x/bin/helpers/project-artifacts.mjs +2 -2
- package/x/bin/main-cli.js +8 -4
- package/x/bin/scripts/clean-source-types.mjs +5 -2
- package/x/bin/scripts/prepare-npm-publish.mjs +9 -7
- package/x/bin/scripts/publish-guard.mjs +7 -5
- package/x/dist/loader/controller/index.js +1 -1
- package/x/dist/utils/constants/defaults.json +1 -0
- package/x/dist/utils/constants/index.d.ts +3 -0
- package/x/dist/utils/constants/index.js +1 -1
- package/x/dist/utils/helpers/handlers/adapters.js +1 -1
- package/x/dist/utils/helpers/protocol/index.d.ts +1 -1
- package/x/dist/utils/helpers/protocol/index.js +1 -1
- package/x/dist/utils/helpers/state/props-from-tmp.d.ts +1 -1
- package/x/dist/utils/helpers/state/props-from-tmp.js +1 -1
- package/x/dist/utils/helpers/state/request-key-guard.d.ts +1 -1
- package/x/dist/utils/helpers/state/request-key-guard.js +1 -1
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -1
- package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -1
package/README.md
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
> **EN** — Microservice runtime: Express or Elysia HTTP, DI loaders, live `tmp.yml`, standardized API responses.
|
|
4
4
|
> **TR** — Microservice runtime: Express veya Elysia HTTP, DI loader'lar, canlı `tmp.yml`, standart API cevapları.
|
|
5
5
|
|
|
6
|
-
**CLI:** `xry` · **Version:** `3.
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.45.1` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
## What's new in 3.
|
|
10
|
+
## What's new in 3.45.1 / 3.45.1'da ne değişti
|
|
11
11
|
|
|
12
12
|
| Change / Değişiklik | EN | TR |
|
|
13
13
|
|---------------------|----|----|
|
|
14
|
-
| **
|
|
15
|
-
|
|
|
16
|
-
| **CLI banner** | Leads with `@xrystal/core` (bin still `xry`) | Banner paket adıyla açılır |
|
|
17
|
-
| **Runtime coverage** | bun + node runners / bundler `auto` tested | Her iki runtime doğrulandı |
|
|
14
|
+
| **No silent fallbacks** | Missing `cliBinFile` / `paths.source` throws | Eksikse uyarır, sessiz fallback yok |
|
|
15
|
+
| **Doctor labels** | Uses `paths.*` keys from tmp | Klasör adı hardcode değil |
|
|
18
16
|
|
|
19
|
-
Carried from **3.
|
|
17
|
+
Carried from **3.45.0:** CLI identity = `@xrystal/core`, brand hardcode cleanup, publish path SSOT.
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
20
|
npx xry sync # force-apply tmp.yml → tsconfig (usually auto)
|
|
@@ -81,7 +79,7 @@ npx xry doctor # EN: optional health check · TR: isteğe bağlı sağlı
|
|
|
81
79
|
```json
|
|
82
80
|
{
|
|
83
81
|
"dependencies": {
|
|
84
|
-
"@xrystal/core": "^3.
|
|
82
|
+
"@xrystal/core": "^3.45.1",
|
|
85
83
|
"elysia": "^1.4.19"
|
|
86
84
|
},
|
|
87
85
|
"scripts": {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "3.45.1",
|
|
5
|
+
"description": "microservice runtime library",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -73,11 +73,12 @@ export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
73
73
|
printSection('Project')
|
|
74
74
|
console.log(` ${'root'.padEnd(18)}${chalk.bold(root)}`)
|
|
75
75
|
if (distLayout) {
|
|
76
|
-
|
|
77
|
-
console.log(` ${'
|
|
78
|
-
console.log(` ${'
|
|
76
|
+
const layout = distLayout.layout
|
|
77
|
+
console.log(` ${'paths.root'.padEnd(18)}${chalk.bold(distLayout.rootFolderPath)}`)
|
|
78
|
+
console.log(` ${'paths.source'.padEnd(18)}${chalk.bold(layout.mainFolderPath)}`)
|
|
79
|
+
console.log(` ${'paths.special.dist'.padEnd(18)}${chalk.bold(distLayout.distPrefix)}`)
|
|
79
80
|
} else {
|
|
80
|
-
console.log(chalk.yellow(` layout: tmp.yml not resolved — run ${CLI_PRIMARY_NAME} tmp`))
|
|
81
|
+
console.log(chalk.yellow(` layout: tmp.yml not resolved — run ${CLI_PRIMARY_NAME} tmp (then sync heals tsconfig)`))
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
printSection('CLI (tool)')
|
|
@@ -143,15 +144,15 @@ export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
143
144
|
|
|
144
145
|
printSection('Toolchain')
|
|
145
146
|
const toolchain = resolveToolchainPathsFromProject(root)
|
|
146
|
-
console.log(` ${'source'.padEnd(18)}${chalk.bold(toolchain.mainSourceRel)}`)
|
|
147
|
-
console.log(` ${'outDir'.padEnd(18)}${chalk.bold(toolchain.outDir)}`)
|
|
147
|
+
console.log(` ${'paths.source'.padEnd(18)}${chalk.bold(toolchain.mainSourceRel)}`)
|
|
148
|
+
console.log(` ${'outDir'.padEnd(18)}${chalk.bold(toolchain.outDir)} ${chalk.gray('(← paths.special.dist)')}`)
|
|
148
149
|
const tsAudit = auditTsconfigAlignment(root)
|
|
149
150
|
if (tsAudit.missing) {
|
|
150
|
-
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}missing
|
|
151
|
+
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}missing — will auto-heal on next command / ${CLI_PRIMARY_NAME} sync`))
|
|
151
152
|
} else if (tsAudit.ok) {
|
|
152
153
|
console.log(chalk.green(` ${'tsconfig'.padEnd(18)}aligned with tmp.yml`))
|
|
153
154
|
} else {
|
|
154
|
-
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}drift
|
|
155
|
+
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}drift — auto-heal on next command / ${CLI_PRIMARY_NAME} sync`))
|
|
155
156
|
for (const note of tsAudit.notes) console.log(chalk.gray(` · ${note}`))
|
|
156
157
|
}
|
|
157
158
|
console.log(` ${'eslint'.padEnd(18)}${toolchain.eslintFiles.join(', ')}`)
|
|
@@ -41,7 +41,7 @@ function resolveTestTarget(root) {
|
|
|
41
41
|
export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
42
42
|
cli
|
|
43
43
|
.command('dev')
|
|
44
|
-
.description('Watch
|
|
44
|
+
.description('Watch TypeScript entry with dev env files')
|
|
45
45
|
.action(() => {
|
|
46
46
|
const root = getProjectRoot()
|
|
47
47
|
const { layout, runtime } = readTmpBuildContext(root)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { readCliPackageJson, readProjectPackageJson, getProjectRoot } from '../helpers/project-root.mjs'
|
|
3
3
|
import { compareSemver, getVersionState, resolveVersionBaseline, runTagRelease } from '../scripts/version-check.mjs'
|
|
4
|
-
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
4
|
+
import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
5
5
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
6
6
|
|
|
7
7
|
export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
@@ -40,7 +40,7 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
40
40
|
const projectPkg = readProjectPackageJson(root)
|
|
41
41
|
const state = getVersionState('HEAD', root)
|
|
42
42
|
|
|
43
|
-
console.log(chalk.cyan(`\n${
|
|
43
|
+
console.log(chalk.cyan(`\n${PACKAGE_NAME} version\n`))
|
|
44
44
|
console.log(chalk.gray(' CLI (tool)'))
|
|
45
45
|
console.log(` ${packageDefaults.packageName}: ${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
46
46
|
console.log('')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import { CLI_BIN_NAMES, CLI_PRIMARY_NAME } from './cli-identity.mjs'
|
|
3
|
+
import { CLI_BIN_NAMES, CLI_PRIMARY_NAME, PACKAGE_NAME } from './cli-identity.mjs'
|
|
4
4
|
|
|
5
5
|
export const LIST_BULLET = chalk.cyan('◆')
|
|
6
6
|
import { brandTitle } from './banner.mjs'
|
|
@@ -8,7 +8,7 @@ import { packageDefaults } from './package-defaults.mjs'
|
|
|
8
8
|
|
|
9
9
|
const QUICK_COMMANDS = [
|
|
10
10
|
{ cmd: 'create', hint: '<name> [path]', desc: 'Scaffold service · path defaults to cwd' },
|
|
11
|
-
{ cmd: 'dev', desc: 'Watch
|
|
11
|
+
{ cmd: 'dev', desc: 'Watch TypeScript entry + dev env' },
|
|
12
12
|
{ cmd: 'build', desc: 'Bundle to dist/ (tmp.yml layout)' },
|
|
13
13
|
{ cmd: 'start', desc: 'Run production dist/index.js' },
|
|
14
14
|
{ cmd: 'test', desc: 'Run tests folder from tmp.yml' },
|
|
@@ -31,7 +31,7 @@ const COMMAND_GROUPS = [
|
|
|
31
31
|
{ cmd: 'tmp', desc: 'Ensure tmp.yml exists (runtime config seed)' },
|
|
32
32
|
{ cmd: 'hooks install', desc: 'Install .git/hooks pre-commit version check' },
|
|
33
33
|
{ cmd: 'hooks status', desc: 'Show whether pre-commit hook is installed' },
|
|
34
|
-
{ cmd: 'sync', desc: '
|
|
34
|
+
{ cmd: 'sync', desc: 'Force-sync tsconfig from tmp.yml (auto-heals otherwise)' },
|
|
35
35
|
],
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -112,7 +112,8 @@ export function formatRootHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
112
112
|
|
|
113
113
|
return [
|
|
114
114
|
chalk.bold.white(`\n Usage`),
|
|
115
|
-
chalk.gray(` ${
|
|
115
|
+
chalk.gray(` ${PACKAGE_NAME} [options] [command]`),
|
|
116
|
+
chalk.dim(` invoke: ${cliName}`),
|
|
116
117
|
...sections,
|
|
117
118
|
formatOptionsSection(cliName),
|
|
118
119
|
].join('\n')
|
|
@@ -10,22 +10,81 @@ import {
|
|
|
10
10
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
11
11
|
const packageRoot = path.resolve(here, '..', '..', '..')
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const REQUIRED_IDENTITY_KEYS = [
|
|
14
|
+
'packageName',
|
|
15
|
+
'packageRootFolder',
|
|
16
|
+
'cliName',
|
|
17
|
+
'cliBinFile',
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
function findAuthoredDefaultsPath(root) {
|
|
21
|
+
const matches = []
|
|
22
|
+
|
|
23
|
+
function walk(dir, depth = 0) {
|
|
24
|
+
if (depth > 6 || !fs.existsSync(dir)) return
|
|
25
|
+
let entries
|
|
26
|
+
try {
|
|
27
|
+
entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
28
|
+
} catch {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'x') continue
|
|
33
|
+
const full = path.join(dir, entry.name)
|
|
34
|
+
if (entry.isDirectory()) {
|
|
35
|
+
walk(full, depth + 1)
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
if (entry.name === 'defaults.json' && full.replace(/\\/g, '/').endsWith('utils/constants/defaults.json')) {
|
|
39
|
+
matches.push(full)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
walk(root)
|
|
45
|
+
return matches[0] ?? null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function assertIdentityDefaults(raw, sourceLabel) {
|
|
49
|
+
const missing = REQUIRED_IDENTITY_KEYS.filter((key) => {
|
|
50
|
+
const value = raw?.[key]
|
|
51
|
+
return value == null || String(value).trim() === ''
|
|
52
|
+
})
|
|
53
|
+
if (missing.length > 0) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`package defaults incomplete (${sourceLabel}): missing ${missing.join(', ')}`,
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(raw.cliBinNames) || raw.cliBinNames.length === 0) {
|
|
59
|
+
if (!raw.cliName) {
|
|
60
|
+
throw new Error(`package defaults incomplete (${sourceLabel}): cliBinNames or cliName required`)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
14
64
|
|
|
15
65
|
function loadRawDefaults() {
|
|
16
|
-
|
|
17
|
-
|
|
66
|
+
const authoredPath = findAuthoredDefaultsPath(packageRoot)
|
|
67
|
+
if (authoredPath && fs.existsSync(authoredPath)) {
|
|
68
|
+
const raw = JSON.parse(fs.readFileSync(authoredPath, 'utf8'))
|
|
69
|
+
assertIdentityDefaults(raw, authoredPath)
|
|
70
|
+
return raw
|
|
18
71
|
}
|
|
19
72
|
if (packageIdentityDefaults && typeof packageIdentityDefaults === 'object') {
|
|
73
|
+
assertIdentityDefaults(packageIdentityDefaults, 'embedded packageIdentityDefaults')
|
|
20
74
|
return packageIdentityDefaults
|
|
21
75
|
}
|
|
22
76
|
throw new Error(
|
|
23
|
-
|
|
77
|
+
'package defaults missing. Expected utils/constants/defaults.json in package root or embedded packageIdentityDefaults',
|
|
24
78
|
)
|
|
25
79
|
}
|
|
26
80
|
|
|
27
81
|
const raw = loadRawDefaults()
|
|
28
82
|
const seed = loadSeedLayoutFromBundledTmp(packageRoot, raw)
|
|
83
|
+
if (!seed?.mainSourceFolder || !String(seed.mainSourceFolder).trim()) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`${raw.packageName}: bundled tmp seed missing paths.source — cannot resolve main source folder`,
|
|
86
|
+
)
|
|
87
|
+
}
|
|
29
88
|
|
|
30
89
|
export const packageDefaults = Object.freeze({
|
|
31
90
|
...raw,
|
|
@@ -43,12 +102,48 @@ export const packageDefaults = Object.freeze({
|
|
|
43
102
|
export const coreVersionPattern = /^\d{2}\.\d{2}\.\d{2}-v\d+$/
|
|
44
103
|
export const semverVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/
|
|
45
104
|
|
|
105
|
+
export const PACKAGE_NAME = packageDefaults.packageName
|
|
46
106
|
export const CLI_PRIMARY_NAME = packageDefaults.cliName
|
|
47
107
|
export const CLI_BIN_NAMES = packageDefaults.cliBinNames
|
|
108
|
+
export const CLI_BIN_FILE = packageDefaults.cliBinFile
|
|
109
|
+
|
|
110
|
+
/** Commander / banner description from brand SSOT. */
|
|
111
|
+
export function packageCliDescription() {
|
|
112
|
+
const brand = packageDefaults.brand ?? {}
|
|
113
|
+
const title = [brand.primary, brand.secondary].filter(Boolean).join(' ')
|
|
114
|
+
const tagline = brand.tagline ? String(brand.tagline) : ''
|
|
115
|
+
if (title && tagline) return `${title} — ${tagline}`
|
|
116
|
+
if (!tagline) {
|
|
117
|
+
throw new Error(`${PACKAGE_NAME}: brand.tagline missing in defaults`)
|
|
118
|
+
}
|
|
119
|
+
return tagline
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Log / error prefix: always the npm package name. */
|
|
123
|
+
export function packageLogTag() {
|
|
124
|
+
return PACKAGE_NAME
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Relative bin entry for package.json / manifests. */
|
|
128
|
+
export function resolveCliBinEntry() {
|
|
129
|
+
if (!packageDefaults.packageRootFolder || !CLI_BIN_FILE) {
|
|
130
|
+
throw new Error(`${PACKAGE_NAME}: packageRootFolder/cliBinFile missing — check defaults.json`)
|
|
131
|
+
}
|
|
132
|
+
return `./${packageDefaults.packageRootFolder}/bin/${CLI_BIN_FILE}`
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Main source folder segment from tmp seed (no silent fallback). */
|
|
136
|
+
export function resolveMainSourceRel() {
|
|
137
|
+
const folder = packageDefaults.mainSourceFolder
|
|
138
|
+
if (!folder || !String(folder).trim()) {
|
|
139
|
+
throw new Error(`${PACKAGE_NAME}: paths.source missing from tmp seed — run sync / fix tmp.yml`)
|
|
140
|
+
}
|
|
141
|
+
return String(folder).replace(/^\.\//, '')
|
|
142
|
+
}
|
|
48
143
|
|
|
49
144
|
export function resolveInvokedAs(argv = process.argv) {
|
|
50
145
|
const base = path.basename(argv[1] || CLI_PRIMARY_NAME)
|
|
51
|
-
if (base ===
|
|
146
|
+
if (base === CLI_BIN_FILE) return CLI_PRIMARY_NAME
|
|
52
147
|
if (CLI_BIN_NAMES.includes(base)) return base
|
|
53
148
|
return CLI_PRIMARY_NAME
|
|
54
149
|
}
|
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
6
6
|
import { isCorePackageName } from './build-config.mjs'
|
|
7
7
|
import { auditTsconfigAlignment, syncProjectToolchain } from './toolchain-config.mjs'
|
|
8
8
|
import { ensureTmpFile, relativeFromRoot } from './tmp-layout.mjs'
|
|
9
|
-
import { packageDefaults } from './package-defaults.mjs'
|
|
9
|
+
import { packageDefaults, resolveCliBinEntry } from './package-defaults.mjs'
|
|
10
10
|
|
|
11
11
|
const CLI_BIN_DIR = path.dirname(fileURLToPath(import.meta.url))
|
|
12
12
|
const CLI_GENERATED_DIR = path.join(CLI_BIN_DIR, '.generated')
|
|
@@ -175,7 +175,7 @@ export function syncPackageManifest(root = process.cwd(), { write = true } = {})
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
const { distPrefix, distRel } = resolveDistLayout(root)
|
|
178
|
-
const binEntry =
|
|
178
|
+
const binEntry = resolveCliBinEntry()
|
|
179
179
|
const bin = Object.fromEntries(packageDefaults.cliBinNames.map((name) => [name, binEntry]))
|
|
180
180
|
|
|
181
181
|
const next = {
|
package/x/bin/main-cli.js
CHANGED
|
@@ -12,7 +12,11 @@ import { registerTagCommand, registerVersionCommand } from './commands/release.m
|
|
|
12
12
|
import { registerHooksCommand } from './commands/hooks.mjs'
|
|
13
13
|
import { printBanner, shouldShowBanner } from './helpers/banner.mjs'
|
|
14
14
|
import { formatRootHelp, formatCreateCommandHelp, isCreateHelpRequest, isRootHelpRequest, printQuickStartGuide } from './helpers/cli-help.mjs'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
PACKAGE_NAME,
|
|
17
|
+
packageCliDescription,
|
|
18
|
+
resolveInvokedAs,
|
|
19
|
+
} from './helpers/cli-identity.mjs'
|
|
16
20
|
import { readCliPackageJson, getProjectRoot } from './helpers/project-root.mjs'
|
|
17
21
|
import { ensureProjectArtifacts } from './helpers/project-artifacts.mjs'
|
|
18
22
|
|
|
@@ -49,9 +53,9 @@ if (isCreateHelpRequest()) {
|
|
|
49
53
|
const cli = new Command()
|
|
50
54
|
|
|
51
55
|
cli
|
|
52
|
-
.name(
|
|
53
|
-
.description(
|
|
54
|
-
.version(pkg.version, '-V, --version', `Show ${
|
|
56
|
+
.name(PACKAGE_NAME)
|
|
57
|
+
.description(packageCliDescription())
|
|
58
|
+
.version(pkg.version, '-V, --version', `Show ${PACKAGE_NAME} version`)
|
|
55
59
|
.configureHelp({
|
|
56
60
|
helpWidth: () => Math.min(100, Math.max(56, process.stdout.columns || 80)),
|
|
57
61
|
sortSubcommands: true,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
|
|
4
|
+
import { resolveMainSourceRel } from '../helpers/package-defaults.mjs'
|
|
5
|
+
|
|
4
6
|
const root = process.cwd()
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
+
const sourceRel = resolveMainSourceRel()
|
|
8
|
+
const sourceRoot = path.join(root, sourceRel)
|
|
9
|
+
const keepRel = path.join(sourceRel, 'utils', 'models', 'types', 'shims.d.ts')
|
|
7
10
|
|
|
8
11
|
function walk(dir) {
|
|
9
12
|
for (const name of fs.readdirSync(dir)) {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
+
import { packageDefaults, resolveMainSourceRel } from '../helpers/package-defaults.mjs'
|
|
4
5
|
import { PublishGuardError, runPublishGuards } from './publish-guard.mjs'
|
|
5
6
|
|
|
6
7
|
const root = process.cwd()
|
|
7
8
|
|
|
8
9
|
const pathsToRemove = [
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
resolveMainSourceRel(),
|
|
11
|
+
`${packageDefaults.packageRootFolder}/tests`,
|
|
11
12
|
'.github',
|
|
12
13
|
'.vscode',
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
`${packageDefaults.packageRootFolder}/logs`,
|
|
15
|
+
`${packageDefaults.packageRootFolder}/docker`,
|
|
15
16
|
'tsconfig.json',
|
|
16
17
|
'eslint.config.js',
|
|
17
18
|
'.gitignore',
|
|
@@ -25,14 +26,15 @@ for (const rel of pathsToRemove) {
|
|
|
25
26
|
console.log(`prepare-npm-publish: removed ${rel}`)
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const distRel = path.join(packageDefaults.packageRootFolder, packageDefaults.layoutPaths.dist)
|
|
30
|
+
if (!fs.existsSync(path.join(root, distRel))) {
|
|
31
|
+
console.error(`prepare-npm-publish: ${distRel} missing — run build first`)
|
|
30
32
|
process.exit(1)
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
try {
|
|
34
36
|
const { jsCount } = runPublishGuards(root, { strictDisk: true })
|
|
35
|
-
console.log(`prepare-npm-publish: ready (${jsCount} .js in
|
|
37
|
+
console.log(`prepare-npm-publish: ready (${jsCount} .js in ${distRel}, verified)`)
|
|
36
38
|
} catch (error) {
|
|
37
39
|
console.error(`prepare-npm-publish: ✗ ${error instanceof PublishGuardError ? error.message : error.message}`)
|
|
38
40
|
process.exit(1)
|
|
@@ -2,7 +2,7 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
|
|
5
|
-
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
5
|
+
import { packageDefaults, resolveMainSourceRel } from '../helpers/package-defaults.mjs'
|
|
6
6
|
|
|
7
7
|
export class PublishGuardError extends Error {
|
|
8
8
|
constructor(message) {
|
|
@@ -34,10 +34,11 @@ export function assertFilesListNoSource(pkg) {
|
|
|
34
34
|
const files = Array.isArray(pkg.files) ? pkg.files : []
|
|
35
35
|
const bad = files.filter((entry) => {
|
|
36
36
|
const normalized = String(entry).replace(/^\.\//, '').replace(/\\/g, '/')
|
|
37
|
-
|
|
37
|
+
const sourceRel = resolveMainSourceRel()
|
|
38
|
+
return normalized === sourceRel || normalized.startsWith(`${sourceRel}/`)
|
|
38
39
|
})
|
|
39
40
|
if (bad.length > 0) {
|
|
40
|
-
throw new PublishGuardError(`package.json files must not include
|
|
41
|
+
throw new PublishGuardError(`package.json files must not include ${resolveMainSourceRel()}/ (found: ${bad.join(', ')})`)
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -65,8 +66,9 @@ export function assertMainExportsPointToDist(pkg) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export function assertSourceAbsentOnDisk(root = process.cwd()) {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const sourceRel = resolveMainSourceRel()
|
|
70
|
+
if (fs.existsSync(path.join(root, sourceRel))) {
|
|
71
|
+
throw new PublishGuardError(`${sourceRel}/ must not exist on disk at publish time`)
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{Constants as h}from"../../utils/constants";import g from"qs";import S from"../../loader/logger";import T from"../../loader/system";import{bindLoaderTmpSync as E,getClientIp as D,getConfiguredProtocols as O,isRealtimeProtocol as q,LoggerLayerEnum as j,parseResponseMessage as P,ProtocolEnum as y,x,controllerContextStorage,getControllerCtx,runControllerStore as B,adapterBagFromRequest as I,isFetchRequest as M,toHandler as H,toRealtimeHandler as N,resolveCtrOptions as A}from"../../utils";export{controllerContextStorage,getControllerCtx};export const runController=B;function b(t){return t instanceof Response||t instanceof Blob||t instanceof Uint8Array||t instanceof ArrayBuffer}function l(t){if(!t||typeof t!=="object")return null;return t}function w(t,e){const r=l(e);if(!r)return;if(r.statusCode!==void 0)return void t.httpStatus(Number(r.statusCode));if(r.code!==void 0){const a=Number(r.code);if(a>=100)t.httpStatus(a);else t.code(a)}}function R(t){const e=l(t);if(!e)return{data:void 0,extraData:void 0,message:void 0};const r=l(e.payload);if(r)return{data:r.data!==void 0?r.data:r,extraData:r.extraData,message:e.message};if(e.data!==void 0||e.extraData!==void 0)return{data:e.data,extraData:e.extraData,message:e.message};if(!(e.status!==void 0||e.message!==void 0||e.code!==void 0||e.statusCode!==void 0)&&Object.keys(e).length>0)return{data:e,extraData:void 0,message:e.message};return{data:void 0,extraData:void 0,message:e.message}}function F(t){return t instanceof ReadableStream||typeof t==="object"&&t!==null&&typeof t.getReader==="function"}function k(t){if(Array.isArray(t))return t[0]??"";return t??""}export function resolveBuilder(t){const e=t.ctx?.builder??t.res?.builder??t.socket?.builder;if(e)return e;throw Error(`[${h.packageName}] use dtoMiddleware() — builder attaches at request start via @xrystal/dto adapter`)}export class BaseController{system=x.get(T);logger=x.get(S);supportedProtocols=[y.HTTP,y.WEBSOCKET];get store(){return getControllerCtx()}get protocol(){return this.store?.protocol||y.HTTP}get req(){const t=this.store,e=t?.ctx||{},r=t?.req||{},a=M(e.request)?e.request:void 0,o=I(e.request),n=e.headers??r.headers??a?.headers??o?.headers,s=n instanceof Headers?Object.fromEntries(n.entries()):n??{},i=a?.url??o?.url??r.url??e.url??"";let c=t?.metadata?.parsedQuery||e.query||r.query||o?.query||{};if(!Object.keys(c).length&&i.includes("?"))c=g.parse(i.split("?")[1]);let u=e.cookies||r.cookies||o?.cookies||{};const d=s.cookie;if(!Object.keys(u).length&&typeof d==="string")u=Object.fromEntries(d.split(";").map((f)=>{const[m,p]=f.trim().split("=");return[decodeURIComponent(m),decodeURIComponent(p||"")]}));return{url:i,method:(e.method||r.method||a?.method||o?.method||"").toUpperCase(),headers:s,body:t?.metadata?.parsedBody||e.body||r.body||o?.body||{},query:c,params:{...r.params,...e.params,...o?.params,...o?.routeParams},cookies:u,ip:D(r,e),lang:e.lang||r.lang||"en",requestId:t?.requestId??e.requestId??r.ctx?.requestId??String(s["x-request-id"]??s["x-correlation-id"]??""),startTime:e.startTime??r.ctx?.startTime??Date.now(),t:e.t||r.t||((f)=>f),accounts:e.accounts||r.accounts||e.user}}get res(){const t=this.store;if(!t)throw Error(`[${h.packageName}] controller context missing`);const e=t.metadata?.locals??{};return{builder:resolveBuilder(t),locals:e}}async parseRequestBody(){const t=this.store;if(!t)return;const e=t.ctx?.request,r=t.req||e||t.ctx?.req,a=this.req,o=k(a.headers["content-type"]).toLowerCase(),n=parseInt(k(a.headers["content-length"])||"-1",10);let s=a.body;const i=(d)=>{if(!d)return{};if(o.includes("application/json"))try{return JSON.parse(d)}catch{return d}if(o.includes("application/x-www-form-urlencoded"))return g.parse(d);try{return JSON.parse(d)}catch{try{return g.parse(d)}catch{return d}}},c=F,u=s&&typeof s==="object"&&!c(s)&&Object.keys(s).length>0;if(!q(this.protocol)&&!["GET","HEAD","OPTIONS"].includes(a.method)&&!u){if(r instanceof Request&&(c(s)||n>0))try{s=i(await r.clone().text())}catch{if(typeof s==="string")s=i(s)}else if(r&&typeof r==="object"&&"on"in r&&typeof r.on==="function"&&n!==0){const d=r;s=await new Promise((f)=>{let m="";const p=setTimeout(()=>f({}),200);d.on("data",(C)=>{m+=String(C)});d.on("end",()=>{clearTimeout(p);f(i(m))});d.on("error",()=>{clearTimeout(p);f({})})})}else if(typeof s==="string"&&s.length)s=i(s)}if(typeof FormData<"u"&&s instanceof FormData)s=Object.fromEntries(s.entries());if(!t.metadata)t.metadata={locals:{}};t.metadata.parsedBody=s||{};t.metadata.parsedQuery=a.query}}export default class Controller extends BaseController{async onInit(){await this.syncFromTmp();E(this)}syncFromTmp=()=>{this.supportedProtocols=O()};parseMessage(t,e,r=!1){return P(t,e,r)}args(t){const e=this.req,r=this.store.metadata?.locals??{};return{req:e,res:{builder:t,locals:r},builder:t,body:e.body,query:e.query,queries:e.query,params:e.params,cookies:e.cookies,locals:r,t:e.t}}fail(t,e,r){w(t,e);const{data:a,extraData:o}=R(e),n=l(e),s=this.parseMessage(n?.message??e,r,!0),i=a!==void 0||o!==void 0?{data:a,extraData:o}:void 0;return(a!==void 0?t.as.fail(a,s,i):t.as.fail(s,i)).build()}ok(t,e,r,a){let o="success_process",n=e!==void 0?e:r;if(typeof e==="string"){o=e;n=r}const{data:s,extraData:i,message:c}=R(n);if(typeof c==="string")o=c;w(t,n);return t.as.ok(s,this.parseMessage(o,a,!1),i!==void 0?{extraData:i}:void 0).build()}async schema({checks:t,logic:e,response:r}){const a=resolveBuilder(this.store);try{await this.parseRequestBody();const n=this.args(a);if(t){const u=await t(n);if(u!==!0)return this.fail(a,u,n.req.t)}let s=e?await e(n):{};const i=l(s);if(i&&typeof i.response==="function")s=await i.response();if(b(s))return s;if(i?.status===!1)return this.fail(a,s,n.req.t);const c=r?await r({...n,logicResult:s}):s;if(b(c))return c;return this.ok(a,c,s,n.req.t)}catch(o){const n=o instanceof Error?o.message:String(o);this.logger?.log(j.ERROR,`Controller Error: ${n}`);return a.as.internalServerError(this.parseMessage(n,this.req.t,!0)).build()}}ctr(t,e){const{framework:r,protocol:a}=A(e),o=()=>this.schema(t);if(q(a))return N(o,a);return H(o,r)}}
|
|
@@ -36,6 +36,9 @@ export declare class Constants {
|
|
|
36
36
|
environments: string;
|
|
37
37
|
dist: string;
|
|
38
38
|
};
|
|
39
|
+
static readonly cliBinFile: string;
|
|
40
|
+
/** Prefer package name in logs/errors (not a short brand alias). */
|
|
41
|
+
static readonly logTag: string;
|
|
39
42
|
static readonly bundledCoreTmpPath: string;
|
|
40
43
|
}
|
|
41
44
|
export { seedFromTmp, loadSeedFromBundledTmp } from '../../utils/helpers/tmp/seed-from-tmp';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"node:path";import{packageRootDir as q}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,framework:j.framework,layoutPaths:Object.freeze({...j.layout}),brand:Object.freeze({...b.brand}),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const v=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static brand=packageDefaults.brand;static mainSourceFolder=packageDefaults.mainSourceFolder;static framework=packageDefaults.framework;static layoutPaths=packageDefaults.layoutPaths;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|
|
1
|
+
import n from"node:path";import{packageRootDir as q}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,framework:j.framework,layoutPaths:Object.freeze({...j.layout}),brand:Object.freeze({...b.brand}),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const v=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static brand=packageDefaults.brand;static mainSourceFolder=packageDefaults.mainSourceFolder;static framework=packageDefaults.framework;static layoutPaths=packageDefaults.layoutPaths;static cliBinFile=packageDefaults.cliBinFile;static logTag=packageDefaults.packageName;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FrameworkEnum as G,ProtocolEnum as K}from"../../../utils/models";import{detectSocketProtocol as L}from"../../../utils/helpers/protocol";import{getFramework as M}from"../../../utils/helpers/framework";import{runAction as I}from"../../../utils/helpers/handlers/execute";export function toRealtimeHandler(z,D){const B=(b)=>{const J=L(b,D);return I({socket:b,ctx:{ws:b},protocol:J},z)},j=(b)=>B(b);j.with=(b)=>()=>B(b);return j}export const toHandler=(z,D)=>{const B=D??M();switch(B){case G.ELYSIA:return(j)=>I({framework:B,ctx:j},z);case G.FETCH:return(j,b)=>I({framework:B,ctx:{request:j,...b}},z);case G.NODE:return(j,b)=>I({framework:B,req:j,res:b},z,b);case G.EXPRESS:return(j,b,J)=>{I({framework:B,req:j,res:b,metadata:{locals:b.locals||{}}},z,b).catch(J)};case G.WEBSOCKET:case G.SOCKETIO:throw Error(
|
|
1
|
+
import{FrameworkEnum as G,ProtocolEnum as K}from"../../../utils/models";import{detectSocketProtocol as L}from"../../../utils/helpers/protocol";import{getFramework as M}from"../../../utils/helpers/framework";import{runAction as I}from"../../../utils/helpers/handlers/execute";import{Constants as N}from"../../../utils/constants";export function toRealtimeHandler(z,D){const B=(b)=>{const J=L(b,D);return I({socket:b,ctx:{ws:b},protocol:J},z)},j=(b)=>B(b);j.with=(b)=>()=>B(b);return j}export const toHandler=(z,D)=>{const B=D??M();switch(B){case G.ELYSIA:return(j)=>I({framework:B,ctx:j},z);case G.FETCH:return(j,b)=>I({framework:B,ctx:{request:j,...b}},z);case G.NODE:return(j,b)=>I({framework:B,req:j,res:b},z,b);case G.EXPRESS:return(j,b,J)=>{I({framework:B,req:j,res:b,metadata:{locals:b.locals||{}}},z,b).catch(J)};case G.WEBSOCKET:case G.SOCKETIO:throw Error(`[${N.packageName}] realtime: ctr({ ... }, { protocol: "ws" | "socketio" })`);default:return(j)=>I({framework:G.ELYSIA,ctx:j},z)}},toWebSocket=(z,D)=>toRealtimeHandler(D,K.WEBSOCKET)(z),toSocketIo=(z,D)=>toRealtimeHandler(D,K.SOCKETIO)(z);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProtocolEnum } from '../../../utils/models/enums';
|
|
2
2
|
import { getRuntimeTmpConfigs } from '../../../utils/helpers/tmp/runtime-tmp';
|
|
3
|
-
declare const REALTIME_MIDDLEWARE_HINT
|
|
3
|
+
declare const REALTIME_MIDDLEWARE_HINT: string;
|
|
4
4
|
export declare function parseProtocol(value: unknown): ProtocolEnum;
|
|
5
5
|
export declare function isRealtimeProtocol(protocol?: ProtocolEnum): boolean;
|
|
6
6
|
export declare function isHttpProtocol(protocol?: ProtocolEnum): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ProtocolEnum as h}from"../../../utils/models/enums";import{getRuntimeTmpConfigs as
|
|
1
|
+
import{Constants as J}from"../../../utils/constants";import{ProtocolEnum as h}from"../../../utils/models/enums";import{getRuntimeTmpConfigs as K}from"../../../utils/helpers/tmp/runtime-tmp";const G={http:h.HTTP,https:h.HTTPS,ws:h.WEBSOCKET,websocket:h.WEBSOCKET,socketio:h.SOCKETIO,socket:h.SOCKETIO},REALTIME_MIDDLEWARE_HINT=`[${J.packageName}] tmp.yml lists both ws and socketio — use realtimeMiddleware("ws") or realtimeMiddleware("socketio")`;export function parseProtocol(b){if(!b)return h.HTTP;const j=String(b).toLowerCase().replace(/[-_\s.]/g,"");if(G[j])return G[j];return Object.values(h).includes(String(b))?b:h.HTTP}export function isRealtimeProtocol(b){return b===h.WEBSOCKET||b===h.SOCKETIO}export function isHttpProtocol(b){return!b||b===h.HTTP||b===h.HTTPS}function B(){return K()?.service}export function resolveProtocolsFromConfig(b){const j=b?.protocols;if(!j)return[h.HTTP];return(Array.isArray(j)?j:[j]).map(parseProtocol)}export function getConfiguredProtocols(){try{return resolveProtocolsFromConfig(B())}catch{return[h.HTTP,h.WEBSOCKET]}}export function getConfiguredRealtimeProtocols(b){return resolveProtocolsFromConfig(b).filter(isRealtimeProtocol)}export function defaultRealtimeProtocolFromConfig(b){const j=getConfiguredRealtimeProtocols(b);if(j.length===1)return j[0];if(j.length>1)return;return h.WEBSOCKET}export function getDefaultRealtimeProtocol(){try{return defaultRealtimeProtocolFromConfig(B())}catch{return h.WEBSOCKET}}export function resolveRealtimeMiddlewareProtocol(b,j){if(b!==void 0&&b!==null&&b!=="")return parseProtocol(b);let q=j;if(!q)try{q=B()}catch{return h.WEBSOCKET}const z=getConfiguredRealtimeProtocols(q);if(z.length===1)return z[0];if(z.length>1)throw Error(REALTIME_MIDDLEWARE_HINT);return h.WEBSOCKET}export function detectSocketProtocol(b,j){if(j)return j;const q=b;if(q?.__xrystalProtocol)return q.__xrystalProtocol;return h.WEBSOCKET}export function attachSocketTransport(b,j,q){const z=b;if(j===h.SOCKETIO)q.attachSocketIo(b);else q.attachWebSocket(b);z.__xrystalProtocol=j}export{REALTIME_MIDDLEWARE_HINT};
|
|
@@ -4,6 +4,6 @@ export type GStoreBoot = {
|
|
|
4
4
|
warnOnRequestKeys: boolean;
|
|
5
5
|
vars: Record<string, unknown>;
|
|
6
6
|
};
|
|
7
|
-
export declare const G_PROP_NOT_ALLOWED
|
|
7
|
+
export declare const G_PROP_NOT_ALLOWED: string;
|
|
8
8
|
export declare function resolveGStoreBoot(tmp?: Record<string, unknown>): GStoreBoot;
|
|
9
9
|
export declare function propsFromTmp(tmp?: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Constants as I}from"../../../utils/constants";import{readTmpServiceBlock as J}from"../../../utils/helpers/tmp/tmp-schema";export const G_PROP_NOT_ALLOWED=`[${I.packageName}] G prop not declared in tmp.yml vars — set autoCreateProps: true to allow runtime keys`;const F=()=>({});function L(j){return J(j).loaders?.system?.gStore}function M(j){if(typeof j.bootstrap==="boolean")return j.bootstrap;return!0}function Q(j){if(typeof j.autoCreateProps==="boolean")return j.autoCreateProps;return!0}function U(j){if(typeof j.warnOnRequestKeys==="boolean")return j.warnOnRequestKeys;return!0}export function resolveGStoreBoot(j={}){const x=j.configs??j,z=L(x);if(!z)return{bootstrap:!0,allowAutoCreateProps:!0,warnOnRequestKeys:!0,vars:F()};const E=z.options??{},D=z.vars,H=D&&typeof D==="object"&&!Array.isArray(D)?{...D}:F();return{bootstrap:M(E),allowAutoCreateProps:Q(E),warnOnRequestKeys:U(E),vars:H}}export function propsFromTmp(j={}){const x=resolveGStoreBoot(j);return x.bootstrap?x.vars:F()}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const G_REQUEST_KEY_WARN
|
|
1
|
+
export declare const G_REQUEST_KEY_WARN: string;
|
|
2
2
|
export declare function looksLikeRequestScopedKey(key: string): boolean;
|
|
3
3
|
export declare function warnIfRequestScopedKey(key: string, enabled: boolean): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Constants as B}from"../../../utils/constants";import{getRunContext as D}from"../../../utils/helpers/context";import{getControllerCtx as F}from"../../../utils/helpers/context/controller-store";export const G_REQUEST_KEY_WARN=`[${B.packageName}] G: key looks request-scoped — use run/controller context, not global G`;const H=new Set(["requestid","reqid","correlationid","cookies","cookie","headers","header","body","query","queries","params","locals","session","sessionid"]);export function looksLikeRequestScopedKey(j){const z=j.trim();if(!z)return!1;const f=z.toLowerCase();if(H.has(f))return!0;if(f.endsWith("requestid")||f.endsWith("correlationid"))return!0;if(f==="req"||f==="res")return!0;return!1}export function warnIfRequestScopedKey(j,z){if(!z||!looksLikeRequestScopedKey(j))return;const f=D()?"run":F()?"controller":"outside-request";console.warn(`${G_REQUEST_KEY_WARN} (key: ${j}, scope: ${f})`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onRuntimeTmpChange as
|
|
1
|
+
import{packageDefaults as w}from"../../../utils/constants";import{onRuntimeTmpChange as x}from"../../../utils/helpers/tmp/runtime-tmp";export function bindLoaderTmpSync(j){const q=j.constructor.name;x(async()=>{try{await j.syncFromTmp()}catch(b){const v=b instanceof Error?b.message:String(b);console.warn(`[${w.packageName}] ${q} tmp reload failed: ${v}`)}})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{healToolchainIfLayoutNeedsSync as
|
|
1
|
+
import{packageDefaults as A}from"../../../utils/constants";import{healToolchainIfLayoutNeedsSync as B,resetToolchainHealState as E}from"../../../utils/helpers/tmp/toolchain-heal";let v;const w=[];export function setRuntimeTmpConfigs(j){v=j}export function getRuntimeTmpConfigs(){return v}export function onRuntimeTmpChange(j){w.push(j);return()=>{const b=w.indexOf(j);if(b>=0)w.splice(b,1)}}export async function notifyRuntimeTmpChange(j){if(j)v=j;const b=v;if(!b)return;if(b.rootFolderPath&&b.service?.paths)try{B(process.cwd(),b)}catch(q){const z=q instanceof Error?q.message:String(q);console.warn(`[${A.packageName}] toolchain auto-sync skipped: ${z}`)}for(const q of w)await q(b)}export function clearRuntimeTmpConfigs(){v=void 0;w.length=0;E()}
|