libmodulor 0.4.0 → 0.6.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 (246) hide show
  1. package/.github/dependabot.yml +19 -0
  2. package/CHANGELOG.md +35 -1
  3. package/README.md +10 -4
  4. package/dist/esm/app/workers/AppSrcFilePathBuilder.d.ts +16 -0
  5. package/dist/esm/app/workers/AppSrcFilePathBuilder.js +6 -4
  6. package/dist/esm/apps/Helper/index.js +1 -0
  7. package/dist/esm/apps/Helper/src/i18n.js +4 -0
  8. package/dist/esm/apps/Helper/src/lib/project.d.ts +2 -0
  9. package/dist/esm/apps/Helper/src/lib/project.js +120 -0
  10. package/dist/esm/apps/Helper/src/manifest.d.ts +5 -0
  11. package/dist/esm/apps/Helper/src/manifest.js +5 -0
  12. package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.d.ts +15 -0
  13. package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.js +118 -0
  14. package/dist/esm/apps/Helper/src/ucds/GenerateAppsTestsUCD.js +3 -2
  15. package/dist/esm/bundlers/vite/StripUCDLifecycleServerPlugin.js +3 -0
  16. package/dist/esm/convention.d.ts +1 -0
  17. package/dist/esm/convention.js +17 -4
  18. package/dist/esm/dt/Validation.d.ts +8 -0
  19. package/dist/esm/dt/Validation.js +8 -0
  20. package/dist/esm/dt/base/TBase.d.ts +2 -1
  21. package/dist/esm/dt/base/TBoolean.js +2 -0
  22. package/dist/esm/dt/base/TInt.js +3 -0
  23. package/dist/esm/dt/base/TNumber.js +2 -0
  24. package/dist/esm/dt/base/TObject.d.ts +15 -0
  25. package/dist/esm/dt/base/TObject.js +14 -0
  26. package/dist/esm/dt/base/TString.js +1 -1
  27. package/dist/esm/dt/final/TAmount.js +1 -0
  28. package/dist/esm/dt/final/TCountryISO3166Alpha2.js +1 -0
  29. package/dist/esm/dt/final/TCurrencyISO4217.js +1 -0
  30. package/dist/esm/dt/final/TDateTimeFormat.js +1 -0
  31. package/dist/esm/dt/final/TEmail.js +2 -0
  32. package/dist/esm/dt/final/TEmoji.js +4 -0
  33. package/dist/esm/dt/final/TFile.js +3 -0
  34. package/dist/esm/dt/final/THostAddress.js +2 -0
  35. package/dist/esm/dt/final/TIPv6.js +1 -0
  36. package/dist/esm/dt/final/TJWT.js +8 -0
  37. package/dist/esm/dt/final/TPercentage.js +5 -0
  38. package/dist/esm/dt/final/TSQLQuery.js +1 -0
  39. package/dist/esm/dt/final/TSSHPrivateKey.js +3 -1
  40. package/dist/esm/dt/final/TSemVerVersion.js +1 -0
  41. package/dist/esm/dt/final/TShellCommand.js +1 -0
  42. package/dist/esm/dt/final/TURL.js +2 -0
  43. package/dist/esm/dt/final/TUUID.js +1 -0
  44. package/dist/esm/dt/final/TYesNo.js +1 -1
  45. package/dist/esm/dt/index.d.ts +1 -1
  46. package/dist/esm/i18n/WordingManager.d.ts +16 -0
  47. package/dist/esm/i18n/types.d.ts +5 -0
  48. package/dist/esm/icon/Icon.d.ts +7 -0
  49. package/dist/esm/index.d.ts +3 -0
  50. package/dist/esm/index.js +4 -0
  51. package/dist/esm/index.node.d.ts +1 -0
  52. package/dist/esm/index.node.js +1 -0
  53. package/dist/esm/index.react.d.ts +1 -1
  54. package/dist/esm/product/manifest.d.ts +15 -0
  55. package/dist/esm/products/Helper/container.js +4 -0
  56. package/dist/esm/products/Helper/index.js +5 -0
  57. package/dist/esm/products/Helper/manifest.d.ts +6 -1
  58. package/dist/esm/std/BufferManager.d.ts +18 -0
  59. package/dist/esm/std/ClockManager.d.ts +5 -0
  60. package/dist/esm/std/EnvironmentManager.d.ts +10 -0
  61. package/dist/esm/std/HTTPAPICaller.d.ts +6 -0
  62. package/dist/esm/std/I18nManager.d.ts +26 -0
  63. package/dist/esm/std/JWTManager.d.ts +26 -0
  64. package/dist/esm/std/JobManager.d.ts +6 -0
  65. package/dist/esm/std/LLMManager.d.ts +25 -0
  66. package/dist/esm/std/LLMManager.js +1 -0
  67. package/dist/esm/std/PromptManager.d.ts +8 -0
  68. package/dist/esm/std/SettingsManager.d.ts +19 -0
  69. package/dist/esm/std/SettingsManager.js +9 -0
  70. package/dist/esm/std/ShellCommandExecutor.d.ts +19 -0
  71. package/dist/esm/std/ShellCommandExecutor.js +1 -0
  72. package/dist/esm/std/impl/ConsoleLogger.js +7 -1
  73. package/dist/esm/std/impl/FakeEmailManager.js +1 -0
  74. package/dist/esm/std/impl/FakeJobManager.js +1 -0
  75. package/dist/esm/std/impl/FetchHTTPAPICallExecutor.d.ts +9 -0
  76. package/dist/esm/std/impl/FetchHTTPAPICallExecutor.js +11 -0
  77. package/dist/esm/std/impl/MistralAILLMManager.d.ts +17 -0
  78. package/dist/esm/std/impl/MistralAILLMManager.js +56 -0
  79. package/dist/esm/std/impl/NodeCryptoManager.js +6 -1
  80. package/dist/esm/std/impl/NodeDeterministicCryptoManager.d.ts +14 -0
  81. package/dist/esm/std/impl/NodeDeterministicCryptoManager.js +17 -3
  82. package/dist/esm/std/impl/NodeFSManager.js +10 -0
  83. package/dist/esm/std/impl/NodeHTTPAPICallExecutorAgentBuilder.js +2 -0
  84. package/dist/esm/std/impl/NodePromptManager.js +3 -0
  85. package/dist/esm/std/impl/NodeSpawnShellCommandExecutor.d.ts +4 -0
  86. package/dist/esm/std/impl/NodeSpawnShellCommandExecutor.js +41 -0
  87. package/dist/esm/std/impl/OllamaLLMManager.d.ts +20 -0
  88. package/dist/esm/std/impl/OllamaLLMManager.js +56 -0
  89. package/dist/esm/std/impl/OpenAILLMManager.d.ts +17 -0
  90. package/dist/esm/std/impl/OpenAILLMManager.js +51 -0
  91. package/dist/esm/std/impl/SimpleHTTPAPICaller.js +14 -0
  92. package/dist/esm/std/impl/SimpleMapI18nManager.js +4 -2
  93. package/dist/esm/std/impl/StdDateClockManager.js +3 -0
  94. package/dist/esm/std/impl/UCDataStoreExternalResourceManager.js +3 -0
  95. package/dist/esm/std/impl/WebCryptoManager.js +9 -0
  96. package/dist/esm/std/index.d.ts +2 -0
  97. package/dist/esm/std/index.js +2 -0
  98. package/dist/esm/target/lib/cli/renderer.js +3 -0
  99. package/dist/esm/target/lib/client/consts.d.ts +3 -0
  100. package/dist/esm/target/lib/client/consts.js +3 -0
  101. package/dist/esm/target/lib/mcp-server/MCPServerBooter.js +1 -0
  102. package/dist/esm/target/lib/react/UCContainer.js +1 -0
  103. package/dist/esm/target/lib/react/UCPanel.js +4 -0
  104. package/dist/esm/target/lib/react/form.d.ts +26 -2
  105. package/dist/esm/target/lib/react/form.js +18 -1
  106. package/dist/esm/target/lib/react/useUC.d.ts +8 -0
  107. package/dist/esm/target/lib/react/useUC.js +22 -0
  108. package/dist/esm/target/lib/react/useUCOR.d.ts +15 -0
  109. package/dist/esm/target/lib/react/useUCOR.js +45 -0
  110. package/dist/esm/target/lib/rn/input.d.ts +7 -0
  111. package/dist/esm/target/lib/rn/input.js +2 -0
  112. package/dist/esm/target/lib/server/AuthenticationChecker.js +2 -1
  113. package/dist/esm/target/lib/server/BasicAuthenticationChecker.js +1 -0
  114. package/dist/esm/target/lib/server/CSPDirectivesBuilder.js +13 -0
  115. package/dist/esm/target/lib/server/CustomerFacingErrorBuilder.js +3 -0
  116. package/dist/esm/target/lib/server/PrivateApiKeyAuthenticationChecker.js +1 -0
  117. package/dist/esm/target/lib/server/PublicApiKeyChecker.js +1 -1
  118. package/dist/esm/target/lib/server/RequestChecker.js +5 -4
  119. package/dist/esm/target/lib/server/RequestHandler.d.ts +5 -0
  120. package/dist/esm/target/lib/server/RequestLogger.js +5 -0
  121. package/dist/esm/target/lib/server/ServerManager.d.ts +19 -0
  122. package/dist/esm/target/lib/server/consts.d.ts +3 -0
  123. package/dist/esm/target/lib/server/consts.js +3 -0
  124. package/dist/esm/target/lib/web/input.d.ts +21 -0
  125. package/dist/esm/target/lib/web/input.js +4 -0
  126. package/dist/esm/target/node-core-cli/NodeCoreCLIManager.js +2 -2
  127. package/dist/esm/target/node-express-server/NodeExpressServerManager.js +5 -0
  128. package/dist/esm/target/node-express-server/lib/AuthCookieCreator.js +1 -1
  129. package/dist/esm/target/node-express-server/middlewares/AuthenticationCheckerMiddlewareBuilder.js +1 -0
  130. package/dist/esm/target/node-express-server/middlewares/PublicApiKeyCheckerMiddlewareBuilder.js +1 -0
  131. package/dist/esm/target/node-express-server/middlewares/RequestCheckerMiddlewareBuilder.js +1 -0
  132. package/dist/esm/target/node-express-server/middlewares/RequestHandlerMiddlewareBuilder.js +8 -0
  133. package/dist/esm/target/node-express-server/middlewares/RequestLoggerMiddlewareBuilder.js +1 -0
  134. package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.d.ts +10 -0
  135. package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.js +14 -0
  136. package/dist/esm/target/react-native-pure/UCForm.js +2 -2
  137. package/dist/esm/target/react-native-pure/UCFormField.d.ts +2 -9
  138. package/dist/esm/target/react-native-pure/UCFormField.js +9 -20
  139. package/dist/esm/target/react-native-pure/UCFormFieldControl.d.ts +3 -10
  140. package/dist/esm/target/react-native-pure/UCFormFieldControl.js +9 -8
  141. package/dist/esm/target/react-native-pure/UCFormFieldDesc.d.ts +2 -5
  142. package/dist/esm/target/react-native-pure/UCFormFieldDesc.js +2 -2
  143. package/dist/esm/target/react-native-pure/UCFormFieldErr.d.ts +2 -6
  144. package/dist/esm/target/react-native-pure/UCFormFieldLabel.d.ts +2 -5
  145. package/dist/esm/target/react-native-pure/UCFormFieldLabel.js +2 -2
  146. package/dist/esm/target/react-native-pure/UCFormSubmitControl.d.ts +2 -7
  147. package/dist/esm/target/react-native-pure/UCFormSubmitControl.js +1 -1
  148. package/dist/esm/target/react-web-pure/UCForm.js +1 -1
  149. package/dist/esm/target/react-web-pure/UCFormField.d.ts +2 -9
  150. package/dist/esm/target/react-web-pure/UCFormField.js +9 -20
  151. package/dist/esm/target/react-web-pure/UCFormFieldControl.d.ts +3 -10
  152. package/dist/esm/target/react-web-pure/UCFormFieldControl.js +20 -5
  153. package/dist/esm/target/react-web-pure/UCFormFieldDesc.d.ts +2 -5
  154. package/dist/esm/target/react-web-pure/UCFormFieldDesc.js +2 -2
  155. package/dist/esm/target/react-web-pure/UCFormFieldErr.d.ts +2 -6
  156. package/dist/esm/target/react-web-pure/UCFormFieldLabel.d.ts +2 -5
  157. package/dist/esm/target/react-web-pure/UCFormFieldLabel.js +3 -3
  158. package/dist/esm/target/react-web-pure/UCFormSubmitControl.d.ts +2 -4
  159. package/dist/esm/target/react-web-pure/UCFormSubmitControl.js +1 -1
  160. package/dist/esm/testing/AppTester.d.ts +4 -0
  161. package/dist/esm/testing/AppTester.js +16 -0
  162. package/dist/esm/testing/AppTesterConfigurator.d.ts +68 -0
  163. package/dist/esm/testing/UCDataStoreTester.d.ts +9 -0
  164. package/dist/esm/testing/UCDataStoreTester.js +13 -0
  165. package/dist/esm/testing/impl/SimpleAppDocsEmitter.js +22 -2
  166. package/dist/esm/testing/impl/SimpleAppTesterConfigurator.js +1 -0
  167. package/dist/esm/testing/impl/SimpleHTMLAppTestReportEmitter.js +9 -3
  168. package/dist/esm/testing/impl/TypeScriptLibUCDefASTParser.js +12 -4
  169. package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +6 -0
  170. package/dist/esm/testing/opts.d.ts +38 -0
  171. package/dist/esm/testing/opts.js +1 -1
  172. package/dist/esm/testing/uc-input.js +2 -0
  173. package/dist/esm/testing/workers/AppTesterCtxInitializer.js +7 -0
  174. package/dist/esm/testing/workers/UCExecutor.js +1 -0
  175. package/dist/esm/testing/workers/checkers/AppIndexChecker.js +1 -0
  176. package/dist/esm/testing/workers/checkers/UCDefSourcesChecker.js +4 -0
  177. package/dist/esm/uc/UC.js +19 -1
  178. package/dist/esm/uc/UCInputField.d.ts +28 -0
  179. package/dist/esm/uc/UCInputField.js +42 -0
  180. package/dist/esm/uc/data.d.ts +3 -0
  181. package/dist/esm/uc/def.d.ts +7 -0
  182. package/dist/esm/uc/exec.d.ts +39 -0
  183. package/dist/esm/uc/exec.js +29 -0
  184. package/dist/esm/uc/ext.d.ts +30 -1
  185. package/dist/esm/uc/helpers/UCOutputBuilder.js +5 -0
  186. package/dist/esm/uc/helpers/UCOutputReader.js +3 -1
  187. package/dist/esm/uc/impl/HTTPUCTransporter.js +4 -0
  188. package/dist/esm/uc/impl/InMemoryUCDataStore.js +7 -0
  189. package/dist/esm/uc/impl/KnexUCDataStore.d.ts +4 -0
  190. package/dist/esm/uc/impl/KnexUCDataStore.js +14 -0
  191. package/dist/esm/uc/impl/SimpleUCManager.js +6 -0
  192. package/dist/esm/uc/input-field.d.ts +60 -0
  193. package/dist/esm/uc/input-field.js +33 -0
  194. package/dist/esm/uc/input.d.ts +24 -0
  195. package/dist/esm/uc/lifecycle/client/IdleClientMain.js +1 -0
  196. package/dist/esm/uc/lifecycle/server/IdleServerMain.js +2 -0
  197. package/dist/esm/uc/manager.d.ts +11 -0
  198. package/dist/esm/uc/metadata.d.ts +10 -0
  199. package/dist/esm/uc/opi-layout.d.ts +3 -0
  200. package/dist/esm/uc/opi.d.ts +8 -0
  201. package/dist/esm/uc/output-field.d.ts +9 -0
  202. package/dist/esm/uc/output-part.d.ts +22 -0
  203. package/dist/esm/uc/output.d.ts +3 -0
  204. package/dist/esm/uc/policies/RoleRegularUCPolicy.js +1 -0
  205. package/dist/esm/uc/policies/funcs.js +1 -0
  206. package/dist/esm/uc/policy.d.ts +22 -0
  207. package/dist/esm/uc/sec.d.ts +9 -0
  208. package/dist/esm/uc/server.d.ts +10 -0
  209. package/dist/esm/uc/settings.d.ts +25 -0
  210. package/dist/esm/uc/side-effect.d.ts +16 -0
  211. package/dist/esm/uc/side-effect.js +16 -0
  212. package/dist/esm/uc/utils/rInput.d.ts +12 -0
  213. package/dist/esm/uc/utils/rInput.js +2 -0
  214. package/dist/esm/uc/utils/rVal.d.ts +25 -0
  215. package/dist/esm/uc/utils/rVal.js +27 -0
  216. package/dist/esm/uc/utils/recIs.d.ts +9 -0
  217. package/dist/esm/uc/utils/recIs.js +12 -1
  218. package/dist/esm/uc/utils/stripUCDLifecycleServer.d.ts +13 -0
  219. package/dist/esm/uc/utils/stripUCDLifecycleServer.js +17 -0
  220. package/dist/esm/uc/utils/ucifcoIsForArray.d.ts +6 -0
  221. package/dist/esm/uc/utils/ucifcoIsForArray.js +6 -0
  222. package/dist/esm/uc/workers/SimpleAggregateFinder.d.ts +12 -0
  223. package/dist/esm/uc/workers/SimpleAggregateFinder.js +12 -0
  224. package/dist/esm/uc/workers/UCBuilder.d.ts +7 -0
  225. package/dist/esm/uc/workers/UCBuilder.js +7 -0
  226. package/dist/esm/uc/workers/UCExecChecker.js +2 -0
  227. package/dist/esm/uc/workers/UCInputFilesProcessor.js +10 -4
  228. package/dist/esm/uc/workers/UCOutputFilesProcessor.js +6 -2
  229. package/dist/esm/utils/async/sleep.d.ts +10 -0
  230. package/dist/esm/utils/async/sleep.js +10 -0
  231. package/dist/esm/utils/http/appendData.js +5 -1
  232. package/dist/esm/utils/ioc/ContainerPrinter.js +2 -0
  233. package/dist/esm/utils/ioc/bindCommon.js +4 -0
  234. package/dist/esm/utils/ioc/bindNodeCLI.js +2 -0
  235. package/dist/esm/utils/ioc/bindNodeCore.js +1 -0
  236. package/dist/esm/utils/ioc/bindProduct.js +2 -0
  237. package/dist/esm/utils/ioc/bindRN.js +1 -0
  238. package/dist/esm/utils/ioc/bindServer.js +1 -0
  239. package/dist/esm/utils/ioc/bindWeb.js +2 -0
  240. package/dist/esm/utils/ioc/container.js +6 -0
  241. package/dist/esm/utils/numbers/units.js +3 -0
  242. package/dist/esm/utils/types/funcs.d.ts +35 -0
  243. package/dist/esm/utils/types/funcs.js +35 -0
  244. package/dist/esm/utils/types/utility-types.d.ts +17 -0
  245. package/dist/esm/utils/types/utility-types.js +1 -0
  246. package/package.json +13 -14
@@ -1,10 +1,25 @@
1
1
  import type { Validation } from '../Validation.js';
2
2
  import { TBase, type TName } from './TBase.js';
3
3
  export declare enum TObjectShapeValidationStrategy {
4
+ /**
5
+ * No shape validation is performed
6
+ *
7
+ * To be used when the object can have multiple shapes or that its shape is not important.
8
+ *
9
+ * Otherwise, you can still override {@link validate} in the `T*` class and do your own validation.
10
+ */
4
11
  NONE = "NONE",
12
+ /**
13
+ * Validate against the {@link TObject.example()}
14
+ *
15
+ * It checks that the keys of the value, sorted alphabetically, are the same as the example's keys.
16
+ */
5
17
  SAME_AS_EXAMPLE = "SAME_AS_EXAMPLE"
6
18
  }
7
19
  export interface TObjectConstraints {
20
+ /**
21
+ * @defaultValue {@link TObjectShapeValidationStrategy.SAME_AS_EXAMPLE}
22
+ */
8
23
  shapeValidationStrategy: TObjectShapeValidationStrategy;
9
24
  }
10
25
  export declare class TObject<T extends object> extends TBase<T> {
@@ -1,7 +1,19 @@
1
1
  import { TBase } from './TBase.js';
2
2
  export var TObjectShapeValidationStrategy;
3
3
  (function (TObjectShapeValidationStrategy) {
4
+ /**
5
+ * No shape validation is performed
6
+ *
7
+ * To be used when the object can have multiple shapes or that its shape is not important.
8
+ *
9
+ * Otherwise, you can still override {@link validate} in the `T*` class and do your own validation.
10
+ */
4
11
  TObjectShapeValidationStrategy["NONE"] = "NONE";
12
+ /**
13
+ * Validate against the {@link TObject.example()}
14
+ *
15
+ * It checks that the keys of the value, sorted alphabetically, are the same as the example's keys.
16
+ */
5
17
  TObjectShapeValidationStrategy["SAME_AS_EXAMPLE"] = "SAME_AS_EXAMPLE";
6
18
  })(TObjectShapeValidationStrategy || (TObjectShapeValidationStrategy = {}));
7
19
  export class TObject extends TBase {
@@ -19,6 +31,7 @@ export class TObject extends TBase {
19
31
  return {};
20
32
  }
21
33
  fmt(ifNullOrUndefined) {
34
+ // typeof this.raw is 'object', hence the check for nullity
22
35
  if (this.raw === null || typeof this.raw !== 'object') {
23
36
  return super.fmt(ifNullOrUndefined);
24
37
  }
@@ -26,6 +39,7 @@ export class TObject extends TBase {
26
39
  }
27
40
  validate() {
28
41
  const validation = super.validate();
42
+ // typeof this.raw is 'object', hence the check for nullity
29
43
  if (this.raw === null || typeof this.raw !== 'object') {
30
44
  validation.add({
31
45
  constraint: 'type',
@@ -1,7 +1,7 @@
1
1
  import { TBase } from './TBase.js';
2
2
  export class TString extends TBase {
3
3
  constraints;
4
- static DEFAULT_MAX_LENGTH = 999_999;
4
+ static DEFAULT_MAX_LENGTH = 999_999; // This is totally arbitrary and will probably be changed
5
5
  static DEFAULT_MIN_LENGTH = 0;
6
6
  constructor(constraints) {
7
7
  super();
@@ -1,4 +1,5 @@
1
1
  import { TNumber } from '../base/TNumber.js';
2
+ // NOTE : We accept negative values (used for example in accounting)
2
3
  export class TAmount extends TNumber {
3
4
  currencyCode;
4
5
  constructor(currencyCode, constraints, decimalsCount) {
@@ -1,5 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TCountryISO3166Alpha2 extends TString {
3
+ // From https://www.iban.com/country-codes
3
4
  static OPTIONS = [
4
5
  ['Afghanistan', 'AF'],
5
6
  ['Albania', 'AL'],
@@ -1,5 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TCurrencyISO4217 extends TString {
3
+ // From https://www.iban.com/currency-codes
3
4
  static OPTIONS = [
4
5
  ['Euro', 'EUR', '€'],
5
6
  ['Pound Sterling', 'GBP', '£'],
@@ -1,4 +1,5 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // TODO : Validate this model with some simple heuristics. Do not make it too complicated, it's not really worth it.
2
3
  export class TDateTimeFormat extends TString {
3
4
  tName() {
4
5
  return 'DateTimeFormat';
@@ -1,5 +1,7 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TEmail extends TString {
3
+ // Inspired by https://github.com/jquense/yup/blob/master/src/string.ts#L19
4
+ // Which is inspired by https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
3
5
  static FORMAT = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
4
6
  constructor(constraints) {
5
7
  super({
@@ -1,4 +1,8 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // It is too difficult to validate safely an emoji
3
+ // See : https://stackoverflow.com/questions/18862256/how-to-detect-emoji-using-javascript
4
+ // Plus it does not bring much
5
+ // At first, I used maxLength/minLength == 1 but it was naive. Composite ones' length is greater than 1.
2
6
  export class TEmoji extends TString {
3
7
  tName() {
4
8
  return 'Emoji';
@@ -6,6 +6,8 @@ export class TFile extends TObject {
6
6
  fileConstraints;
7
7
  constructor(fileConstraints) {
8
8
  super({
9
+ // We usually process instances of https://developer.mozilla.org/fr/docs/Web/API/File
10
+ // Therefore, it's not strictly the same as the example, with some extra fields that we don't control.
9
11
  shapeValidationStrategy: TObjectShapeValidationStrategy.NONE,
10
12
  });
11
13
  this.fileConstraints = fileConstraints;
@@ -36,6 +38,7 @@ export class TFile extends TObject {
36
38
  validation.concat(new TFileMimeType(this.fileConstraints.type)
37
39
  .assign(val.type)
38
40
  .validate());
41
+ // TODO : Add validation on file size
39
42
  return validation;
40
43
  }
41
44
  }
@@ -1,4 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // TODO : Validate using IPv4, DomainName, etc. rules
3
+ // But watch out, hostname can be as simple as "localhost" as well
2
4
  export class THostAddress extends TString {
3
5
  tName() {
4
6
  return 'HostAddress';
@@ -1,5 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TIPv6 extends TString {
3
+ // Inspired by https://community.fortra.com/forums/intermapper/miscellaneous-topics/5acc4fcf-fa83-e511-80cf-0050568460e4?_ga=2.113564423.1432958022.1523882681-2146416484.1523557976
3
4
  static FORMAT = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
4
5
  constructor(constraints) {
5
6
  super({
@@ -23,12 +23,20 @@ export class TJWT extends TString {
23
23
  });
24
24
  }
25
25
  const [header, payload, _signature] = parts;
26
+ // Using atob on Node.js platforms triggers the following deprecation message :
27
+ //
28
+ // This function is only provided for compatibility with legacy web platform APIs and should never be used in new code,
29
+ // because they use strings to represent binary data and predate the introduction of typed arrays in JavaScript.
30
+ // For code running using Node.js APIs, converting between base64-encoded strings and binary data should be performed using Buffer.from(str, 'base64') andbuf.toString('base64').
31
+ //
32
+ // However this code must be executable everywhere (including and especially browsers) so we need to use it, for portability reasons
26
33
  if (header) {
27
34
  JSON.parse(atob(header));
28
35
  }
29
36
  if (payload) {
30
37
  JSON.parse(atob(payload));
31
38
  }
39
+ // signature is ignored for now
32
40
  }
33
41
  catch (err) {
34
42
  validation.add({
@@ -1,4 +1,6 @@
1
1
  import { TNumber } from '../base/TNumber.js';
2
+ // TODO : Add some constraints (e.g. between 0 and 1, etc.)
3
+ // Not forgetting that a percentage can be higher hein ! 1.25 is a valid value for 125% !
2
4
  export class TPercentage extends TNumber {
3
5
  constructor(constraints, decimalsCount) {
4
6
  super(constraints, decimalsCount, 'percent');
@@ -13,6 +15,9 @@ export class TPercentage extends TNumber {
13
15
  if (typeof this.raw !== 'number') {
14
16
  return super.fmt(ifNullOrUndefined);
15
17
  }
18
+ // Although it works on web, using fmtNumber and setting the unit to 'percent' does not work on React Native (Hermes)
19
+ // Instead of displaying '89%', it displays '89 percent'
20
+ // Hence the usage here of style: 'percent' directly
16
21
  return new Intl.NumberFormat(undefined, {
17
22
  maximumFractionDigits: this.decimalsCount,
18
23
  style: 'percent',
@@ -1,4 +1,5 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // TODO : Add basic syntax validation (without adding any dependencies)
2
3
  export class TSQLQuery extends TString {
3
4
  tName() {
4
5
  return 'SQLQuery';
@@ -1,7 +1,9 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export const SSHPrivatekKeyTypes = ['OPENSSH', 'RSA'];
3
3
  export class TSSHPrivateKey extends TString {
4
- static FORMAT = /^-----BEGIN (OPENSSH|RSA) PRIVATE KEY-----\n(.+)?\n-----END (OPENSSH|RSA) PRIVATE KEY-----$/is;
4
+ static FORMAT =
5
+ // @ts-ignore
6
+ /^-----BEGIN (OPENSSH|RSA) PRIVATE KEY-----\n(.+)?\n-----END (OPENSSH|RSA) PRIVATE KEY-----$/is;
5
7
  constructor(constraints) {
6
8
  super({
7
9
  ...constraints,
@@ -1,4 +1,5 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // TODO : Add basic syntax validation (without adding any dependencies)
2
3
  export class TSemVerVersion extends TString {
3
4
  static FORMAT = /^([0-9]+)\.([0-9]+)\.([0-9]+)$/;
4
5
  constructor(constraints) {
@@ -1,4 +1,5 @@
1
1
  import { TString } from '../base/TString.js';
2
+ // TODO : Add basic syntax validation (without adding any dependencies)
2
3
  export class TShellCommand extends TString {
3
4
  tName() {
4
5
  return 'ShellCommand';
@@ -1,5 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TURL extends TString {
3
+ // Inspired by https://github.com/jquense/yup/blob/master/src/string.ts#L24
3
4
  static FORMAT = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
4
5
  constructor(constraints) {
5
6
  super({
@@ -20,6 +21,7 @@ export class TURL extends TString {
20
21
  return 'url';
21
22
  }
22
23
  validate() {
24
+ // Workaround for https://github.com/jquense/yup/issues/224
23
25
  if (this.isLocalhost()) {
24
26
  this.removeFormatConstraint();
25
27
  }
@@ -1,5 +1,6 @@
1
1
  import { TString } from '../base/TString.js';
2
2
  export class TUUID extends TString {
3
+ // Inspired by https://github.com/jquense/yup/blob/master/src/string.ts#L29
3
4
  static FORMAT = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
4
5
  constructor(constraints) {
5
6
  super({
@@ -15,6 +15,6 @@ export class TYesNo extends TString {
15
15
  return 'YesNo';
16
16
  }
17
17
  example() {
18
- return 'Y';
18
+ return 'Y'; // Yes Man !
19
19
  }
20
20
  }
@@ -4,7 +4,7 @@ export { TInt, type TIntConstraints } from './base/TInt.js';
4
4
  export { TNumber, type TNumberConstraints } from './base/TNumber.js';
5
5
  export { TObject, type TObjectConstraints, TObjectShapeValidationStrategy, } from './base/TObject.js';
6
6
  export { TString, type TStringConstraints } from './base/TString.js';
7
- export { TUInt, type TUIntConstraints } from './base/TUInt.js';
7
+ export { TUInt, type TUIntConstraints, type UInt } from './base/TUInt.js';
8
8
  export { type Address, TAddress } from './final/TAddress.js';
9
9
  export { type Amount, TAmount } from './final/TAmount.js';
10
10
  export { type ApiKey, TApiKey } from './final/TApiKey.js';
@@ -2,6 +2,22 @@ import type { DataType, TBase, TName } from '../dt/index.js';
2
2
  import type { ProductWording } from '../product/index.js';
3
3
  import type { I18nManager } from '../std/index.js';
4
4
  import type { UCClientConfirmConfig, UCDef, UCExecState, UCFieldKey, UCInput, UCInputField, UCName, UCOPIBase, UCOutputPartIdx, UCOutputPartWording, UCWording } from '../uc/index.js';
5
+ /**
6
+ * A key to translate
7
+ *
8
+ * - uc_CreateX_desc, uc_CreateX_label
9
+ * - ucif_name_desc, uc_name_label, uc_isEnabled_desc, uc_isEnabled_label
10
+ *
11
+ * NOTE : The choice has been made to consider the input fields as "global".
12
+ * Which means, their key is not prefixed by the use case name (e.g. ucif_CreateX_ucif_name_desc).
13
+ * This has multiple advantages :
14
+ *
15
+ * - The same field present in multiple use cases will be automatically translated
16
+ * - It gives more consistency through the app with the same thing always named the same way
17
+ *
18
+ * One might argue that a label can be different for "name" in "CreateX" and "CreateY".
19
+ * In this case, we consider that the input field shouldn't be named "name" in both places.
20
+ */
5
21
  export type WordingManagerKey = `dt_${TName}_${string}_${keyof UCWording}` | `p_${keyof ProductWording}` | `uc_${UCName}_${keyof UCWording}` | `uc_${UCName}_client_confirm_${keyof UCClientConfirmConfig}` | `uc_${UCName}_i_submit_${UCExecState}` | `uc_${UCName}_op_${UCOutputPartIdx}_${keyof UCOutputPartWording}` | `ucif_${UCFieldKey}_${keyof UCWording}` | `ucof_${UCFieldKey}_${keyof UCWording}`;
6
22
  export declare class WordingManager {
7
23
  private i18nManager;
@@ -1,6 +1,11 @@
1
1
  import type { ViolationI18nable, YesNo } from '../dt/index.js';
2
2
  import type { UCClientConfirmConfig, UCExecState, UCWording } from '../uc/index.js';
3
3
  export type I18nLanguageCode = 'en' | 'fr';
4
+ /**
5
+ * A translation value
6
+ *
7
+ * It can contain `{{placeholders}}`.
8
+ */
4
9
  export type I18nTranslation = string;
5
10
  export type I18nTranslationKey = string;
6
11
  export type I18nCoreKey = ViolationI18nable | `dt_YesNo_${YesNo}_${keyof UCWording}` | `uc_client_confirm_${keyof UCClientConfirmConfig}` | `uc_i_submit_${UCExecState}`;
@@ -1 +1,8 @@
1
+ /**
2
+ * The icon code (e.g. https://fontawesome.com/v6/search?o=s&m=free)
3
+ *
4
+ * There are thousands of them so we voluntarily keep it a simple string and not a union type that would become unmaintainable.
5
+ *
6
+ * You can naturally use a different icon library as long as the renderer handles it.
7
+ */
1
8
  export type IconCode = string;
@@ -11,8 +11,11 @@ export * from './std/impl/FakeFSManager.js';
11
11
  export * from './std/impl/FakeHTTPAPICallExecutor.js';
12
12
  export * from './std/impl/FakeJobManager.js';
13
13
  export * from './std/impl/FetchHTTPAPICallExecutor.js';
14
+ export * from './std/impl/MistralAILLMManager.js';
14
15
  export * from './std/impl/NoopHTTPAPICallExecutorAgentBuilder.js';
15
16
  export * from './std/impl/NoopXMLManager.js';
17
+ export * from './std/impl/OllamaLLMManager.js';
18
+ export * from './std/impl/OpenAILLMManager.js';
16
19
  export * from './std/impl/SettingsServerClientManager.js';
17
20
  export * from './std/impl/SimpleFormDataBuilder.js';
18
21
  export * from './std/impl/SimpleHTTPAPICaller.js';
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ // Export only the implementations that have no external dependencies (Otherwise, export them in index.x.ts)
1
2
  export * from './app/index.js';
2
3
  export * from './dt/index.js';
3
4
  export * from './error/index.js';
@@ -11,8 +12,11 @@ export * from './std/impl/FakeFSManager.js';
11
12
  export * from './std/impl/FakeHTTPAPICallExecutor.js';
12
13
  export * from './std/impl/FakeJobManager.js';
13
14
  export * from './std/impl/FetchHTTPAPICallExecutor.js';
15
+ export * from './std/impl/MistralAILLMManager.js';
14
16
  export * from './std/impl/NoopHTTPAPICallExecutorAgentBuilder.js';
15
17
  export * from './std/impl/NoopXMLManager.js';
18
+ export * from './std/impl/OllamaLLMManager.js';
19
+ export * from './std/impl/OpenAILLMManager.js';
16
20
  export * from './std/impl/SettingsServerClientManager.js';
17
21
  export * from './std/impl/SimpleFormDataBuilder.js';
18
22
  export * from './std/impl/SimpleHTTPAPICaller.js';
@@ -6,6 +6,7 @@ export { NodeFormDataBuilder } from './std/impl/NodeFormDataBuilder.js';
6
6
  export { NodeFSManager } from './std/impl/NodeFSManager.js';
7
7
  export { NodeHTTPAPICallExecutorAgentBuilder } from './std/impl/NodeHTTPAPICallExecutorAgentBuilder.js';
8
8
  export { NodePromptManager } from './std/impl/NodePromptManager.js';
9
+ export { NodeSpawnShellCommandExecutor } from './std/impl/NodeSpawnShellCommandExecutor.js';
9
10
  export { NodeCoreCLIManager } from './target/node-core-cli/NodeCoreCLIManager.js';
10
11
  export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
11
12
  export { bindNodeCLI } from './utils/ioc/bindNodeCLI.js';
@@ -6,6 +6,7 @@ export { NodeFormDataBuilder } from './std/impl/NodeFormDataBuilder.js';
6
6
  export { NodeFSManager } from './std/impl/NodeFSManager.js';
7
7
  export { NodeHTTPAPICallExecutorAgentBuilder } from './std/impl/NodeHTTPAPICallExecutorAgentBuilder.js';
8
8
  export { NodePromptManager } from './std/impl/NodePromptManager.js';
9
+ export { NodeSpawnShellCommandExecutor } from './std/impl/NodeSpawnShellCommandExecutor.js';
9
10
  export { NodeCoreCLIManager } from './target/node-core-cli/NodeCoreCLIManager.js';
10
11
  export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
11
12
  export { bindNodeCLI } from './utils/ioc/bindNodeCLI.js';
@@ -1,5 +1,5 @@
1
1
  export { DIContext, useDIContext, DIContextProvider, type DIContextT, } from './target/lib/react/DIContextProvider.js';
2
- export type { UCFormFieldControlOnChange, UCFormProps, RenderUCForm, } from './target/lib/react/form.js';
2
+ export type { UCFormFieldControlOnChange, UCFormFieldControlProps, UCFormFieldDescProps, UCFormFieldElement, UCFormFieldErrProps, UCFormFieldLabelProps, UCFormFieldProps, UCFormProps, UCFormSubmitControlProps, UC_FORM_FIELD_ELEMENTS, RenderUCForm, validateFormField, } from './target/lib/react/form.js';
3
3
  export type { UCPanelCtx, UCPanelOnDone, UCPanelOnError, UCPanelOnInit, UCPanelOnStartSubmitting, UCPanelOnSubmit, UCPanelState, } from './target/lib/react/panel.js';
4
4
  export type { UCEntrypointTouchableProps, RenderUCEntrypointTouchable, RenderUCExecTouchable, UCExecTouchableProps, } from './target/lib/react/touchable.js';
5
5
  export { UCContainer } from './target/lib/react/UCContainer.js';
@@ -1,8 +1,23 @@
1
1
  import type { AppName } from '../app/index.js';
2
2
  import type { UCName } from '../uc/index.js';
3
3
  export interface ProductAppReg {
4
+ /**
5
+ * It must correspond to the app folder name in the {@link APPS_ROOT_PATH}.
6
+ */
4
7
  name: AppName;
8
+ /**
9
+ * By default, a product mounts all the enabled use cases of an app.
10
+ *
11
+ * With this, you can override this default behavior.
12
+ */
5
13
  ucds?: {
14
+ /**
15
+ * Use Cases to exclude from the product
16
+ *
17
+ * For example, you can have a generic `Auth` app, used in multiple products.
18
+ * Some of them will require `SignUp` while others won't. With this setting,
19
+ * you can exclude the use cases that you don't want. In this case, they won't be mounted.
20
+ */
6
21
  exclude?: UCName[];
7
22
  } | undefined;
8
23
  }
@@ -1,4 +1,5 @@
1
1
  import { Container } from 'inversify';
2
+ import { NodeSpawnShellCommandExecutor } from '../../std/impl/NodeSpawnShellCommandExecutor.js';
2
3
  import { VitestAppTestSuiteEmitter } from '../../testing/impl/VitestAppTestSuiteEmitter.js';
3
4
  import { VitestAppTestSuiteRunner } from '../../testing/impl/VitestAppTestSuiteRunner.js';
4
5
  import { CONTAINER_OPTS } from '../../utils/index.js';
@@ -19,4 +20,7 @@ container
19
20
  container
20
21
  .bind('AppTestSuiteRunner')
21
22
  .to(VitestAppTestSuiteRunner);
23
+ container
24
+ .bind('ShellCommandExecutor')
25
+ .to(NodeSpawnShellCommandExecutor);
22
26
  export default container;
@@ -1,8 +1,13 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { APPS_ROOT_DIR_NAME } from '../../convention.js';
2
4
  import { NodeCoreCLIManager } from '../../target/node-core-cli/NodeCoreCLIManager.js';
3
5
  import container from './container.js';
4
6
  const i18nManager = container.get('I18nManager');
5
7
  await i18nManager.init();
8
+ // Before screaming, yes, this is not using any powerful CLI library.
9
+ // The goal is to reduce the usage of dependencies as much as possible.
10
+ // As long as the built-in Node.js API allows to build it without too many workarounds, let's keep it this way.
6
11
  await container.resolve(NodeCoreCLIManager).handleCommand({
7
12
  appsRootPath: container
8
13
  .get('FSManager')
@@ -1 +1,6 @@
1
- export const Manifest: import("../../product/index.js").ProductManifest;
1
+ export declare const Manifest: {
2
+ appReg: {
3
+ name: "Helper";
4
+ }[];
5
+ name: string;
6
+ };
@@ -1,4 +1,22 @@
1
1
  export type BufferManagerBase64String = string;
2
+ /**
3
+ * The `Buffer` api is available in Node and similar server side environments. But it's not in browsers.
4
+ *
5
+ * Hence the need for this interface to provide multiple implementations (e.g. using https://github.com/feross/buffer).
6
+ *
7
+ * But the problem is that both implementations are redundant.
8
+ *
9
+ * TODO : Consider alternatives to BufferManager
10
+ *
11
+ * Possible solutions :
12
+ *
13
+ * - Import the buffer lib as a polyfill
14
+ * - Use only ECMAScript compatible primitives (`ArrayBuffer`, `Uint8Array`, `DataView`, etc.)
15
+ * - Use BinaryJS
16
+ * - Use Fast-Buffer
17
+ *
18
+ * Note that for the last two, keeping this interface makes actually sense since other impl. not `Buffer`-like can be used.
19
+ */
2
20
  export interface BufferManager {
3
21
  decodeBase64<T extends string>(value: BufferManagerBase64String): T;
4
22
  decodeUint8Array<T extends string>(value: Uint8Array): T;
@@ -1,4 +1,9 @@
1
1
  import type { Timestamp } from '../dt/index.js';
2
+ /**
3
+ * A key representing the date (e.g. 20241125141012)
4
+ *
5
+ * Useful to set a prefix when naming files in order to sort them
6
+ */
2
7
  export type ClockManagerDateKey = string;
3
8
  export interface ClockManager {
4
9
  now(): Date;
@@ -3,6 +3,16 @@ export type EnvironmentManagerEnvVarName = string;
3
3
  type Browser = 'chrome' | 'edge' | 'firefox' | 'opera' | 'safari';
4
4
  type MobileOS = 'android' | 'ios';
5
5
  type OS = 'darwin' | 'linux' | 'macos' | 'windows' | 'windows_nt';
6
+ /**
7
+ * The type of environment
8
+ *
9
+ * The goal of this is not to give the final platform where the runtime is executed.
10
+ * For instance, in the context of a browser, we want to know that it's running on 'firefox' and not 'macos'.
11
+ *
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform
13
+ * @see https://reactnative.dev/docs/platform#os
14
+ * @see https://nodejs.org/api/os.html#ostype
15
+ */
6
16
  export type EnvironmentManagerType = Browser | MobileOS | OS | (string & {});
7
17
  export interface EnvironmentManager {
8
18
  cwd(): FilePath;
@@ -18,6 +18,9 @@ export interface HTTPAPICallerInputOpts {
18
18
  xml?: XMLManagerParseOpts;
19
19
  }
20
20
  export interface HTTPAPICallerInput<AH extends object | undefined, Req extends object, ResBad, ResGood, O> {
21
+ /**
22
+ * They are the last ones to be set so they will override any other header already set by `authorizationHeader` or `basicAuth` if any.
23
+ */
21
24
  additionalHeadersBuilder?: AdditionalHeadersBuilder<AH> | undefined;
22
25
  authorizationHeader?: HTTPAPICallerAuthorizationHeader | undefined;
23
26
  basicAuth?: HTTPAPICallerBasicAuth | undefined;
@@ -25,6 +28,9 @@ export interface HTTPAPICallerInput<AH extends object | undefined, Req extends o
25
28
  errBuilder: ErrBuilder<ResBad>;
26
29
  method: HTTPMethod;
27
30
  opts?: HTTPAPICallerInputOpts | undefined;
31
+ /**
32
+ * If not set, it will assume that `ResGood` and `O` are the same and thus return `ResGood` as is.
33
+ */
28
34
  outputBuilder?: OutputBuilder<ResGood, O> | undefined;
29
35
  req?: {
30
36
  builder: ReqBuilder<Req>;
@@ -7,8 +7,34 @@ export interface I18nManagerTOpts {
7
7
  vars?: Record<string, string>;
8
8
  }
9
9
  export interface I18nManager extends Initializable {
10
+ /**
11
+ * Add a translation key
12
+ *
13
+ * It might not work for all the implementations, depending on where the translations are stored.
14
+ *
15
+ * @param key
16
+ * @param value
17
+ */
10
18
  add<K extends I18nTranslationKey>(key: K, value: string): Promise<void>;
19
+ /**
20
+ * Get the current lang code
21
+ */
11
22
  l(): I18nLanguageCode;
23
+ /**
24
+ * Get the translation for the given key
25
+ *
26
+ * If the key is missing, it should return `opts.fallback` if any. Otherwise, it should return the key itself.
27
+ *
28
+ * Optionally it can fail (by throwing) but that is not recommended since it impacts end users.
29
+ *
30
+ * @param key
31
+ * @param opts
32
+ */
12
33
  t<T extends I18nTranslationKey>(key: T, opts?: I18nManagerTOpts): string;
34
+ /**
35
+ * Get the translation for the given key, otherwise `null`
36
+ * @param key
37
+ * @param opts
38
+ */
13
39
  tOrNull<T extends I18nTranslationKey>(key: T, opts?: I18nManagerTOpts): string | null;
14
40
  }
@@ -16,6 +16,9 @@ export interface JWTManagerSettings extends Settings {
16
16
  jwt_manager_subject: string | null;
17
17
  }
18
18
  export type JWTManagerDecodeOpts = Pick<JWTManagerEncodeOpts, 'secret'> & {
19
+ /**
20
+ * The public key to verify JWTs using an `alg` of type `RS*`
21
+ */
19
22
  spki?: SSHPublicKey;
20
23
  };
21
24
  export interface JWTManagerEncodeOpts {
@@ -28,7 +31,30 @@ export interface JWTManagerEncodeOpts {
28
31
  sub?: JWTManagerSettings['jwt_manager_subject'];
29
32
  }
30
33
  export interface JWTManager {
34
+ /**
35
+ * Decode the token
36
+ *
37
+ * Pass the ad-hoc opts when using a specific `alg` (e.g. `spki` when decoding a `RS*` token).
38
+ * If invalid, it must throw an {@link UnauthorizedError} (no errors related to the impl. should be thrown).
39
+ *
40
+ * @param value
41
+ * @param opts
42
+ */
31
43
  decode<T extends JWTManagerPayload>(value: JWT, opts?: JWTManagerDecodeOpts): Promise<T>;
44
+ /**
45
+ * Encode the payload
46
+ *
47
+ * It uses the global {@link JWTManagerSettings} or the ones provided via `opts`.
48
+ *
49
+ * @param payload
50
+ * @param opts
51
+ */
32
52
  encode<T extends object>(payload: T, opts?: JWTManagerEncodeOpts): Promise<JWT>;
53
+ /**
54
+ * Check whether the token is usable or not
55
+ *
56
+ * Note that the signature is not checked. Indeed, the main purpose of this method is to be used client side to save some requests (e.g. when the token is expired).
57
+ * In this case, no need to send a request that will trigger an error. Better to renew the token at the client's initiative.
58
+ */
33
59
  isUsable(value: JWT): Promise<boolean>;
34
60
  }
@@ -13,5 +13,11 @@ export interface JobManagerSettings extends Settings {
13
13
  }[];
14
14
  }
15
15
  export interface JobManager extends Clearable, Initializable {
16
+ /**
17
+ * Send a new job on the queue for processing
18
+ * @param queueName
19
+ * @param jobName
20
+ * @param input
21
+ */
16
22
  dispatch<I>(queueName: JobManagerQueueName, jobName: JobManagerJobName, input: I): Promise<void>;
17
23
  }
@@ -0,0 +1,25 @@
1
+ import type { FreeTextLong } from '../dt/index.js';
2
+ export type LLMManagerModel = string;
3
+ export type LLMManagerTemperature = number;
4
+ export interface LLMManagerSendReq {
5
+ messages: {
6
+ content: FreeTextLong;
7
+ /**
8
+ * In the case of OpenAI :
9
+ * > With o1 models and newer, developer messages replace the previous system messages
10
+ */
11
+ role: 'assistant' | 'developer' | 'system' | 'user';
12
+ }[];
13
+ model: LLMManagerModel;
14
+ temperature?: LLMManagerTemperature;
15
+ }
16
+ export interface LLMManagerSendRes {
17
+ choices: {
18
+ message: {
19
+ content: string;
20
+ };
21
+ }[];
22
+ }
23
+ export interface LLMManager {
24
+ send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
25
+ }