@nudojs/service 0.1.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @nudojs/service
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6c38283: docs and ci
8
+ - 9f7f819: fix pkg info
9
+ - c175f71: version
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [6c38283]
14
+ - Updated dependencies [9f7f819]
15
+ - Updated dependencies [c175f71]
16
+ - @nudojs/cli@0.2.0
17
+ - @nudojs/core@0.2.0
18
+ - @nudojs/parser@0.2.0
19
+
3
20
  ## 0.1.0
4
21
 
5
22
  ### Minor Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nudo Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ import {
19
19
  resetMemo,
20
20
  getUnreachableRanges,
21
21
  resetUnreachableRanges,
22
- setNodeTypeCollector
22
+ setNodeTypeCollector,
23
+ setSampleCount
23
24
  } from "@nudojs/cli/evaluator";
24
25
  function resolveModule(source, fromDir) {
25
26
  const extensions = [".js", ".ts", ".mjs"];
@@ -99,6 +100,12 @@ function analyzeFile(filePath, source, activeCases) {
99
100
  fnVal._memoize = fn.name;
100
101
  }
101
102
  }
103
+ const sampleDirective = fn.directives.find((d) => d.kind === "sample");
104
+ if (sampleDirective && sampleDirective.kind === "sample") {
105
+ setSampleCount(sampleDirective.count);
106
+ } else {
107
+ setSampleCount(3);
108
+ }
102
109
  const caseDirectives = fn.directives.filter((d) => d.kind === "case");
103
110
  const activeCaseIdx = activeCases?.get(fn.name) ?? 0;
104
111
  for (let ci = 0; ci < caseDirectives.length; ci++) {
@@ -446,6 +453,7 @@ function getCompletionsForType(tv) {
446
453
  }
447
454
 
448
455
  // src/dts-generator.ts
456
+ import { isTemplate, getTemplateParts } from "@nudojs/core";
449
457
  function typeValueToTSType(tv) {
450
458
  switch (tv.kind) {
451
459
  case "literal": {
@@ -458,6 +466,14 @@ function typeValueToTSType(tv) {
458
466
  }
459
467
  case "primitive":
460
468
  return tv.type;
469
+ case "refined": {
470
+ if (isTemplate(tv)) {
471
+ const parts = getTemplateParts(tv);
472
+ const inner = parts.map((p) => p.kind === "literal" && typeof p.value === "string" ? p.value : `\${${typeValueToTSType(p)}}`).join("");
473
+ return `\`${inner}\``;
474
+ }
475
+ return typeValueToTSType(tv.base);
476
+ }
461
477
  case "object": {
462
478
  const entries = Object.entries(tv.properties);
463
479
  if (entries.length === 0) return "{}";
package/package.json CHANGED
@@ -1,14 +1,24 @@
1
1
  {
2
2
  "name": "@nudojs/service",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/nudojs/nudo.git",
9
+ "directory": "packages/service"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "provenance": true,
14
+ "registry": "https://registry.npmjs.org"
15
+ },
6
16
  "dependencies": {
7
17
  "@babel/traverse": "^7.29.0",
8
18
  "@babel/types": "^7.29.0",
9
- "@nudojs/core": "0.1.0",
10
- "@nudojs/parser": "0.1.0",
11
- "@nudojs/cli": "0.1.0"
19
+ "@nudojs/core": "0.2.0",
20
+ "@nudojs/parser": "0.2.0",
21
+ "@nudojs/cli": "0.2.0"
12
22
  },
13
23
  "scripts": {
14
24
  "build": "tsup src/index.ts --format esm --dts"
package/src/analyzer.ts CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  getUnreachableRanges,
25
25
  resetUnreachableRanges,
26
26
  setNodeTypeCollector,
27
+ setSampleCount,
27
28
  } from "@nudojs/cli/evaluator";
28
29
 
29
30
  export type SourceLocation = {
@@ -201,6 +202,13 @@ export function analyzeFile(filePath: string, source: string, activeCases?: Map<
201
202
  }
202
203
  }
203
204
 
205
+ const sampleDirective = fn.directives.find((d) => d.kind === "sample");
206
+ if (sampleDirective && sampleDirective.kind === "sample") {
207
+ setSampleCount(sampleDirective.count);
208
+ } else {
209
+ setSampleCount(3);
210
+ }
211
+
204
212
  const caseDirectives = fn.directives.filter((d) => d.kind === "case");
205
213
  const activeCaseIdx = activeCases?.get(fn.name) ?? 0;
206
214
 
@@ -1,5 +1,5 @@
1
1
  import type { TypeValue } from "@nudojs/core";
2
- import { typeValueToString } from "@nudojs/core";
2
+ import { typeValueToString, isTemplate, getTemplateParts } from "@nudojs/core";
3
3
  import type { AnalysisResult } from "./analyzer.ts";
4
4
 
5
5
  export function typeValueToTSType(tv: TypeValue): string {
@@ -14,6 +14,16 @@ export function typeValueToTSType(tv: TypeValue): string {
14
14
  }
15
15
  case "primitive":
16
16
  return tv.type;
17
+ case "refined": {
18
+ if (isTemplate(tv)) {
19
+ const parts = getTemplateParts(tv)!;
20
+ const inner = parts
21
+ .map((p) => (p.kind === "literal" && typeof p.value === "string" ? p.value : `\${${typeValueToTSType(p)}}`))
22
+ .join("");
23
+ return `\`${inner}\``;
24
+ }
25
+ return typeValueToTSType(tv.base);
26
+ }
17
27
  case "object": {
18
28
  const entries = Object.entries(tv.properties);
19
29
  if (entries.length === 0) return "{}";