@content-collections/core 0.8.1 → 0.8.2

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/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import z__default, { ZodRawShape, z as z$1, ZodObject, ZodTypeAny, ZodString } from 'zod';
2
2
  export * from 'zod';
3
3
 
4
- type CacheFn = <TInput, TOutput>(input: TInput, compute: (input: TInput) => Promise<TOutput> | TOutput) => Promise<TOutput>;
4
+ type Options$2 = {
5
+ key: string;
6
+ };
7
+ type CacheFn = <TInput, TOutput>(input: TInput, compute: (input: TInput) => Promise<TOutput> | TOutput, options?: Options$2) => Promise<TOutput>;
5
8
 
6
9
  declare const importSymbol: unique symbol;
7
10
  type Import<T> = {
package/dist/index.js CHANGED
@@ -6,8 +6,8 @@ import { createHash } from "node:crypto";
6
6
  import { existsSync } from "node:fs";
7
7
  import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
8
8
  import path, { join } from "node:path";
9
- function createKey(config, input) {
10
- return createHash("sha256").update(config).update(JSON.stringify(input)).digest("hex");
9
+ function createKey(config, input, key) {
10
+ return createHash("sha256").update(config).update(JSON.stringify(input)).update(key).digest("hex");
11
11
  }
12
12
  async function createCacheDirectory(directory) {
13
13
  const cacheDirectory = path.join(directory, ".content-collections", "cache");
@@ -55,8 +55,8 @@ async function createCacheManager(baseDirectory, configChecksum) {
55
55
  collectionMapping[file] = fileMapping;
56
56
  }
57
57
  let newFileMapping = [];
58
- const cacheFn = async (input, fn) => {
59
- const key = createKey(configChecksum, input);
58
+ const cacheFn = async (input, fn, options) => {
59
+ const key = createKey(configChecksum, input, options?.key || "");
60
60
  newFileMapping.push(key);
61
61
  const filePath = join(directory, `${key}.cache`);
62
62
  if (fileMapping?.includes(key) || newFileMapping.includes(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@content-collections/core",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",