@aws-amplify/graphql-model-transformer 1.4.0 → 1.5.0-rds.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 (163) hide show
  1. package/API.md +15 -15
  2. package/CHANGELOG.md +11 -0
  3. package/lib/graphql-types/mutation.d.ts.map +1 -1
  4. package/lib/graphql-types/mutation.js +9 -2
  5. package/lib/graphql-types/mutation.js.map +1 -1
  6. package/lib/rds-lambda.zip +0 -0
  7. package/lib/rds-notification-lambda.zip +0 -0
  8. package/lib/rds-patching-lambda.zip +0 -0
  9. package/lib/resolvers/generators/dynamodb-vtl-generator.d.ts +6 -5
  10. package/lib/resolvers/generators/dynamodb-vtl-generator.d.ts.map +1 -1
  11. package/lib/resolvers/generators/dynamodb-vtl-generator.js +5 -5
  12. package/lib/resolvers/generators/dynamodb-vtl-generator.js.map +1 -1
  13. package/lib/resolvers/generators/rds-vtl-generator.d.ts +6 -5
  14. package/lib/resolvers/generators/rds-vtl-generator.d.ts.map +1 -1
  15. package/lib/resolvers/generators/rds-vtl-generator.js +10 -10
  16. package/lib/resolvers/generators/rds-vtl-generator.js.map +1 -1
  17. package/lib/resolvers/generators/vtl-generator.d.ts +6 -5
  18. package/lib/resolvers/generators/vtl-generator.d.ts.map +1 -1
  19. package/lib/resolvers/rds/mutation.d.ts +4 -3
  20. package/lib/resolvers/rds/mutation.d.ts.map +1 -1
  21. package/lib/resolvers/rds/mutation.js +7 -3
  22. package/lib/resolvers/rds/mutation.js.map +1 -1
  23. package/lib/resolvers/rds/query.d.ts +2 -1
  24. package/lib/resolvers/rds/query.d.ts.map +1 -1
  25. package/lib/resolvers/rds/query.js +3 -1
  26. package/lib/resolvers/rds/query.js.map +1 -1
  27. package/lib/resolvers/rds/resolver.d.ts +6 -2
  28. package/lib/resolvers/rds/resolver.d.ts.map +1 -1
  29. package/lib/resolvers/rds/resolver.js +39 -25
  30. package/lib/resolvers/rds/resolver.js.map +1 -1
  31. package/lib/resources/model-resource-generator.js +5 -5
  32. package/lib/resources/model-resource-generator.js.map +1 -1
  33. package/package.json +4 -4
  34. package/publish-notification-lambda/node_modules/.package-lock.json +13 -13
  35. package/publish-notification-lambda/node_modules/@smithy/protocol-http/package.json +2 -2
  36. package/publish-notification-lambda/node_modules/@smithy/types/README.md +37 -0
  37. package/publish-notification-lambda/node_modules/@smithy/types/package.json +3 -2
  38. package/publish-notification-lambda/node_modules/@types/node/README.md +2 -2
  39. package/publish-notification-lambda/node_modules/@types/node/package.json +2 -7
  40. package/publish-notification-lambda/node_modules/tslib/package.json +1 -1
  41. package/publish-notification-lambda/node_modules/tslib/tslib.es6.mjs +1 -1
  42. package/publish-notification-lambda/package-lock.json +13 -13
  43. package/rds-lambda/handler.ts +2 -1
  44. package/rds-lambda/node_modules/.package-lock.json +370 -345
  45. package/rds-lambda/node_modules/@babel/code-frame/README.md +1 -1
  46. package/rds-lambda/node_modules/@babel/code-frame/package.json +3 -2
  47. package/rds-lambda/node_modules/@babel/core/cjs-proxy.cjs +3 -1
  48. package/rds-lambda/node_modules/@babel/core/package.json +10 -10
  49. package/rds-lambda/node_modules/@babel/generator/package.json +3 -3
  50. package/rds-lambda/node_modules/@babel/helper-compilation-targets/package.json +1 -5
  51. package/rds-lambda/node_modules/@babel/helpers/package.json +6 -6
  52. package/rds-lambda/node_modules/@babel/highlight/README.md +1 -1
  53. package/rds-lambda/node_modules/@babel/highlight/package.json +2 -3
  54. package/rds-lambda/node_modules/@babel/parser/package.json +3 -3
  55. package/rds-lambda/node_modules/@babel/traverse/package.json +6 -5
  56. package/rds-lambda/node_modules/@babel/types/README.md +1 -1
  57. package/rds-lambda/node_modules/@babel/types/package.json +3 -4
  58. package/rds-lambda/node_modules/@jest/console/package.json +5 -5
  59. package/rds-lambda/node_modules/@jest/core/package.json +20 -20
  60. package/rds-lambda/node_modules/@jest/environment/package.json +4 -4
  61. package/rds-lambda/node_modules/@jest/expect/package.json +4 -4
  62. package/rds-lambda/node_modules/@jest/expect-utils/package.json +3 -3
  63. package/rds-lambda/node_modules/@jest/fake-timers/package.json +6 -6
  64. package/rds-lambda/node_modules/@jest/globals/package.json +5 -5
  65. package/rds-lambda/node_modules/@jest/reporters/package.json +10 -10
  66. package/rds-lambda/node_modules/@jest/test-result/package.json +5 -5
  67. package/rds-lambda/node_modules/@jest/test-sequencer/package.json +5 -5
  68. package/rds-lambda/node_modules/@jest/transform/package.json +6 -6
  69. package/rds-lambda/node_modules/@jridgewell/resolve-uri/package.json +2 -2
  70. package/rds-lambda/node_modules/@jridgewell/trace-mapping/package.json +3 -3
  71. package/rds-lambda/node_modules/@smithy/protocol-http/package.json +2 -2
  72. package/rds-lambda/node_modules/@smithy/types/README.md +37 -0
  73. package/rds-lambda/node_modules/@smithy/types/package.json +3 -2
  74. package/rds-lambda/node_modules/@types/node/README.md +2 -2
  75. package/rds-lambda/node_modules/@types/node/package.json +2 -7
  76. package/rds-lambda/node_modules/babel-jest/package.json +4 -4
  77. package/rds-lambda/node_modules/browserslist/package.json +4 -4
  78. package/rds-lambda/node_modules/caniuse-lite/package.json +1 -1
  79. package/rds-lambda/node_modules/dedent/README.md +56 -0
  80. package/rds-lambda/node_modules/dedent/dist/dedent.d.mts +17 -0
  81. package/rds-lambda/node_modules/dedent/dist/dedent.mjs +59 -0
  82. package/rds-lambda/node_modules/dedent/package.json +54 -10
  83. package/rds-lambda/node_modules/electron-to-chromium/full-chromium-versions.json +1 -1
  84. package/rds-lambda/node_modules/electron-to-chromium/full-versions.json +1 -1
  85. package/rds-lambda/node_modules/electron-to-chromium/package.json +1 -1
  86. package/rds-lambda/node_modules/electron-to-chromium/versions.json +1 -1
  87. package/rds-lambda/node_modules/expect/package.json +7 -7
  88. package/rds-lambda/node_modules/is-core-module/CHANGELOG.md +7 -0
  89. package/rds-lambda/node_modules/is-core-module/core.json +3 -3
  90. package/rds-lambda/node_modules/is-core-module/package.json +5 -5
  91. package/rds-lambda/node_modules/istanbul-lib-report/CHANGELOG.md +7 -0
  92. package/rds-lambda/node_modules/istanbul-lib-report/package.json +5 -6
  93. package/rds-lambda/node_modules/istanbul-reports/CHANGELOG.md +7 -0
  94. package/rds-lambda/node_modules/istanbul-reports/package.json +1 -1
  95. package/rds-lambda/node_modules/jest/package.json +4 -4
  96. package/rds-lambda/node_modules/jest-circus/package.json +13 -14
  97. package/rds-lambda/node_modules/jest-cli/package.json +7 -7
  98. package/rds-lambda/node_modules/jest-config/package.json +11 -11
  99. package/rds-lambda/node_modules/jest-diff/package.json +4 -4
  100. package/rds-lambda/node_modules/jest-each/package.json +4 -4
  101. package/rds-lambda/node_modules/jest-environment-node/package.json +7 -7
  102. package/rds-lambda/node_modules/jest-haste-map/package.json +4 -4
  103. package/rds-lambda/node_modules/jest-leak-detector/package.json +3 -3
  104. package/rds-lambda/node_modules/jest-matcher-utils/package.json +5 -5
  105. package/rds-lambda/node_modules/jest-message-util/package.json +3 -3
  106. package/rds-lambda/node_modules/jest-mock/package.json +3 -3
  107. package/rds-lambda/node_modules/jest-resolve/package.json +5 -5
  108. package/rds-lambda/node_modules/jest-resolve-dependencies/package.json +7 -7
  109. package/rds-lambda/node_modules/jest-runner/package.json +17 -17
  110. package/rds-lambda/node_modules/jest-runtime/package.json +15 -15
  111. package/rds-lambda/node_modules/jest-snapshot/package.json +12 -12
  112. package/rds-lambda/node_modules/jest-util/package.json +2 -2
  113. package/rds-lambda/node_modules/jest-validate/package.json +3 -3
  114. package/rds-lambda/node_modules/jest-watcher/package.json +4 -4
  115. package/rds-lambda/node_modules/jest-worker/package.json +4 -4
  116. package/rds-lambda/node_modules/make-dir/license +1 -1
  117. package/rds-lambda/node_modules/make-dir/node_modules/lru-cache/LICENSE +15 -0
  118. package/rds-lambda/node_modules/make-dir/node_modules/lru-cache/README.md +166 -0
  119. package/rds-lambda/node_modules/make-dir/node_modules/lru-cache/package.json +34 -0
  120. package/rds-lambda/node_modules/make-dir/node_modules/semver/LICENSE +15 -0
  121. package/rds-lambda/node_modules/make-dir/node_modules/semver/README.md +637 -0
  122. package/rds-lambda/node_modules/make-dir/node_modules/semver/package.json +87 -0
  123. package/rds-lambda/node_modules/make-dir/node_modules/semver/range.bnf +16 -0
  124. package/rds-lambda/node_modules/make-dir/node_modules/yallist/LICENSE +15 -0
  125. package/rds-lambda/node_modules/make-dir/node_modules/yallist/README.md +204 -0
  126. package/rds-lambda/node_modules/make-dir/node_modules/yallist/package.json +29 -0
  127. package/rds-lambda/node_modules/make-dir/package.json +15 -11
  128. package/rds-lambda/node_modules/make-dir/readme.md +1 -1
  129. package/rds-lambda/node_modules/pretty-format/package.json +3 -3
  130. package/rds-lambda/node_modules/resolve/lib/core.json +4 -1
  131. package/rds-lambda/node_modules/resolve/package.json +6 -6
  132. package/rds-lambda/node_modules/tslib/package.json +1 -1
  133. package/rds-lambda/node_modules/tslib/tslib.es6.mjs +1 -1
  134. package/rds-lambda/package-lock.json +370 -345
  135. package/rds-patching-lambda/node_modules/.package-lock.json +13 -13
  136. package/rds-patching-lambda/node_modules/@smithy/protocol-http/package.json +2 -2
  137. package/rds-patching-lambda/node_modules/@smithy/types/README.md +37 -0
  138. package/rds-patching-lambda/node_modules/@smithy/types/package.json +3 -2
  139. package/rds-patching-lambda/node_modules/@types/node/README.md +2 -2
  140. package/rds-patching-lambda/node_modules/@types/node/package.json +2 -7
  141. package/rds-patching-lambda/node_modules/tslib/package.json +1 -1
  142. package/rds-patching-lambda/node_modules/tslib/tslib.es6.mjs +1 -1
  143. package/rds-patching-lambda/package-lock.json +13 -13
  144. package/src/__tests__/__snapshots__/model-transformer.test.ts.snap +688 -0
  145. package/src/__tests__/model-transformer.test.ts +58 -1
  146. package/src/graphql-types/mutation.ts +11 -3
  147. package/src/resolvers/generators/dynamodb-vtl-generator.ts +7 -5
  148. package/src/resolvers/generators/rds-vtl-generator.ts +12 -10
  149. package/src/resolvers/generators/vtl-generator.ts +6 -5
  150. package/src/resolvers/rds/mutation.ts +18 -3
  151. package/src/resolvers/rds/query.ts +9 -1
  152. package/src/resolvers/rds/resolver.ts +45 -26
  153. package/src/resources/model-resource-generator.ts +5 -5
  154. package/tsconfig.tsbuildinfo +1 -1
  155. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/LICENSE +0 -21
  156. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/README.md +0 -200
  157. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -164
  158. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +0 -1
  159. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/package.json +0 -75
  160. package/rds-lambda/node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +0 -198
  161. package/rds-lambda/node_modules/@types/prettier/LICENSE +0 -21
  162. package/rds-lambda/node_modules/@types/prettier/README.md +0 -16
  163. package/rds-lambda/node_modules/@types/prettier/package.json +0 -65
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-runtime",
3
- "version": "29.6.1",
3
+ "version": "29.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -17,12 +17,12 @@
17
17
  "./package.json": "./package.json"
18
18
  },
19
19
  "dependencies": {
20
- "@jest/environment": "^29.6.1",
21
- "@jest/fake-timers": "^29.6.1",
22
- "@jest/globals": "^29.6.1",
20
+ "@jest/environment": "^29.6.2",
21
+ "@jest/fake-timers": "^29.6.2",
22
+ "@jest/globals": "^29.6.2",
23
23
  "@jest/source-map": "^29.6.0",
24
- "@jest/test-result": "^29.6.1",
25
- "@jest/transform": "^29.6.1",
24
+ "@jest/test-result": "^29.6.2",
25
+ "@jest/transform": "^29.6.2",
26
26
  "@jest/types": "^29.6.1",
27
27
  "@types/node": "*",
28
28
  "chalk": "^4.0.0",
@@ -30,21 +30,21 @@
30
30
  "collect-v8-coverage": "^1.0.0",
31
31
  "glob": "^7.1.3",
32
32
  "graceful-fs": "^4.2.9",
33
- "jest-haste-map": "^29.6.1",
34
- "jest-message-util": "^29.6.1",
35
- "jest-mock": "^29.6.1",
33
+ "jest-haste-map": "^29.6.2",
34
+ "jest-message-util": "^29.6.2",
35
+ "jest-mock": "^29.6.2",
36
36
  "jest-regex-util": "^29.4.3",
37
- "jest-resolve": "^29.6.1",
38
- "jest-snapshot": "^29.6.1",
39
- "jest-util": "^29.6.1",
37
+ "jest-resolve": "^29.6.2",
38
+ "jest-snapshot": "^29.6.2",
39
+ "jest-util": "^29.6.2",
40
40
  "slash": "^3.0.0",
41
41
  "strip-bom": "^4.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@jest/test-utils": "^29.6.1",
44
+ "@jest/test-utils": "^29.6.2",
45
45
  "@types/glob": "^7.1.1",
46
46
  "@types/graceful-fs": "^4.1.3",
47
- "jest-environment-node": "^29.6.1"
47
+ "jest-environment-node": "^29.6.2"
48
48
  },
49
49
  "engines": {
50
50
  "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
55
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
56
56
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-snapshot",
3
- "version": "29.6.1",
3
+ "version": "29.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -22,31 +22,31 @@
22
22
  "@babel/plugin-syntax-jsx": "^7.7.2",
23
23
  "@babel/plugin-syntax-typescript": "^7.7.2",
24
24
  "@babel/types": "^7.3.3",
25
- "@jest/expect-utils": "^29.6.1",
26
- "@jest/transform": "^29.6.1",
25
+ "@jest/expect-utils": "^29.6.2",
26
+ "@jest/transform": "^29.6.2",
27
27
  "@jest/types": "^29.6.1",
28
- "@types/prettier": "^2.1.5",
29
28
  "babel-preset-current-node-syntax": "^1.0.0",
30
29
  "chalk": "^4.0.0",
31
- "expect": "^29.6.1",
30
+ "expect": "^29.6.2",
32
31
  "graceful-fs": "^4.2.9",
33
- "jest-diff": "^29.6.1",
32
+ "jest-diff": "^29.6.2",
34
33
  "jest-get-type": "^29.4.3",
35
- "jest-matcher-utils": "^29.6.1",
36
- "jest-message-util": "^29.6.1",
37
- "jest-util": "^29.6.1",
34
+ "jest-matcher-utils": "^29.6.2",
35
+ "jest-message-util": "^29.6.2",
36
+ "jest-util": "^29.6.2",
38
37
  "natural-compare": "^1.4.0",
39
- "pretty-format": "^29.6.1",
38
+ "pretty-format": "^29.6.2",
40
39
  "semver": "^7.5.3"
41
40
  },
42
41
  "devDependencies": {
43
42
  "@babel/preset-flow": "^7.7.2",
44
43
  "@babel/preset-react": "^7.12.1",
45
- "@jest/test-utils": "^29.6.1",
44
+ "@jest/test-utils": "^29.6.2",
46
45
  "@tsd/typescript": "^5.0.4",
47
46
  "@types/babel__core": "^7.1.14",
48
47
  "@types/graceful-fs": "^4.1.3",
49
48
  "@types/natural-compare": "^1.4.0",
49
+ "@types/prettier": "^2.1.5",
50
50
  "@types/semver": "^7.1.0",
51
51
  "ansi-regex": "^5.0.1",
52
52
  "ansi-styles": "^5.0.0",
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
62
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
63
63
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-util",
3
- "version": "29.6.1",
3
+ "version": "29.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
37
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
38
38
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-validate",
3
- "version": "29.6.1",
3
+ "version": "29.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -22,7 +22,7 @@
22
22
  "chalk": "^4.0.0",
23
23
  "jest-get-type": "^29.4.3",
24
24
  "leven": "^3.1.0",
25
- "pretty-format": "^29.6.1"
25
+ "pretty-format": "^29.6.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/yargs": "^17.0.8"
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
36
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
37
37
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jest-watcher",
3
3
  "description": "Delightful JavaScript Testing.",
4
- "version": "29.6.1",
4
+ "version": "29.6.2",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "exports": {
@@ -12,13 +12,13 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "dependencies": {
15
- "@jest/test-result": "^29.6.1",
15
+ "@jest/test-result": "^29.6.2",
16
16
  "@jest/types": "^29.6.1",
17
17
  "@types/node": "*",
18
18
  "ansi-escapes": "^4.2.1",
19
19
  "chalk": "^4.0.0",
20
20
  "emittery": "^0.13.1",
21
- "jest-util": "^29.6.1",
21
+ "jest-util": "^29.6.2",
22
22
  "string-length": "^4.0.1"
23
23
  },
24
24
  "repository": {
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
40
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
41
41
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-worker",
3
- "version": "29.6.1",
3
+ "version": "29.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@types/node": "*",
21
- "jest-util": "^29.6.1",
21
+ "jest-util": "^29.6.2",
22
22
  "merge-stream": "^2.0.0",
23
23
  "supports-color": "^8.0.0"
24
24
  },
@@ -28,7 +28,7 @@
28
28
  "@types/merge-stream": "^1.1.2",
29
29
  "@types/supports-color": "^8.1.0",
30
30
  "get-stream": "^6.0.0",
31
- "jest-leak-detector": "^29.6.1",
31
+ "jest-leak-detector": "^29.6.2",
32
32
  "tsd-lite": "^0.7.0",
33
33
  "worker-farm": "^1.6.0"
34
34
  },
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "1f019afdcdfc54a6664908bb45f343db4e3d0848"
41
+ "gitHead": "0fd5b1c37555f485c56a6ad2d6b010a72204f9f6"
42
42
  }
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,166 @@
1
+ # lru cache
2
+
3
+ A cache object that deletes the least-recently-used items.
4
+
5
+ [![Build Status](https://travis-ci.org/isaacs/node-lru-cache.svg?branch=master)](https://travis-ci.org/isaacs/node-lru-cache) [![Coverage Status](https://coveralls.io/repos/isaacs/node-lru-cache/badge.svg?service=github)](https://coveralls.io/github/isaacs/node-lru-cache)
6
+
7
+ ## Installation:
8
+
9
+ ```javascript
10
+ npm install lru-cache --save
11
+ ```
12
+
13
+ ## Usage:
14
+
15
+ ```javascript
16
+ var LRU = require("lru-cache")
17
+ , options = { max: 500
18
+ , length: function (n, key) { return n * 2 + key.length }
19
+ , dispose: function (key, n) { n.close() }
20
+ , maxAge: 1000 * 60 * 60 }
21
+ , cache = new LRU(options)
22
+ , otherCache = new LRU(50) // sets just the max size
23
+
24
+ cache.set("key", "value")
25
+ cache.get("key") // "value"
26
+
27
+ // non-string keys ARE fully supported
28
+ // but note that it must be THE SAME object, not
29
+ // just a JSON-equivalent object.
30
+ var someObject = { a: 1 }
31
+ cache.set(someObject, 'a value')
32
+ // Object keys are not toString()-ed
33
+ cache.set('[object Object]', 'a different value')
34
+ assert.equal(cache.get(someObject), 'a value')
35
+ // A similar object with same keys/values won't work,
36
+ // because it's a different object identity
37
+ assert.equal(cache.get({ a: 1 }), undefined)
38
+
39
+ cache.reset() // empty the cache
40
+ ```
41
+
42
+ If you put more stuff in it, then items will fall out.
43
+
44
+ If you try to put an oversized thing in it, then it'll fall out right
45
+ away.
46
+
47
+ ## Options
48
+
49
+ * `max` The maximum size of the cache, checked by applying the length
50
+ function to all values in the cache. Not setting this is kind of
51
+ silly, since that's the whole purpose of this lib, but it defaults
52
+ to `Infinity`. Setting it to a non-number or negative number will
53
+ throw a `TypeError`. Setting it to 0 makes it be `Infinity`.
54
+ * `maxAge` Maximum age in ms. Items are not pro-actively pruned out
55
+ as they age, but if you try to get an item that is too old, it'll
56
+ drop it and return undefined instead of giving it to you.
57
+ Setting this to a negative value will make everything seem old!
58
+ Setting it to a non-number will throw a `TypeError`.
59
+ * `length` Function that is used to calculate the length of stored
60
+ items. If you're storing strings or buffers, then you probably want
61
+ to do something like `function(n, key){return n.length}`. The default is
62
+ `function(){return 1}`, which is fine if you want to store `max`
63
+ like-sized things. The item is passed as the first argument, and
64
+ the key is passed as the second argumnet.
65
+ * `dispose` Function that is called on items when they are dropped
66
+ from the cache. This can be handy if you want to close file
67
+ descriptors or do other cleanup tasks when items are no longer
68
+ accessible. Called with `key, value`. It's called *before*
69
+ actually removing the item from the internal cache, so if you want
70
+ to immediately put it back in, you'll have to do that in a
71
+ `nextTick` or `setTimeout` callback or it won't do anything.
72
+ * `stale` By default, if you set a `maxAge`, it'll only actually pull
73
+ stale items out of the cache when you `get(key)`. (That is, it's
74
+ not pre-emptively doing a `setTimeout` or anything.) If you set
75
+ `stale:true`, it'll return the stale value before deleting it. If
76
+ you don't set this, then it'll return `undefined` when you try to
77
+ get a stale entry, as if it had already been deleted.
78
+ * `noDisposeOnSet` By default, if you set a `dispose()` method, then
79
+ it'll be called whenever a `set()` operation overwrites an existing
80
+ key. If you set this option, `dispose()` will only be called when a
81
+ key falls out of the cache, not when it is overwritten.
82
+ * `updateAgeOnGet` When using time-expiring entries with `maxAge`,
83
+ setting this to `true` will make each item's effective time update
84
+ to the current time whenever it is retrieved from cache, causing it
85
+ to not expire. (It can still fall out of cache based on recency of
86
+ use, of course.)
87
+
88
+ ## API
89
+
90
+ * `set(key, value, maxAge)`
91
+ * `get(key) => value`
92
+
93
+ Both of these will update the "recently used"-ness of the key.
94
+ They do what you think. `maxAge` is optional and overrides the
95
+ cache `maxAge` option if provided.
96
+
97
+ If the key is not found, `get()` will return `undefined`.
98
+
99
+ The key and val can be any value.
100
+
101
+ * `peek(key)`
102
+
103
+ Returns the key value (or `undefined` if not found) without
104
+ updating the "recently used"-ness of the key.
105
+
106
+ (If you find yourself using this a lot, you *might* be using the
107
+ wrong sort of data structure, but there are some use cases where
108
+ it's handy.)
109
+
110
+ * `del(key)`
111
+
112
+ Deletes a key out of the cache.
113
+
114
+ * `reset()`
115
+
116
+ Clear the cache entirely, throwing away all values.
117
+
118
+ * `has(key)`
119
+
120
+ Check if a key is in the cache, without updating the recent-ness
121
+ or deleting it for being stale.
122
+
123
+ * `forEach(function(value,key,cache), [thisp])`
124
+
125
+ Just like `Array.prototype.forEach`. Iterates over all the keys
126
+ in the cache, in order of recent-ness. (Ie, more recently used
127
+ items are iterated over first.)
128
+
129
+ * `rforEach(function(value,key,cache), [thisp])`
130
+
131
+ The same as `cache.forEach(...)` but items are iterated over in
132
+ reverse order. (ie, less recently used items are iterated over
133
+ first.)
134
+
135
+ * `keys()`
136
+
137
+ Return an array of the keys in the cache.
138
+
139
+ * `values()`
140
+
141
+ Return an array of the values in the cache.
142
+
143
+ * `length`
144
+
145
+ Return total length of objects in cache taking into account
146
+ `length` options function.
147
+
148
+ * `itemCount`
149
+
150
+ Return total quantity of objects currently in cache. Note, that
151
+ `stale` (see options) items are returned as part of this item
152
+ count.
153
+
154
+ * `dump()`
155
+
156
+ Return an array of the cache entries ready for serialization and usage
157
+ with 'destinationCache.load(arr)`.
158
+
159
+ * `load(cacheEntriesArray)`
160
+
161
+ Loads another cache entries array, obtained with `sourceCache.dump()`,
162
+ into the cache. The destination cache is reset before loading new entries
163
+
164
+ * `prune()`
165
+
166
+ Manually iterates over the entire cache proactively pruning old entries
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "lru-cache",
3
+ "description": "A cache object that deletes the least-recently-used items.",
4
+ "version": "6.0.0",
5
+ "author": "Isaac Z. Schlueter <i@izs.me>",
6
+ "keywords": [
7
+ "mru",
8
+ "lru",
9
+ "cache"
10
+ ],
11
+ "scripts": {
12
+ "test": "tap",
13
+ "snap": "tap",
14
+ "preversion": "npm test",
15
+ "postversion": "npm publish",
16
+ "prepublishOnly": "git push origin --follow-tags"
17
+ },
18
+ "main": "index.js",
19
+ "repository": "git://github.com/isaacs/node-lru-cache.git",
20
+ "devDependencies": {
21
+ "benchmark": "^2.1.4",
22
+ "tap": "^14.10.7"
23
+ },
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "yallist": "^4.0.0"
27
+ },
28
+ "files": [
29
+ "index.js"
30
+ ],
31
+ "engines": {
32
+ "node": ">=10"
33
+ }
34
+ }
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.