@romaintaillandier1978/dotenv-never-lies 1.1.1 → 1.3.0

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 (212) hide show
  1. package/README.md +103 -42
  2. package/dist/cli/commands/assert.d.ts +3 -4
  3. package/dist/cli/commands/assert.d.ts.map +1 -1
  4. package/dist/cli/commands/explain.d.ts +2 -3
  5. package/dist/cli/commands/explain.d.ts.map +1 -1
  6. package/dist/cli/commands/export.d.ts +4 -3
  7. package/dist/cli/commands/export.d.ts.map +1 -1
  8. package/dist/cli/commands/export.js +46 -0
  9. package/dist/cli/commands/generate.d.ts +2 -2
  10. package/dist/cli/commands/generate.d.ts.map +1 -1
  11. package/dist/cli/commands/infer.d.ts +15 -0
  12. package/dist/cli/commands/infer.d.ts.map +1 -0
  13. package/dist/cli/commands/infer.js +86 -0
  14. package/dist/cli/commands/init.d.ts +15 -0
  15. package/dist/cli/commands/init.d.ts.map +1 -0
  16. package/dist/cli/commands/init.js +30 -0
  17. package/dist/cli/commands/program.d.ts +4 -0
  18. package/dist/cli/commands/program.d.ts.map +1 -0
  19. package/dist/cli/commands/program.js +1 -0
  20. package/dist/cli/index.js +74 -30
  21. package/dist/cli/utils/infer-schema.d.ts +2 -2
  22. package/dist/cli/utils/infer-schema.d.ts.map +1 -1
  23. package/dist/cli/utils/infer-schema.js +20 -22
  24. package/dist/cli/utils/printer.d.ts +2 -0
  25. package/dist/cli/utils/printer.d.ts.map +1 -1
  26. package/dist/cli/utils/printer.js +104 -1
  27. package/dist/core.d.ts.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -0
  31. package/dist/infer/__tests__/port-vs-version.test.d.ts +2 -0
  32. package/dist/infer/__tests__/port-vs-version.test.d.ts.map +1 -0
  33. package/dist/infer/__tests__/port-vs-version.test.js +32 -0
  34. package/dist/infer/__tests__/rules/basic.test.d.ts +2 -0
  35. package/dist/infer/__tests__/rules/basic.test.d.ts.map +1 -0
  36. package/dist/infer/__tests__/rules/basic.test.js +85 -0
  37. package/dist/infer/__tests__/rules/boolean.test.d.ts +2 -0
  38. package/dist/infer/__tests__/rules/boolean.test.d.ts.map +1 -0
  39. package/dist/infer/__tests__/rules/boolean.test.js +34 -0
  40. package/dist/infer/__tests__/rules/duration.test.d.ts +2 -0
  41. package/dist/infer/__tests__/rules/duration.test.d.ts.map +1 -0
  42. package/dist/infer/__tests__/rules/duration.test.js +24 -0
  43. package/dist/infer/__tests__/rules/ip.test.d.ts +2 -0
  44. package/dist/infer/__tests__/rules/ip.test.d.ts.map +1 -0
  45. package/dist/infer/__tests__/rules/ip.test.js +24 -0
  46. package/dist/infer/__tests__/rules/json.test.d.ts +2 -0
  47. package/dist/infer/__tests__/rules/json.test.d.ts.map +1 -0
  48. package/dist/infer/__tests__/rules/json.test.js +38 -0
  49. package/dist/infer/__tests__/rules/list.test.d.ts +2 -0
  50. package/dist/infer/__tests__/rules/list.test.d.ts.map +1 -0
  51. package/dist/infer/__tests__/rules/list.test.js +130 -0
  52. package/dist/infer/__tests__/rules/port.test.d.ts +2 -0
  53. package/dist/infer/__tests__/rules/port.test.d.ts.map +1 -0
  54. package/dist/infer/__tests__/rules/port.test.js +24 -0
  55. package/dist/infer/__tests__/rules/url.test.d.ts +2 -0
  56. package/dist/infer/__tests__/rules/url.test.d.ts.map +1 -0
  57. package/dist/infer/__tests__/rules/url.test.js +39 -0
  58. package/dist/infer/__tests__/rules/version.test.d.ts +2 -0
  59. package/dist/infer/__tests__/rules/version.test.d.ts.map +1 -0
  60. package/dist/infer/__tests__/rules/version.test.js +37 -0
  61. package/dist/infer/generated/basic.d.ts +8 -0
  62. package/dist/infer/generated/basic.d.ts.map +1 -0
  63. package/dist/infer/generated/basic.js +24 -0
  64. package/dist/infer/generated/boolean.d.ts +3 -0
  65. package/dist/infer/generated/boolean.d.ts.map +1 -0
  66. package/dist/infer/generated/boolean.js +9 -0
  67. package/dist/infer/generated/duration.d.ts +3 -0
  68. package/dist/infer/generated/duration.d.ts.map +1 -0
  69. package/dist/infer/generated/duration.js +9 -0
  70. package/dist/infer/generated/ip.d.ts +3 -0
  71. package/dist/infer/generated/ip.d.ts.map +1 -0
  72. package/dist/infer/generated/ip.js +9 -0
  73. package/dist/infer/generated/json.d.ts +4 -0
  74. package/dist/infer/generated/json.d.ts.map +1 -0
  75. package/dist/infer/generated/json.js +10 -0
  76. package/dist/infer/generated/list.d.ts +8 -0
  77. package/dist/infer/generated/list.d.ts.map +1 -0
  78. package/dist/infer/generated/list.js +49 -0
  79. package/dist/infer/generated/port.d.ts +4 -0
  80. package/dist/infer/generated/port.d.ts.map +1 -0
  81. package/dist/infer/generated/port.js +10 -0
  82. package/dist/infer/generated/url.d.ts +14 -0
  83. package/dist/infer/generated/url.d.ts.map +1 -0
  84. package/dist/infer/generated/url.js +30 -0
  85. package/dist/infer/generated/version.d.ts +4 -0
  86. package/dist/infer/generated/version.d.ts.map +1 -0
  87. package/dist/infer/generated/version.js +10 -0
  88. package/dist/infer/helpers.d.ts +11 -0
  89. package/dist/infer/helpers.d.ts.map +1 -0
  90. package/dist/infer/helpers.js +41 -0
  91. package/dist/infer/index.d.ts +4 -0
  92. package/dist/infer/index.d.ts.map +1 -0
  93. package/dist/infer/index.js +35 -0
  94. package/dist/infer/rules/basic.d.ts +11 -0
  95. package/dist/infer/rules/basic.d.ts.map +1 -0
  96. package/dist/infer/rules/basic.js +90 -0
  97. package/dist/infer/rules/boolean.d.ts +3 -0
  98. package/dist/infer/rules/boolean.d.ts.map +1 -0
  99. package/dist/infer/rules/boolean.js +25 -0
  100. package/dist/infer/rules/duration.d.ts +3 -0
  101. package/dist/infer/rules/duration.d.ts.map +1 -0
  102. package/dist/infer/rules/duration.js +25 -0
  103. package/dist/infer/rules/ip.d.ts +3 -0
  104. package/dist/infer/rules/ip.d.ts.map +1 -0
  105. package/dist/infer/rules/ip.js +25 -0
  106. package/dist/infer/rules/json.d.ts +3 -0
  107. package/dist/infer/rules/json.d.ts.map +1 -0
  108. package/dist/infer/rules/json.js +59 -0
  109. package/dist/infer/rules/list.d.ts +12 -0
  110. package/dist/infer/rules/list.d.ts.map +1 -0
  111. package/dist/infer/rules/list.js +221 -0
  112. package/dist/infer/rules/port.d.ts +3 -0
  113. package/dist/infer/rules/port.d.ts.map +1 -0
  114. package/dist/infer/rules/port.js +30 -0
  115. package/dist/infer/rules/url.d.ts +4 -0
  116. package/dist/infer/rules/url.d.ts.map +1 -0
  117. package/dist/infer/rules/url.js +143 -0
  118. package/dist/infer/rules/version.d.ts +3 -0
  119. package/dist/infer/rules/version.d.ts.map +1 -0
  120. package/dist/infer/rules/version.js +26 -0
  121. package/dist/infer/types.d.ts +87 -0
  122. package/dist/infer/types.d.ts.map +1 -0
  123. package/dist/infer/types.js +1 -0
  124. package/dist/infer-rules/basic.d.ts +5 -0
  125. package/dist/infer-rules/basic.d.ts.map +1 -0
  126. package/dist/infer-rules/basic.js +48 -0
  127. package/dist/infer-rules/boolean.d.ts +3 -0
  128. package/dist/infer-rules/boolean.d.ts.map +1 -0
  129. package/dist/infer-rules/boolean.js +25 -0
  130. package/dist/infer-rules/dotted.d.ts +4 -0
  131. package/dist/infer-rules/dotted.d.ts.map +1 -0
  132. package/dist/infer-rules/dotted.js +48 -0
  133. package/dist/infer-rules/duration.d.ts +3 -0
  134. package/dist/infer-rules/duration.d.ts.map +1 -0
  135. package/dist/infer-rules/duration.js +25 -0
  136. package/dist/infer-rules/index.d.ts +50 -0
  137. package/dist/infer-rules/index.d.ts.map +1 -0
  138. package/dist/infer-rules/index.js +42 -0
  139. package/dist/infer-rules/json.d.ts +3 -0
  140. package/dist/infer-rules/json.d.ts.map +1 -0
  141. package/dist/infer-rules/json.js +50 -0
  142. package/dist/infer-rules/list.d.ts +5 -0
  143. package/dist/infer-rules/list.d.ts.map +1 -0
  144. package/dist/infer-rules/list.js +200 -0
  145. package/dist/infer-rules/path.d.ts +5 -0
  146. package/dist/infer-rules/path.d.ts.map +1 -0
  147. package/dist/infer-rules/path.js +78 -0
  148. package/dist/infer-rules/port.d.ts +3 -0
  149. package/dist/infer-rules/port.d.ts.map +1 -0
  150. package/dist/infer-rules/port.js +26 -0
  151. package/dist/infer-rules/simple.d.ts +3 -0
  152. package/dist/infer-rules/simple.d.ts.map +1 -0
  153. package/dist/infer-rules/simple.js +37 -0
  154. package/dist/infer-rules/url.d.ts +4 -0
  155. package/dist/infer-rules/url.d.ts.map +1 -0
  156. package/dist/infer-rules/url.js +149 -0
  157. package/dist/llm-kit/context.json.d.ts +2 -0
  158. package/dist/llm-kit/context.json.d.ts.map +1 -0
  159. package/dist/llm-kit/context.json.js +22 -0
  160. package/dist/sample/DNLTest.d.ts +2 -0
  161. package/dist/sample/DNLTest.d.ts.map +1 -0
  162. package/dist/sample/DNLTest.js +4 -0
  163. package/dist/sample/debug.d.ts +2 -0
  164. package/dist/sample/debug.d.ts.map +1 -0
  165. package/dist/sample/debug.js +5 -0
  166. package/dist/sample/env.dnl.d.ts +426 -0
  167. package/dist/sample/env.dnl.d.ts.map +1 -0
  168. package/dist/sample/env.dnl.js +429 -0
  169. package/dist/schemas/bool.d.ts +9 -0
  170. package/dist/schemas/bool.d.ts.map +1 -0
  171. package/dist/schemas/bool.js +22 -0
  172. package/dist/schemas/boolean.d.ts +9 -0
  173. package/dist/schemas/boolean.d.ts.map +1 -0
  174. package/dist/schemas/boolean.js +23 -0
  175. package/dist/schemas/dotted.d.ts +21 -0
  176. package/dist/schemas/dotted.d.ts.map +1 -0
  177. package/dist/schemas/dotted.js +45 -0
  178. package/dist/schemas/duration.d.ts +11 -0
  179. package/dist/schemas/duration.d.ts.map +1 -0
  180. package/dist/schemas/duration.js +44 -0
  181. package/dist/schemas/index.d.ts +9 -0
  182. package/dist/schemas/index.d.ts.map +1 -0
  183. package/dist/schemas/index.js +8 -0
  184. package/dist/schemas/ip-and-version.d.ts +12 -0
  185. package/dist/schemas/ip-and-version.d.ts.map +1 -0
  186. package/dist/schemas/ip-and-version.js +35 -0
  187. package/dist/schemas/ip.d.ts +11 -0
  188. package/dist/schemas/ip.d.ts.map +1 -0
  189. package/dist/schemas/ip.js +33 -0
  190. package/dist/schemas/json.d.ts +15 -0
  191. package/dist/schemas/json.d.ts.map +1 -0
  192. package/dist/schemas/json.js +34 -0
  193. package/dist/schemas/list.d.ts +89 -0
  194. package/dist/schemas/list.d.ts.map +1 -0
  195. package/dist/schemas/list.js +139 -0
  196. package/dist/schemas/path.d.ts +23 -0
  197. package/dist/schemas/path.d.ts.map +1 -0
  198. package/dist/schemas/path.js +33 -0
  199. package/dist/schemas/port.d.ts +8 -0
  200. package/dist/schemas/port.d.ts.map +1 -0
  201. package/dist/schemas/port.js +9 -0
  202. package/dist/schemas/urls.d.ts +15 -0
  203. package/dist/schemas/urls.d.ts.map +1 -0
  204. package/dist/schemas/urls.js +54 -0
  205. package/package.json +11 -6
  206. package/dist/DnlTest.d.ts +0 -2
  207. package/dist/DnlTest.d.ts.map +0 -1
  208. package/dist/DnlTest.js +0 -12
  209. package/dist/cli/utils/exitCodes.d.ts +0 -8
  210. package/dist/cli/utils/exitCodes.d.ts.map +0 -1
  211. package/dist/cli/utils/exitCodes.js +0 -8
  212. package/dist/romaintaillandier1978-dotenv-never-lies-0.3.0.tgz +0 -0
@@ -0,0 +1,200 @@
1
+ import { inferSimpleSchemaForListItem } from "../cli/utils/infer-schema.js";
2
+ import { matchesEnvKey } from "./index.js";
3
+ const DOUBLE_SEPARATORS = [
4
+ [";", "="],
5
+ [",", "="],
6
+ ["&", "="],
7
+ ];
8
+ const KEY_PAIR_NAMES_LIST = ["_MAPS", "_LABELS", "_HEADERS", "_PARAMS"];
9
+ export const keyValueListRule = {
10
+ type: "keyValueList",
11
+ priority: 9,
12
+ threshold: 6,
13
+ tryInfer({ name, rawValue }) {
14
+ if (rawValue.startsWith("{") || rawValue.startsWith("["))
15
+ return null;
16
+ const pairs = rawValue.split(/[;,&]/).filter(Boolean);
17
+ let validPairs = 0;
18
+ for (const pair of pairs) {
19
+ if (pair.includes("="))
20
+ validPairs++;
21
+ }
22
+ if (validPairs < 2)
23
+ return null;
24
+ const reasons = ["Multiple key=value pairs detected"];
25
+ let confidence = 6;
26
+ const { matched, reason } = matchesEnvKey(name, KEY_PAIR_NAMES_LIST);
27
+ if (matched) {
28
+ confidence += 1;
29
+ reasons.push(`${reason} (+1)`);
30
+ }
31
+ return {
32
+ schema: `keyValueListSchema("${name}")`,
33
+ importedSchemas: ["keyValueListSchema"],
34
+ confidence,
35
+ reasons,
36
+ };
37
+ },
38
+ };
39
+ const KEY_PAIR_NAMES = ["_ENV", "_VARS", "_CONFIG", "_OPTIONS"];
40
+ export const keyValueRule = {
41
+ type: "keyValue",
42
+ priority: 8,
43
+ threshold: 5,
44
+ tryInfer({ name, rawValue }) {
45
+ if (rawValue.startsWith("{") || rawValue.startsWith("["))
46
+ return null;
47
+ if (!rawValue.includes("="))
48
+ return null;
49
+ const reasons = ["Single key=value structure"];
50
+ let confidence = 4;
51
+ const { matched, reason } = matchesEnvKey(name, KEY_PAIR_NAMES);
52
+ if (matched) {
53
+ confidence += 1;
54
+ reasons.push(`${reason} (+1)`);
55
+ }
56
+ return {
57
+ schema: `keyValueSchema("${name}")`,
58
+ importedSchemas: ["keyValueSchema"],
59
+ confidence,
60
+ reasons,
61
+ };
62
+ },
63
+ };
64
+ const LIST_KEYS = ["_LIST", "_ITEMS", "_ARRAY", "_VALUES"];
65
+ const allElementsAreEquals = (elements) => {
66
+ const e0 = elements[0];
67
+ return elements.every((e) => e === e0);
68
+ };
69
+ export const listRule = {
70
+ type: "list",
71
+ priority: 7,
72
+ threshold: 5,
73
+ tryInfer({ name, rawValue }) {
74
+ if (rawValue.startsWith("{") || rawValue.startsWith("["))
75
+ return null;
76
+ if (rawValue.includes("="))
77
+ return null;
78
+ let confidence = 0;
79
+ const reasons = [];
80
+ const semicolonItems = rawValue.split(";").filter(Boolean);
81
+ const commaItems = rawValue.split(",").filter(Boolean);
82
+ let parts = [];
83
+ if (semicolonItems.length > 1) {
84
+ confidence += 4;
85
+ reasons.push("multiple values separated by semicolon ';' (+4)");
86
+ parts = semicolonItems;
87
+ }
88
+ else if (commaItems.length > 1) {
89
+ confidence += 4;
90
+ reasons.push("multiple values separated by comma ',' (+4)");
91
+ parts = commaItems;
92
+ }
93
+ if (!parts || parts.length === 0)
94
+ return null;
95
+ const { matched, reason } = matchesEnvKey(name, LIST_KEYS);
96
+ if (matched) {
97
+ confidence += 1;
98
+ reasons.push(`${reason} (+1)`);
99
+ }
100
+ const itemTypes = parts.map((value) => inferSimpleSchemaForListItem("", value));
101
+ if (allElementsAreEquals(itemTypes)) {
102
+ reasons.push("All elements are of the same type (+2)");
103
+ confidence += 2;
104
+ switch (itemTypes[0]) {
105
+ case 'portSchema("")':
106
+ reasons.push("All elements are PORTS (+2)");
107
+ confidence += 2;
108
+ return {
109
+ schema: `listSchema("${name}", { of: ${itemTypes[0]} })`,
110
+ importedSchemas: ["listSchema", "portSchema"],
111
+ confidence,
112
+ reasons,
113
+ };
114
+ case "z.url()":
115
+ reasons.push("All elements are URLs (+2)");
116
+ confidence += 2;
117
+ return {
118
+ schema: `urlListSchema("${name}")`,
119
+ importedSchemas: ["urlListSchema"],
120
+ confidence,
121
+ reasons,
122
+ };
123
+ case "z.email()":
124
+ reasons.push("All elements are emails (+2)");
125
+ confidence += 2;
126
+ return {
127
+ schema: `emailListSchema("${name}")`,
128
+ importedSchemas: ["emailListSchema"],
129
+ confidence,
130
+ reasons,
131
+ };
132
+ case "z.number()":
133
+ reasons.push("All elements are numbers (+2)");
134
+ confidence += 2;
135
+ return {
136
+ schema: `listSchema("${name}", { of: z.number() })`,
137
+ importedSchemas: ["listSchema"],
138
+ confidence,
139
+ reasons,
140
+ };
141
+ default:
142
+ //vraie liste de string
143
+ reasons.push("All elements are strings (+2)");
144
+ confidence += 2;
145
+ return {
146
+ schema: `listSchema("${name}")`,
147
+ importedSchemas: ["listSchema"],
148
+ confidence,
149
+ reasons,
150
+ };
151
+ }
152
+ }
153
+ // liste de type mixte
154
+ return {
155
+ schema: `listSchema("${name}")`,
156
+ importedSchemas: ["listSchema"],
157
+ confidence,
158
+ reasons,
159
+ };
160
+ },
161
+ };
162
+ const URL_LIST_KEYS = ["_URLS", "_LINKS", "_ENDPOINTS", "_APIS", "CORS"];
163
+ // export const urlListRule: InferencePass = {
164
+ // type: "urlList",
165
+ // priority: 6, // juste sous url, au-dessus de filePath
166
+ // threshold: 5,
167
+ // tryInfer({ name, rawValue }) {
168
+ // const parts = rawValue
169
+ // .split(/[;,]/)
170
+ // .map((v) => v.trim())
171
+ // .filter(Boolean);
172
+ // if (parts.length < 2) return null;
173
+ // let confidence = 1;
174
+ // const reasons: string[] = ["Multiple values separated by delimiter (+1)"];
175
+ // for (const part of parts) {
176
+ // try {
177
+ // const url = new URL(part);
178
+ // if (url.protocol !== "http:" && url.protocol !== "https:") {
179
+ // return null;
180
+ // }
181
+ // } catch {
182
+ // return null;
183
+ // }
184
+ // }
185
+ // confidence += 5;
186
+ // reasons.push("All values are valid http(s) URLs (+5)");
187
+ // const { matched, reason } = matchesEnvKey(name, URL_LIST_KEYS);
188
+ // console.log("urlListRule", name, matched, reason);
189
+ // if (matched) {
190
+ // confidence += 2;
191
+ // reasons.push(`${reason} (+2)`);
192
+ // }
193
+ // return {
194
+ // schema: `urlListSchema("${name}")`,
195
+ // importedSchema: "urlListSchema",
196
+ // confidence,
197
+ // reasons,
198
+ // };
199
+ // },
200
+ // };
@@ -0,0 +1,5 @@
1
+ import { InferencePass } from "./index.js";
2
+ export declare const filePathRule: InferencePass;
3
+ export declare const pathRule: InferencePass;
4
+ export declare const filenameRule: InferencePass;
5
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/infer-rules/path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAI1D,eAAO,MAAM,YAAY,EAAE,aAwB1B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,aAyBtB,CAAC;AAIF,eAAO,MAAM,YAAY,EAAE,aAuB1B,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { looksLikePath, looksLikeFilename, looksLikeFilePath } from "../schemas/path.js";
2
+ import { looksLikeHttpUrl } from "../schemas/urls.js";
3
+ import { matchesEnvKey } from "./index.js";
4
+ const FILE_KEYS = ["_FILE", "_CERT", "_KEY", "_PATH"];
5
+ export const filePathRule = {
6
+ type: "filePath",
7
+ priority: 2,
8
+ threshold: 4,
9
+ tryInfer({ name, rawValue }) {
10
+ if (!looksLikeFilePath(rawValue))
11
+ return null;
12
+ if (looksLikeHttpUrl(rawValue))
13
+ return null;
14
+ let confidence = 4;
15
+ const reasons = ["Value looks like a file path (+4)"];
16
+ const { matched, reason } = matchesEnvKey(name, FILE_KEYS);
17
+ if (matched) {
18
+ confidence += 1;
19
+ reasons.push(`${reason} (+1)`);
20
+ }
21
+ return {
22
+ schema: `filePathSchema(${JSON.stringify(name)})`,
23
+ importedSchemas: ["filePathSchema"],
24
+ confidence,
25
+ reasons,
26
+ };
27
+ },
28
+ };
29
+ const PATH_KEYS = ["_PATH", "_DIR", "_HOME", "_ROOT"];
30
+ export const pathRule = {
31
+ type: "path",
32
+ priority: 2,
33
+ threshold: 4,
34
+ tryInfer({ name, rawValue }) {
35
+ if (!looksLikePath(rawValue))
36
+ return null;
37
+ if (looksLikeFilePath(rawValue))
38
+ return null; // important
39
+ if (looksLikeHttpUrl(rawValue))
40
+ return null;
41
+ let confidence = 4;
42
+ const reasons = ["Value looks like a directory path (+4)"];
43
+ const { matched, reason } = matchesEnvKey(name, PATH_KEYS);
44
+ if (matched) {
45
+ confidence += 1;
46
+ reasons.push(`${reason} (+1)`);
47
+ }
48
+ return {
49
+ schema: `pathSchema(${JSON.stringify(name)})`,
50
+ importedSchemas: ["pathSchema"],
51
+ confidence,
52
+ reasons,
53
+ };
54
+ },
55
+ };
56
+ const FILENAME_KEYS = ["_FILE", "_FILENAME", "_NAME"];
57
+ export const filenameRule = {
58
+ type: "filename",
59
+ priority: 1,
60
+ threshold: 4,
61
+ tryInfer({ name, rawValue }) {
62
+ if (!looksLikeFilename(rawValue))
63
+ return null;
64
+ let confidence = 4;
65
+ const reasons = ["Value looks like a filename (+4)"];
66
+ const { matched, reason } = matchesEnvKey(name, FILENAME_KEYS);
67
+ if (matched) {
68
+ confidence += 1;
69
+ reasons.push(`${reason} (+1)`);
70
+ }
71
+ return {
72
+ schema: `filenameSchema(${JSON.stringify(name)})`,
73
+ importedSchemas: ["filenameSchema"],
74
+ confidence,
75
+ reasons,
76
+ };
77
+ },
78
+ };
@@ -0,0 +1,3 @@
1
+ import { InferencePass } from "./index.js";
2
+ export declare const portRule: InferencePass;
3
+ //# sourceMappingURL=port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/infer-rules/port.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAI1D,eAAO,MAAM,QAAQ,EAAE,aAyBtB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { matchesEnvKey } from "./index.js";
2
+ const PORT_KEYS = ["PORT", "PORT_", "_PORT"];
3
+ export const portRule = {
4
+ type: "port",
5
+ priority: 7,
6
+ threshold: 5,
7
+ tryInfer({ name, rawValue }) {
8
+ const port = Number(rawValue);
9
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
10
+ return null;
11
+ }
12
+ let confidence = 5; // valeur seule = déjà crédible
13
+ const reasons = ["Valid TCP/UDP port number"];
14
+ const { matched, reason } = matchesEnvKey(name, PORT_KEYS);
15
+ if (matched) {
16
+ confidence += 2;
17
+ reasons.push(`${reason} (+2)`);
18
+ }
19
+ return {
20
+ schema: `portSchema("${name}")`,
21
+ importedSchemas: ["portSchema"],
22
+ confidence,
23
+ reasons,
24
+ };
25
+ },
26
+ };
@@ -0,0 +1,3 @@
1
+ import { InferencePass } from "./index.js";
2
+ export declare const simpleRule: InferencePass;
3
+ //# sourceMappingURL=simple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../../src/infer-rules/simple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,aAuCxB,CAAC"}
@@ -0,0 +1,37 @@
1
+ export const simpleRule = {
2
+ type: "simple",
3
+ priority: 1,
4
+ threshold: 5,
5
+ tryInfer({ name, rawValue }) {
6
+ if (rawValue === undefined) {
7
+ return {
8
+ schema: "z.string().optional()",
9
+ confidence: 1,
10
+ };
11
+ }
12
+ if (!isNaN(Number(rawValue))) {
13
+ return {
14
+ schema: "z.coerce.number()",
15
+ confidence: 10,
16
+ };
17
+ }
18
+ try {
19
+ new URL(rawValue);
20
+ return {
21
+ schema: "z.url()",
22
+ confidence: 10,
23
+ };
24
+ }
25
+ catch { }
26
+ if (/^[^@]+@[^@]+\.[^@]+$/.test(rawValue)) {
27
+ return {
28
+ schema: "z.string().email()",
29
+ confidence: 10,
30
+ };
31
+ }
32
+ return {
33
+ schema: `z.string()`,
34
+ confidence: 1,
35
+ };
36
+ },
37
+ };
@@ -0,0 +1,4 @@
1
+ import { InferencePass } from "./index.js";
2
+ export declare const URL_KEYS: string[];
3
+ export declare const urlRule: InferencePass;
4
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/infer-rules/url.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,aAAa,EAAkC,MAAM,YAAY,CAAC;AAE3F,eAAO,MAAM,QAAQ,EAAE,MAAM,EAAyF,CAAC;AAsFvH,eAAO,MAAM,OAAO,EAAE,aA+ErB,CAAC"}
@@ -0,0 +1,149 @@
1
+ import { looksLikeUrl, looksLikeHttpUrl, looksLikeDbUrl, looksLikeQueueUrl, looksLikeWsUrl, looksLikeStorageUrl, looksLikeOtherUrl } from "../schemas/urls.js";
2
+ import { matchesEnvKey } from "./index.js";
3
+ export const URL_KEYS = ["URL", "URI", "LINK", "ENDPOINT", "API_URL", "API_ENDPOINT", "API_LINK", "API_URI"];
4
+ const DB_KEYS = ["DB", "DATABASE", "DB_URL", "DATABASE_URL", "DB_URI", "DATABASE_URI"];
5
+ const QUEUE_KEYS = ["QUEUE", "MESSAGE_QUEUE", "MESSAGE_QUEUE_URL", "MESSAGE_QUEUE_URI", "MESSAGE_QUEUE_LINK", "MESSAGE_QUEUE_ENDPOINT"];
6
+ const WS_KEYS = ["WS", "WEBSOCKET", "WEBSOCKET_URL", "WEBSOCKET_URI", "WEBSOCKET_LINK", "WEBSOCKET_ENDPOINT"];
7
+ const STORAGE_KEYS = ["STORAGE", "STORAGE_URL", "STORAGE_URI", "STORAGE_LINK", "STORAGE_ENDPOINT"];
8
+ const OTHER_KEYS = ["OTHER", "MISC", "MISC_URL", "MISC_URI", "MISC_LINK", "MISC_ENDPOINT"];
9
+ const subUrlRule = (input) => {
10
+ input.confidence += 2;
11
+ const reasons = [`Valid ${input.message} URL (+2)`];
12
+ const { matched, reason } = matchesEnvKey(input.name, input.keys);
13
+ if (matched) {
14
+ input.confidence += 2;
15
+ reasons.push(`${reason} (+2)`);
16
+ }
17
+ return {
18
+ schema: input.schema,
19
+ importedSchemas: input.importedSchemas,
20
+ confidence: input.confidence,
21
+ reasons,
22
+ };
23
+ };
24
+ const subUrlRules = {
25
+ HTTP: (name) => {
26
+ return {
27
+ message: "HTTP",
28
+ keys: URL_KEYS,
29
+ schema: `httpUrlSchema(${JSON.stringify(name)})`,
30
+ importedSchemas: ["httpUrlSchema"],
31
+ };
32
+ },
33
+ DATABASE: (name) => {
34
+ return {
35
+ message: "database",
36
+ keys: DB_KEYS,
37
+ schema: `databaseUrlSchema(${JSON.stringify(name)})`,
38
+ importedSchemas: ["databaseUrlSchema"],
39
+ };
40
+ },
41
+ QUEUE: (name) => {
42
+ return {
43
+ message: "queue",
44
+ keys: QUEUE_KEYS,
45
+ schema: `queueUrlSchema(${JSON.stringify(name)})`,
46
+ importedSchemas: ["queueUrlSchema"],
47
+ };
48
+ },
49
+ WS: (name) => {
50
+ return {
51
+ message: "ws",
52
+ keys: WS_KEYS,
53
+ schema: `wsUrlSchema(${JSON.stringify(name)})`,
54
+ importedSchemas: ["wsUrlSchema"],
55
+ };
56
+ },
57
+ STORAGE: (name) => {
58
+ return {
59
+ message: "storage",
60
+ keys: STORAGE_KEYS,
61
+ schema: `storageUrlSchema(${JSON.stringify(name)})`,
62
+ importedSchemas: ["storageUrlSchema"],
63
+ };
64
+ },
65
+ OTHER: (name) => {
66
+ return {
67
+ message: "other",
68
+ keys: OTHER_KEYS,
69
+ schema: `otherUrlSchema(${JSON.stringify(name)})`,
70
+ importedSchemas: ["otherUrlSchema"],
71
+ };
72
+ },
73
+ };
74
+ export const urlRule = {
75
+ type: "url",
76
+ priority: 5,
77
+ threshold: 5,
78
+ tryInfer({ name, rawValue }) {
79
+ if (!looksLikeUrl(rawValue))
80
+ return null;
81
+ let confidence = 5;
82
+ const reasons = ["Valid URL (+5)"];
83
+ const { matched, reason } = matchesEnvKey(name, URL_KEYS);
84
+ if (matched) {
85
+ confidence += 2;
86
+ reasons.push(`${reason} (+2)`);
87
+ }
88
+ if (looksLikeHttpUrl(rawValue)) {
89
+ return subUrlRule({
90
+ name,
91
+ rawValue,
92
+ confidence,
93
+ reasons,
94
+ ...subUrlRules.HTTP(name),
95
+ });
96
+ }
97
+ if (looksLikeDbUrl(rawValue)) {
98
+ return subUrlRule({
99
+ name,
100
+ rawValue,
101
+ confidence,
102
+ reasons,
103
+ ...subUrlRules.DATABASE(name),
104
+ });
105
+ }
106
+ if (looksLikeQueueUrl(rawValue)) {
107
+ return subUrlRule({
108
+ name,
109
+ rawValue,
110
+ confidence,
111
+ reasons,
112
+ ...subUrlRules.QUEUE(name),
113
+ });
114
+ }
115
+ if (looksLikeWsUrl(rawValue)) {
116
+ return subUrlRule({
117
+ name,
118
+ rawValue,
119
+ confidence,
120
+ reasons,
121
+ ...subUrlRules.WS(name),
122
+ });
123
+ }
124
+ if (looksLikeStorageUrl(rawValue)) {
125
+ return subUrlRule({
126
+ name,
127
+ rawValue,
128
+ confidence,
129
+ reasons,
130
+ ...subUrlRules.STORAGE(name),
131
+ });
132
+ }
133
+ if (looksLikeOtherUrl(rawValue)) {
134
+ return subUrlRule({
135
+ name,
136
+ rawValue,
137
+ confidence,
138
+ reasons,
139
+ ...subUrlRules.OTHER(name),
140
+ });
141
+ }
142
+ return {
143
+ schema: "z.url()",
144
+ importedSchemas: [],
145
+ confidence,
146
+ reasons,
147
+ };
148
+ },
149
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.json.d.ts","sourceRoot":"","sources":["../../src/llm-kit/context.json.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ // TODO : l'injecter chez l'utilisateur dans .dnl/context.json
2
+ // Créer un schéma de ce type à destination d'un LLM
3
+ const context = {
4
+ schemaFile: "env.dnl.ts",
5
+ generatedTypes: "types/env.dnl.ts",
6
+ runtimeImport: "env.dnl.js",
7
+ conventions: {
8
+ descriptionsRequired: true,
9
+ secretsMustBeExplicit: true,
10
+ },
11
+ };
12
+ // injecter directement dans cursor context :
13
+ const contextInjection = `This project uses dotenv-never-lies.
14
+ The environment schema is defined in ${context.schemaFile}.
15
+ Types are generated in ${context.generatedTypes}.
16
+ Runtime import is ${context.runtimeImport}.
17
+ Conventions:
18
+ - Descriptions are required.
19
+ - Secrets must be explicit.
20
+ Secrets must not be exposed.
21
+ `;
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DNLTest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DNLTest.d.ts","sourceRoot":"","sources":["../../src/sample/DNLTest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import envDefinition from "./env.dnl.js";
2
+ //const env: Env = envDefinition.assert();
3
+ const env = envDefinition.assert();
4
+ //env.NODE_CORS_ORIGIN;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/sample/debug.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { listRule } from "../infer/rules/list.js";
2
+ listRule.tryInfer({
3
+ name: "MIXED_LIST",
4
+ rawValue: ";;;",
5
+ });