@zintrust/core 0.4.30 → 0.4.32
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 +15 -0
- package/package.json +5 -1
- package/src/boot.d.ts +3 -0
- package/src/boot.d.ts.map +1 -0
- package/src/boot.js +1 -0
- package/src/cli/commands/D1ProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/D1ProxyCommand.js +24 -159
- package/src/cli/commands/KvProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/KvProxyCommand.js +23 -155
- package/src/cli/commands/ProxyScaffoldUtils.d.ts +31 -0
- package/src/cli/commands/ProxyScaffoldUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyScaffoldUtils.js +120 -0
- package/src/cli/commands/WranglerProxyCommandUtils.d.ts +26 -0
- package/src/cli/commands/WranglerProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/WranglerProxyCommandUtils.js +63 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/GovernanceScaffolder.js +3 -40
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +1 -34
- package/src/cli/scaffolding/ScaffoldingVersionUtils.d.ts +6 -0
- package/src/cli/scaffolding/ScaffoldingVersionUtils.d.ts.map +1 -0
- package/src/cli/scaffolding/ScaffoldingVersionUtils.js +34 -0
- package/src/index.js +3 -3
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +46 -1
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -1
- package/src/proxy/d1/ZintrustD1Proxy.js +356 -31
- package/src/proxy/kv/ZintrustKvProxy.d.ts +42 -1
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -1
- package/src/proxy/kv/ZintrustKvProxy.js +297 -34
- package/src/templates/project/basic/src/boot/bootstrap.ts.tpl +3 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
|
+
import { isNonEmptyString } from '../../helper/index.js';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
4
|
+
import { join } from '../../node-singletons/path.js';
|
|
5
|
+
export const trimNonEmptyOption = (value) => {
|
|
6
|
+
if (!isNonEmptyString(value))
|
|
7
|
+
return undefined;
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
10
|
+
};
|
|
11
|
+
export const resolveConfigPath = (raw, fallback = 'wrangler.jsonc') => {
|
|
12
|
+
return trimNonEmptyOption(raw) ?? fallback;
|
|
13
|
+
};
|
|
14
|
+
const isJsonWhitespace = (char) => {
|
|
15
|
+
return char === ' ' || char === '\n' || char === '\r' || char === '\t';
|
|
16
|
+
};
|
|
17
|
+
const findJsonKeyValueStart = (content, key) => {
|
|
18
|
+
const keyPosition = content.indexOf(`"${key}"`);
|
|
19
|
+
if (keyPosition < 0)
|
|
20
|
+
return -1;
|
|
21
|
+
let cursor = keyPosition + key.length + 2;
|
|
22
|
+
while (isJsonWhitespace(content[cursor]))
|
|
23
|
+
cursor++;
|
|
24
|
+
if (content[cursor] !== ':')
|
|
25
|
+
return -1;
|
|
26
|
+
cursor++;
|
|
27
|
+
while (isJsonWhitespace(content[cursor]))
|
|
28
|
+
cursor++;
|
|
29
|
+
return cursor;
|
|
30
|
+
};
|
|
31
|
+
export const findQuotedValue = (content, key) => {
|
|
32
|
+
const valueStart = findJsonKeyValueStart(content, key);
|
|
33
|
+
if (valueStart < 0 || content[valueStart] !== '"')
|
|
34
|
+
return undefined;
|
|
35
|
+
const valueEnd = content.indexOf('"', valueStart + 1);
|
|
36
|
+
if (valueEnd < 0)
|
|
37
|
+
return undefined;
|
|
38
|
+
return trimNonEmptyOption(content.slice(valueStart + 1, valueEnd));
|
|
39
|
+
};
|
|
40
|
+
const hasEnvBlock = (content, envName) => {
|
|
41
|
+
const valueStart = findJsonKeyValueStart(content, envName);
|
|
42
|
+
return valueStart >= 0 && content[valueStart] === '{';
|
|
43
|
+
};
|
|
44
|
+
const findEnvObjectStart = (content) => {
|
|
45
|
+
const valueStart = findJsonKeyValueStart(content, 'env');
|
|
46
|
+
if (valueStart < 0 || content[valueStart] !== '{')
|
|
47
|
+
return -1;
|
|
48
|
+
return valueStart;
|
|
49
|
+
};
|
|
50
|
+
const isObjectEffectivelyEmpty = (content, objectStart) => {
|
|
51
|
+
let cursor = objectStart + 1;
|
|
52
|
+
while (isJsonWhitespace(content[cursor]))
|
|
53
|
+
cursor++;
|
|
54
|
+
return content[cursor] === '}';
|
|
55
|
+
};
|
|
56
|
+
export const injectEnvBlock = (content, envName, block) => {
|
|
57
|
+
if (hasEnvBlock(content, envName))
|
|
58
|
+
return content;
|
|
59
|
+
const envObjectStart = findEnvObjectStart(content);
|
|
60
|
+
if (envObjectStart >= 0 && isObjectEffectivelyEmpty(content, envObjectStart)) {
|
|
61
|
+
const closingBraceIndex = content.indexOf('}', envObjectStart);
|
|
62
|
+
if (closingBraceIndex >= 0) {
|
|
63
|
+
return `${content.slice(0, envObjectStart)}{\n${block}\n }${content.slice(closingBraceIndex + 1)}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (envObjectStart >= 0) {
|
|
67
|
+
return `${content.slice(0, envObjectStart + 1)}\n${block},${content.slice(envObjectStart + 1)}`;
|
|
68
|
+
}
|
|
69
|
+
const closingIndex = content.lastIndexOf('}');
|
|
70
|
+
if (closingIndex < 0) {
|
|
71
|
+
throw ErrorFactory.createCliError('Invalid wrangler.jsonc: missing closing brace.');
|
|
72
|
+
}
|
|
73
|
+
const before = content.slice(0, closingIndex).trimEnd();
|
|
74
|
+
const suffix = before.endsWith('{') ? '\n' : ',\n';
|
|
75
|
+
return `${before}${suffix} "env": {\n${block}\n }\n}\n`;
|
|
76
|
+
};
|
|
77
|
+
export const renderDefaultWranglerConfig = (envBlock, compatibilityDate) => {
|
|
78
|
+
return [
|
|
79
|
+
'{',
|
|
80
|
+
' "name": "zintrust-api",',
|
|
81
|
+
' "main": "./src/functions/cloudflare.ts",',
|
|
82
|
+
` "compatibility_date": "${compatibilityDate}",`,
|
|
83
|
+
' "compatibility_flags": ["nodejs_compat"],',
|
|
84
|
+
' "env": {',
|
|
85
|
+
envBlock,
|
|
86
|
+
' }',
|
|
87
|
+
'}',
|
|
88
|
+
'',
|
|
89
|
+
].join('\n');
|
|
90
|
+
};
|
|
91
|
+
export const ensureProxyEntrypoint = (options) => {
|
|
92
|
+
const entryFilePath = join(options.cwd, options.entryFile);
|
|
93
|
+
if (existsSync(entryFilePath)) {
|
|
94
|
+
return { created: false, entryFilePath };
|
|
95
|
+
}
|
|
96
|
+
const lastSlashIndex = entryFilePath.lastIndexOf('/');
|
|
97
|
+
const entryDir = lastSlashIndex > 0 ? entryFilePath.slice(0, lastSlashIndex) : options.cwd;
|
|
98
|
+
mkdirSync(entryDir, { recursive: true });
|
|
99
|
+
writeFileSync(entryFilePath, [
|
|
100
|
+
`export { ${options.exportName} } from '${options.moduleSpecifier}';`,
|
|
101
|
+
`export { ${options.exportName} as default } from '${options.moduleSpecifier}';`,
|
|
102
|
+
'',
|
|
103
|
+
].join('\n'), 'utf-8');
|
|
104
|
+
return { created: true, entryFilePath };
|
|
105
|
+
};
|
|
106
|
+
export const ensureWranglerConfig = (options) => {
|
|
107
|
+
if (!existsSync(options.configPath)) {
|
|
108
|
+
const values = options.resolveValues(undefined, options.options);
|
|
109
|
+
writeFileSync(options.configPath, renderDefaultWranglerConfig(options.renderEnvBlock(values), options.compatibilityDate), 'utf-8');
|
|
110
|
+
return { createdFile: true, insertedEnv: true, values };
|
|
111
|
+
}
|
|
112
|
+
const content = readFileSync(options.configPath, 'utf-8');
|
|
113
|
+
const values = options.resolveValues(content, options.options);
|
|
114
|
+
const next = injectEnvBlock(content, options.envName, options.renderEnvBlock(values));
|
|
115
|
+
if (next !== content) {
|
|
116
|
+
writeFileSync(options.configPath, next, 'utf-8');
|
|
117
|
+
return { createdFile: false, insertedEnv: true, values };
|
|
118
|
+
}
|
|
119
|
+
return { createdFile: false, insertedEnv: false, values };
|
|
120
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CommandOptions, IBaseCommand } from '../BaseCommand';
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
export type WranglerProxyCommandOptions = CommandOptions & {
|
|
4
|
+
config?: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
watch?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type CreateWranglerProxyCommandInput<TValues, TOptions extends WranglerProxyCommandOptions> = {
|
|
9
|
+
name: string;
|
|
10
|
+
aliases: string[];
|
|
11
|
+
description: string;
|
|
12
|
+
envName: string;
|
|
13
|
+
defaultConfig: string;
|
|
14
|
+
compatibilityDate: string;
|
|
15
|
+
entryFile: string;
|
|
16
|
+
exportName: string;
|
|
17
|
+
moduleSpecifier: string;
|
|
18
|
+
addOptions: (command: Command) => void;
|
|
19
|
+
resolveValues: (content: string | undefined, options: TOptions) => TValues;
|
|
20
|
+
renderEnvBlock: (values: TValues) => string;
|
|
21
|
+
afterConfigResolved?: (values: TValues) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const addWranglerProxyBaseOptions: (command: Command, defaultConfig: string) => void;
|
|
24
|
+
export declare const createWranglerProxyCommand: <TValues, TOptions extends WranglerProxyCommandOptions>(input: CreateWranglerProxyCommandInput<TValues, TOptions>) => IBaseCommand;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=WranglerProxyCommandUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WranglerProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerProxyCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAWrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,CAAC,OAAO,EAAE,QAAQ,SAAS,2BAA2B,IAAI;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC3E,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC5C,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,eAAe,MAAM,KAAG,IAIrF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,EAAE,QAAQ,SAAS,2BAA2B,EAC9F,OAAO,+BAA+B,CAAC,OAAO,EAAE,QAAQ,CAAC,KACxD,YA0DF,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { maybeRunProxyWatchMode, parseIntOption } from '../commands/ProxyCommandUtils.js';
|
|
3
|
+
import { ensureProxyEntrypoint, ensureWranglerConfig, resolveConfigPath, } from '../commands/ProxyScaffoldUtils.js';
|
|
4
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
5
|
+
import { Logger } from '../../config/logger.js';
|
|
6
|
+
import { join } from '../../node-singletons/path.js';
|
|
7
|
+
export const addWranglerProxyBaseOptions = (command, defaultConfig) => {
|
|
8
|
+
command.option('-c, --config <path>', 'Wrangler config file', defaultConfig);
|
|
9
|
+
command.option('--port <port>', 'Local Wrangler dev port');
|
|
10
|
+
command.option('--watch', 'Auto-restart proxy on file changes');
|
|
11
|
+
};
|
|
12
|
+
export const createWranglerProxyCommand = (input) => {
|
|
13
|
+
return BaseCommand.create({
|
|
14
|
+
name: input.name,
|
|
15
|
+
aliases: input.aliases,
|
|
16
|
+
description: input.description,
|
|
17
|
+
addOptions: input.addOptions,
|
|
18
|
+
execute: async (options) => {
|
|
19
|
+
const typedOptions = options;
|
|
20
|
+
await maybeRunProxyWatchMode(typedOptions.watch);
|
|
21
|
+
const port = parseIntOption(typedOptions.port, 'port');
|
|
22
|
+
const cwd = process.cwd();
|
|
23
|
+
const entrypoint = ensureProxyEntrypoint({
|
|
24
|
+
cwd,
|
|
25
|
+
entryFile: input.entryFile,
|
|
26
|
+
exportName: input.exportName,
|
|
27
|
+
moduleSpecifier: input.moduleSpecifier,
|
|
28
|
+
});
|
|
29
|
+
const configPath = join(cwd, resolveConfigPath(typedOptions.config, input.defaultConfig));
|
|
30
|
+
const result = ensureWranglerConfig({
|
|
31
|
+
configPath,
|
|
32
|
+
options: typedOptions,
|
|
33
|
+
envName: input.envName,
|
|
34
|
+
resolveValues: input.resolveValues,
|
|
35
|
+
renderEnvBlock: input.renderEnvBlock,
|
|
36
|
+
compatibilityDate: input.compatibilityDate,
|
|
37
|
+
});
|
|
38
|
+
if (entrypoint.created) {
|
|
39
|
+
Logger.info(`Created ${entrypoint.entryFilePath} from @zintrust/core proxy entrypoint.`);
|
|
40
|
+
}
|
|
41
|
+
if (result.createdFile) {
|
|
42
|
+
Logger.info(`Created ${configPath} with a default ${input.envName} environment.`);
|
|
43
|
+
}
|
|
44
|
+
else if (result.insertedEnv) {
|
|
45
|
+
Logger.info(`Added env.${input.envName} to ${configPath}.`);
|
|
46
|
+
}
|
|
47
|
+
input.afterConfigResolved?.(result.values);
|
|
48
|
+
const args = ['dev', '--config', configPath, '--env', input.envName];
|
|
49
|
+
if (port !== undefined) {
|
|
50
|
+
args.push('--port', String(port));
|
|
51
|
+
}
|
|
52
|
+
const exitCode = await SpawnUtil.spawnAndWait({
|
|
53
|
+
command: 'wrangler',
|
|
54
|
+
args,
|
|
55
|
+
env: process.env,
|
|
56
|
+
forwardSignals: false,
|
|
57
|
+
});
|
|
58
|
+
if (exitCode !== 0) {
|
|
59
|
+
process.exit(exitCode);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GovernanceScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/GovernanceScaffolder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"GovernanceScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/GovernanceScaffolder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAsSH,eAAO,MAAM,oBAAoB;0BAEhB,MAAM,YACV,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC;EA+DpC,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - Architecture tests (Vitest)
|
|
7
7
|
*/
|
|
8
8
|
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
9
|
+
import { toCompatibleGovernanceVersion } from '../scaffolding/ScaffoldingVersionUtils.js';
|
|
9
10
|
import { VersionChecker } from '../services/VersionChecker.js';
|
|
10
11
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
11
12
|
import { resolvePackageManager } from '../../common/index.js';
|
|
@@ -50,53 +51,15 @@ const ensureDevDependency = (devDependencies, name, version) => {
|
|
|
50
51
|
devDependencies[name] = version;
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
|
-
const extractMajorMinorVersion = (value) => {
|
|
54
|
-
const trimmed = value.trim();
|
|
55
|
-
let start = -1;
|
|
56
|
-
for (let index = 0; index < trimmed.length; index++) {
|
|
57
|
-
const char = trimmed[index];
|
|
58
|
-
if (char !== undefined && char >= '0' && char <= '9') {
|
|
59
|
-
start = index;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (start < 0)
|
|
64
|
-
return undefined;
|
|
65
|
-
let end = start;
|
|
66
|
-
while (end < trimmed.length) {
|
|
67
|
-
const char = trimmed[end];
|
|
68
|
-
const isDigit = char !== undefined && char >= '0' && char <= '9';
|
|
69
|
-
if (!isDigit && char !== '.')
|
|
70
|
-
break;
|
|
71
|
-
end++;
|
|
72
|
-
}
|
|
73
|
-
const parts = trimmed.slice(start, end).split('.');
|
|
74
|
-
if (parts.length < 3)
|
|
75
|
-
return undefined;
|
|
76
|
-
const [major, minor, patch] = parts;
|
|
77
|
-
if (!major || !minor || !patch)
|
|
78
|
-
return undefined;
|
|
79
|
-
return { major, minor };
|
|
80
|
-
};
|
|
81
|
-
const toCompatibleGovernanceVersion = (value) => {
|
|
82
|
-
const parsed = extractMajorMinorVersion(value);
|
|
83
|
-
if (parsed === undefined)
|
|
84
|
-
return undefined;
|
|
85
|
-
return `^${parsed.major}.${parsed.minor}.0`;
|
|
86
|
-
};
|
|
87
54
|
const inferGovernanceVersion = (pkg) => {
|
|
88
55
|
const deps = getStringRecord(pkg.dependencies);
|
|
89
56
|
const core = deps?.['@zintrust/core'];
|
|
90
57
|
if (typeof core === 'string' && core.trim() !== '') {
|
|
91
|
-
|
|
92
|
-
if (compatibleFromCore !== undefined)
|
|
93
|
-
return compatibleFromCore;
|
|
58
|
+
return toCompatibleGovernanceVersion(core);
|
|
94
59
|
}
|
|
95
60
|
const currentVersion = VersionChecker.getCurrentVersion().trim();
|
|
96
61
|
if (currentVersion !== '' && currentVersion !== '0.0.0') {
|
|
97
|
-
|
|
98
|
-
if (compatibleFromCli !== undefined)
|
|
99
|
-
return compatibleFromCli;
|
|
62
|
+
return toCompatibleGovernanceVersion(currentVersion);
|
|
100
63
|
}
|
|
101
64
|
return '^0.4.0';
|
|
102
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ProjectScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"ProjectScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ProjectScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OA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,GAAG;IAChE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAsBA;AA8ID;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,GAAE,MAAsB,GAAG,kBAAkB,CAsB/F;AAED,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAEhC;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;EAM5B,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { EnvFileBackfill } from '../env/EnvFileBackfill.js';
|
|
6
6
|
import { EnvData } from '../scaffolding/env.js';
|
|
7
|
+
import { toCompatibleGovernanceVersion } from '../scaffolding/ScaffoldingVersionUtils.js';
|
|
7
8
|
import { Logger } from '../../config/logger.js';
|
|
8
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
10
|
import { randomBytes } from '../../node-singletons/crypto.js';
|
|
@@ -20,40 +21,6 @@ const loadCoreVersion = () => {
|
|
|
20
21
|
return '0.0.0';
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
|
-
const extractMajorMinorVersion = (value) => {
|
|
24
|
-
const trimmed = value.trim();
|
|
25
|
-
let start = -1;
|
|
26
|
-
for (let index = 0; index < trimmed.length; index++) {
|
|
27
|
-
const char = trimmed[index];
|
|
28
|
-
if (char !== undefined && char >= '0' && char <= '9') {
|
|
29
|
-
start = index;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (start < 0)
|
|
34
|
-
return undefined;
|
|
35
|
-
let end = start;
|
|
36
|
-
while (end < trimmed.length) {
|
|
37
|
-
const char = trimmed[end];
|
|
38
|
-
const isDigit = char !== undefined && char >= '0' && char <= '9';
|
|
39
|
-
if (!isDigit && char !== '.')
|
|
40
|
-
break;
|
|
41
|
-
end++;
|
|
42
|
-
}
|
|
43
|
-
const parts = trimmed.slice(start, end).split('.');
|
|
44
|
-
if (parts.length < 3)
|
|
45
|
-
return undefined;
|
|
46
|
-
const [major, minor, patch] = parts;
|
|
47
|
-
if (!major || !minor || !patch)
|
|
48
|
-
return undefined;
|
|
49
|
-
return { major, minor };
|
|
50
|
-
};
|
|
51
|
-
const toCompatibleGovernanceVersion = (version) => {
|
|
52
|
-
const parsed = extractMajorMinorVersion(version);
|
|
53
|
-
if (parsed !== undefined)
|
|
54
|
-
return `^${parsed.major}.${parsed.minor}.0`;
|
|
55
|
-
return '^0.4.0';
|
|
56
|
-
};
|
|
57
24
|
const createDirectories = (projectPath, directories) => {
|
|
58
25
|
let count = 0;
|
|
59
26
|
if (!fs.existsSync(projectPath)) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const extractMajorMinorVersion: (value: string) => {
|
|
2
|
+
major: string;
|
|
3
|
+
minor: string;
|
|
4
|
+
} | undefined;
|
|
5
|
+
export declare const toCompatibleGovernanceVersion: (value: string, fallback?: string) => string;
|
|
6
|
+
//# sourceMappingURL=ScaffoldingVersionUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaffoldingVersionUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ScaffoldingVersionUtils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,GACnC,OAAO,MAAM,KACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SA6BrC,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,EAAE,iBAAmB,KAAG,MAKlF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const extractMajorMinorVersion = (value) => {
|
|
2
|
+
const trimmed = value.trim();
|
|
3
|
+
let start = -1;
|
|
4
|
+
for (let index = 0; index < trimmed.length; index++) {
|
|
5
|
+
const char = trimmed[index];
|
|
6
|
+
if (char !== undefined && char >= '0' && char <= '9') {
|
|
7
|
+
start = index;
|
|
8
|
+
break;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (start < 0)
|
|
12
|
+
return undefined;
|
|
13
|
+
let end = start;
|
|
14
|
+
while (end < trimmed.length) {
|
|
15
|
+
const char = trimmed[end];
|
|
16
|
+
const isDigit = char !== undefined && char >= '0' && char <= '9';
|
|
17
|
+
if (!isDigit && char !== '.')
|
|
18
|
+
break;
|
|
19
|
+
end++;
|
|
20
|
+
}
|
|
21
|
+
const parts = trimmed.slice(start, end).split('.');
|
|
22
|
+
if (parts.length < 3)
|
|
23
|
+
return undefined;
|
|
24
|
+
const [major, minor, patch] = parts;
|
|
25
|
+
if (!major || !minor || !patch)
|
|
26
|
+
return undefined;
|
|
27
|
+
return { major, minor };
|
|
28
|
+
};
|
|
29
|
+
export const toCompatibleGovernanceVersion = (value, fallback = '^0.4.0') => {
|
|
30
|
+
const parsed = extractMajorMinorVersion(value);
|
|
31
|
+
if (parsed === undefined)
|
|
32
|
+
return fallback;
|
|
33
|
+
return `^${parsed.major}.${parsed.minor}.0`;
|
|
34
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.32
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-03-
|
|
8
|
+
* Built: 2026-03-29T15:48:46.014Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-03-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-03-29T15:48:45.972Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
type KvGetType = 'text' | 'json' | 'arrayBuffer';
|
|
2
|
+
type KVNamespacePutOptions = {
|
|
3
|
+
expirationTtl?: number;
|
|
4
|
+
};
|
|
5
|
+
type KVNamespace = {
|
|
6
|
+
get: {
|
|
7
|
+
(key: string): Promise<string | null>;
|
|
8
|
+
(key: string, type: 'json'): Promise<Record<string, unknown> | null>;
|
|
9
|
+
(key: string, type: 'arrayBuffer'): Promise<ArrayBuffer | null>;
|
|
10
|
+
(key: string, type: KvGetType): Promise<Record<string, unknown> | ArrayBuffer | string | null>;
|
|
11
|
+
};
|
|
12
|
+
put: (key: string, value: string, options?: KVNamespacePutOptions) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
type D1AllResult<T> = {
|
|
15
|
+
results?: T[];
|
|
16
|
+
};
|
|
17
|
+
type D1RunResult = {
|
|
18
|
+
meta?: unknown;
|
|
19
|
+
};
|
|
20
|
+
type D1PreparedStatement = {
|
|
21
|
+
bind: (...values: unknown[]) => D1PreparedStatement;
|
|
22
|
+
all: <T = unknown>() => Promise<D1AllResult<T>>;
|
|
23
|
+
first: <T = unknown>() => Promise<T | null>;
|
|
24
|
+
run: () => Promise<D1RunResult>;
|
|
25
|
+
};
|
|
26
|
+
type D1Database = {
|
|
27
|
+
prepare: (sql: string) => D1PreparedStatement;
|
|
28
|
+
};
|
|
29
|
+
type D1Env = {
|
|
30
|
+
DB?: D1Database;
|
|
31
|
+
D1_BINDING?: string;
|
|
32
|
+
APP_KEY?: string;
|
|
33
|
+
D1_REMOTE_SECRET?: string;
|
|
34
|
+
ZT_PROXY_SIGNING_WINDOW_MS?: string;
|
|
35
|
+
ZT_NONCES?: KVNamespace;
|
|
36
|
+
ZT_PROXY_DEBUG?: string;
|
|
37
|
+
ZT_MAX_BODY_BYTES?: string;
|
|
38
|
+
ZT_MAX_SQL_BYTES?: string;
|
|
39
|
+
ZT_MAX_PARAMS?: string;
|
|
40
|
+
ZT_D1_STATEMENTS_JSON?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare const ZintrustD1Proxy: Readonly<{
|
|
43
|
+
_ZINTRUST_CLOUDFLARE_D1_PROXY_VERSION: "0.1.15";
|
|
44
|
+
_ZINTRUST_CLOUDFLARE_D1_PROXY_BUILD_DATE: "__BUILD_DATE__";
|
|
45
|
+
fetch(request: Request, env: D1Env): Promise<Response>;
|
|
46
|
+
}>;
|
|
2
47
|
export default ZintrustD1Proxy;
|
|
3
48
|
//# sourceMappingURL=ZintrustD1Proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZintrustD1Proxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/d1/ZintrustD1Proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ZintrustD1Proxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/d1/ZintrustD1Proxy.ts"],"names":[],"mappings":"AAMA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;AAEjD,KAAK,qBAAqB,GAAG;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACtC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACrE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG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