@pikku/kysely 0.6.3 → 0.6.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @pikku/pino
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8a14f3a: refactor: removing user session from channel object
8
+ - Updated dependencies [ebc04eb]
9
+ - Updated dependencies [8a14f3a]
10
+ - Updated dependencies [2c47386]
11
+ - @pikku/core@0.6.17
12
+
3
13
  ## 0.6.3
4
14
 
5
15
  ### Patch Changes
@@ -1,3 +1,4 @@
1
+ import { CoreUserSession } from '@pikku/core';
1
2
  import { Channel, ChannelStore } from '@pikku/core/channel';
2
3
  import { Kysely } from 'kysely';
3
4
  export declare class KyselyChannelStore extends ChannelStore {
@@ -6,5 +7,7 @@ export declare class KyselyChannelStore extends ChannelStore {
6
7
  addChannel({ channelId, channelName, openingData, }: Channel): Promise<void>;
7
8
  removeChannels(channelIds: string[]): Promise<void>;
8
9
  setUserSession(channelId: string, session: any): Promise<void>;
9
- getChannel(channelId: string): Promise<Channel>;
10
+ getChannelAndSession(channelId: string): Promise<Channel & {
11
+ session: CoreUserSession;
12
+ }>;
10
13
  }
@@ -28,7 +28,7 @@ export class KyselyChannelStore extends ChannelStore {
28
28
  .set('userSession', session)
29
29
  .executeTakeFirstOrThrow();
30
30
  }
31
- async getChannel(channelId) {
31
+ async getChannelAndSession(channelId) {
32
32
  const result = await this.database
33
33
  .selectFrom('serverless.lambdaChannels')
34
34
  .selectAll()
@@ -36,7 +36,7 @@ export class KyselyChannelStore extends ChannelStore {
36
36
  .executeTakeFirstOrThrow();
37
37
  return {
38
38
  openingData: result.openingData,
39
- userSession: result.userSession,
39
+ session: result.userSession,
40
40
  channelName: result.channelName,
41
41
  };
42
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "module": "dist/src/index.js",
@@ -17,7 +17,7 @@
17
17
  "release": "npm run build && npm test"
18
18
  },
19
19
  "peerDependencies": {
20
- "@pikku/core": "^0.6.13"
20
+ "@pikku/core": "^0.6.17"
21
21
  },
22
22
  "dependencies": {
23
23
  "kysely": "^0.27.6",
@@ -0,0 +1,16 @@
1
+ CREATE SCHEMA serverless;
2
+
3
+ CREATE TABLE serverless.lambda_channels (
4
+ channel_id TEXT PRIMARY KEY,
5
+ channel_name TEXT NOT NULL,
6
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
7
+ opening_data JSONB NOT NULL DEFAULT '{}',
8
+ user_session JSONB,
9
+ last_interaction TIMESTAMPTZ NOT NULL DEFAULT now()
10
+ );
11
+
12
+ CREATE TABLE serverless.lambda_channel_subscriptions (
13
+ channel_id TEXT NOT NULL REFERENCES serverless.lambda_channels(channel_id) ON DELETE CASCADE,
14
+ topic TEXT NOT NULL,
15
+ PRIMARY KEY (channel_id, topic)
16
+ );
@@ -37,16 +37,17 @@ export class KyselyChannelStore extends ChannelStore {
37
37
  .executeTakeFirstOrThrow()
38
38
  }
39
39
 
40
- public async getChannel(channelId: string) {
40
+ public async getChannelAndSession(channelId: string) {
41
41
  const result = await this.database
42
42
  .selectFrom('serverless.lambdaChannels')
43
43
  .selectAll()
44
44
  .where('channelId', '=', channelId)
45
45
  .executeTakeFirstOrThrow()
46
+
46
47
  return {
47
48
  openingData: result.openingData as any,
48
- userSession: result.userSession as CoreUserSession,
49
+ session: result.userSession as CoreUserSession,
49
50
  channelName: result.channelName,
50
- } as Channel
51
+ } as Channel & { session: CoreUserSession }
51
52
  }
52
53
  }