@ttsc/evidence 0.25.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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +279 -0
  3. package/lib/index.d.ts +65 -0
  4. package/lib/index.js +87 -0
  5. package/lib/internal/loadPrismaModels.d.ts +1 -0
  6. package/lib/internal/loadPrismaModels.js +197 -0
  7. package/lib/internal/loadSwaggerOperations.d.ts +1 -0
  8. package/lib/internal/loadSwaggerOperations.js +156 -0
  9. package/lib/internal/normalizeSwaggerDocument.d.ts +1 -0
  10. package/lib/internal/normalizeSwaggerDocument.js +7 -0
  11. package/lib/structures/ITtscEvidenceDocumentedConfig.d.ts +32 -0
  12. package/lib/structures/ITtscEvidenceDocumentedConfig.js +2 -0
  13. package/lib/structures/ITtscEvidenceGraphClaim.d.ts +14 -0
  14. package/lib/structures/ITtscEvidenceGraphClaim.js +2 -0
  15. package/lib/structures/ITtscEvidenceGraphClaimBase.d.ts +102 -0
  16. package/lib/structures/ITtscEvidenceGraphClaimBase.js +2 -0
  17. package/lib/structures/ITtscEvidenceGraphConfig.d.ts +19 -0
  18. package/lib/structures/ITtscEvidenceGraphConfig.js +2 -0
  19. package/lib/structures/ITtscEvidenceGraphMarkdownClaim.d.ts +40 -0
  20. package/lib/structures/ITtscEvidenceGraphMarkdownClaim.js +2 -0
  21. package/lib/structures/ITtscEvidenceGraphMarkdownReference.d.ts +76 -0
  22. package/lib/structures/ITtscEvidenceGraphMarkdownReference.js +2 -0
  23. package/lib/structures/ITtscEvidenceGraphPrismaClaim.d.ts +65 -0
  24. package/lib/structures/ITtscEvidenceGraphPrismaClaim.js +2 -0
  25. package/lib/structures/ITtscEvidenceGraphPrismaReference.d.ts +75 -0
  26. package/lib/structures/ITtscEvidenceGraphPrismaReference.js +2 -0
  27. package/lib/structures/ITtscEvidenceGraphReference.d.ts +14 -0
  28. package/lib/structures/ITtscEvidenceGraphReference.js +2 -0
  29. package/lib/structures/ITtscEvidenceGraphReferenceBase.d.ts +73 -0
  30. package/lib/structures/ITtscEvidenceGraphReferenceBase.js +2 -0
  31. package/lib/structures/ITtscEvidenceGraphSwaggerReference.d.ts +39 -0
  32. package/lib/structures/ITtscEvidenceGraphSwaggerReference.js +2 -0
  33. package/lib/structures/ITtscEvidenceGraphTypeScriptClaim.d.ts +54 -0
  34. package/lib/structures/ITtscEvidenceGraphTypeScriptClaim.js +2 -0
  35. package/lib/structures/ITtscEvidenceGraphTypeScriptReference.d.ts +83 -0
  36. package/lib/structures/ITtscEvidenceGraphTypeScriptReference.js +2 -0
  37. package/lib/structures/index.d.ts +13 -0
  38. package/lib/structures/index.js +29 -0
  39. package/lib/typings/ITtscLintContributorRules.d.ts +34 -0
  40. package/lib/typings/ITtscLintContributorRules.js +2 -0
  41. package/lib/typings/ITtscLintRuleOptionsMap.d.ts +20 -0
  42. package/lib/typings/ITtscLintRuleOptionsMap.js +2 -0
  43. package/lib/typings/TtscEvidenceGraphMarkdownSymbol.d.ts +32 -0
  44. package/lib/typings/TtscEvidenceGraphMarkdownSymbol.js +2 -0
  45. package/lib/typings/TtscEvidenceGraphPrismaSymbol.d.ts +38 -0
  46. package/lib/typings/TtscEvidenceGraphPrismaSymbol.js +2 -0
  47. package/lib/typings/TtscEvidenceGraphTypeScriptSymbol.d.ts +64 -0
  48. package/lib/typings/TtscEvidenceGraphTypeScriptSymbol.js +2 -0
  49. package/lib/typings/index.d.ts +5 -0
  50. package/lib/typings/index.js +21 -0
  51. package/native/base.go +298 -0
  52. package/native/config.go +798 -0
  53. package/native/declaration.go +240 -0
  54. package/native/documented.go +353 -0
  55. package/native/exports.go +484 -0
  56. package/native/glob.go +207 -0
  57. package/native/graph.go +1409 -0
  58. package/native/health.go +45 -0
  59. package/native/hints.go +261 -0
  60. package/native/imports.go +373 -0
  61. package/native/inputs.go +125 -0
  62. package/native/loader.go +424 -0
  63. package/native/markdown.go +423 -0
  64. package/native/model.go +296 -0
  65. package/native/prisma.go +719 -0
  66. package/native/prisma_cache.go +213 -0
  67. package/native/prisma_locator.go +417 -0
  68. package/native/singular.go +369 -0
  69. package/native/swagger.go +331 -0
  70. package/native/swagger_cache.go +274 -0
  71. package/native/todo.go +138 -0
  72. package/native/typescript.go +1199 -0
  73. package/native/typescript_cache.go +96 -0
  74. package/package.json +64 -0
@@ -0,0 +1,96 @@
1
+ package evidence
2
+
3
+ import (
4
+ "sync"
5
+
6
+ shimast "github.com/microsoft/typescript-go/shim/ast"
7
+ )
8
+
9
+ // typeScriptInventories remembers a scanned file for as long as the host keeps
10
+ // handing back the same parsed source.
11
+ //
12
+ // Scanning the Program into inventories is the single largest cost of a graph
13
+ // rebuild, and a watch cycle repeats it after every keystroke for every file —
14
+ // including the thousands the edit did not touch. The compiler already answers
15
+ // which files changed: it reuses the `*ast.SourceFile` of an unchanged file and
16
+ // produces a new one for an edited file, so the pointer is both the cheapest
17
+ // and the most exact key available. A scan can never be served for content the
18
+ // host no longer holds.
19
+ //
20
+ // This is the rule's own memory rather than host state, the same standing the
21
+ // Swagger and Prisma caches have. The mutex is there because a resident host
22
+ // may hold several projects at once.
23
+ //
24
+ // Two generations are kept. On each cycle the live generation becomes the
25
+ // previous one and a fresh live generation starts, so a lookup still hits after
26
+ // one intervening cycle while resident memory stays bounded by twice the file
27
+ // set rather than growing with the session's edit count. A resident host
28
+ // alternating between two projects pays a miss per switch; correctness does not
29
+ // depend on the hit.
30
+ var typeScriptInventories = newTypeScriptInventoryCache()
31
+
32
+ // typeScriptInventoryKey identifies one scan. The address is part of it because
33
+ // one physical file can be addressed differently under two configured roots,
34
+ // and the address is baked into every unit identity the scan produces.
35
+ type typeScriptInventoryKey struct {
36
+ address string
37
+ file *shimast.SourceFile
38
+ }
39
+
40
+ func newTypeScriptInventoryCache() *typeScriptInventoryCache {
41
+ return &typeScriptInventoryCache{
42
+ live: map[typeScriptInventoryKey]*artifactInventory{},
43
+ }
44
+ }
45
+
46
+ type typeScriptInventoryCache struct {
47
+ mutex sync.Mutex
48
+ live map[typeScriptInventoryKey]*artifactInventory
49
+ previous map[typeScriptInventoryKey]*artifactInventory
50
+ }
51
+
52
+ // beginCycle retires the previous generation and starts a new live one.
53
+ func (cache *typeScriptInventoryCache) beginCycle() {
54
+ if cache == nil {
55
+ return
56
+ }
57
+ cache.mutex.Lock()
58
+ defer cache.mutex.Unlock()
59
+ cache.previous = cache.live
60
+ cache.live = map[typeScriptInventoryKey]*artifactInventory{}
61
+ }
62
+
63
+ // scan returns the inventory of one parsed source, scanning it only when this
64
+ // exact source has not been scanned under this address recently.
65
+ func (cache *typeScriptInventoryCache) scan(
66
+ address artifactAddress,
67
+ file *shimast.SourceFile,
68
+ ) *artifactInventory {
69
+ if cache == nil || file == nil {
70
+ return scanTypeScriptInventoryAt(address, file)
71
+ }
72
+ key := typeScriptInventoryKey{address: address.Key, file: file}
73
+ cache.mutex.Lock()
74
+ if inventory, hit := cache.live[key]; hit {
75
+ cache.mutex.Unlock()
76
+ return inventory
77
+ }
78
+ if inventory, hit := cache.previous[key]; hit {
79
+ cache.live[key] = inventory
80
+ cache.mutex.Unlock()
81
+ return inventory
82
+ }
83
+ cache.mutex.Unlock()
84
+
85
+ // Scanning happens outside the lock. Two projects that share a file may
86
+ // scan it twice on the same cycle, which costs one redundant walk and keeps
87
+ // an unrelated project's rebuild from waiting on this one.
88
+ inventory := scanTypeScriptInventoryAt(address, file)
89
+ cache.mutex.Lock()
90
+ defer cache.mutex.Unlock()
91
+ if existing, hit := cache.live[key]; hit {
92
+ return existing
93
+ }
94
+ cache.live[key] = inventory
95
+ return inventory
96
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@ttsc/evidence",
3
+ "version": "0.25.0",
4
+ "description": "Evidence-graph lint contributor for @ttsc/lint: declare provenance with a JSDoc @evidence tag and fail the build when it is missing or dangling.",
5
+ "main": "lib/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./lib/index.d.ts",
9
+ "default": "./lib/index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "LICENSE",
18
+ "README.md",
19
+ "lib",
20
+ "native/*.go",
21
+ "!native/*_test.go"
22
+ ],
23
+ "keywords": [
24
+ "ttsc",
25
+ "lint",
26
+ "evidence",
27
+ "provenance",
28
+ "traceability",
29
+ "jsdoc",
30
+ "typescript",
31
+ "openapi",
32
+ "swagger",
33
+ "prisma"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/samchon/ttsc"
38
+ },
39
+ "author": "Jeongho Nam",
40
+ "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/samchon/ttsc/issues"
43
+ },
44
+ "peerDependencies": {
45
+ "@ttsc/lint": ">=0.24.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^25.3.0",
49
+ "rimraf": "^6.1.2",
50
+ "typescript": "^7.0.2",
51
+ "@ttsc/lint": "0.25.0",
52
+ "ttsc": "0.25.0"
53
+ },
54
+ "dependencies": {
55
+ "@prisma/prisma-schema-wasm": "7.10.0-2.d0368e25c88e68caa4d283b5f2d88d1b76ed9356",
56
+ "@typia/interface": "13.2.0",
57
+ "@typia/utils": "13.2.0",
58
+ "yaml": "^2.9.0"
59
+ },
60
+ "homepage": "https://ttsc.dev",
61
+ "scripts": {
62
+ "build": "rimraf lib && tsc"
63
+ }
64
+ }