@rudderhq/db 0.7.2 → 0.7.3

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.
Files changed (62) hide show
  1. package/dist/backup-lib.d.ts.map +1 -1
  2. package/dist/backup-lib.js +59 -43
  3. package/dist/backup-lib.js.map +1 -1
  4. package/dist/backup-lib.test.js +122 -2
  5. package/dist/backup-lib.test.js.map +1 -1
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +8 -3
  8. package/dist/client.js.map +1 -1
  9. package/dist/client.test.js +209 -4
  10. package/dist/client.test.js.map +1 -1
  11. package/dist/migrations/0149_app_builder_verified_source_ready.sql +3 -0
  12. package/dist/migrations/0150_rudder_plugins_v1.sql +114 -0
  13. package/dist/migrations/0151_agent_issue_creation_requests.sql +49 -0
  14. package/dist/migrations/meta/_journal.json +21 -0
  15. package/dist/schema/{plugin_jobs.d.ts → agent_issue_creation_requests.d.ts} +134 -142
  16. package/dist/schema/{plugin_jobs.d.ts.map → agent_issue_creation_requests.d.ts.map} +1 -1
  17. package/dist/schema/agent_issue_creation_requests.js +40 -0
  18. package/dist/schema/agent_issue_creation_requests.js.map +1 -0
  19. package/dist/schema/app_builder_apps.js +1 -1
  20. package/dist/schema/app_builder_apps.js.map +1 -1
  21. package/dist/schema/index.d.ts +2 -8
  22. package/dist/schema/index.d.ts.map +1 -1
  23. package/dist/schema/index.js +2 -8
  24. package/dist/schema/index.js.map +1 -1
  25. package/dist/schema/issues.d.ts.map +1 -1
  26. package/dist/schema/issues.js +4 -0
  27. package/dist/schema/issues.js.map +1 -1
  28. package/dist/schema/rudder_plugins.d.ts +978 -0
  29. package/dist/schema/rudder_plugins.d.ts.map +1 -0
  30. package/dist/schema/rudder_plugins.js +91 -0
  31. package/dist/schema/rudder_plugins.js.map +1 -0
  32. package/package.json +2 -2
  33. package/dist/schema/plugin_config.d.ts +0 -123
  34. package/dist/schema/plugin_config.d.ts.map +0 -1
  35. package/dist/schema/plugin_config.js +0 -26
  36. package/dist/schema/plugin_config.js.map +0 -1
  37. package/dist/schema/plugin_entities.d.ts +0 -213
  38. package/dist/schema/plugin_entities.d.ts.map +0 -1
  39. package/dist/schema/plugin_entities.js +0 -37
  40. package/dist/schema/plugin_entities.js.map +0 -1
  41. package/dist/schema/plugin_jobs.js +0 -83
  42. package/dist/schema/plugin_jobs.js.map +0 -1
  43. package/dist/schema/plugin_logs.d.ts +0 -125
  44. package/dist/schema/plugin_logs.d.ts.map +0 -1
  45. package/dist/schema/plugin_logs.js +0 -29
  46. package/dist/schema/plugin_logs.js.map +0 -1
  47. package/dist/schema/plugin_organization_settings.d.ts +0 -158
  48. package/dist/schema/plugin_organization_settings.d.ts.map +0 -1
  49. package/dist/schema/plugin_organization_settings.js +0 -34
  50. package/dist/schema/plugin_organization_settings.js.map +0 -1
  51. package/dist/schema/plugin_state.d.ts +0 -169
  52. package/dist/schema/plugin_state.d.ts.map +0 -1
  53. package/dist/schema/plugin_state.js +0 -68
  54. package/dist/schema/plugin_state.js.map +0 -1
  55. package/dist/schema/plugin_webhooks.d.ts +0 -239
  56. package/dist/schema/plugin_webhooks.d.ts.map +0 -1
  57. package/dist/schema/plugin_webhooks.js +0 -52
  58. package/dist/schema/plugin_webhooks.js.map +0 -1
  59. package/dist/schema/plugins.d.ts +0 -246
  60. package/dist/schema/plugins.d.ts.map +0 -1
  61. package/dist/schema/plugins.js +0 -31
  62. package/dist/schema/plugins.js.map +0 -1
@@ -1,125 +0,0 @@
1
- /**
2
- * `plugin_logs` table — structured log storage for plugin workers.
3
- *
4
- * Each row stores a single log entry emitted by a plugin worker via
5
- * `ctx.logger.info(...)` etc. Logs are queryable by plugin, level, and
6
- * time range to support the operator logs panel and debugging workflows.
7
- *
8
- * Rows are inserted by the host when handling `log` notifications from
9
- * the worker process. A capped retention policy can be applied via
10
- * periodic cleanup (e.g. delete rows older than 7 days).
11
- *
12
- * @see doc/engineering/PLUGIN_RUNTIME_CONTRACT.md — Observability
13
- */
14
- export declare const pluginLogs: import("drizzle-orm/pg-core").PgTableWithColumns<{
15
- name: "plugin_logs";
16
- schema: undefined;
17
- columns: {
18
- id: import("drizzle-orm/pg-core").PgColumn<{
19
- name: "id";
20
- tableName: "plugin_logs";
21
- dataType: "string";
22
- columnType: "PgUUID";
23
- data: string;
24
- driverParam: string;
25
- notNull: true;
26
- hasDefault: true;
27
- isPrimaryKey: true;
28
- isAutoincrement: false;
29
- hasRuntimeDefault: false;
30
- enumValues: undefined;
31
- baseColumn: never;
32
- identity: undefined;
33
- generated: undefined;
34
- }, {}, {}>;
35
- pluginId: import("drizzle-orm/pg-core").PgColumn<{
36
- name: "plugin_id";
37
- tableName: "plugin_logs";
38
- dataType: "string";
39
- columnType: "PgUUID";
40
- data: string;
41
- driverParam: string;
42
- notNull: true;
43
- hasDefault: false;
44
- isPrimaryKey: false;
45
- isAutoincrement: false;
46
- hasRuntimeDefault: false;
47
- enumValues: undefined;
48
- baseColumn: never;
49
- identity: undefined;
50
- generated: undefined;
51
- }, {}, {}>;
52
- level: import("drizzle-orm/pg-core").PgColumn<{
53
- name: "level";
54
- tableName: "plugin_logs";
55
- dataType: "string";
56
- columnType: "PgText";
57
- data: string;
58
- driverParam: string;
59
- notNull: true;
60
- hasDefault: true;
61
- isPrimaryKey: false;
62
- isAutoincrement: false;
63
- hasRuntimeDefault: false;
64
- enumValues: [string, ...string[]];
65
- baseColumn: never;
66
- identity: undefined;
67
- generated: undefined;
68
- }, {}, {}>;
69
- message: import("drizzle-orm/pg-core").PgColumn<{
70
- name: "message";
71
- tableName: "plugin_logs";
72
- dataType: "string";
73
- columnType: "PgText";
74
- data: string;
75
- driverParam: string;
76
- notNull: true;
77
- hasDefault: false;
78
- isPrimaryKey: false;
79
- isAutoincrement: false;
80
- hasRuntimeDefault: false;
81
- enumValues: [string, ...string[]];
82
- baseColumn: never;
83
- identity: undefined;
84
- generated: undefined;
85
- }, {}, {}>;
86
- meta: import("drizzle-orm/pg-core").PgColumn<{
87
- name: "meta";
88
- tableName: "plugin_logs";
89
- dataType: "json";
90
- columnType: "PgJsonb";
91
- data: Record<string, unknown>;
92
- driverParam: unknown;
93
- notNull: false;
94
- hasDefault: false;
95
- isPrimaryKey: false;
96
- isAutoincrement: false;
97
- hasRuntimeDefault: false;
98
- enumValues: undefined;
99
- baseColumn: never;
100
- identity: undefined;
101
- generated: undefined;
102
- }, {}, {
103
- $type: Record<string, unknown>;
104
- }>;
105
- createdAt: import("drizzle-orm/pg-core").PgColumn<{
106
- name: "created_at";
107
- tableName: "plugin_logs";
108
- dataType: "date";
109
- columnType: "PgTimestamp";
110
- data: Date;
111
- driverParam: string;
112
- notNull: true;
113
- hasDefault: true;
114
- isPrimaryKey: false;
115
- isAutoincrement: false;
116
- hasRuntimeDefault: false;
117
- enumValues: undefined;
118
- baseColumn: never;
119
- identity: undefined;
120
- generated: undefined;
121
- }, {}, {}>;
122
- };
123
- dialect: "pg";
124
- }>;
125
- //# sourceMappingURL=plugin_logs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_logs.d.ts","sourceRoot":"","sources":["../../src/schema/plugin_logs.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBtB,CAAC"}
@@ -1,29 +0,0 @@
1
- import { index, jsonb, pgTable, text, timestamp, uuid, } from "drizzle-orm/pg-core";
2
- import { plugins } from "./plugins.js";
3
- /**
4
- * `plugin_logs` table — structured log storage for plugin workers.
5
- *
6
- * Each row stores a single log entry emitted by a plugin worker via
7
- * `ctx.logger.info(...)` etc. Logs are queryable by plugin, level, and
8
- * time range to support the operator logs panel and debugging workflows.
9
- *
10
- * Rows are inserted by the host when handling `log` notifications from
11
- * the worker process. A capped retention policy can be applied via
12
- * periodic cleanup (e.g. delete rows older than 7 days).
13
- *
14
- * @see doc/engineering/PLUGIN_RUNTIME_CONTRACT.md — Observability
15
- */
16
- export const pluginLogs = pgTable("plugin_logs", {
17
- id: uuid("id").primaryKey().defaultRandom(),
18
- pluginId: uuid("plugin_id")
19
- .notNull()
20
- .references(() => plugins.id, { onDelete: "cascade" }),
21
- level: text("level").notNull().default("info"),
22
- message: text("message").notNull(),
23
- meta: jsonb("meta").$type(),
24
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
25
- }, (table) => ({
26
- pluginTimeIdx: index("plugin_logs_plugin_time_idx").on(table.pluginId, table.createdAt),
27
- levelIdx: index("plugin_logs_level_idx").on(table.level),
28
- }));
29
- //# sourceMappingURL=plugin_logs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_logs.js","sourceRoot":"","sources":["../../src/schema/plugin_logs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,IAAI,GACL,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAC/B,aAAa,EACb;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;SACxB,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAA2B;IACpD,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACV,aAAa,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC,EAAE,CACpD,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,SAAS,CAChB;IACD,QAAQ,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;CACzD,CAAC,CACH,CAAC"}
@@ -1,158 +0,0 @@
1
- /**
2
- * `plugin_organization_settings` table — stores operator-managed plugin settings
3
- * scoped to a specific organization.
4
- *
5
- * This is distinct from `plugin_config`, which stores instance-wide plugin
6
- * configuration. Each organization can have at most one settings row per plugin.
7
- *
8
- * Rows represent explicit overrides from the default organization behavior:
9
- * - no row => plugin is enabled for the organization by default
10
- * - row with `enabled = false` => plugin is disabled for that organization
11
- * - row with `enabled = true` => plugin remains enabled and stores organization settings
12
- */
13
- export declare const pluginOrganizationSettings: import("drizzle-orm/pg-core").PgTableWithColumns<{
14
- name: "plugin_organization_settings";
15
- schema: undefined;
16
- columns: {
17
- id: import("drizzle-orm/pg-core").PgColumn<{
18
- name: "id";
19
- tableName: "plugin_organization_settings";
20
- dataType: "string";
21
- columnType: "PgUUID";
22
- data: string;
23
- driverParam: string;
24
- notNull: true;
25
- hasDefault: true;
26
- isPrimaryKey: true;
27
- isAutoincrement: false;
28
- hasRuntimeDefault: false;
29
- enumValues: undefined;
30
- baseColumn: never;
31
- identity: undefined;
32
- generated: undefined;
33
- }, {}, {}>;
34
- orgId: import("drizzle-orm/pg-core").PgColumn<{
35
- name: "org_id";
36
- tableName: "plugin_organization_settings";
37
- dataType: "string";
38
- columnType: "PgUUID";
39
- data: string;
40
- driverParam: string;
41
- notNull: true;
42
- hasDefault: false;
43
- isPrimaryKey: false;
44
- isAutoincrement: false;
45
- hasRuntimeDefault: false;
46
- enumValues: undefined;
47
- baseColumn: never;
48
- identity: undefined;
49
- generated: undefined;
50
- }, {}, {}>;
51
- pluginId: import("drizzle-orm/pg-core").PgColumn<{
52
- name: "plugin_id";
53
- tableName: "plugin_organization_settings";
54
- dataType: "string";
55
- columnType: "PgUUID";
56
- data: string;
57
- driverParam: string;
58
- notNull: true;
59
- hasDefault: false;
60
- isPrimaryKey: false;
61
- isAutoincrement: false;
62
- hasRuntimeDefault: false;
63
- enumValues: undefined;
64
- baseColumn: never;
65
- identity: undefined;
66
- generated: undefined;
67
- }, {}, {}>;
68
- enabled: import("drizzle-orm/pg-core").PgColumn<{
69
- name: "enabled";
70
- tableName: "plugin_organization_settings";
71
- dataType: "boolean";
72
- columnType: "PgBoolean";
73
- data: boolean;
74
- driverParam: boolean;
75
- notNull: true;
76
- hasDefault: true;
77
- isPrimaryKey: false;
78
- isAutoincrement: false;
79
- hasRuntimeDefault: false;
80
- enumValues: undefined;
81
- baseColumn: never;
82
- identity: undefined;
83
- generated: undefined;
84
- }, {}, {}>;
85
- settingsJson: import("drizzle-orm/pg-core").PgColumn<{
86
- name: "settings_json";
87
- tableName: "plugin_organization_settings";
88
- dataType: "json";
89
- columnType: "PgJsonb";
90
- data: Record<string, unknown>;
91
- driverParam: unknown;
92
- notNull: true;
93
- hasDefault: true;
94
- isPrimaryKey: false;
95
- isAutoincrement: false;
96
- hasRuntimeDefault: false;
97
- enumValues: undefined;
98
- baseColumn: never;
99
- identity: undefined;
100
- generated: undefined;
101
- }, {}, {
102
- $type: Record<string, unknown>;
103
- }>;
104
- lastError: import("drizzle-orm/pg-core").PgColumn<{
105
- name: "last_error";
106
- tableName: "plugin_organization_settings";
107
- dataType: "string";
108
- columnType: "PgText";
109
- data: string;
110
- driverParam: string;
111
- notNull: false;
112
- hasDefault: false;
113
- isPrimaryKey: false;
114
- isAutoincrement: false;
115
- hasRuntimeDefault: false;
116
- enumValues: [string, ...string[]];
117
- baseColumn: never;
118
- identity: undefined;
119
- generated: undefined;
120
- }, {}, {}>;
121
- createdAt: import("drizzle-orm/pg-core").PgColumn<{
122
- name: "created_at";
123
- tableName: "plugin_organization_settings";
124
- dataType: "date";
125
- columnType: "PgTimestamp";
126
- data: Date;
127
- driverParam: string;
128
- notNull: true;
129
- hasDefault: true;
130
- isPrimaryKey: false;
131
- isAutoincrement: false;
132
- hasRuntimeDefault: false;
133
- enumValues: undefined;
134
- baseColumn: never;
135
- identity: undefined;
136
- generated: undefined;
137
- }, {}, {}>;
138
- updatedAt: import("drizzle-orm/pg-core").PgColumn<{
139
- name: "updated_at";
140
- tableName: "plugin_organization_settings";
141
- dataType: "date";
142
- columnType: "PgTimestamp";
143
- data: Date;
144
- driverParam: string;
145
- notNull: true;
146
- hasDefault: true;
147
- isPrimaryKey: false;
148
- isAutoincrement: false;
149
- hasRuntimeDefault: false;
150
- enumValues: undefined;
151
- baseColumn: never;
152
- identity: undefined;
153
- generated: undefined;
154
- }, {}, {}>;
155
- };
156
- dialect: "pg";
157
- }>;
158
- //# sourceMappingURL=plugin_organization_settings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_organization_settings.d.ts","sourceRoot":"","sources":["../../src/schema/plugin_organization_settings.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBtC,CAAC"}
@@ -1,34 +0,0 @@
1
- import { boolean, index, jsonb, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
2
- import { organizations } from "./organizations.js";
3
- import { plugins } from "./plugins.js";
4
- /**
5
- * `plugin_organization_settings` table — stores operator-managed plugin settings
6
- * scoped to a specific organization.
7
- *
8
- * This is distinct from `plugin_config`, which stores instance-wide plugin
9
- * configuration. Each organization can have at most one settings row per plugin.
10
- *
11
- * Rows represent explicit overrides from the default organization behavior:
12
- * - no row => plugin is enabled for the organization by default
13
- * - row with `enabled = false` => plugin is disabled for that organization
14
- * - row with `enabled = true` => plugin remains enabled and stores organization settings
15
- */
16
- export const pluginOrganizationSettings = pgTable("plugin_organization_settings", {
17
- id: uuid("id").primaryKey().defaultRandom(),
18
- orgId: uuid("org_id")
19
- .notNull()
20
- .references(() => organizations.id, { onDelete: "cascade" }),
21
- pluginId: uuid("plugin_id")
22
- .notNull()
23
- .references(() => plugins.id, { onDelete: "cascade" }),
24
- enabled: boolean("enabled").notNull().default(true),
25
- settingsJson: jsonb("settings_json").$type().notNull().default({}),
26
- lastError: text("last_error"),
27
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
28
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
29
- }, (table) => ({
30
- organizationIdx: index("plugin_organization_settings_org_idx").on(table.orgId),
31
- pluginIdx: index("plugin_organization_settings_plugin_idx").on(table.pluginId),
32
- organizationPluginUq: uniqueIndex("plugin_organization_settings_org_plugin_uq").on(table.orgId, table.pluginId),
33
- }));
34
- //# sourceMappingURL=plugin_organization_settings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_organization_settings.js","sourceRoot":"","sources":["../../src/schema/plugin_organization_settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAC/C,8BAA8B,EAC9B;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SAClB,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC9D,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;SACxB,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACxD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACnD,YAAY,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,EAA2B,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3F,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACjF,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACV,eAAe,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9E,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC9E,oBAAoB,EAAE,WAAW,CAAC,4CAA4C,CAAC,CAAC,EAAE,CAChF,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,QAAQ,CACf;CACF,CAAC,CACH,CAAC"}
@@ -1,169 +0,0 @@
1
- /**
2
- * `plugin_state` table — scoped key-value storage for plugin workers.
3
- *
4
- * Each row stores a single JSON value identified by
5
- * `(plugin_id, scope_kind, scope_id, namespace, state_key)`. Plugins use
6
- * this table through `ctx.state.get()`, `ctx.state.set()`, and
7
- * `ctx.state.delete()` in the SDK.
8
- *
9
- * Scope kinds determine the granularity of isolation:
10
- * - `instance` — one value shared across the whole Rudder instance
11
- * - `organization` — one value per organization
12
- * - `project` — one value per project
13
- * - `project_workspace` — one value per project workspace
14
- * - `agent` — one value per agent
15
- * - `issue` — one value per issue
16
- * - `goal` — one value per goal
17
- * - `run` — one value per agent run
18
- *
19
- * The `namespace` column defaults to `"default"` and can be used to
20
- * logically group keys without polluting the root namespace.
21
- *
22
- * @see doc/engineering/PLUGIN_RUNTIME_CONTRACT.md — `plugin_state`
23
- */
24
- export declare const pluginState: import("drizzle-orm/pg-core").PgTableWithColumns<{
25
- name: "plugin_state";
26
- schema: undefined;
27
- columns: {
28
- id: import("drizzle-orm/pg-core").PgColumn<{
29
- name: "id";
30
- tableName: "plugin_state";
31
- dataType: "string";
32
- columnType: "PgUUID";
33
- data: string;
34
- driverParam: string;
35
- notNull: true;
36
- hasDefault: true;
37
- isPrimaryKey: true;
38
- isAutoincrement: false;
39
- hasRuntimeDefault: false;
40
- enumValues: undefined;
41
- baseColumn: never;
42
- identity: undefined;
43
- generated: undefined;
44
- }, {}, {}>;
45
- pluginId: import("drizzle-orm/pg-core").PgColumn<{
46
- name: "plugin_id";
47
- tableName: "plugin_state";
48
- dataType: "string";
49
- columnType: "PgUUID";
50
- data: string;
51
- driverParam: string;
52
- notNull: true;
53
- hasDefault: false;
54
- isPrimaryKey: false;
55
- isAutoincrement: false;
56
- hasRuntimeDefault: false;
57
- enumValues: undefined;
58
- baseColumn: never;
59
- identity: undefined;
60
- generated: undefined;
61
- }, {}, {}>;
62
- scopeKind: import("drizzle-orm/pg-core").PgColumn<{
63
- name: "scope_kind";
64
- tableName: "plugin_state";
65
- dataType: "string";
66
- columnType: "PgText";
67
- data: "issue" | "organization" | "agent" | "project" | "goal" | "run" | "instance" | "project_workspace";
68
- driverParam: string;
69
- notNull: true;
70
- hasDefault: false;
71
- isPrimaryKey: false;
72
- isAutoincrement: false;
73
- hasRuntimeDefault: false;
74
- enumValues: [string, ...string[]];
75
- baseColumn: never;
76
- identity: undefined;
77
- generated: undefined;
78
- }, {}, {
79
- $type: "issue" | "organization" | "agent" | "project" | "goal" | "run" | "instance" | "project_workspace";
80
- }>;
81
- scopeId: import("drizzle-orm/pg-core").PgColumn<{
82
- name: "scope_id";
83
- tableName: "plugin_state";
84
- dataType: "string";
85
- columnType: "PgText";
86
- data: string;
87
- driverParam: string;
88
- notNull: false;
89
- hasDefault: false;
90
- isPrimaryKey: false;
91
- isAutoincrement: false;
92
- hasRuntimeDefault: false;
93
- enumValues: [string, ...string[]];
94
- baseColumn: never;
95
- identity: undefined;
96
- generated: undefined;
97
- }, {}, {}>;
98
- namespace: import("drizzle-orm/pg-core").PgColumn<{
99
- name: "namespace";
100
- tableName: "plugin_state";
101
- dataType: "string";
102
- columnType: "PgText";
103
- data: string;
104
- driverParam: string;
105
- notNull: true;
106
- hasDefault: true;
107
- isPrimaryKey: false;
108
- isAutoincrement: false;
109
- hasRuntimeDefault: false;
110
- enumValues: [string, ...string[]];
111
- baseColumn: never;
112
- identity: undefined;
113
- generated: undefined;
114
- }, {}, {}>;
115
- stateKey: import("drizzle-orm/pg-core").PgColumn<{
116
- name: "state_key";
117
- tableName: "plugin_state";
118
- dataType: "string";
119
- columnType: "PgText";
120
- data: string;
121
- driverParam: string;
122
- notNull: true;
123
- hasDefault: false;
124
- isPrimaryKey: false;
125
- isAutoincrement: false;
126
- hasRuntimeDefault: false;
127
- enumValues: [string, ...string[]];
128
- baseColumn: never;
129
- identity: undefined;
130
- generated: undefined;
131
- }, {}, {}>;
132
- valueJson: import("drizzle-orm/pg-core").PgColumn<{
133
- name: "value_json";
134
- tableName: "plugin_state";
135
- dataType: "json";
136
- columnType: "PgJsonb";
137
- data: unknown;
138
- driverParam: unknown;
139
- notNull: true;
140
- hasDefault: false;
141
- isPrimaryKey: false;
142
- isAutoincrement: false;
143
- hasRuntimeDefault: false;
144
- enumValues: undefined;
145
- baseColumn: never;
146
- identity: undefined;
147
- generated: undefined;
148
- }, {}, {}>;
149
- updatedAt: import("drizzle-orm/pg-core").PgColumn<{
150
- name: "updated_at";
151
- tableName: "plugin_state";
152
- dataType: "date";
153
- columnType: "PgTimestamp";
154
- data: Date;
155
- driverParam: string;
156
- notNull: true;
157
- hasDefault: true;
158
- isPrimaryKey: false;
159
- isAutoincrement: false;
160
- hasRuntimeDefault: false;
161
- enumValues: undefined;
162
- baseColumn: never;
163
- identity: undefined;
164
- generated: undefined;
165
- }, {}, {}>;
166
- };
167
- dialect: "pg";
168
- }>;
169
- //# sourceMappingURL=plugin_state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_state.d.ts","sourceRoot":"","sources":["../../src/schema/plugin_state.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDvB,CAAC"}
@@ -1,68 +0,0 @@
1
- import { index, jsonb, pgTable, text, timestamp, unique, uuid, } from "drizzle-orm/pg-core";
2
- import { plugins } from "./plugins.js";
3
- /**
4
- * `plugin_state` table — scoped key-value storage for plugin workers.
5
- *
6
- * Each row stores a single JSON value identified by
7
- * `(plugin_id, scope_kind, scope_id, namespace, state_key)`. Plugins use
8
- * this table through `ctx.state.get()`, `ctx.state.set()`, and
9
- * `ctx.state.delete()` in the SDK.
10
- *
11
- * Scope kinds determine the granularity of isolation:
12
- * - `instance` — one value shared across the whole Rudder instance
13
- * - `organization` — one value per organization
14
- * - `project` — one value per project
15
- * - `project_workspace` — one value per project workspace
16
- * - `agent` — one value per agent
17
- * - `issue` — one value per issue
18
- * - `goal` — one value per goal
19
- * - `run` — one value per agent run
20
- *
21
- * The `namespace` column defaults to `"default"` and can be used to
22
- * logically group keys without polluting the root namespace.
23
- *
24
- * @see doc/engineering/PLUGIN_RUNTIME_CONTRACT.md — `plugin_state`
25
- */
26
- export const pluginState = pgTable("plugin_state", {
27
- id: uuid("id").primaryKey().defaultRandom(),
28
- /** FK to the owning plugin. Cascades on delete. */
29
- pluginId: uuid("plugin_id")
30
- .notNull()
31
- .references(() => plugins.id, { onDelete: "cascade" }),
32
- /** Granularity of the scope (e.g. `"instance"`, `"project"`, `"issue"`). */
33
- scopeKind: text("scope_kind").$type().notNull(),
34
- /**
35
- * UUID or text identifier for the scoped object.
36
- * Null for `instance` scope (which has no associated entity).
37
- */
38
- scopeId: text("scope_id"),
39
- /**
40
- * Sub-namespace to avoid key collisions within a scope.
41
- * Defaults to `"default"` if the plugin does not specify one.
42
- */
43
- namespace: text("namespace").notNull().default("default"),
44
- /** The key identifying this state entry within the namespace. */
45
- stateKey: text("state_key").notNull(),
46
- /** JSON-serializable value stored by the plugin. */
47
- valueJson: jsonb("value_json").notNull(),
48
- /** Timestamp of the most recent write. */
49
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
50
- }, (table) => ({
51
- /**
52
- * Unique constraint enforces that there is at most one value per
53
- * (plugin, scope kind, scope id, namespace, key) tuple.
54
- *
55
- * `nullsNotDistinct()` is required so that `scope_id IS NULL` entries
56
- * (used by `instance` scope) are treated as equal by PostgreSQL rather
57
- * than as distinct nulls — otherwise the upsert target in `set()` would
58
- * fail to match existing rows and create duplicates.
59
- *
60
- * Requires PostgreSQL 15+.
61
- */
62
- uniqueEntry: unique("plugin_state_unique_entry_idx")
63
- .on(table.pluginId, table.scopeKind, table.scopeId, table.namespace, table.stateKey)
64
- .nullsNotDistinct(),
65
- /** Speed up lookups by plugin + scope kind (most common access pattern). */
66
- pluginScopeIdx: index("plugin_state_plugin_scope_idx").on(table.pluginId, table.scopeKind),
67
- }));
68
- //# sourceMappingURL=plugin_state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin_state.js","sourceRoot":"","sources":["../../src/schema/plugin_state.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,MAAM,EACN,IAAI,GACL,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAChC,cAAc,EACd;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,mDAAmD;IACnD,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;SACxB,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACxD,4EAA4E;IAC5E,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,EAAwB,CAAC,OAAO,EAAE;IACrE;;;OAGG;IACH,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IACzB;;;OAGG;IACH,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;IACzD,iEAAiE;IACjE,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;IACrC,oDAAoD;IACpD,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACxC,0CAA0C;IAC1C,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACV;;;;;;;;;;OAUG;IACH,WAAW,EAAE,MAAM,CAAC,+BAA+B,CAAC;SACjD,EAAE,CACD,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,QAAQ,CACf;SACA,gBAAgB,EAAE;IACrB,4EAA4E;IAC5E,cAAc,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC,EAAE,CACvD,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,SAAS,CAChB;CACF,CAAC,CACH,CAAC"}