@farcaster/snap 1.7.0 → 1.7.1

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.
@@ -1,12 +1,9 @@
1
1
  export type DataStoreValue = string | number | boolean | null | DataStoreValue[] | {
2
2
  [key: string]: DataStoreValue;
3
3
  };
4
- export type SnapDataStoreOperations = {
4
+ export type SnapDataStore = {
5
5
  get(key: string): Promise<DataStoreValue | null>;
6
6
  set(key: string, value: DataStoreValue): Promise<void>;
7
7
  };
8
- export type SnapDataStore = SnapDataStoreOperations & {
9
- withLock<T>(fn: (store: SnapDataStoreOperations) => Promise<T>): Promise<T>;
10
- };
11
8
  export declare function createDefaultDataStore(): SnapDataStore;
12
9
  export declare function createInMemoryDataStore(): SnapDataStore;
package/dist/dataStore.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export function createDefaultDataStore() {
2
- const err = new Error("Data store is not configured. Use withUpstash() from @farcaster/snap-upstash or provide a data store implementation.");
2
+ const err = new Error("Data store is not configured. Use withTursoServerless() from @farcaster/snap-turso or provide a data store implementation.");
3
3
  return {
4
4
  get(_key) {
5
5
  return Promise.reject(err);
@@ -7,29 +7,16 @@ export function createDefaultDataStore() {
7
7
  set(_key, _value) {
8
8
  return Promise.reject(err);
9
9
  },
10
- withLock(_fn) {
11
- return Promise.reject(err);
12
- },
13
10
  };
14
11
  }
15
12
  export function createInMemoryDataStore() {
16
13
  const data = new Map();
17
- const ops = {
18
- get: async (key) => {
14
+ return {
15
+ async get(key) {
19
16
  return data.get(key) ?? null;
20
17
  },
21
- set: async (key, value) => {
18
+ async set(key, value) {
22
19
  data.set(key, value);
23
20
  },
24
21
  };
25
- /** Serializes `withLock` callbacks so async work does not interleave across callers. */
26
- let lockChain = Promise.resolve();
27
- return {
28
- ...ops,
29
- withLock(fn) {
30
- const run = lockChain.then(() => fn(ops));
31
- lockChain = run.then(() => undefined, () => undefined);
32
- return run;
33
- },
34
- };
35
22
  }
package/dist/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export { SPEC_VERSION, MEDIA_TYPE, EFFECT_VALUES, } from "./constants.js";
3
3
  export { DEFAULT_THEME_ACCENT, PALETTE_COLOR, PALETTE_COLOR_ACCENT, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, type PaletteColor, } from "./colors.js";
4
4
  export { ACTION_TYPE_GET, ACTION_TYPE_POST, snapResponseSchema, payloadSchema, type SnapAction, type SnapContext, type SnapResponse, type SnapHandlerResult, type SnapFunction, type SnapPayload, } from "./schemas.js";
5
5
  export { validateSnapResponse, type ValidationResult, } from "./validator.js";
6
- export { type DataStoreValue, type SnapDataStore, type SnapDataStoreOperations, createDefaultDataStore, createInMemoryDataStore, } from "./dataStore.js";
6
+ export { type DataStoreValue, type SnapDataStore, createDefaultDataStore, createInMemoryDataStore, } from "./dataStore.js";
7
7
  export { type Middleware, useMiddleware } from "./middleware.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/snap",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Farcaster Snaps 🫰",
5
5
  "repository": {
6
6
  "type": "git",
package/src/dataStore.ts CHANGED
@@ -6,18 +6,14 @@ export type DataStoreValue =
6
6
  | DataStoreValue[]
7
7
  | { [key: string]: DataStoreValue };
8
8
 
9
- export type SnapDataStoreOperations = {
9
+ export type SnapDataStore = {
10
10
  get(key: string): Promise<DataStoreValue | null>;
11
11
  set(key: string, value: DataStoreValue): Promise<void>;
12
12
  };
13
13
 
14
- export type SnapDataStore = SnapDataStoreOperations & {
15
- withLock<T>(fn: (store: SnapDataStoreOperations) => Promise<T>): Promise<T>;
16
- };
17
-
18
14
  export function createDefaultDataStore(): SnapDataStore {
19
15
  const err = new Error(
20
- "Data store is not configured. Use withUpstash() from @farcaster/snap-upstash or provide a data store implementation.",
16
+ "Data store is not configured. Use withTursoServerless() from @farcaster/snap-turso or provide a data store implementation.",
21
17
  );
22
18
  return {
23
19
  get(_key: string): Promise<never> {
@@ -26,37 +22,17 @@ export function createDefaultDataStore(): SnapDataStore {
26
22
  set(_key: string, _value: DataStoreValue): Promise<never> {
27
23
  return Promise.reject(err);
28
24
  },
29
- withLock<T>(
30
- _fn: (store: SnapDataStoreOperations) => Promise<T>,
31
- ): Promise<never> {
32
- return Promise.reject(err);
33
- },
34
25
  };
35
26
  }
36
27
 
37
28
  export function createInMemoryDataStore(): SnapDataStore {
38
29
  const data = new Map<string, DataStoreValue>();
39
- const ops: SnapDataStoreOperations = {
40
- get: async (key: string): Promise<DataStoreValue | null> => {
30
+ return {
31
+ async get(key: string): Promise<DataStoreValue | null> {
41
32
  return data.get(key) ?? null;
42
33
  },
43
- set: async (key: string, value: DataStoreValue): Promise<void> => {
34
+ async set(key: string, value: DataStoreValue): Promise<void> {
44
35
  data.set(key, value);
45
36
  },
46
37
  };
47
- /** Serializes `withLock` callbacks so async work does not interleave across callers. */
48
- let lockChain: Promise<unknown> = Promise.resolve();
49
- return {
50
- ...ops,
51
- withLock<T>(
52
- fn: (store: SnapDataStoreOperations) => Promise<T>,
53
- ): Promise<T> {
54
- const run = lockChain.then(() => fn(ops));
55
- lockChain = run.then(
56
- () => undefined,
57
- () => undefined,
58
- );
59
- return run;
60
- },
61
- };
62
38
  }
package/src/index.ts CHANGED
@@ -32,7 +32,6 @@ export {
32
32
  export {
33
33
  type DataStoreValue,
34
34
  type SnapDataStore,
35
- type SnapDataStoreOperations,
36
35
  createDefaultDataStore,
37
36
  createInMemoryDataStore,
38
37
  } from "./dataStore";