@pikku/kysely 0.13.30 → 0.13.31

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,3 +1,20 @@
1
+ ## 0.13.31
2
+
3
+ ### Patch Changes
4
+
5
+ - 01c0209: `@pikku/kysely` re-exports `Kysely`, `PostgresDialect` and `CamelCasePlugin` from its own copy of kysely. The local-services codegen writes these imports into a project, so it now opens and types the database with the same kysely copy the generated services were built against, instead of a second copy the project may resolve on its own.
6
+ - 5bce779: Webhook trigger sources are off until someone turns them on, and addons declare their own.
7
+
8
+ An addon calls `wireTriggerWebhookSource` in its own package, and an app that wires the addon gets the source (its route included) without declaring it: named and routed after the addon's namespace, so two instances get one each. A source the app declares under the same name wins.
9
+
10
+ Every source now has an `enabled` switch in the `triggerSourceStore`, off by default. `reconcileTriggerSources` registers only enabled sources and records each one's `baseUrl` and `labelPrefix`; a disabled source's route answers 404 without running `receive`. New in core: `enableTriggerSource` registers a source with its provider and `disableTriggerSource` stops it receiving, then tears it down, both at the recorded address unless one is given. The admin addon exposes them as `triggerSourceEnable` and `triggerSourceDisable`. The `pikkuTriggerSource` table gains `enabled`, `baseUrl` and `labelPrefix`: run `pikku db generate` for the migration.
11
+
12
+ - Updated dependencies [dfcd351]
13
+ - Updated dependencies [cf40182]
14
+ - Updated dependencies [5bce779]
15
+ - Updated dependencies [5bce779]
16
+ - @pikku/core@0.12.130
17
+
1
18
  ## 0.13.30
2
19
 
3
20
  ### Patch Changes
@@ -21,6 +21,7 @@ export { KyselyAuditService } from './kysely-audit-service.js';
21
21
  export { KyselyAnalyticsService } from './kysely-analytics-service.js';
22
22
  export { KyselyVirtualUserRunStore } from './kysely-virtual-user-run-store.js';
23
23
  export { KyselyVirtualUserScheduleStore } from './kysely-virtual-user-schedule-store.js';
24
+ export { CamelCasePlugin, Kysely, PostgresDialect } from 'kysely';
24
25
  export { SerializePlugin, BaseSerializePlugin, type Serializer, type Deserializer, } from './serialize-plugin.js';
25
26
  export { createCoercionPlugin, type ColumnKind, type CoercionMap, type CreateCoercionPluginOptions, } from './coercion-plugin.js';
26
27
  export { createClassificationPlugin, type CreateClassificationPluginOptions, } from './classification-plugin.js';
package/dist/src/index.js CHANGED
@@ -20,6 +20,10 @@ export { KyselyAuditService } from './kysely-audit-service.js';
20
20
  export { KyselyAnalyticsService } from './kysely-analytics-service.js';
21
21
  export { KyselyVirtualUserRunStore } from './kysely-virtual-user-run-store.js';
22
22
  export { KyselyVirtualUserScheduleStore } from './kysely-virtual-user-schedule-store.js';
23
+ // Re-exported so a generated file that constructs the services above opens and
24
+ // types its database with the same copy of kysely those services were built
25
+ // against, rather than a second copy the project may resolve on its own.
26
+ export { CamelCasePlugin, Kysely, PostgresDialect } from 'kysely';
23
27
  export { SerializePlugin, BaseSerializePlugin, } from './serialize-plugin.js';
24
28
  export { createCoercionPlugin, } from './coercion-plugin.js';
25
29
  export { createClassificationPlugin, } from './classification-plugin.js';
@@ -240,7 +240,10 @@ export interface PikkuFeatureFlagsTable {
240
240
  export interface PikkuTriggerSourceTable {
241
241
  name: string;
242
242
  kind: string;
243
+ baseUrl: string | null;
244
+ labelPrefix: string | null;
243
245
  declared: Generated<boolean>;
246
+ enabled: Generated<boolean>;
244
247
  status: string | null;
245
248
  /** The last setup's provider identifiers as JSON; never a secret. */
246
249
  state: string | null;
@@ -10,5 +10,6 @@ export declare class KyselyTriggerSourceStore implements TriggerSourceStore {
10
10
  listTriggerSources(): Promise<TriggerSourceRow[]>;
11
11
  getTriggerSource(name: string): Promise<TriggerSourceRow | null>;
12
12
  recordTriggerSource(name: string, result: TriggerSourceResult): Promise<void>;
13
+ setTriggerSourceEnabled(name: string, enabled: boolean): Promise<void>;
13
14
  deleteTriggerSource(name: string): Promise<void>;
14
15
  }
@@ -15,7 +15,10 @@ const parseState = (value) => {
15
15
  const toRow = (row) => ({
16
16
  name: row.name,
17
17
  kind: row.kind,
18
+ baseUrl: row.baseUrl,
19
+ labelPrefix: row.labelPrefix,
18
20
  declared: !!row.declared,
21
+ enabled: !!row.enabled,
19
22
  status: row.status,
20
23
  state: parseState(row.state),
21
24
  detail: row.detail,
@@ -35,11 +38,15 @@ export class KyselyTriggerSourceStore {
35
38
  }
36
39
  async syncTriggerSources(sources) {
37
40
  await this.db.transaction().execute(async (trx) => {
38
- for (const { name, kind } of sources) {
41
+ for (const { name, kind, baseUrl, labelPrefix } of sources) {
42
+ const address = {
43
+ ...(baseUrl !== undefined ? { baseUrl } : {}),
44
+ ...(labelPrefix !== undefined ? { labelPrefix } : {}),
45
+ };
39
46
  await trx
40
47
  .insertInto('pikkuTriggerSource')
41
- .values({ name, kind, declared: true })
42
- .onConflict((oc) => oc.column('name').doUpdateSet({ kind, declared: true }))
48
+ .values({ name, kind, declared: true, ...address })
49
+ .onConflict((oc) => oc.column('name').doUpdateSet({ kind, declared: true, ...address }))
43
50
  .execute();
44
51
  }
45
52
  const markStale = trx
@@ -83,6 +90,16 @@ export class KyselyTriggerSourceStore {
83
90
  throw new Error(`Unknown trigger source: ${name}`);
84
91
  }
85
92
  }
93
+ async setTriggerSourceEnabled(name, enabled) {
94
+ const { numUpdatedRows } = await this.db
95
+ .updateTable('pikkuTriggerSource')
96
+ .set({ enabled })
97
+ .where('name', '=', name)
98
+ .executeTakeFirst();
99
+ if (!numUpdatedRows) {
100
+ throw new Error(`Unknown trigger source: ${name}`);
101
+ }
102
+ }
86
103
  async deleteTriggerSource(name) {
87
104
  await this.db
88
105
  .deleteFrom('pikkuTriggerSource')
@@ -11,7 +11,10 @@ export const triggerSourceSchema = {
11
11
  .createTable('pikkuTriggerSource')
12
12
  .addColumn('name', 'text', (col) => col.primaryKey())
13
13
  .addColumn('kind', 'text', (col) => col.notNull())
14
+ .addColumn('baseUrl', 'text')
15
+ .addColumn('labelPrefix', 'text')
14
16
  .addColumn('declared', 'boolean', (col) => col.defaultTo(true).notNull())
17
+ .addColumn('enabled', 'boolean', (col) => col.defaultTo(false).notNull())
15
18
  .addColumn('status', 'text')
16
19
  .addColumn('state', 'text')
17
20
  .addColumn('detail', 'text')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely",
3
- "version": "0.13.30",
3
+ "version": "0.13.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -26,7 +26,7 @@
26
26
  "prepublishOnly": "bun run build"
27
27
  },
28
28
  "peerDependencies": {
29
- "@pikku/core": "^0.12.128"
29
+ "@pikku/core": "^0.12.130"
30
30
  },
31
31
  "dependencies": {
32
32
  "kysely": "^0.29.5"