@lunora/config 1.0.0-alpha.47 → 1.0.0-alpha.470

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 (169) hide show
  1. package/LICENSE.md +336 -104
  2. package/README.md +6 -6
  3. package/dist/celld/index.d.mts +77 -0
  4. package/dist/celld/index.d.ts +77 -0
  5. package/dist/celld/index.mjs +1 -0
  6. package/dist/celld-names/index.d.mts +57 -0
  7. package/dist/celld-names/index.d.ts +57 -0
  8. package/dist/celld-names/index.mjs +1 -0
  9. package/dist/cli/index.d.mts +2 -0
  10. package/dist/cli/index.d.ts +2 -0
  11. package/dist/cli/index.mjs +1 -0
  12. package/dist/cloudflare/index.d.mts +941 -0
  13. package/dist/cloudflare/index.d.ts +941 -0
  14. package/dist/cloudflare/index.mjs +1 -0
  15. package/dist/index.d.mts +1045 -1044
  16. package/dist/index.d.ts +1045 -1044
  17. package/dist/index.mjs +1 -25
  18. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  19. package/dist/packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs +1 -0
  20. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  21. package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
  22. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  23. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs +1 -0
  24. package/dist/packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs +1 -0
  25. package/dist/packem_shared/CELLD_RELEASE_ASSETS_DIRECTORY-YBhEotjs.mjs +1 -0
  26. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs +1 -0
  27. package/dist/packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs +1 -0
  28. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DWyZ_2QM.mjs +1 -0
  29. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs +1 -0
  30. package/dist/packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs +1 -0
  31. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-BlvZ242-.mjs +1 -0
  32. package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
  33. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  34. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs +6 -0
  35. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-FoysLtF0.mjs +1 -0
  36. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  37. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  38. package/dist/packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs +9 -0
  39. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  40. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  41. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  42. package/dist/packem_shared/MissingBuildOutputError-BAyekzof.mjs +1 -0
  43. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs +1 -0
  44. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BiQ1zNsR.mjs +1 -0
  45. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D66_hwjD.mjs +1 -0
  46. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BqFeetpX.mjs +1 -0
  47. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-D296PlpV.mjs +1 -0
  48. package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
  49. package/dist/packem_shared/STUDIO_PATH-CvVcvTbQ.mjs +1 -0
  50. package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
  51. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-BZEXldUo.mjs +1 -0
  52. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  53. package/dist/packem_shared/WRANGLER_FILES-BF8PUjuo.mjs +1 -0
  54. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  55. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  56. package/dist/packem_shared/applyAdditiveEdit-DEwPKcJg.mjs +6 -0
  57. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  58. package/dist/packem_shared/assertBuildTargetMatches-D11J7F38.mjs +1 -0
  59. package/dist/packem_shared/assertWranglerSatisfiesSchema-_70vhvqk.mjs +3 -0
  60. package/dist/packem_shared/asset-headers-CPuEX21i.mjs +4 -0
  61. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  62. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.mts +593 -0
  63. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.ts +593 -0
  64. package/dist/packem_shared/bindingsNeedingDatabase-3KyGflIq.mjs +3 -0
  65. package/dist/packem_shared/blockingFindingsMessage-BQ9z7cie.mjs +1 -0
  66. package/dist/packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs +19 -0
  67. package/dist/packem_shared/canonicalPath-DrfMiT3U.mjs +1 -0
  68. package/dist/packem_shared/celld-binding-id-9MiUoteo.mjs +1 -0
  69. package/dist/packem_shared/celld-config-Ef1RZ02t.mjs +3 -0
  70. package/dist/packem_shared/checkDevEnv-BwZSVBbB.mjs +3 -0
  71. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  72. package/dist/packem_shared/clearApiSpecMarker-DMGpP41V.mjs +2 -0
  73. package/dist/packem_shared/collectExportGaps-DHUtghqe.mjs +2 -0
  74. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  75. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  76. package/dist/packem_shared/createStudioDocumentCache-XBG1aWbl.mjs +1 -0
  77. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.mts +190 -0
  78. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.ts +190 -0
  79. package/dist/packem_shared/describePreservedCrons-i5XT6rtl.mjs +1 -0
  80. package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
  81. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  82. package/dist/packem_shared/devTriggerHints-CN_RJxWW.mjs +1 -0
  83. package/dist/packem_shared/devVariablesStamp-BQkGEn9d.mjs +1 -0
  84. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  85. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  86. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  87. package/dist/packem_shared/discoverSchemaInfo-DRPnqgif.mjs +1 -0
  88. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  89. package/dist/packem_shared/emitProjectAssetHeaders-BdqdTVN3.mjs +1 -0
  90. package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
  91. package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
  92. package/dist/packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs +1 -0
  93. package/dist/packem_shared/index.d-BoUSSRrk.d.mts +270 -0
  94. package/dist/packem_shared/index.d-C1nVDcie.d.ts +270 -0
  95. package/dist/packem_shared/inferLunoraBindings-Biq1OW9V.mjs +1 -0
  96. package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
  97. package/dist/packem_shared/isOwnedStudioAssets-CHII-uIX.mjs +1 -0
  98. package/dist/packem_shared/materializeServiceDevConfigs-CI1HXv7f.mjs +1 -0
  99. package/dist/packem_shared/mergeWranglerEnvironment-CxT2PV1N.mjs +1 -0
  100. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  101. package/dist/packem_shared/pendingBindingChanges-DqP40pSQ.mjs +1 -0
  102. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.mts +338 -0
  103. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.ts +338 -0
  104. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  105. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  106. package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
  107. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  108. package/dist/packem_shared/queue-info-D38n7YdX.mjs +1 -0
  109. package/dist/packem_shared/readManifest-Cighz3WC.mjs +6 -0
  110. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  111. package/dist/packem_shared/reconcile-services-CjgIJKim.mjs +1 -0
  112. package/dist/packem_shared/reconcileWranglerBindings-DAdI2Z-R.mjs +1 -0
  113. package/dist/packem_shared/reconcileWranglerCompatibilityDate-Cj94osA-.mjs +1 -0
  114. package/dist/packem_shared/renderStudioHtml-CRDTNivi.mjs +15 -0
  115. package/dist/packem_shared/resolveLocalWorkerEnv-C1s-quRt.mjs +1 -0
  116. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  117. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  118. package/dist/packem_shared/scanWranglerVariablesForSecrets-DmdOBmwn.mjs +1 -0
  119. package/dist/packem_shared/secret-key-xi4VK8Jw.mjs +1 -0
  120. package/dist/packem_shared/sendStudioAsset-B81Pex91.mjs +1 -0
  121. package/dist/packem_shared/serveJsonHandler-B8_GE6QC.mjs +1 -0
  122. package/dist/packem_shared/spa-assets-wX8rTPEQ.mjs +1 -0
  123. package/dist/packem_shared/startCelldDevSession-DfuDVsha.mjs +1 -0
  124. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  125. package/dist/packem_shared/studio-assets-BKWx838V.mjs +1 -0
  126. package/dist/packem_shared/validate-bindings-DSMH8bRQ.mjs +1 -0
  127. package/dist/packem_shared/withTailConsumer-BXOIqXxv.mjs +1 -0
  128. package/dist/packem_shared/wranglerCodegenInputs-B8iRZZZw.mjs +1 -0
  129. package/dist/packem_shared/wranglerToAlchemy-ClIdvJFu.mjs +5 -0
  130. package/dist/packem_shared/write-atomic-9sY2z8DB.mjs +3 -0
  131. package/dist/packem_shared/writeAssetHeaders-C5igmezc.mjs +1 -0
  132. package/dist/studio-host/index.d.mts +371 -136
  133. package/dist/studio-host/index.d.ts +371 -136
  134. package/dist/studio-host/index.mjs +1 -7
  135. package/package.json +43 -10
  136. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  137. package/dist/packem_shared/AGENT_MODE_ENV-DM1Siczo.mjs +0 -17
  138. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  139. package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +0 -163
  140. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  141. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  142. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  143. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  144. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  145. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  146. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-8bNMHGiu.mjs +0 -104
  147. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  148. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  149. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  150. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  151. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  152. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  153. package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
  154. package/dist/packem_shared/buildPackageSecretsBlock-B8iSX1Zo.mjs +0 -281
  155. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  156. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  157. package/dist/packem_shared/detectFramework-U08038Yp.mjs +0 -41
  158. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  159. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  160. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  161. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  162. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  163. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  164. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  165. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  166. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  167. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  168. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  169. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -1,61 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { discoverSchema, schemaFromIr } from '@lunora/codegen';
3
- import { seedPlan } from '@lunora/seed';
4
- import { Project } from 'ts-morph';
5
- import { join } from 'node:path';
6
-
7
- const SEED_ENDPOINT = "/__lunora/seed";
8
- const MAX_SEED_ROWS = 1e3;
9
- const jsonReplacer = (_key, value) => {
10
- if (typeof value === "bigint") {
11
- return Number(value);
12
- }
13
- if (value instanceof ArrayBuffer) {
14
- return [...new Uint8Array(value)];
15
- }
16
- return value;
17
- };
18
- const clampCount = (count) => {
19
- if (typeof count !== "number" || !Number.isFinite(count)) {
20
- return 10;
21
- }
22
- return Math.min(Math.max(1, Math.floor(count)), MAX_SEED_ROWS);
23
- };
24
- const handleSeedRequest = (request) => {
25
- if (request.method !== "POST") {
26
- return { body: { error: "method-not-allowed", ok: false }, status: 405 };
27
- }
28
- const { body } = request;
29
- if (body === void 0 || typeof body !== "object") {
30
- return { body: { error: "invalid-request", ok: false }, status: 400 };
31
- }
32
- const { count, existingIds, seed, table } = body;
33
- if (typeof table !== "string" || table.length === 0) {
34
- return { body: { error: "missing-table", ok: false }, status: 400 };
35
- }
36
- const lunoraDirectory = request.schemaDirectory ?? "lunora";
37
- const schemaPath = join(request.projectRoot, lunoraDirectory, "schema.ts");
38
- if (!existsSync(schemaPath)) {
39
- return { body: { error: "schema-not-found", ok: false }, status: 404 };
40
- }
41
- const project = new Project({ skipAddingFilesFromTsConfig: true });
42
- const ir = discoverSchema(project, schemaPath);
43
- if (!ir.tables.some((candidate) => candidate.name === table)) {
44
- return { body: { error: "unknown-table", ok: false, table }, status: 404 };
45
- }
46
- const schema = schemaFromIr(ir);
47
- const plan = seedPlan(schema, {
48
- // Pass every sampled parent table as `existingIds` so the generator links
49
- // to live rows and never fabricates parents — matching the studio's
50
- // "existing rows are not affected, FKs point at what's there" semantics.
51
- existingIds: existingIds ?? {},
52
- defaultCount: clampCount(count),
53
- only: [table],
54
- seed: seed ?? 0
55
- });
56
- const rows = plan.find((entry) => entry.table === table)?.rows ?? [];
57
- const jsonSafeRows = JSON.parse(JSON.stringify(rows, jsonReplacer));
58
- return { body: { ok: true, rows: jsonSafeRows }, status: 200 };
59
- };
60
-
61
- export { SEED_ENDPOINT, handleSeedRequest };
@@ -1,25 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { parse } from 'jsonc-parser';
3
- import { join } from 'node:path';
4
-
5
- const WRANGLER_FILES = ["wrangler.jsonc", "wrangler.json"];
6
- const findWranglerFile = (projectRoot) => {
7
- for (const candidate of WRANGLER_FILES) {
8
- const fullPath = join(projectRoot, candidate);
9
- if (existsSync(fullPath)) {
10
- return fullPath;
11
- }
12
- }
13
- return void 0;
14
- };
15
- const readWranglerJsonc = (wranglerPath) => {
16
- const text = readFileSync(wranglerPath, "utf8");
17
- const parseErrors = [];
18
- const value = parse(text, parseErrors, { allowTrailingComma: true });
19
- if (parseErrors.length > 0 || value === null || typeof value !== "object") {
20
- return { parsed: void 0, text };
21
- }
22
- return { parsed: value, text };
23
- };
24
-
25
- export { WRANGLER_FILES, findWranglerFile, readWranglerJsonc };
@@ -1,228 +0,0 @@
1
- import { Project, SyntaxKind } from 'ts-morph';
2
- import { collectCalls } from './parseSchema-DSeyktvG.mjs';
3
-
4
- const IDENTIFIER_PATTERN = /^[A-Za-z_$][\w$]*$/u;
5
- const VALIDATOR_METHODS = /* @__PURE__ */ new Set([
6
- "any",
7
- "array",
8
- "bigint",
9
- "boolean",
10
- "bytes",
11
- "date",
12
- "id",
13
- "literal",
14
- "null",
15
- "number",
16
- "object",
17
- "optional",
18
- "record",
19
- "storage",
20
- "string",
21
- "timestamp",
22
- "union"
23
- ]);
24
- const isValidatorExpression = (node) => {
25
- if (node.getKind() === SyntaxKind.ParenthesizedExpression) {
26
- return isValidatorExpression(node.asKindOrThrow(SyntaxKind.ParenthesizedExpression).getExpression());
27
- }
28
- if (node.getKind() !== SyntaxKind.CallExpression) {
29
- return false;
30
- }
31
- const call = node.asKindOrThrow(SyntaxKind.CallExpression);
32
- const callee = call.getExpression();
33
- if (callee.getKind() !== SyntaxKind.PropertyAccessExpression) {
34
- return false;
35
- }
36
- const access = callee.asKindOrThrow(SyntaxKind.PropertyAccessExpression);
37
- if (access.getExpression().getKind() !== SyntaxKind.Identifier || access.getExpression().getText() !== "v" || !VALIDATOR_METHODS.has(access.getName())) {
38
- return false;
39
- }
40
- return call.getArguments().every((argument) => isValidatorArgument(argument));
41
- };
42
- const isValidatorArgument = (node) => {
43
- const kind = node.getKind();
44
- if (kind === SyntaxKind.ParenthesizedExpression) {
45
- return isValidatorArgument(node.asKindOrThrow(SyntaxKind.ParenthesizedExpression).getExpression());
46
- }
47
- if (kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral || kind === SyntaxKind.TrueKeyword || kind === SyntaxKind.FalseKeyword || kind === SyntaxKind.NullKeyword) {
48
- return true;
49
- }
50
- if (kind === SyntaxKind.PrefixUnaryExpression) {
51
- const unary = node.asKindOrThrow(SyntaxKind.PrefixUnaryExpression);
52
- return unary.getOperand().getKind() === SyntaxKind.NumericLiteral;
53
- }
54
- if (kind === SyntaxKind.ObjectLiteralExpression) {
55
- return node.asKindOrThrow(SyntaxKind.ObjectLiteralExpression).getProperties().every((property) => {
56
- if (property.getKind() !== SyntaxKind.PropertyAssignment) {
57
- return false;
58
- }
59
- const initializer = property.getInitializer();
60
- return initializer !== void 0 && isValidatorArgument(initializer);
61
- });
62
- }
63
- if (kind === SyntaxKind.ArrayLiteralExpression) {
64
- return node.asKindOrThrow(SyntaxKind.ArrayLiteralExpression).getElements().every((element) => isValidatorArgument(element));
65
- }
66
- return isValidatorExpression(node);
67
- };
68
- const isAllowedValidatorText = (validator) => {
69
- if (typeof validator !== "string" || validator.trim().length === 0) {
70
- return false;
71
- }
72
- const project = new Project({ compilerOptions: { allowJs: true }, useInMemoryFileSystem: true });
73
- const sourceFile = project.createSourceFile("validator.ts", `const __v = (${validator});`, { overwrite: true });
74
- if (project.getProgram().getSyntacticDiagnostics(sourceFile).length > 0) {
75
- return false;
76
- }
77
- if (sourceFile.getStatements().length !== 1) {
78
- return false;
79
- }
80
- const declaration = sourceFile.getVariableDeclaration("__v");
81
- const initializer = declaration?.getInitializer();
82
- return initializer !== void 0 && isValidatorExpression(initializer);
83
- };
84
- const ADDITIVE_KINDS = /* @__PURE__ */ new Set(["addIndex", "addOptionalColumn", "addTable"]);
85
- const classifyEdit = (edit) => ADDITIVE_KINDS.has(edit.kind) ? "additive" : "destructive";
86
- const isIdentifier = (value) => typeof value === "string" && IDENTIFIER_PATTERN.test(value);
87
- const validateAdditiveEdit = (edit) => {
88
- if (!isIdentifier(edit.table)) {
89
- return "invalid-identifier";
90
- }
91
- if (edit.kind === "addOptionalColumn") {
92
- if (!isIdentifier(edit.column)) {
93
- return "invalid-identifier";
94
- }
95
- if (!isAllowedValidatorText(edit.validator)) {
96
- return "invalid-validator";
97
- }
98
- }
99
- if (edit.kind === "addIndex") {
100
- if (!isIdentifier(edit.name)) {
101
- return "invalid-identifier";
102
- }
103
- if (!Array.isArray(edit.fields) || !edit.fields.every((field) => isIdentifier(field))) {
104
- return "invalid-identifier";
105
- }
106
- }
107
- return void 0;
108
- };
109
- const findTablesObject = (source) => {
110
- const project = new Project({ compilerOptions: { allowJs: true }, useInMemoryFileSystem: true });
111
- const sourceFile = project.createSourceFile("schema.ts", source, { overwrite: true });
112
- let defineSchemaCall;
113
- for (const call of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)) {
114
- if (call.getExpression().getText() === "defineSchema") {
115
- defineSchemaCall = call;
116
- break;
117
- }
118
- }
119
- if (defineSchemaCall === void 0) {
120
- const aliased = sourceFile.getImportDeclarations().some((declaration) => declaration.getNamedImports().some((named) => named.getName() === "defineSchema" && named.getAliasNode() !== void 0));
121
- return { reason: aliased ? "aliased-define-schema" : "no-define-schema" };
122
- }
123
- const tablesArgument = defineSchemaCall.getArguments()[0];
124
- if (tablesArgument?.getKind() !== SyntaxKind.ObjectLiteralExpression) {
125
- return { reason: "non-object-argument" };
126
- }
127
- return { object: tablesArgument.asKindOrThrow(SyntaxKind.ObjectLiteralExpression), sourceFile };
128
- };
129
- const findTableProperty = (tablesObject, table) => {
130
- for (const property of tablesObject.getProperties()) {
131
- if (property.getKind() === SyntaxKind.PropertyAssignment && property.getNameNode().getText().replaceAll(/["']/gu, "") === table) {
132
- return property;
133
- }
134
- }
135
- return void 0;
136
- };
137
- const findDefineTableShape = (tableProperty) => {
138
- const defineTableCall = tableProperty.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find((call) => call.getExpression().getText() === "defineTable");
139
- const shape = defineTableCall?.getArguments()[0];
140
- return shape?.getKind() === SyntaxKind.ObjectLiteralExpression ? shape.asKindOrThrow(SyntaxKind.ObjectLiteralExpression) : void 0;
141
- };
142
- const applyAddTable = (tablesObject, edit) => {
143
- if (findTableProperty(tablesObject, edit.table) !== void 0) {
144
- return "duplicate-table";
145
- }
146
- tablesObject.addPropertyAssignment({
147
- initializer: `defineTable({
148
- // Add your column validators here.
149
- // Example:
150
- // text: v.string(),
151
- // createdAt: v.number(),
152
- })`,
153
- name: edit.table
154
- });
155
- return void 0;
156
- };
157
- const applyAddOptionalColumn = (tablesObject, edit) => {
158
- const tableProperty = findTableProperty(tablesObject, edit.table);
159
- if (tableProperty === void 0) {
160
- return "unknown-table";
161
- }
162
- const shape = findDefineTableShape(tableProperty);
163
- if (shape === void 0) {
164
- return "unknown-table";
165
- }
166
- const exists = shape.getProperties().some(
167
- (property) => property.getKind() === SyntaxKind.PropertyAssignment && property.getNameNode().getText().replaceAll(/["']/gu, "") === edit.column
168
- );
169
- if (exists) {
170
- return "duplicate-column";
171
- }
172
- shape.addPropertyAssignment({ initializer: `v.optional(${edit.validator})`, name: edit.column });
173
- return void 0;
174
- };
175
- const applyAddIndex = (tableProperty, edit) => {
176
- if (tableProperty === void 0) {
177
- return "unknown-table";
178
- }
179
- const initializer = tableProperty.getInitializer();
180
- if (initializer === void 0) {
181
- return "unknown-table";
182
- }
183
- const duplicate = collectCalls(initializer).some((call) => {
184
- const expression = call.getExpression();
185
- if (expression.getKind() !== SyntaxKind.PropertyAccessExpression) {
186
- return false;
187
- }
188
- const access = expression.asKindOrThrow(SyntaxKind.PropertyAccessExpression);
189
- const [nameArgument] = call.getArguments();
190
- return access.getName() === "index" && nameArgument?.getKind() === SyntaxKind.StringLiteral && nameArgument.asKindOrThrow(SyntaxKind.StringLiteral).getLiteralText() === edit.name;
191
- });
192
- if (duplicate) {
193
- return "duplicate-index";
194
- }
195
- const fields = edit.fields.map((field) => JSON.stringify(field)).join(", ");
196
- const options = edit.unique === true ? ", { unique: true }" : "";
197
- tableProperty.setInitializer(`${initializer.getText()}.index(${JSON.stringify(edit.name)}, [${fields}]${options})`);
198
- return void 0;
199
- };
200
- const applyAdditiveEdit = (source, edit) => {
201
- if (classifyEdit(edit) === "destructive") {
202
- return { ok: false, reason: "destructive" };
203
- }
204
- const additive = edit;
205
- const invalid = validateAdditiveEdit(additive);
206
- if (invalid !== void 0) {
207
- return { ok: false, reason: invalid };
208
- }
209
- const located = findTablesObject(source);
210
- if ("reason" in located) {
211
- return { ok: false, reason: located.reason };
212
- }
213
- const { object: tablesObject, sourceFile } = located;
214
- let failure;
215
- if (additive.kind === "addTable") {
216
- failure = applyAddTable(tablesObject, additive);
217
- } else if (additive.kind === "addOptionalColumn") {
218
- failure = applyAddOptionalColumn(tablesObject, additive);
219
- } else {
220
- failure = applyAddIndex(findTableProperty(tablesObject, additive.table), additive);
221
- }
222
- if (failure !== void 0) {
223
- return { ok: false, reason: failure };
224
- }
225
- return { ok: true, text: sourceFile.getFullText() };
226
- };
227
-
228
- export { applyAdditiveEdit, classifyEdit };
@@ -1,72 +0,0 @@
1
- import { readFileSync, statSync } from 'node:fs';
2
- import { createRequire } from 'node:module';
3
- import { normalize, join, relative, isAbsolute, dirname } from 'node:path';
4
-
5
- const loadStudioAssets = (logger, resolveFrom = import.meta.url) => {
6
- try {
7
- const require = createRequire(resolveFrom);
8
- return {
9
- script: readFileSync(require.resolve("@lunora/studio/standalone/studio.js")),
10
- styles: readFileSync(require.resolve("@lunora/studio/styles.css"))
11
- };
12
- } catch (error) {
13
- const message = error instanceof Error ? error.message : String(error);
14
- logger?.warnOnce?.(`[lunora] studio assets unavailable (build @lunora/studio?): ${message}`);
15
- return void 0;
16
- }
17
- };
18
- const studioAssetsStamp = (resolveFrom = import.meta.url) => {
19
- try {
20
- const require = createRequire(resolveFrom);
21
- const scriptMtime = statSync(require.resolve("@lunora/studio/standalone/studio.js")).mtimeMs;
22
- const stylesMtime = statSync(require.resolve("@lunora/studio/styles.css")).mtimeMs;
23
- return Math.max(scriptMtime, stylesMtime);
24
- } catch {
25
- return void 0;
26
- }
27
- };
28
- const resolveStandaloneDirectory = (resolveFrom = import.meta.url) => {
29
- try {
30
- return dirname(createRequire(resolveFrom).resolve("@lunora/studio/standalone/studio.js"));
31
- } catch {
32
- return void 0;
33
- }
34
- };
35
- const resolveContainedFile = (directory, fileName) => {
36
- if (fileName === "" || fileName === "." || fileName === ".." || fileName.includes("/") || fileName.includes("\\") || fileName.includes("\0")) {
37
- return void 0;
38
- }
39
- const resolved = normalize(join(directory, fileName));
40
- const relativePath = relative(directory, resolved);
41
- if (relativePath === "" || relativePath.startsWith("..") || isAbsolute(relativePath) || relativePath.includes("/") || relativePath.includes("\\")) {
42
- return void 0;
43
- }
44
- return resolved;
45
- };
46
- const readStandaloneAsset = (fileName, resolveFrom = import.meta.url) => {
47
- const directory = resolveStandaloneDirectory(resolveFrom);
48
- if (directory === void 0) {
49
- return void 0;
50
- }
51
- const resolved = resolveContainedFile(directory, fileName);
52
- if (resolved === void 0) {
53
- return void 0;
54
- }
55
- try {
56
- return readFileSync(resolved);
57
- } catch {
58
- return void 0;
59
- }
60
- };
61
- const isStandaloneModulePath = (pathname) => pathname.endsWith(".js") || pathname.endsWith(".js.map");
62
- const assetContentType = (fileName) => {
63
- if (fileName.endsWith(".css")) {
64
- return "text/css; charset=utf-8";
65
- }
66
- if (fileName.endsWith(".map")) {
67
- return "application/json; charset=utf-8";
68
- }
69
- return "text/javascript; charset=utf-8";
70
- };
71
-
72
- export { assetContentType, isStandaloneModulePath, loadStudioAssets, readStandaloneAsset, resolveContainedFile, resolveStandaloneDirectory, studioAssetsStamp };
@@ -1,281 +0,0 @@
1
- import { randomBytes } from 'node:crypto';
2
- import { existsSync, readFileSync, writeFileSync, renameSync, rmSync, statSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { LunoraError } from '@lunora/errors';
5
- import { DEV_VARS_FILE, DEV_VARS_EXAMPLE_FILE, splitDevVariableLine, parseDevVariableEntries, DEV_VARS_NEWLINE, unquoteDevVariable } from './DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
6
- import { CORE_SECRETS, PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs';
7
-
8
- const requiredSecrets = (packageNames) => [...CORE_SECRETS, ...secretsForPackages(packageNames)];
9
- const SECRET_BYTES = 32;
10
- const SECRET_KEY = /(?:KEY|PASSWORD|SECRET|TOKEN)$/u;
11
- const PLACEHOLDER_MARKERS = [
12
- "replace",
13
- "openssl",
14
- "changeme",
15
- "change-me",
16
- "change_me",
17
- "change-this",
18
- "change_this",
19
- "your-",
20
- "your_",
21
- "example",
22
- "placeholder",
23
- "todo",
24
- "fill-me",
25
- "fill_me",
26
- "fill-in",
27
- "fill_in",
28
- "xxx"
29
- ];
30
- const REGEXP_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/gu;
31
- const MARKER_ENDS_ALPHANUMERIC = /[a-z0-9]$/u;
32
- const isPlaceholderValue = (value) => {
33
- const normalised = value.trim().toLowerCase();
34
- if (normalised === "") {
35
- return true;
36
- }
37
- if (normalised.startsWith("<") && normalised.endsWith(">")) {
38
- return true;
39
- }
40
- return PLACEHOLDER_MARKERS.some((marker) => {
41
- const escaped = marker.replaceAll(REGEXP_SPECIAL_CHARS, String.raw`\$&`);
42
- const needsTrailingBoundary = MARKER_ENDS_ALPHANUMERIC.test(marker);
43
- const pattern = needsTrailingBoundary ? `(^|[^a-z0-9])${escaped}([^a-z0-9]|$)` : `(^|[^a-z0-9])${escaped}`;
44
- return new RegExp(pattern, "u").test(normalised);
45
- });
46
- };
47
- const isPlaceholder = (rawValue) => isPlaceholderValue(unquoteDevVariable(rawValue.trim()));
48
- const defaultRandomHex = (bytes) => randomBytes(bytes).toString("hex");
49
- const generatedSecretFor = (key, rawValue, randomHex) => SECRET_KEY.test(key) && isPlaceholder(rawValue) ? randomHex(SECRET_BYTES) : void 0;
50
- const PROVIDER_SECRET_KEYS = new Set(
51
- [...CORE_SECRETS, ...Object.values(PACKAGE_SECRETS_REGISTRY).flat()].filter((entry) => SECRET_KEY.test(entry.key) && entry.placeholderValue.startsWith("<")).map((entry) => entry.key)
52
- );
53
- const isMintableSecretKey = (key) => SECRET_KEY.test(key) && !PROVIDER_SECRET_KEYS.has(key);
54
- const generateSecretValue = (randomHex = defaultRandomHex) => randomHex(SECRET_BYTES);
55
- const planDevVariablesScaffold = (input) => {
56
- if (input.devVarsExists) {
57
- return { status: "exists" };
58
- }
59
- if (input.exampleContent === void 0) {
60
- return { status: "no-example" };
61
- }
62
- const randomHex = input.randomHex ?? defaultRandomHex;
63
- const generatedKeys = [];
64
- const lines = input.exampleContent.split(DEV_VARS_NEWLINE).map((line) => {
65
- const parsed = splitDevVariableLine(line);
66
- const secret = parsed ? generatedSecretFor(parsed.key, parsed.value, randomHex) : void 0;
67
- if (!parsed || secret === void 0) {
68
- return line;
69
- }
70
- generatedKeys.push(parsed.key);
71
- return `${parsed.key}="${secret}"`;
72
- });
73
- return { content: lines.join("\n"), generatedKeys, status: "generate" };
74
- };
75
- const planDevVariablesAugment = (input) => {
76
- const randomHex = input.randomHex ?? defaultRandomHex;
77
- const present = new Set(parseDevVariableEntries(input.existingContent).map((entry) => entry.key));
78
- const additions = [];
79
- const generatedKeys = [];
80
- const missingKeys = [];
81
- for (const line of input.exampleContent.split(DEV_VARS_NEWLINE)) {
82
- const parsed = splitDevVariableLine(line);
83
- if (!parsed || present.has(parsed.key)) {
84
- continue;
85
- }
86
- const secret = generatedSecretFor(parsed.key, parsed.value, randomHex);
87
- missingKeys.push(parsed.key);
88
- if (secret === void 0) {
89
- additions.push(`${parsed.key}="${unquoteDevVariable(parsed.value)}"`);
90
- } else {
91
- generatedKeys.push(parsed.key);
92
- additions.push(`${parsed.key}="${secret}"`);
93
- }
94
- }
95
- return { additions, generatedKeys, missingKeys };
96
- };
97
- const generatedSuffix = (keys) => keys.length > 0 ? ` (generated ${keys.join(", ")})` : "";
98
- const atomicCreateDevVariables = (path, content) => {
99
- const temporaryPath = `${path}.tmp-${String(process.pid)}`;
100
- try {
101
- writeFileSync(temporaryPath, content, { encoding: "utf8", flag: "wx", mode: 384 });
102
- renameSync(temporaryPath, path);
103
- } catch (error) {
104
- rmSync(temporaryPath, { force: true });
105
- throw error;
106
- }
107
- };
108
- const APPEND_MAX_ATTEMPTS = 5;
109
- const fingerprintOf = (path) => {
110
- try {
111
- const stats = statSync(path);
112
- return { mtimeMs: stats.mtimeMs, size: stats.size };
113
- } catch {
114
- return void 0;
115
- }
116
- };
117
- const sameFingerprint = (a, b) => {
118
- if (a === void 0 || b === void 0) {
119
- return false;
120
- }
121
- return a.mtimeMs === b.mtimeMs && a.size === b.size;
122
- };
123
- const appendDevVariables = (path, buildAdditions) => {
124
- for (let attempt = 0; attempt < APPEND_MAX_ATTEMPTS; attempt += 1) {
125
- const beforeFingerprint = fingerprintOf(path);
126
- const existing = readFileSync(path, "utf8");
127
- const additions = buildAdditions(existing);
128
- if (additions.length === 0) {
129
- return [];
130
- }
131
- const separator = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
132
- const content = `${existing}${separator}${additions.join("\n")}
133
- `;
134
- const temporaryPath = `${path}.tmp-${String(process.pid)}-${randomBytes(6).toString("hex")}`;
135
- try {
136
- writeFileSync(temporaryPath, content, { encoding: "utf8", mode: 384 });
137
- const beforeRenameFingerprint = fingerprintOf(path);
138
- if (!sameFingerprint(beforeFingerprint, beforeRenameFingerprint)) {
139
- rmSync(temporaryPath, { force: true });
140
- continue;
141
- }
142
- renameSync(temporaryPath, path);
143
- return additions;
144
- } catch (error) {
145
- rmSync(temporaryPath, { force: true });
146
- throw error;
147
- }
148
- }
149
- throw new LunoraError("INTERNAL", `Failed to append to ${path} after ${String(APPEND_MAX_ATTEMPTS)} attempts — a concurrent writer kept winning the race.`);
150
- };
151
- const ensureDevVariables = async (deps) => {
152
- const devVariablesPath = join(deps.cwd, DEV_VARS_FILE);
153
- const examplePath = join(deps.cwd, DEV_VARS_EXAMPLE_FILE);
154
- if (!existsSync(examplePath)) {
155
- return { addedKeys: [], generatedKeys: [], status: "no-example" };
156
- }
157
- const exampleContent = readFileSync(examplePath, "utf8");
158
- if (!existsSync(devVariablesPath)) {
159
- const plan = planDevVariablesScaffold({ devVarsExists: false, exampleContent, randomHex: deps.randomHex });
160
- if (plan.status !== "generate") {
161
- return { addedKeys: [], generatedKeys: [], status: "no-example" };
162
- }
163
- const proceed2 = deps.yes === true || await deps.confirm(`No ${DEV_VARS_FILE} found. Generate it from ${DEV_VARS_EXAMPLE_FILE} (secrets auto-filled)?`);
164
- if (!proceed2) {
165
- deps.info(`Skipped — copy ${DEV_VARS_EXAMPLE_FILE} to ${DEV_VARS_FILE} and fill it in when you're ready.`);
166
- return { addedKeys: [], generatedKeys: [], status: "declined" };
167
- }
168
- if (existsSync(devVariablesPath)) {
169
- return { addedKeys: [], generatedKeys: [], status: "skipped-exists" };
170
- }
171
- atomicCreateDevVariables(devVariablesPath, plan.content);
172
- deps.info(`Created ${DEV_VARS_FILE}${generatedSuffix(plan.generatedKeys)}.`);
173
- return { addedKeys: [], generatedKeys: plan.generatedKeys, status: "generated" };
174
- }
175
- const augment = planDevVariablesAugment({ existingContent: readFileSync(devVariablesPath, "utf8"), exampleContent, randomHex: deps.randomHex });
176
- if (augment.missingKeys.length === 0) {
177
- return { addedKeys: [], generatedKeys: [], status: "exists" };
178
- }
179
- const list = augment.missingKeys.join(", ");
180
- const proceed = deps.yes === true || await deps.confirm(`${DEV_VARS_FILE} is missing ${String(augment.missingKeys.length)} key(s) from ${DEV_VARS_EXAMPLE_FILE} (${list}). Add them?`);
181
- if (!proceed) {
182
- deps.info(`Skipped — add ${list} to ${DEV_VARS_FILE} when you're ready.`);
183
- return { addedKeys: [], generatedKeys: [], status: "declined" };
184
- }
185
- const written = appendDevVariables(
186
- devVariablesPath,
187
- (currentContent) => planDevVariablesAugment({ existingContent: currentContent, exampleContent, randomHex: deps.randomHex }).additions
188
- );
189
- const writtenKeys = written.map((line) => splitDevVariableLine(line)?.key).filter((key) => key !== void 0);
190
- if (writtenKeys.length === 0) {
191
- return { addedKeys: [], generatedKeys: [], status: "exists" };
192
- }
193
- const writtenGeneratedKeys = augment.generatedKeys.filter((key) => writtenKeys.includes(key));
194
- deps.info(`Updated ${DEV_VARS_FILE} — added ${writtenKeys.join(", ")}${generatedSuffix(writtenGeneratedKeys)}.`);
195
- return { addedKeys: writtenKeys, generatedKeys: writtenGeneratedKeys, status: "augmented" };
196
- };
197
- const secretEntryBlock = (entry) => {
198
- const lines = [`# ${entry.description}`, `# Docs: ${entry.docsUrl}`, `${entry.key}="${entry.placeholderValue}"`];
199
- return lines.join("\n");
200
- };
201
- const buildPackageSecretsBlock = (packageNames, existingKeys) => {
202
- const entries = requiredSecrets(packageNames).filter((entry) => !existingKeys.has(entry.key));
203
- if (entries.length === 0) {
204
- return "";
205
- }
206
- return entries.map((entry) => secretEntryBlock(entry)).join("\n\n");
207
- };
208
- const ensureDevVariablesExample = (cwd, packageNames) => {
209
- const examplePath = join(cwd, DEV_VARS_EXAMPLE_FILE);
210
- const existing = existsSync(examplePath) ? readFileSync(examplePath, "utf8") : "";
211
- const existingKeys = new Set(parseDevVariableEntries(existing).map((entry) => entry.key));
212
- const block = buildPackageSecretsBlock(packageNames, existingKeys);
213
- if (block === "") {
214
- return [];
215
- }
216
- const separator = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
217
- const newContent = `${existing}${separator}
218
- ${block}
219
- `;
220
- const temporaryPath = `${examplePath}.tmp-${String(process.pid)}`;
221
- try {
222
- writeFileSync(temporaryPath, newContent, { encoding: "utf8" });
223
- renameSync(temporaryPath, examplePath);
224
- } catch (error) {
225
- rmSync(temporaryPath, { force: true });
226
- throw error;
227
- }
228
- return requiredSecrets(packageNames).filter((entry) => !existingKeys.has(entry.key)).map((entry) => entry.key);
229
- };
230
- const planDevSecretsFill = (input) => {
231
- const randomHex = input.randomHex ?? defaultRandomHex;
232
- const filledKeys = [];
233
- const lines = input.existingContent.split(DEV_VARS_NEWLINE).map((line) => {
234
- const parsed = splitDevVariableLine(line);
235
- const secret = parsed ? generatedSecretFor(parsed.key, parsed.value, randomHex) : void 0;
236
- if (!parsed || secret === void 0) {
237
- return line;
238
- }
239
- filledKeys.push(parsed.key);
240
- return `${parsed.key}="${secret}"`;
241
- });
242
- const present = new Set(parseDevVariableEntries(input.existingContent).map((entry) => entry.key));
243
- const addedKeys = [];
244
- const additions = [];
245
- for (const entry of CORE_SECRETS) {
246
- if (present.has(entry.key)) {
247
- continue;
248
- }
249
- addedKeys.push(entry.key);
250
- additions.push(`# ${entry.description}`, `${entry.key}="${randomHex(SECRET_BYTES)}"`);
251
- }
252
- const body = lines.join("\n");
253
- if (additions.length === 0) {
254
- return { addedKeys, content: body, filledKeys };
255
- }
256
- const separator = body === "" || body.endsWith("\n") ? "" : "\n";
257
- return { addedKeys, content: `${body}${separator}${additions.join("\n")}
258
- `, filledKeys };
259
- };
260
- const fillDevSecrets = (deps) => {
261
- const devVariablesPath = join(deps.cwd, DEV_VARS_FILE);
262
- const exists = existsSync(devVariablesPath);
263
- const existingContent = exists ? readFileSync(devVariablesPath, "utf8") : "";
264
- const plan = planDevSecretsFill({ existingContent, randomHex: deps.randomHex });
265
- if (plan.filledKeys.length === 0 && plan.addedKeys.length === 0) {
266
- return { addedKeys: [], filledKeys: [], status: "unchanged" };
267
- }
268
- const temporaryPath = `${devVariablesPath}.tmp-${String(process.pid)}`;
269
- try {
270
- writeFileSync(temporaryPath, plan.content, { encoding: "utf8", mode: 384 });
271
- renameSync(temporaryPath, devVariablesPath);
272
- } catch (error) {
273
- rmSync(temporaryPath, { force: true });
274
- throw error;
275
- }
276
- const generated = [...plan.filledKeys, ...plan.addedKeys];
277
- deps.info?.(`Generated ${String(generated.length)} dev secret(s) in ${DEV_VARS_FILE}: ${generated.join(", ")}`);
278
- return { addedKeys: plan.addedKeys, filledKeys: plan.filledKeys, status: exists ? "filled" : "created" };
279
- };
280
-
281
- export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets };