devflare 1.0.0-next.22 → 1.0.0-next.24
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/LLM.md +221 -7
- package/dist/account-5nm1xn0v.js +475 -0
- package/dist/account-j8nfggg4.js +475 -0
- package/dist/account-qhe8vtds.js +475 -0
- package/dist/bridge/miniflare.d.ts +1 -1
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/browser.d.ts +35 -15
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -2
- package/dist/build-vctfnmsf.js +54 -0
- package/dist/build-vy95gy3f.js +54 -0
- package/dist/build-yzx0gsaj.js +54 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -1
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/type-generation/generator.d.ts +4 -2
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/compiler/types.d.ts +1 -1
- package/dist/config/compiler/types.d.ts.map +1 -1
- package/dist/config/define.d.ts +7 -4
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +2 -2
- package/dist/config/local-dev-vars.d.ts.map +1 -1
- package/dist/config/schema-env.d.ts +28 -8
- package/dist/config/schema-env.d.ts.map +1 -1
- package/dist/config/schema-runtime.d.ts +11 -1
- package/dist/config/schema-runtime.d.ts.map +1 -1
- package/dist/config/schema-types-bindings-platform.d.ts +378 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +551 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +254 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +885 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +377 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +47 -18
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config-entry.d.ts +2 -0
- package/dist/config-entry.d.ts.map +1 -1
- package/dist/config-entry.js +3 -1
- package/dist/config-gq5jh4cx.js +105 -0
- package/dist/config-rq32csms.js +105 -0
- package/dist/config-vec13050.js +105 -0
- package/dist/deploy-01j0ep5n.js +1055 -0
- package/dist/deploy-krj3k9zm.js +1055 -0
- package/dist/deploy-mem96qyn.js +1066 -0
- package/dist/deploy-tjypkhg7.js +1055 -0
- package/dist/dev-apkr7cfv.js +2597 -0
- package/dist/dev-bh581ew3.js +2597 -0
- package/dist/dev-gn5y93z9.js +2597 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/doctor-9asw8x18.js +259 -0
- package/dist/doctor-h5q28qt1.js +259 -0
- package/dist/doctor-khk550tw.js +259 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index-0bv2qjs1.js +1555 -0
- package/dist/index-3tkzn06q.js +413 -0
- package/dist/index-4j9ah79n.js +1033 -0
- package/dist/index-8fyz6gcm.js +699 -0
- package/dist/index-97z629zr.js +109 -0
- package/dist/index-b28c4yr4.js +1205 -0
- package/dist/index-bfjpjs07.js +581 -0
- package/dist/index-c8p4njqy.js +479 -0
- package/dist/index-cna43592.js +1573 -0
- package/dist/index-cr06zrgw.js +1033 -0
- package/dist/index-cwjjdtgn.js +74 -0
- package/dist/index-d00njc1f.js +147 -0
- package/dist/index-dgeamyfk.js +1426 -0
- package/dist/index-dref9ecb.js +476 -0
- package/dist/index-e151t4ge.js +895 -0
- package/dist/index-e7kakw0j.js +1033 -0
- package/dist/index-f1g5jdm8.js +1426 -0
- package/dist/index-f46984zs.js +1554 -0
- package/dist/index-ftf7yqhs.js +74 -0
- package/dist/index-grk8pzhr.js +185 -0
- package/dist/index-h332fg62.js +1205 -0
- package/dist/index-hzmpecq9.js +52 -0
- package/dist/index-j1csb7gb.js +581 -0
- package/dist/index-j7x7f72h.js +185 -0
- package/dist/index-ja2rdbt0.js +476 -0
- package/dist/index-jkqbjwt2.js +476 -0
- package/dist/index-kc207nyr.js +52 -0
- package/dist/index-meq8ydc0.js +895 -0
- package/dist/index-mh5renra.js +895 -0
- package/dist/index-myfjejs0.js +185 -0
- package/dist/index-p9xq83p7.js +147 -0
- package/dist/index-q15nj71j.js +52 -0
- package/dist/index-qkfvd3cs.js +109 -0
- package/dist/index-qqp65pyv.js +699 -0
- package/dist/index-rnz879kf.js +1426 -0
- package/dist/index-s0fmwxbk.js +74 -0
- package/dist/index-s96e5dd9.js +699 -0
- package/dist/index-stzx8nc4.js +111 -0
- package/dist/index-th4vrnbk.js +1205 -0
- package/dist/index-vtcmsgaf.js +581 -0
- package/dist/index-x2k3awjs.js +147 -0
- package/dist/index-x8x547tz.js +1426 -0
- package/dist/index-xxxd0mvw.js +109 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/login-280p2cm9.js +77 -0
- package/dist/login-4n266whq.js +77 -0
- package/dist/login-g9rb7dj3.js +77 -0
- package/dist/previews-3m3ffpaw.js +1337 -0
- package/dist/previews-tr8sm03d.js +1337 -0
- package/dist/previews-ykamw25e.js +1337 -0
- package/dist/productions-4m1pd6ts.js +505 -0
- package/dist/productions-62y489ff.js +505 -0
- package/dist/productions-cgn3fz7d.js +505 -0
- package/dist/runtime/exports.d.ts +23 -0
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -3
- package/dist/secrets-4050kqf5.js +91 -0
- package/dist/secrets-gywxctdh.js +91 -0
- package/dist/secrets-p112cajt.js +91 -0
- package/dist/sveltekit/index.js +4 -4
- package/dist/test/index.js +23 -11
- package/dist/test/resolve-service-bindings.d.ts +1 -1
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -1
- package/dist/types-17kkqw37.js +705 -0
- package/dist/types-apmt10yj.js +705 -0
- package/dist/types-ttrrgdfj.js +705 -0
- package/dist/vite/index.js +5 -5
- package/dist/vite/plugin-context.d.ts.map +1 -1
- package/dist/vite/plugin-programmatic.d.ts.map +1 -1
- package/dist/worker-2k1jyr6p.js +513 -0
- package/dist/worker-4fd49jm0.js +513 -0
- package/dist/worker-jqgn6jyj.js +513 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadConfig,
|
|
3
|
+
resolveConfigPath
|
|
4
|
+
} from "./index-f46984zs.js";
|
|
5
|
+
import {
|
|
6
|
+
getEffectiveAccountId,
|
|
7
|
+
getPrimaryAccount,
|
|
8
|
+
getWorkspaceAccountId
|
|
9
|
+
} from "./index-1d4jg11n.js";
|
|
10
|
+
|
|
11
|
+
// src/cli/command-utils.ts
|
|
12
|
+
function asOptionalString(value) {
|
|
13
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
14
|
+
}
|
|
15
|
+
function resolveNamedSelection(options) {
|
|
16
|
+
if (options.explicitValue) {
|
|
17
|
+
return {
|
|
18
|
+
value: options.explicitValue,
|
|
19
|
+
source: "option"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (options.fallbackValue) {
|
|
23
|
+
return {
|
|
24
|
+
value: options.fallbackValue,
|
|
25
|
+
source: "arg"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (options.configuredValue) {
|
|
29
|
+
return {
|
|
30
|
+
value: options.configuredValue,
|
|
31
|
+
source: "config"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
value: undefined,
|
|
36
|
+
source: "none"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function getConfiguredAccountId(cwd) {
|
|
40
|
+
const workspaceAccountId = getWorkspaceAccountId();
|
|
41
|
+
if (workspaceAccountId) {
|
|
42
|
+
return workspaceAccountId;
|
|
43
|
+
}
|
|
44
|
+
const envAccountId = process.env.CLOUDFLARE_ACCOUNT_ID?.trim();
|
|
45
|
+
if (envAccountId) {
|
|
46
|
+
return envAccountId;
|
|
47
|
+
}
|
|
48
|
+
const configPath = await resolveConfigPath(cwd);
|
|
49
|
+
if (!configPath) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const config = await loadConfig({ cwd });
|
|
54
|
+
return config.accountId;
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function resolveCloudflareAccountId(options) {
|
|
60
|
+
if (options.explicitAccountId) {
|
|
61
|
+
return options.explicitAccountId;
|
|
62
|
+
}
|
|
63
|
+
if (options.configuredAccountId) {
|
|
64
|
+
return options.configuredAccountId;
|
|
65
|
+
}
|
|
66
|
+
const primaryAccount = await getPrimaryAccount(options.apiOptions);
|
|
67
|
+
if (!primaryAccount) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const effective = await getEffectiveAccountId(primaryAccount.id);
|
|
71
|
+
return effective.accountId;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { asOptionalString, resolveNamedSelection, getConfiguredAccountId, resolveCloudflareAccountId };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeSecretsStoreBinding
|
|
3
|
+
} from "./index-cna43592.js";
|
|
4
|
+
|
|
5
|
+
// src/secrets/local-secrets.ts
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
var LOCAL_SECRETS_PATH = join(".devflare", "secrets.local.json");
|
|
9
|
+
var LOCAL_SECRET_WRAPPED_BINDING_SCRIPT = `
|
|
10
|
+
class LocalSecretsStoreSecret {
|
|
11
|
+
constructor(env) {
|
|
12
|
+
this.value = env.value
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async get() {
|
|
16
|
+
return this.value
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function makeBinding(env) {
|
|
21
|
+
return new LocalSecretsStoreSecret(env)
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
function createEmptyLocalSecretsFile() {
|
|
25
|
+
return {
|
|
26
|
+
version: 1,
|
|
27
|
+
stores: {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getLocalSecretsFilePath(cwd) {
|
|
31
|
+
return join(cwd, LOCAL_SECRETS_PATH);
|
|
32
|
+
}
|
|
33
|
+
function parseLocalSecretsFile(raw) {
|
|
34
|
+
const parsed = JSON.parse(raw);
|
|
35
|
+
if (parsed.version !== 1 || !parsed.stores || typeof parsed.stores !== "object") {
|
|
36
|
+
return createEmptyLocalSecretsFile();
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
version: 1,
|
|
40
|
+
stores: parsed.stores
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function readLocalSecretsFile(cwd) {
|
|
44
|
+
const filePath = getLocalSecretsFilePath(cwd);
|
|
45
|
+
if (!existsSync(filePath)) {
|
|
46
|
+
return createEmptyLocalSecretsFile();
|
|
47
|
+
}
|
|
48
|
+
return parseLocalSecretsFile(readFileSync(filePath, "utf8"));
|
|
49
|
+
}
|
|
50
|
+
function writeLocalSecretsFile(cwd, file) {
|
|
51
|
+
const filePath = getLocalSecretsFilePath(cwd);
|
|
52
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
53
|
+
writeFileSync(filePath, `${JSON.stringify(file, null, "\t")}
|
|
54
|
+
`, {
|
|
55
|
+
encoding: "utf8",
|
|
56
|
+
mode: 384
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function writeLocalSecret({ cwd, storeId, name, value }) {
|
|
60
|
+
const file = readLocalSecretsFile(cwd);
|
|
61
|
+
file.stores[storeId] ??= {};
|
|
62
|
+
file.stores[storeId][name] = {
|
|
63
|
+
value,
|
|
64
|
+
updatedAt: new Date().toISOString()
|
|
65
|
+
};
|
|
66
|
+
writeLocalSecretsFile(cwd, file);
|
|
67
|
+
}
|
|
68
|
+
function readLocalSecret({ cwd, storeId, name }) {
|
|
69
|
+
return readLocalSecretsFile(cwd).stores[storeId]?.[name]?.value;
|
|
70
|
+
}
|
|
71
|
+
function deleteLocalSecret({ cwd, storeId, name }) {
|
|
72
|
+
const file = readLocalSecretsFile(cwd);
|
|
73
|
+
const store = file.stores[storeId];
|
|
74
|
+
if (!store || !(name in store)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
delete store[name];
|
|
78
|
+
if (Object.keys(store).length === 0) {
|
|
79
|
+
delete file.stores[storeId];
|
|
80
|
+
}
|
|
81
|
+
writeLocalSecretsFile(cwd, file);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function listLocalSecrets({ cwd, storeId }) {
|
|
85
|
+
const file = readLocalSecretsFile(cwd);
|
|
86
|
+
const stores = storeId ? { [storeId]: file.stores[storeId] ?? {} } : file.stores;
|
|
87
|
+
return Object.entries(stores).flatMap(([currentStoreId, secrets]) => Object.entries(secrets).map(([name, secret]) => ({
|
|
88
|
+
storeId: currentStoreId,
|
|
89
|
+
name,
|
|
90
|
+
hasValue: typeof secret.value === "string",
|
|
91
|
+
updatedAt: secret.updatedAt
|
|
92
|
+
})));
|
|
93
|
+
}
|
|
94
|
+
function resolveLocalSecretValuesForBindings(config, cwd) {
|
|
95
|
+
const values = {};
|
|
96
|
+
for (const [bindingName, binding] of Object.entries(config.bindings?.secretsStore ?? {})) {
|
|
97
|
+
const normalized = normalizeSecretsStoreBinding(binding, config.secretsStoreId, bindingName);
|
|
98
|
+
const value = readLocalSecret({
|
|
99
|
+
cwd,
|
|
100
|
+
storeId: normalized.storeId,
|
|
101
|
+
name: normalized.secretName
|
|
102
|
+
});
|
|
103
|
+
if (value !== undefined) {
|
|
104
|
+
values[bindingName] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return values;
|
|
108
|
+
}
|
|
109
|
+
function toLocalSecretWorkerName(bindingName, index) {
|
|
110
|
+
const slug = bindingName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "secret";
|
|
111
|
+
return `devflare-local-secret-${index}-${slug}`;
|
|
112
|
+
}
|
|
113
|
+
function buildLocalSecretWrappedBindingConfig(config, cwd) {
|
|
114
|
+
const values = resolveLocalSecretValuesForBindings(config, cwd);
|
|
115
|
+
const entries = Object.entries(values);
|
|
116
|
+
return {
|
|
117
|
+
localBindingNames: entries.map(([bindingName]) => bindingName),
|
|
118
|
+
wrappedBindings: Object.fromEntries(entries.map(([bindingName, value], index) => {
|
|
119
|
+
const scriptName = toLocalSecretWorkerName(bindingName, index);
|
|
120
|
+
return [
|
|
121
|
+
bindingName,
|
|
122
|
+
{
|
|
123
|
+
scriptName,
|
|
124
|
+
bindings: { value }
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
})),
|
|
128
|
+
workers: entries.map(([bindingName], index) => ({
|
|
129
|
+
name: toLocalSecretWorkerName(bindingName, index),
|
|
130
|
+
modules: true,
|
|
131
|
+
script: LOCAL_SECRET_WRAPPED_BINDING_SCRIPT
|
|
132
|
+
}))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function buildLocalSecretNodeBindings(config, cwd) {
|
|
136
|
+
const values = resolveLocalSecretValuesForBindings(config, cwd);
|
|
137
|
+
return Object.fromEntries(Object.entries(values).map(([bindingName, value]) => [
|
|
138
|
+
bindingName,
|
|
139
|
+
{
|
|
140
|
+
async get() {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
]));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { writeLocalSecret, deleteLocalSecret, listLocalSecrets, resolveLocalSecretValuesForBindings, buildLocalSecretWrappedBindingConfig, buildLocalSecretNodeBindings };
|