devflare 1.0.0-next.22 → 1.0.0-next.23

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.
Files changed (114) hide show
  1. package/LLM.md +144 -5
  2. package/dist/account-j8nfggg4.js +475 -0
  3. package/dist/account-qhe8vtds.js +475 -0
  4. package/dist/bridge/miniflare.d.ts +1 -1
  5. package/dist/bridge/miniflare.d.ts.map +1 -1
  6. package/dist/browser.d.ts +13 -13
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.js +4 -2
  9. package/dist/build-vy95gy3f.js +54 -0
  10. package/dist/build-yzx0gsaj.js +54 -0
  11. package/dist/cli/commands/build-artifacts.d.ts.map +1 -1
  12. package/dist/cli/commands/config.d.ts.map +1 -1
  13. package/dist/cli/commands/type-generation/generator.d.ts +4 -2
  14. package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
  15. package/dist/cli/commands/types.d.ts.map +1 -1
  16. package/dist/cli/index.js +1 -1
  17. package/dist/config/compiler/types.d.ts +1 -1
  18. package/dist/config/compiler/types.d.ts.map +1 -1
  19. package/dist/config/define.d.ts +7 -4
  20. package/dist/config/define.d.ts.map +1 -1
  21. package/dist/config/env-vars.d.ts +309 -0
  22. package/dist/config/env-vars.d.ts.map +1 -0
  23. package/dist/config/index.d.ts +2 -1
  24. package/dist/config/index.d.ts.map +1 -1
  25. package/dist/config/loader.d.ts.map +1 -1
  26. package/dist/config/local-dev-vars.d.ts +2 -2
  27. package/dist/config/local-dev-vars.d.ts.map +1 -1
  28. package/dist/config/schema-env.d.ts +6 -6
  29. package/dist/config/schema-types-bindings-platform.d.ts +378 -0
  30. package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
  31. package/dist/config/schema-types-bindings-resources.d.ts +551 -0
  32. package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
  33. package/dist/config/schema-types-bindings.d.ts +254 -0
  34. package/dist/config/schema-types-bindings.d.ts.map +1 -0
  35. package/dist/config/schema-types-build.d.ts +86 -0
  36. package/dist/config/schema-types-build.d.ts.map +1 -0
  37. package/dist/config/schema-types-runtime.d.ts +882 -0
  38. package/dist/config/schema-types-runtime.d.ts.map +1 -0
  39. package/dist/config/schema-types.d.ts +377 -0
  40. package/dist/config/schema-types.d.ts.map +1 -0
  41. package/dist/config/schema.d.ts +14 -15
  42. package/dist/config/schema.d.ts.map +1 -1
  43. package/dist/config-entry.d.ts +2 -0
  44. package/dist/config-entry.d.ts.map +1 -1
  45. package/dist/config-entry.js +3 -1
  46. package/dist/config-gq5jh4cx.js +105 -0
  47. package/dist/config-vec13050.js +105 -0
  48. package/dist/deploy-01j0ep5n.js +1055 -0
  49. package/dist/deploy-tjypkhg7.js +1055 -0
  50. package/dist/dev-bh581ew3.js +2597 -0
  51. package/dist/dev-gn5y93z9.js +2597 -0
  52. package/dist/dev-server/server.d.ts.map +1 -1
  53. package/dist/doctor-h5q28qt1.js +259 -0
  54. package/dist/doctor-khk550tw.js +259 -0
  55. package/dist/env.d.ts +10 -0
  56. package/dist/env.d.ts.map +1 -1
  57. package/dist/index-0bv2qjs1.js +1555 -0
  58. package/dist/index-3tkzn06q.js +413 -0
  59. package/dist/index-8fyz6gcm.js +699 -0
  60. package/dist/index-97z629zr.js +109 -0
  61. package/dist/index-b28c4yr4.js +1205 -0
  62. package/dist/index-c8p4njqy.js +479 -0
  63. package/dist/index-cr06zrgw.js +1033 -0
  64. package/dist/index-cwjjdtgn.js +74 -0
  65. package/dist/index-dref9ecb.js +476 -0
  66. package/dist/index-e151t4ge.js +895 -0
  67. package/dist/index-e7kakw0j.js +1033 -0
  68. package/dist/index-f1g5jdm8.js +1426 -0
  69. package/dist/index-f46984zs.js +1554 -0
  70. package/dist/index-grk8pzhr.js +185 -0
  71. package/dist/index-hzmpecq9.js +52 -0
  72. package/dist/index-j1csb7gb.js +581 -0
  73. package/dist/index-j7x7f72h.js +185 -0
  74. package/dist/index-jkqbjwt2.js +476 -0
  75. package/dist/index-mh5renra.js +895 -0
  76. package/dist/index-p9xq83p7.js +147 -0
  77. package/dist/index-q15nj71j.js +52 -0
  78. package/dist/index-qqp65pyv.js +699 -0
  79. package/dist/index-s0fmwxbk.js +74 -0
  80. package/dist/index-stzx8nc4.js +111 -0
  81. package/dist/index-th4vrnbk.js +1205 -0
  82. package/dist/index-vtcmsgaf.js +581 -0
  83. package/dist/index-x2k3awjs.js +147 -0
  84. package/dist/index-x8x547tz.js +1426 -0
  85. package/dist/index-xxxd0mvw.js +109 -0
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +8 -6
  89. package/dist/login-280p2cm9.js +77 -0
  90. package/dist/login-4n266whq.js +77 -0
  91. package/dist/previews-3m3ffpaw.js +1337 -0
  92. package/dist/previews-tr8sm03d.js +1337 -0
  93. package/dist/productions-62y489ff.js +505 -0
  94. package/dist/productions-cgn3fz7d.js +505 -0
  95. package/dist/runtime/exports.d.ts +23 -0
  96. package/dist/runtime/exports.d.ts.map +1 -1
  97. package/dist/runtime/index.d.ts +1 -1
  98. package/dist/runtime/index.d.ts.map +1 -1
  99. package/dist/runtime/index.js +5 -3
  100. package/dist/secrets-4050kqf5.js +91 -0
  101. package/dist/secrets-p112cajt.js +91 -0
  102. package/dist/sveltekit/index.js +4 -4
  103. package/dist/test/index.js +23 -11
  104. package/dist/test/resolve-service-bindings.d.ts +1 -1
  105. package/dist/test/resolve-service-bindings.d.ts.map +1 -1
  106. package/dist/test/simple-context-lifecycle.d.ts.map +1 -1
  107. package/dist/types-apmt10yj.js +705 -0
  108. package/dist/types-ttrrgdfj.js +705 -0
  109. package/dist/vite/index.js +5 -5
  110. package/dist/vite/plugin-context.d.ts.map +1 -1
  111. package/dist/vite/plugin-programmatic.d.ts.map +1 -1
  112. package/dist/worker-2k1jyr6p.js +513 -0
  113. package/dist/worker-jqgn6jyj.js +513 -0
  114. package/package.json +1 -1
@@ -0,0 +1,185 @@
1
+ import {
2
+ resolveConfigForEnvironment
3
+ } from "./index-0bv2qjs1.js";
4
+
5
+ // src/cli/commands/previews-support/family.ts
6
+ function compareConfiguredWorkerFamilies(left, right) {
7
+ if (left.role === "primary" && right.role !== "primary") {
8
+ return -1;
9
+ }
10
+ if (left.role !== "primary" && right.role === "primary") {
11
+ return 1;
12
+ }
13
+ return left.baseName.localeCompare(right.baseName);
14
+ }
15
+ function comparePreviewScopeRows(left, right) {
16
+ const leftTime = left.updatedAt?.getTime() ?? 0;
17
+ const rightTime = right.updatedAt?.getTime() ?? 0;
18
+ if (rightTime !== leftTime) {
19
+ return rightTime - leftTime;
20
+ }
21
+ return left.scope.localeCompare(right.scope);
22
+ }
23
+ function collectConfiguredWorkerFamilies(config, environment) {
24
+ const resolvedConfig = resolveConfigForEnvironment(config, environment);
25
+ const families = new Map;
26
+ families.set(resolvedConfig.name, {
27
+ baseName: resolvedConfig.name,
28
+ roleLabel: "primary",
29
+ role: "primary"
30
+ });
31
+ for (const [bindingName, binding] of Object.entries(resolvedConfig.bindings?.services ?? {})) {
32
+ const existing = families.get(binding.service);
33
+ if (existing) {
34
+ continue;
35
+ }
36
+ families.set(binding.service, {
37
+ baseName: binding.service,
38
+ roleLabel: bindingName,
39
+ role: "service"
40
+ });
41
+ }
42
+ return Array.from(families.values()).sort(compareConfiguredWorkerFamilies);
43
+ }
44
+ function getWorkerUrl(workerName, workersSubdomain) {
45
+ if (!workersSubdomain) {
46
+ return;
47
+ }
48
+ return `https://${workerName}.${workersSubdomain}.workers.dev`;
49
+ }
50
+ function getWorkerScopeSuffix(workerName, baseName) {
51
+ if (!workerName.startsWith(`${baseName}-`)) {
52
+ return;
53
+ }
54
+ const suffix = workerName.slice(baseName.length + 1).trim();
55
+ return suffix || undefined;
56
+ }
57
+ function buildStableWorkerRowsFromLiveWorkers(families, workers, workersSubdomain) {
58
+ const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
59
+ return families.map((family) => {
60
+ const worker = workersByName.get(family.baseName);
61
+ const status = worker ? "active" : "missing";
62
+ return {
63
+ workerName: family.baseName,
64
+ role: family.roleLabel,
65
+ status,
66
+ updatedAt: worker?.modifiedOn,
67
+ url: worker ? getWorkerUrl(family.baseName, workersSubdomain) : undefined
68
+ };
69
+ });
70
+ }
71
+ function getDedicatedPreviewFamilyNamesFromWorkers(families, workers) {
72
+ const familyNames = new Set;
73
+ const workerNames = workers.map((worker) => worker.name);
74
+ for (const family of families) {
75
+ if (family.role === "primary") {
76
+ familyNames.add(family.baseName);
77
+ continue;
78
+ }
79
+ if (workerNames.some((workerName) => Boolean(getWorkerScopeSuffix(workerName, family.baseName)))) {
80
+ familyNames.add(family.baseName);
81
+ }
82
+ }
83
+ return familyNames;
84
+ }
85
+ function buildPreviewScopeRowsFromLiveWorkers(families, workers, workersSubdomain) {
86
+ const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
87
+ const previewFamilyNames = getDedicatedPreviewFamilyNamesFromWorkers(families, workers);
88
+ const expectedFamilies = families.filter((family) => previewFamilyNames.has(family.baseName));
89
+ const workerCandidatesByScope = buildPreviewWorkerCandidatesByScope(families, workers);
90
+ return Array.from(workerCandidatesByScope.keys()).map((scope) => {
91
+ const resolvedFamilies = expectedFamilies.map((family) => ({
92
+ family,
93
+ worker: workersByName.get(`${family.baseName}-${scope}`)
94
+ }));
95
+ const presentFamilies = resolvedFamilies.filter((entry) => entry.worker);
96
+ const updatedAt = presentFamilies.reduce((latest, entry) => {
97
+ const currentDate = entry.worker?.modifiedOn;
98
+ if (!currentDate) {
99
+ return latest;
100
+ }
101
+ if (!latest || currentDate.getTime() > latest.getTime()) {
102
+ return currentDate;
103
+ }
104
+ return latest;
105
+ }, undefined);
106
+ const primaryEntry = resolvedFamilies.find((entry) => entry.family.role === "primary");
107
+ const entryWorker = primaryEntry?.worker ?? presentFamilies[0]?.worker;
108
+ const missingLabels = resolvedFamilies.filter((entry) => !entry.worker).map((entry) => entry.family.role === "primary" ? "primary" : entry.family.roleLabel);
109
+ const notes = [];
110
+ if (missingLabels.length > 0) {
111
+ notes.push(`missing ${missingLabels.join(", ")}`);
112
+ }
113
+ const strategy = "dedicated workers";
114
+ const status = presentFamilies.length === resolvedFamilies.length ? "ready" : "partial";
115
+ return {
116
+ scope,
117
+ strategy,
118
+ workersLabel: `${presentFamilies.length}/${resolvedFamilies.length}`,
119
+ status,
120
+ updatedAt,
121
+ notes: notes.length > 0 ? notes.join(" · ") : undefined,
122
+ entryUrl: entryWorker ? getWorkerUrl(entryWorker.name, workersSubdomain) : undefined
123
+ };
124
+ }).sort(comparePreviewScopeRows);
125
+ }
126
+ function buildPreviewWorkerCandidatesByScope(families, workers) {
127
+ const candidates = new Map;
128
+ for (const worker of workers) {
129
+ for (const family of families) {
130
+ const scope = getWorkerScopeSuffix(worker.name, family.baseName);
131
+ if (!scope) {
132
+ continue;
133
+ }
134
+ const names = candidates.get(scope) ?? new Set;
135
+ names.add(worker.name);
136
+ candidates.set(scope, names);
137
+ }
138
+ }
139
+ return new Map(Array.from(candidates.entries()).map(([scope, workerNames]) => {
140
+ return [scope, Array.from(workerNames).sort((left, right) => left.localeCompare(right))];
141
+ }));
142
+ }
143
+ function orderPreviewWorkerNamesForDeletion(workerNames, scope, families) {
144
+ const familyPriority = new Map;
145
+ for (const family of families) {
146
+ familyPriority.set(family.baseName, {
147
+ priority: family.role === "primary" ? 0 : 1,
148
+ roleLabel: family.roleLabel
149
+ });
150
+ }
151
+ const resolveFamilyForWorker = (workerName) => {
152
+ for (const family of families) {
153
+ if (getWorkerScopeSuffix(workerName, family.baseName) === scope) {
154
+ const resolved = familyPriority.get(family.baseName);
155
+ if (resolved) {
156
+ return {
157
+ priority: resolved.priority,
158
+ roleLabel: resolved.roleLabel,
159
+ baseName: family.baseName
160
+ };
161
+ }
162
+ }
163
+ }
164
+ return {
165
+ priority: 2,
166
+ roleLabel: workerName
167
+ };
168
+ };
169
+ return [...workerNames].sort((left, right) => {
170
+ const leftFamily = resolveFamilyForWorker(left);
171
+ const rightFamily = resolveFamilyForWorker(right);
172
+ if (leftFamily.priority !== rightFamily.priority) {
173
+ return leftFamily.priority - rightFamily.priority;
174
+ }
175
+ if (leftFamily.roleLabel !== rightFamily.roleLabel) {
176
+ return leftFamily.roleLabel.localeCompare(rightFamily.roleLabel);
177
+ }
178
+ if (leftFamily.baseName && rightFamily.baseName && leftFamily.baseName !== rightFamily.baseName) {
179
+ return leftFamily.baseName.localeCompare(rightFamily.baseName);
180
+ }
181
+ return left.localeCompare(right);
182
+ });
183
+ }
184
+
185
+ export { collectConfiguredWorkerFamilies, buildStableWorkerRowsFromLiveWorkers, buildPreviewScopeRowsFromLiveWorkers, buildPreviewWorkerCandidatesByScope, orderPreviewWorkerNamesForDeletion };
@@ -0,0 +1,52 @@
1
+ import {
2
+ findFiles
3
+ } from "./index-qwgr4q7s.js";
4
+ import {
5
+ resolveConfigPath
6
+ } from "./index-0bv2qjs1.js";
7
+
8
+ // src/cli/config-path.ts
9
+ import { stat } from "node:fs/promises";
10
+ var CONFIG_FILE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs"];
11
+ var SUPPORTED_CONFIG_FILENAMES = CONFIG_FILE_EXTENSIONS.map((extension) => `devflare.config${extension}`);
12
+ function hasKnownConfigExtension(filePath) {
13
+ return CONFIG_FILE_EXTENSIONS.some((extension) => filePath.endsWith(extension));
14
+ }
15
+ async function getExistingFilePath(filePath) {
16
+ try {
17
+ const fileStat = await stat(filePath);
18
+ return fileStat.isFile() ? filePath : null;
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+ async function resolveConfigCandidatePath(candidatePath) {
24
+ const candidates = [candidatePath];
25
+ if (!hasKnownConfigExtension(candidatePath)) {
26
+ for (const extension of CONFIG_FILE_EXTENSIONS) {
27
+ candidates.push(`${candidatePath}${extension}`);
28
+ }
29
+ }
30
+ for (const candidate of candidates) {
31
+ const existingFilePath = await getExistingFilePath(candidate);
32
+ if (existingFilePath) {
33
+ return existingFilePath;
34
+ }
35
+ }
36
+ return await resolveConfigPath(candidatePath) ?? null;
37
+ }
38
+ async function findConfigPathsUnderDirectory(rootDir) {
39
+ const matches = await findFiles([
40
+ ...SUPPORTED_CONFIG_FILENAMES,
41
+ ...SUPPORTED_CONFIG_FILENAMES.map((filename) => `**/${filename}`)
42
+ ], {
43
+ cwd: rootDir,
44
+ absolute: true
45
+ });
46
+ return [...new Set(matches)].sort((left, right) => left.localeCompare(right));
47
+ }
48
+ function formatSupportedConfigFilenames() {
49
+ return SUPPORTED_CONFIG_FILENAMES.join(", ");
50
+ }
51
+
52
+ export { resolveConfigCandidatePath, findConfigPathsUnderDirectory, formatSupportedConfigFilenames };