@microwiseai/snapshot 0.3.5 → 0.3.26
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/dist/commands/install.d.ts +13 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +621 -98
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/license.d.ts +21 -0
- package/dist/commands/license.d.ts.map +1 -0
- package/dist/commands/license.js +120 -0
- package/dist/commands/license.js.map +1 -0
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +32 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +89 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/gitlab.d.ts +26 -20
- package/dist/lib/gitlab.d.ts.map +1 -1
- package/dist/lib/gitlab.js +100 -153
- package/dist/lib/gitlab.js.map +1 -1
- package/dist/lib/package-resolver.d.ts +48 -0
- package/dist/lib/package-resolver.d.ts.map +1 -0
- package/dist/lib/package-resolver.js +178 -0
- package/dist/lib/package-resolver.js.map +1 -0
- package/dist/lib/skit-adapter.d.ts +56 -0
- package/dist/lib/skit-adapter.d.ts.map +1 -0
- package/dist/lib/skit-adapter.js +166 -0
- package/dist/lib/skit-adapter.js.map +1 -0
- package/dist/lib/transitive-resolver.d.ts +86 -0
- package/dist/lib/transitive-resolver.d.ts.map +1 -0
- package/dist/lib/transitive-resolver.js +431 -0
- package/dist/lib/transitive-resolver.js.map +1 -0
- package/dist/lib/types.d.ts +13 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib.d.ts +59 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +134 -0
- package/dist/lib.js.map +1 -0
- package/dist/tools/snapshot-to-license.d.ts +13 -0
- package/dist/tools/snapshot-to-license.d.ts.map +1 -0
- package/dist/tools/snapshot-to-license.js +105 -0
- package/dist/tools/snapshot-to-license.js.map +1 -0
- package/node_modules/@microwiseai/cache/README.md +143 -0
- package/node_modules/@microwiseai/cache/dist/file.d.ts +97 -0
- package/node_modules/@microwiseai/cache/dist/file.d.ts.map +1 -0
- package/node_modules/@microwiseai/cache/dist/file.js +256 -0
- package/node_modules/@microwiseai/cache/dist/file.js.map +1 -0
- package/node_modules/@microwiseai/cache/dist/index.d.ts +10 -0
- package/node_modules/@microwiseai/cache/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/cache/dist/index.js +11 -0
- package/node_modules/@microwiseai/cache/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/cache/dist/memory.d.ts +69 -0
- package/node_modules/@microwiseai/cache/dist/memory.d.ts.map +1 -0
- package/node_modules/@microwiseai/cache/dist/memory.js +152 -0
- package/node_modules/@microwiseai/cache/dist/memory.js.map +1 -0
- package/node_modules/@microwiseai/cache/dist/types.d.ts +76 -0
- package/node_modules/@microwiseai/cache/dist/types.d.ts.map +1 -0
- package/node_modules/@microwiseai/cache/dist/types.js +5 -0
- package/node_modules/@microwiseai/cache/dist/types.js.map +1 -0
- package/node_modules/@microwiseai/cache/package.json +40 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/detector.test.d.ts +7 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/detector.test.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/detector.test.js +139 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/detector.test.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/reporter.test.d.ts +8 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/reporter.test.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/reporter.test.js +195 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/reporter.test.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/types.test.d.ts +8 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/types.test.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/types.test.js +97 -0
- package/node_modules/@microwiseai/import-telemetry/dist/__tests__/types.test.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/detector.d.ts +16 -0
- package/node_modules/@microwiseai/import-telemetry/dist/detector.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/detector.js +103 -0
- package/node_modules/@microwiseai/import-telemetry/dist/detector.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/index.d.ts +48 -0
- package/node_modules/@microwiseai/import-telemetry/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/index.js +56 -0
- package/node_modules/@microwiseai/import-telemetry/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/reporter.d.ts +16 -0
- package/node_modules/@microwiseai/import-telemetry/dist/reporter.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/reporter.js +147 -0
- package/node_modules/@microwiseai/import-telemetry/dist/reporter.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/types.d.ts +75 -0
- package/node_modules/@microwiseai/import-telemetry/dist/types.d.ts.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/dist/types.js +23 -0
- package/node_modules/@microwiseai/import-telemetry/dist/types.js.map +1 -0
- package/node_modules/@microwiseai/import-telemetry/package.json +40 -0
- package/node_modules/@microwiseai/license/README.md +157 -0
- package/node_modules/@microwiseai/license/dist/api/client.d.ts +37 -0
- package/node_modules/@microwiseai/license/dist/api/client.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/api/client.js +95 -0
- package/node_modules/@microwiseai/license/dist/api/client.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/api/endpoints.d.ts +25 -0
- package/node_modules/@microwiseai/license/dist/api/endpoints.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/api/endpoints.js +101 -0
- package/node_modules/@microwiseai/license/dist/api/endpoints.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/api/index.d.ts +7 -0
- package/node_modules/@microwiseai/license/dist/api/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/api/index.js +8 -0
- package/node_modules/@microwiseai/license/dist/api/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/file.d.ts +38 -0
- package/node_modules/@microwiseai/license/dist/cache/file.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/file.js +140 -0
- package/node_modules/@microwiseai/license/dist/cache/file.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/index.d.ts +7 -0
- package/node_modules/@microwiseai/license/dist/cache/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/index.js +10 -0
- package/node_modules/@microwiseai/license/dist/cache/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/memory.d.ts +35 -0
- package/node_modules/@microwiseai/license/dist/cache/memory.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/memory.js +77 -0
- package/node_modules/@microwiseai/license/dist/cache/memory.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/offline.d.ts +29 -0
- package/node_modules/@microwiseai/license/dist/cache/offline.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/cache/offline.js +58 -0
- package/node_modules/@microwiseai/license/dist/cache/offline.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/client.d.ts +42 -0
- package/node_modules/@microwiseai/license/dist/client.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/client.js +83 -0
- package/node_modules/@microwiseai/license/dist/client.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/config.d.ts +27 -0
- package/node_modules/@microwiseai/license/dist/config.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/config.js +52 -0
- package/node_modules/@microwiseai/license/dist/config.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/activate.d.ts +21 -0
- package/node_modules/@microwiseai/license/dist/core/activate.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/activate.js +72 -0
- package/node_modules/@microwiseai/license/dist/core/activate.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/check.d.ts +19 -0
- package/node_modules/@microwiseai/license/dist/core/check.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/check.js +244 -0
- package/node_modules/@microwiseai/license/dist/core/check.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/index.d.ts +7 -0
- package/node_modules/@microwiseai/license/dist/core/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/index.js +10 -0
- package/node_modules/@microwiseai/license/dist/core/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/verify.d.ts +39 -0
- package/node_modules/@microwiseai/license/dist/core/verify.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/core/verify.js +188 -0
- package/node_modules/@microwiseai/license/dist/core/verify.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/env.d.ts +33 -0
- package/node_modules/@microwiseai/license/dist/env.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/env.js +69 -0
- package/node_modules/@microwiseai/license/dist/env.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/cache.d.ts +97 -0
- package/node_modules/@microwiseai/license/dist/helpers/cache.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/cache.js +198 -0
- package/node_modules/@microwiseai/license/dist/helpers/cache.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/index.d.ts +7 -0
- package/node_modules/@microwiseai/license/dist/helpers/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/index.js +9 -0
- package/node_modules/@microwiseai/license/dist/helpers/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/telemetry.d.ts +68 -0
- package/node_modules/@microwiseai/license/dist/helpers/telemetry.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/helpers/telemetry.js +119 -0
- package/node_modules/@microwiseai/license/dist/helpers/telemetry.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/index.d.ts +34 -0
- package/node_modules/@microwiseai/license/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/index.js +48 -0
- package/node_modules/@microwiseai/license/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/id.d.ts +19 -0
- package/node_modules/@microwiseai/license/dist/machine/id.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/id.js +83 -0
- package/node_modules/@microwiseai/license/dist/machine/id.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/index.d.ts +6 -0
- package/node_modules/@microwiseai/license/dist/machine/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/index.js +6 -0
- package/node_modules/@microwiseai/license/dist/machine/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/instance.d.ts +23 -0
- package/node_modules/@microwiseai/license/dist/machine/instance.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/machine/instance.js +52 -0
- package/node_modules/@microwiseai/license/dist/machine/instance.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/index.d.ts +6 -0
- package/node_modules/@microwiseai/license/dist/telemetry/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/index.js +6 -0
- package/node_modules/@microwiseai/license/dist/telemetry/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/manager.d.ts +53 -0
- package/node_modules/@microwiseai/license/dist/telemetry/manager.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/manager.js +125 -0
- package/node_modules/@microwiseai/license/dist/telemetry/manager.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/payload.d.ts +17 -0
- package/node_modules/@microwiseai/license/dist/telemetry/payload.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/telemetry/payload.js +65 -0
- package/node_modules/@microwiseai/license/dist/telemetry/payload.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/api.d.ts +120 -0
- package/node_modules/@microwiseai/license/dist/types/api.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/api.js +5 -0
- package/node_modules/@microwiseai/license/dist/types/api.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/config.d.ts +80 -0
- package/node_modules/@microwiseai/license/dist/types/config.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/config.js +12 -0
- package/node_modules/@microwiseai/license/dist/types/config.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/errors.d.ts +93 -0
- package/node_modules/@microwiseai/license/dist/types/errors.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/errors.js +144 -0
- package/node_modules/@microwiseai/license/dist/types/errors.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/index.d.ts +10 -0
- package/node_modules/@microwiseai/license/dist/types/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/index.js +6 -0
- package/node_modules/@microwiseai/license/dist/types/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/license.d.ts +113 -0
- package/node_modules/@microwiseai/license/dist/types/license.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/types/license.js +5 -0
- package/node_modules/@microwiseai/license/dist/types/license.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/date.d.ts +45 -0
- package/node_modules/@microwiseai/license/dist/utils/date.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/date.js +95 -0
- package/node_modules/@microwiseai/license/dist/utils/date.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/env.d.ts +41 -0
- package/node_modules/@microwiseai/license/dist/utils/env.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/env.js +80 -0
- package/node_modules/@microwiseai/license/dist/utils/env.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/index.d.ts +7 -0
- package/node_modules/@microwiseai/license/dist/utils/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/index.js +7 -0
- package/node_modules/@microwiseai/license/dist/utils/index.js.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/mask.d.ts +27 -0
- package/node_modules/@microwiseai/license/dist/utils/mask.d.ts.map +1 -0
- package/node_modules/@microwiseai/license/dist/utils/mask.js +67 -0
- package/node_modules/@microwiseai/license/dist/utils/mask.js.map +1 -0
- package/node_modules/@microwiseai/license/package.json +52 -0
- package/node_modules/@microwiseai/license-types/README.md +84 -0
- package/node_modules/@microwiseai/license-types/dist/api.d.ts +120 -0
- package/node_modules/@microwiseai/license-types/dist/api.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/api.js +5 -0
- package/node_modules/@microwiseai/license-types/dist/api.js.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/config.d.ts +80 -0
- package/node_modules/@microwiseai/license-types/dist/config.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/config.js +12 -0
- package/node_modules/@microwiseai/license-types/dist/config.js.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/errors.d.ts +93 -0
- package/node_modules/@microwiseai/license-types/dist/errors.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/errors.js +144 -0
- package/node_modules/@microwiseai/license-types/dist/errors.js.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/index.d.ts +10 -0
- package/node_modules/@microwiseai/license-types/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/index.js +6 -0
- package/node_modules/@microwiseai/license-types/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/license.d.ts +113 -0
- package/node_modules/@microwiseai/license-types/dist/license.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-types/dist/license.js +5 -0
- package/node_modules/@microwiseai/license-types/dist/license.js.map +1 -0
- package/node_modules/@microwiseai/license-types/package.json +38 -0
- package/node_modules/@microwiseai/license-utils/README.md +82 -0
- package/node_modules/@microwiseai/license-utils/dist/__tests__/machine.test.d.ts +2 -0
- package/node_modules/@microwiseai/license-utils/dist/__tests__/machine.test.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/__tests__/machine.test.js +124 -0
- package/node_modules/@microwiseai/license-utils/dist/__tests__/machine.test.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/index.d.ts +7 -0
- package/node_modules/@microwiseai/license-utils/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/index.js +15 -0
- package/node_modules/@microwiseai/license-utils/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/id.d.ts +19 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/id.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/id.js +83 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/id.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/index.d.ts +6 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/index.js +6 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/index.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/instance.d.ts +23 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/instance.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/instance.js +52 -0
- package/node_modules/@microwiseai/license-utils/dist/machine/instance.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/date.d.ts +45 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/date.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/date.js +95 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/date.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/env.d.ts +16 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/env.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/env.js +22 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/env.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/index.d.ts +7 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/index.js +7 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/index.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/mask.d.ts +27 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/mask.d.ts.map +1 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/mask.js +67 -0
- package/node_modules/@microwiseai/license-utils/dist/utils/mask.js.map +1 -0
- package/node_modules/@microwiseai/license-utils/package.json +45 -0
- package/node_modules/@microwiseai/telemetry/README.md +86 -0
- package/node_modules/@microwiseai/telemetry/dist/index.d.ts +9 -0
- package/node_modules/@microwiseai/telemetry/dist/index.d.ts.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/index.js +10 -0
- package/node_modules/@microwiseai/telemetry/dist/index.js.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/manager.d.ts +71 -0
- package/node_modules/@microwiseai/telemetry/dist/manager.d.ts.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/manager.js +171 -0
- package/node_modules/@microwiseai/telemetry/dist/manager.js.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/payload.d.ts +13 -0
- package/node_modules/@microwiseai/telemetry/dist/payload.d.ts.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/payload.js +35 -0
- package/node_modules/@microwiseai/telemetry/dist/payload.js.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/types.d.ts +76 -0
- package/node_modules/@microwiseai/telemetry/dist/types.d.ts.map +1 -0
- package/node_modules/@microwiseai/telemetry/dist/types.js +13 -0
- package/node_modules/@microwiseai/telemetry/dist/types.js.map +1 -0
- package/node_modules/@microwiseai/telemetry/package.json +43 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/package.json +26 -2
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic file-based cache with TTL support
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import * as os from 'os';
|
|
7
|
+
const DEFAULT_TTL_SECONDS = 3600; // 1 hour
|
|
8
|
+
/**
|
|
9
|
+
* Get default cache directory
|
|
10
|
+
*/
|
|
11
|
+
function getDefaultCacheDir() {
|
|
12
|
+
return path.join(os.homedir(), '.cache');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* File-based cache with TTL support
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const cache = new FileCache<ConfigData>({
|
|
20
|
+
* baseDir: '~/.myapp',
|
|
21
|
+
* fileName: 'config-cache.json',
|
|
22
|
+
* ttlSeconds: 3600
|
|
23
|
+
* });
|
|
24
|
+
* cache.set('config', configData);
|
|
25
|
+
* const config = cache.get('config');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class FileCache {
|
|
29
|
+
baseDir;
|
|
30
|
+
fileName;
|
|
31
|
+
ttlSeconds;
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.baseDir = options.baseDir ?? getDefaultCacheDir();
|
|
34
|
+
this.fileName = options.fileName ?? 'cache.json';
|
|
35
|
+
this.ttlSeconds = options.ttlSeconds ?? DEFAULT_TTL_SECONDS;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get cache file path
|
|
39
|
+
*/
|
|
40
|
+
getFilePath() {
|
|
41
|
+
return path.join(this.baseDir, this.fileName);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Ensure cache directory exists
|
|
45
|
+
*/
|
|
46
|
+
ensureDir() {
|
|
47
|
+
if (!fs.existsSync(this.baseDir)) {
|
|
48
|
+
fs.mkdirSync(this.baseDir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Read all cache entries from file
|
|
53
|
+
*/
|
|
54
|
+
readAll() {
|
|
55
|
+
try {
|
|
56
|
+
const filePath = this.getFilePath();
|
|
57
|
+
if (!fs.existsSync(filePath)) {
|
|
58
|
+
return new Map();
|
|
59
|
+
}
|
|
60
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
61
|
+
const data = JSON.parse(content);
|
|
62
|
+
return new Map(Object.entries(data));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return new Map();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Write all cache entries to file
|
|
70
|
+
*/
|
|
71
|
+
writeAll(entries) {
|
|
72
|
+
this.ensureDir();
|
|
73
|
+
const data = Object.fromEntries(entries);
|
|
74
|
+
const filePath = this.getFilePath();
|
|
75
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get cached value
|
|
79
|
+
*/
|
|
80
|
+
get(key) {
|
|
81
|
+
const entries = this.readAll();
|
|
82
|
+
const entry = entries.get(key);
|
|
83
|
+
if (!entry) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// Check if expired
|
|
87
|
+
const expiresAt = new Date(entry.expiresAt);
|
|
88
|
+
if (expiresAt <= new Date()) {
|
|
89
|
+
entries.delete(key);
|
|
90
|
+
this.writeAll(entries);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return entry.value;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Set value in cache
|
|
97
|
+
*/
|
|
98
|
+
set(key, value) {
|
|
99
|
+
const entries = this.readAll();
|
|
100
|
+
const now = new Date();
|
|
101
|
+
const expiresAt = new Date(now.getTime() + this.ttlSeconds * 1000);
|
|
102
|
+
entries.set(key, {
|
|
103
|
+
value,
|
|
104
|
+
cachedAt: now.toISOString(),
|
|
105
|
+
expiresAt: expiresAt.toISOString(),
|
|
106
|
+
});
|
|
107
|
+
this.writeAll(entries);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Set value with custom TTL
|
|
111
|
+
*/
|
|
112
|
+
setWithTTL(key, value, ttlSeconds) {
|
|
113
|
+
const entries = this.readAll();
|
|
114
|
+
const now = new Date();
|
|
115
|
+
const expiresAt = new Date(now.getTime() + ttlSeconds * 1000);
|
|
116
|
+
entries.set(key, {
|
|
117
|
+
value,
|
|
118
|
+
cachedAt: now.toISOString(),
|
|
119
|
+
expiresAt: expiresAt.toISOString(),
|
|
120
|
+
});
|
|
121
|
+
this.writeAll(entries);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Delete cached value
|
|
125
|
+
*/
|
|
126
|
+
delete(key) {
|
|
127
|
+
const entries = this.readAll();
|
|
128
|
+
if (entries.delete(key)) {
|
|
129
|
+
this.writeAll(entries);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Clear all cached values
|
|
134
|
+
*/
|
|
135
|
+
clear() {
|
|
136
|
+
try {
|
|
137
|
+
const filePath = this.getFilePath();
|
|
138
|
+
if (fs.existsSync(filePath)) {
|
|
139
|
+
fs.unlinkSync(filePath);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// Ignore deletion errors
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if cache entry is valid
|
|
148
|
+
*/
|
|
149
|
+
isValid(key) {
|
|
150
|
+
return this.get(key) !== null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get cache statistics
|
|
154
|
+
*/
|
|
155
|
+
getStats(key) {
|
|
156
|
+
const entries = this.readAll();
|
|
157
|
+
const entry = entries.get(key);
|
|
158
|
+
if (!entry) {
|
|
159
|
+
return { exists: false };
|
|
160
|
+
}
|
|
161
|
+
const now = new Date();
|
|
162
|
+
const expiresAt = new Date(entry.expiresAt);
|
|
163
|
+
const cachedAt = new Date(entry.cachedAt);
|
|
164
|
+
if (expiresAt <= now) {
|
|
165
|
+
return { exists: false };
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
exists: true,
|
|
169
|
+
cachedAt,
|
|
170
|
+
expiresAt,
|
|
171
|
+
remainingMs: Math.max(0, expiresAt.getTime() - now.getTime()),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get cache directory path
|
|
176
|
+
*/
|
|
177
|
+
getDirectory() {
|
|
178
|
+
return this.baseDir;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Cleanup expired entries
|
|
182
|
+
*/
|
|
183
|
+
cleanup() {
|
|
184
|
+
const entries = this.readAll();
|
|
185
|
+
const now = new Date();
|
|
186
|
+
let removed = 0;
|
|
187
|
+
for (const [key, entry] of entries) {
|
|
188
|
+
const expiresAt = new Date(entry.expiresAt);
|
|
189
|
+
if (expiresAt <= now) {
|
|
190
|
+
entries.delete(key);
|
|
191
|
+
removed++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (removed > 0) {
|
|
195
|
+
this.writeAll(entries);
|
|
196
|
+
}
|
|
197
|
+
return removed;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ============================================================
|
|
201
|
+
// Utility functions
|
|
202
|
+
// ============================================================
|
|
203
|
+
/**
|
|
204
|
+
* Get storage directory path (for compatibility)
|
|
205
|
+
*/
|
|
206
|
+
export function getStorageDir(name, basePath) {
|
|
207
|
+
const base = basePath ?? os.homedir();
|
|
208
|
+
return path.join(base, `.${name}`);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Ensure directory exists
|
|
212
|
+
*/
|
|
213
|
+
export function ensureDir(dirPath) {
|
|
214
|
+
if (!fs.existsSync(dirPath)) {
|
|
215
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Read JSON file safely
|
|
220
|
+
*/
|
|
221
|
+
export function readJsonFile(filePath) {
|
|
222
|
+
try {
|
|
223
|
+
if (!fs.existsSync(filePath)) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
227
|
+
return JSON.parse(content);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Write JSON file safely
|
|
235
|
+
*/
|
|
236
|
+
export function writeJsonFile(filePath, data) {
|
|
237
|
+
const dir = path.dirname(filePath);
|
|
238
|
+
ensureDir(dir);
|
|
239
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Delete file safely
|
|
243
|
+
*/
|
|
244
|
+
export function deleteFile(filePath) {
|
|
245
|
+
try {
|
|
246
|
+
if (fs.existsSync(filePath)) {
|
|
247
|
+
fs.unlinkSync(filePath);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AA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AO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAI,QAAgB,EAAE,IAAO;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,SAAS,CAAC,GAAG,CAAC,CAAC;IACf,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @microwiseai/cache
|
|
3
|
+
*
|
|
4
|
+
* Generic caching utilities for Node.js
|
|
5
|
+
* Provides both in-memory and file-based caching with TTL support
|
|
6
|
+
*/
|
|
7
|
+
export type { Cache, CacheEntry, CacheStats, MemoryCacheOptions, FileCacheOptions, FileCacheEntry, } from './types.js';
|
|
8
|
+
export { MemoryCache, getGlobalCache, clearAllGlobalCaches } from './memory.js';
|
|
9
|
+
export { FileCache, getStorageDir, ensureDir, readJsonFile, writeJsonFile, deleteFile, } from './file.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,KAAK,EACL,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGhF,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @microwiseai/cache
|
|
3
|
+
*
|
|
4
|
+
* Generic caching utilities for Node.js
|
|
5
|
+
* Provides both in-memory and file-based caching with TTL support
|
|
6
|
+
*/
|
|
7
|
+
// Memory cache
|
|
8
|
+
export { MemoryCache, getGlobalCache, clearAllGlobalCaches } from './memory.js';
|
|
9
|
+
// File cache
|
|
10
|
+
export { FileCache, getStorageDir, ensureDir, readJsonFile, writeJsonFile, deleteFile, } from './file.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEhF,aAAa;AACb,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic in-memory cache with TTL support
|
|
3
|
+
*/
|
|
4
|
+
import type { Cache, CacheStats, MemoryCacheOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* In-memory cache with TTL support
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const cache = new MemoryCache<UserData>({ ttlMs: 60000 });
|
|
11
|
+
* cache.set('user:123', userData);
|
|
12
|
+
* const user = cache.get('user:123');
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class MemoryCache<T> implements Cache<T> {
|
|
16
|
+
private store;
|
|
17
|
+
private readonly ttlMs;
|
|
18
|
+
private readonly prefix;
|
|
19
|
+
constructor(options?: MemoryCacheOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Get full cache key with prefix
|
|
22
|
+
*/
|
|
23
|
+
private getKey;
|
|
24
|
+
/**
|
|
25
|
+
* Get cached value
|
|
26
|
+
*/
|
|
27
|
+
get(key: string): T | null;
|
|
28
|
+
/**
|
|
29
|
+
* Set value in cache
|
|
30
|
+
*/
|
|
31
|
+
set(key: string, value: T): void;
|
|
32
|
+
/**
|
|
33
|
+
* Set value with custom TTL
|
|
34
|
+
*/
|
|
35
|
+
setWithTTL(key: string, value: T, ttlMs: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Delete cached value
|
|
38
|
+
*/
|
|
39
|
+
delete(key: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all cached values
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Check if cache entry is valid (exists and not expired)
|
|
46
|
+
*/
|
|
47
|
+
isValid(key: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get cache statistics
|
|
50
|
+
*/
|
|
51
|
+
getStats(key: string): CacheStats;
|
|
52
|
+
/**
|
|
53
|
+
* Get number of entries (including expired)
|
|
54
|
+
*/
|
|
55
|
+
get size(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Cleanup expired entries
|
|
58
|
+
*/
|
|
59
|
+
cleanup(): number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get or create a named global cache
|
|
63
|
+
*/
|
|
64
|
+
export declare function getGlobalCache<T>(name: string, options?: MemoryCacheOptions): MemoryCache<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Clear all global caches
|
|
67
|
+
*/
|
|
68
|
+
export declare function clearAllGlobalCaches(): void;
|
|
69
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAc,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIpF;;;;;;;;;GASG;AACH,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,KAAK,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,GAAE,kBAAuB;IAK5C;;OAEG;IACH,OAAO,CAAC,MAAM;IAId;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAiB1B;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAWhC;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAWtD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAuBjC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,OAAO,IAAI,MAAM;CAalB;AAQD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAAC,CAAC,CAAC,CAK5F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic in-memory cache with TTL support
|
|
3
|
+
*/
|
|
4
|
+
const DEFAULT_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
5
|
+
/**
|
|
6
|
+
* In-memory cache with TTL support
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const cache = new MemoryCache<UserData>({ ttlMs: 60000 });
|
|
11
|
+
* cache.set('user:123', userData);
|
|
12
|
+
* const user = cache.get('user:123');
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class MemoryCache {
|
|
16
|
+
store = new Map();
|
|
17
|
+
ttlMs;
|
|
18
|
+
prefix;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
|
|
21
|
+
this.prefix = options.prefix ?? '';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get full cache key with prefix
|
|
25
|
+
*/
|
|
26
|
+
getKey(key) {
|
|
27
|
+
return this.prefix ? `${this.prefix}:${key}` : key;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get cached value
|
|
31
|
+
*/
|
|
32
|
+
get(key) {
|
|
33
|
+
const fullKey = this.getKey(key);
|
|
34
|
+
const entry = this.store.get(fullKey);
|
|
35
|
+
if (!entry) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
// Check if expired
|
|
39
|
+
if (Date.now() > entry.expiresAt) {
|
|
40
|
+
this.store.delete(fullKey);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return entry.value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set value in cache
|
|
47
|
+
*/
|
|
48
|
+
set(key, value) {
|
|
49
|
+
const fullKey = this.getKey(key);
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
this.store.set(fullKey, {
|
|
52
|
+
value,
|
|
53
|
+
cachedAt: now,
|
|
54
|
+
expiresAt: now + this.ttlMs,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set value with custom TTL
|
|
59
|
+
*/
|
|
60
|
+
setWithTTL(key, value, ttlMs) {
|
|
61
|
+
const fullKey = this.getKey(key);
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
this.store.set(fullKey, {
|
|
64
|
+
value,
|
|
65
|
+
cachedAt: now,
|
|
66
|
+
expiresAt: now + ttlMs,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Delete cached value
|
|
71
|
+
*/
|
|
72
|
+
delete(key) {
|
|
73
|
+
const fullKey = this.getKey(key);
|
|
74
|
+
this.store.delete(fullKey);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Clear all cached values
|
|
78
|
+
*/
|
|
79
|
+
clear() {
|
|
80
|
+
this.store.clear();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if cache entry is valid (exists and not expired)
|
|
84
|
+
*/
|
|
85
|
+
isValid(key) {
|
|
86
|
+
return this.get(key) !== null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get cache statistics
|
|
90
|
+
*/
|
|
91
|
+
getStats(key) {
|
|
92
|
+
const fullKey = this.getKey(key);
|
|
93
|
+
const entry = this.store.get(fullKey);
|
|
94
|
+
if (!entry) {
|
|
95
|
+
return { exists: false };
|
|
96
|
+
}
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
const isExpired = now > entry.expiresAt;
|
|
99
|
+
if (isExpired) {
|
|
100
|
+
return { exists: false };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
exists: true,
|
|
104
|
+
cachedAt: new Date(entry.cachedAt),
|
|
105
|
+
expiresAt: new Date(entry.expiresAt),
|
|
106
|
+
remainingMs: Math.max(0, entry.expiresAt - now),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get number of entries (including expired)
|
|
111
|
+
*/
|
|
112
|
+
get size() {
|
|
113
|
+
return this.store.size;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Cleanup expired entries
|
|
117
|
+
*/
|
|
118
|
+
cleanup() {
|
|
119
|
+
const now = Date.now();
|
|
120
|
+
let removed = 0;
|
|
121
|
+
for (const [key, entry] of this.store) {
|
|
122
|
+
if (now > entry.expiresAt) {
|
|
123
|
+
this.store.delete(key);
|
|
124
|
+
removed++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return removed;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ============================================================
|
|
131
|
+
// Convenience functions for simple use cases (global cache)
|
|
132
|
+
// ============================================================
|
|
133
|
+
const globalCache = new Map();
|
|
134
|
+
/**
|
|
135
|
+
* Get or create a named global cache
|
|
136
|
+
*/
|
|
137
|
+
export function getGlobalCache(name, options) {
|
|
138
|
+
if (!globalCache.has(name)) {
|
|
139
|
+
globalCache.set(name, new MemoryCache(options));
|
|
140
|
+
}
|
|
141
|
+
return globalCache.get(name);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Clear all global caches
|
|
145
|
+
*/
|
|
146
|
+
export function clearAllGlobalCaches() {
|
|
147
|
+
for (const cache of globalCache.values()) {
|
|
148
|
+
cache.clear();
|
|
149
|
+
}
|
|
150
|
+
globalCache.clear();
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,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,CAAC,MAAM,EAAE,EAAE,CAAC;QACzC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IACD,WAAW,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic cache type definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Cache entry with metadata
|
|
6
|
+
*/
|
|
7
|
+
export interface CacheEntry<T> {
|
|
8
|
+
/** Cached value */
|
|
9
|
+
value: T;
|
|
10
|
+
/** Timestamp when cached (ms since epoch) */
|
|
11
|
+
cachedAt: number;
|
|
12
|
+
/** Timestamp when entry expires (ms since epoch) */
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Cache statistics
|
|
17
|
+
*/
|
|
18
|
+
export interface CacheStats {
|
|
19
|
+
/** Whether entry exists */
|
|
20
|
+
exists: boolean;
|
|
21
|
+
/** When the entry was cached */
|
|
22
|
+
cachedAt?: Date;
|
|
23
|
+
/** When the entry will expire */
|
|
24
|
+
expiresAt?: Date;
|
|
25
|
+
/** Milliseconds until expiration */
|
|
26
|
+
remainingMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Memory cache options
|
|
30
|
+
*/
|
|
31
|
+
export interface MemoryCacheOptions {
|
|
32
|
+
/** Time-to-live in milliseconds (default: 5 minutes) */
|
|
33
|
+
ttlMs?: number;
|
|
34
|
+
/** Optional key prefix */
|
|
35
|
+
prefix?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* File cache options
|
|
39
|
+
*/
|
|
40
|
+
export interface FileCacheOptions {
|
|
41
|
+
/** Base directory for cache files (default: ~/.cache) */
|
|
42
|
+
baseDir?: string;
|
|
43
|
+
/** Cache file name (default: cache.json) */
|
|
44
|
+
fileName?: string;
|
|
45
|
+
/** Time-to-live in seconds */
|
|
46
|
+
ttlSeconds?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* File cache entry stored on disk
|
|
50
|
+
*/
|
|
51
|
+
export interface FileCacheEntry<T> {
|
|
52
|
+
/** Cached value */
|
|
53
|
+
value: T;
|
|
54
|
+
/** ISO timestamp when cached */
|
|
55
|
+
cachedAt: string;
|
|
56
|
+
/** ISO timestamp when entry expires */
|
|
57
|
+
expiresAt: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generic cache interface
|
|
61
|
+
*/
|
|
62
|
+
export interface Cache<T> {
|
|
63
|
+
/** Get cached value by key */
|
|
64
|
+
get(key: string): T | null;
|
|
65
|
+
/** Set value in cache */
|
|
66
|
+
set(key: string, value: T): void;
|
|
67
|
+
/** Delete cached value */
|
|
68
|
+
delete(key: string): void;
|
|
69
|
+
/** Clear all cached values */
|
|
70
|
+
clear(): void;
|
|
71
|
+
/** Check if cache entry is valid */
|
|
72
|
+
isValid(key: string): boolean;
|
|
73
|
+
/** Get cache statistics */
|
|
74
|
+
getStats(key: string): CacheStats;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,mBAAmB;IACnB,KAAK,EAAE,CAAC,CAAC;IACT,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,iCAAiC;IACjC,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,mBAAmB;IACnB,KAAK,EAAE,CAAC,CAAC;IACT,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,8BAA8B;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;IAC3B,yBAAyB;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjC,0BAA0B;IAC1B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,8BAA8B;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microwiseai/cache",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Generic caching utilities for Node.js - memory and file-based caching",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"cache",
|
|
26
|
+
"memory-cache",
|
|
27
|
+
"file-cache",
|
|
28
|
+
"ttl",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"author": "MicrowiseAI",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.11.0",
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/detector.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|