@fayz-ai/db 0.9.0 → 0.11.0

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/README.md CHANGED
@@ -39,4 +39,4 @@ export const notes = pgTable('notes', {
39
39
  The data spine beneath every plugin schema; apps compose it in their own `drizzle.config`.
40
40
 
41
41
  ## Roadmap & contributing
42
- Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/ROADMAP.md#db) for current gaps, missing features, and good first issues.
42
+ Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/platform/ROADMAP.md#db) for current gaps, missing features, and good first issues.
package/dist/index.cjs CHANGED
@@ -21,6 +21,43 @@ var products = pgCore.pgTable("products", {
21
21
  var orderItems = pgCore.pgTable("order_items", {
22
22
  id: pgCore.uuid("id").primaryKey()
23
23
  });
24
+ var plgConnections = pgCore.pgTable("plg_connections", {
25
+ id: pgCore.uuid("id").primaryKey(),
26
+ tenantId: pgCore.uuid("tenant_id").notNull(),
27
+ connectorId: pgCore.text("connector_id").notNull(),
28
+ instanceKey: pgCore.text("instance_key").notNull(),
29
+ displayName: pgCore.text("display_name"),
30
+ active: pgCore.boolean("active").notNull(),
31
+ status: pgCore.text("status").notNull(),
32
+ statusDetail: pgCore.text("status_detail"),
33
+ settings: pgCore.jsonb("settings").notNull(),
34
+ providerAccountKey: pgCore.text("provider_account_key"),
35
+ cursors: pgCore.jsonb("cursors").notNull(),
36
+ lastSyncAt: pgCore.timestamp("last_sync_at", { withTimezone: true }),
37
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
38
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull()
39
+ });
40
+ var plgSyncRuns = pgCore.pgTable("plg_sync_runs", {
41
+ id: pgCore.uuid("id").primaryKey(),
42
+ tenantId: pgCore.uuid("tenant_id").notNull(),
43
+ connectionId: pgCore.uuid("connection_id").notNull().references(() => plgConnections.id, { onDelete: "cascade" }),
44
+ connectorId: pgCore.text("connector_id").notNull(),
45
+ direction: pgCore.text("direction").notNull(),
46
+ // `trigger_kind`, never `trigger`: the reserved word already cost one migration.
47
+ triggerKind: pgCore.text("trigger_kind").notNull(),
48
+ status: pgCore.text("status").notNull(),
49
+ stream: pgCore.text("stream"),
50
+ fetched: pgCore.integer("fetched").notNull(),
51
+ written: pgCore.integer("written").notNull(),
52
+ stats: pgCore.jsonb("stats").notNull(),
53
+ cursor: pgCore.text("cursor"),
54
+ correlationId: pgCore.uuid("correlation_id"),
55
+ // What the run has to say when it did NOT fail (031).
56
+ message: pgCore.text("message"),
57
+ error: pgCore.text("error"),
58
+ startedAt: pgCore.timestamp("started_at", { withTimezone: true }).notNull(),
59
+ finishedAt: pgCore.timestamp("finished_at", { withTimezone: true })
60
+ });
24
61
  var tenantId = () => pgCore.uuid("tenant_id").notNull().references(() => tenants.id, { onDelete: "cascade" });
25
62
  var timestamps = {
26
63
  createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -35,6 +72,8 @@ exports.createdAt = createdAt;
35
72
  exports.orderItems = orderItems;
36
73
  exports.orders = orders;
37
74
  exports.people = people;
75
+ exports.plgConnections = plgConnections;
76
+ exports.plgSyncRuns = plgSyncRuns;
38
77
  exports.products = products;
39
78
  exports.tenantId = tenantId;
40
79
  exports.tenants = tenants;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema/spine.ts","../src/helpers.ts"],"names":["pgTable","uuid","timestamp"],"mappings":";;;;;AAYO,IAAM,OAAA,GAAUA,eAAQ,SAAA,EAAW;AAAA,EACxC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAASD,eAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAASD,eAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,YAAA,GAAeD,eAAQ,cAAA,EAAgB;AAAA,EAClD,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,QAAA,GAAWD,eAAQ,UAAA,EAAY;AAAA,EAC1C,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,UAAA,GAAaD,eAAQ,aAAA,EAAe;AAAA,EAC/C,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AC1BM,IAAM,QAAA,GAAW,MACtBA,WAAAA,CAAK,WAAW,EACb,OAAA,EAAQ,CACR,UAAA,CAAW,MAAM,OAAA,CAAQ,EAAA,EAAI,EAAE,QAAA,EAAU,WAAW;AAGlD,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAWC,gBAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA,EAAW;AAAA,EAChF,SAAA,EAAWA,gBAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE;AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA,EAAWA,gBAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE","file":"index.cjs","sourcesContent":["import { pgTable, uuid } from 'drizzle-orm/pg-core'\n\n/**\n * Ring 0 — the core spine, declared as Drizzle *references* only.\n *\n * These tables are owned by the platform (@fayz-ai/saas core) and already exist\n * in every provisioned pool, directly in the `public` schema (industry-pool\n * model — no saas_core schema). We declare a minimal shape here purely so plugin\n * tables can express real foreign keys in TypeScript. They land in the Drizzle\n * *baseline* snapshot (never re-created), so only the `id` FK target is needed —\n * the live columns are authoritative.\n */\nexport const tenants = pgTable('tenants', {\n id: uuid('id').primaryKey(),\n})\n\nexport const people = pgTable('people', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orders = pgTable('orders', {\n id: uuid('id').primaryKey(),\n})\n\nexport const appointments = pgTable('appointments', {\n id: uuid('id').primaryKey(),\n})\n\nexport const products = pgTable('products', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orderItems = pgTable('order_items', {\n id: uuid('id').primaryKey(),\n})\n","import { uuid, timestamp } from 'drizzle-orm/pg-core'\nimport { tenants } from './schema/spine'\n\n/**\n * Canonical tenant-scoping column: `tenant_id uuid NOT NULL REFERENCES\n * public.tenants(id) ON DELETE CASCADE`. Every Ring-1 plugin table uses this\n * so tenancy is identical everywhere (and RLS can assume the column exists).\n */\nexport const tenantId = () =>\n uuid('tenant_id')\n .notNull()\n .references(() => tenants.id, { onDelete: 'cascade' })\n\n/** Standard `created_at` / `updated_at` timestamptz pair with `now()` defaults. */\nexport const timestamps = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n}\n\n/** Just `created_at` (for append-only / event-style tables). */\nexport const createdAt = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n}\n"]}
1
+ {"version":3,"sources":["../src/schema/spine.ts","../src/lib/helpers.ts"],"names":["pgTable","uuid","text","boolean","jsonb","timestamp","integer"],"mappings":";;;;;AAYO,IAAM,OAAA,GAAUA,eAAQ,SAAA,EAAW;AAAA,EACxC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAASD,eAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAASD,eAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAIC,WAAA,CAAK,IAAI,CAAA,CAAE,UAA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EAAE,cAAc,IAAA,EAAM,EAAE,OAAA,EAAQ;AAAA,EACnE,YAAYA,gBAAA,CAAU,aAAA,EAAe,EAAE,YAAA,EAAc,MAAM;AAC7D,CAAC;AC/EM,IAAM,QAAA,GAAW,MACtBJ,WAAAA,CAAK,WAAW,EACb,OAAA,EAAQ,CACR,UAAA,CAAW,MAAM,OAAA,CAAQ,EAAA,EAAI,EAAE,QAAA,EAAU,WAAW;AAGlD,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAWI,gBAAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA,EAAW;AAAA,EAChF,SAAA,EAAWA,gBAAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE;AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA,EAAWA,gBAAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE","file":"index.cjs","sourcesContent":["import { boolean, integer, jsonb, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core'\n\n/**\n * Ring 0 — the core spine, declared as Drizzle *references* only.\n *\n * These tables are owned by the platform (@fayz-ai/admin core) and already exist\n * in every provisioned pool, directly in the `public` schema (industry-pool\n * model — no saas_core schema). We declare a minimal shape here purely so plugin\n * tables can express real foreign keys in TypeScript. They land in the Drizzle\n * *baseline* snapshot (never re-created), so only the `id` FK target is needed —\n * the live columns are authoritative.\n */\nexport const tenants = pgTable('tenants', {\n id: uuid('id').primaryKey(),\n})\n\nexport const people = pgTable('people', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orders = pgTable('orders', {\n id: uuid('id').primaryKey(),\n})\n\nexport const appointments = pgTable('appointments', {\n id: uuid('id').primaryKey(),\n})\n\nexport const products = pgTable('products', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orderItems = pgTable('order_items', {\n id: uuid('id').primaryKey(),\n})\n\n/**\n * The connector spine — `plg_connections` / `plg_sync_runs` (migration 029).\n *\n * Declared in full rather than as a bare `id`, because unlike the Ring 0 tables\n * above these two are OURS: 029 is the authority, and a plugin that wants a real\n * FK to a connection (Google Calendar's channel table is the first) has nothing\n * to point at without this. The columns are therefore kept in agreement with\n * 029 by hand — the migration ships the table, this declares its shape.\n *\n * Deliberately NOT in the migration-generating schema set: 029 already creates\n * these, with RLS, grants and a partial index Drizzle would not reproduce.\n */\nexport const plgConnections = pgTable('plg_connections', {\n id: uuid('id').primaryKey(),\n tenantId: uuid('tenant_id').notNull(),\n connectorId: text('connector_id').notNull(),\n instanceKey: text('instance_key').notNull(),\n displayName: text('display_name'),\n active: boolean('active').notNull(),\n status: text('status').notNull(),\n statusDetail: text('status_detail'),\n settings: jsonb('settings').notNull(),\n providerAccountKey: text('provider_account_key'),\n cursors: jsonb('cursors').notNull(),\n lastSyncAt: timestamp('last_sync_at', { withTimezone: true }),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull(),\n})\n\nexport const plgSyncRuns = pgTable('plg_sync_runs', {\n id: uuid('id').primaryKey(),\n tenantId: uuid('tenant_id').notNull(),\n connectionId: uuid('connection_id')\n .notNull()\n .references(() => plgConnections.id, { onDelete: 'cascade' }),\n connectorId: text('connector_id').notNull(),\n direction: text('direction').notNull(),\n // `trigger_kind`, never `trigger`: the reserved word already cost one migration.\n triggerKind: text('trigger_kind').notNull(),\n status: text('status').notNull(),\n stream: text('stream'),\n fetched: integer('fetched').notNull(),\n written: integer('written').notNull(),\n stats: jsonb('stats').notNull(),\n cursor: text('cursor'),\n correlationId: uuid('correlation_id'),\n // What the run has to say when it did NOT fail (031).\n message: text('message'),\n error: text('error'),\n startedAt: timestamp('started_at', { withTimezone: true }).notNull(),\n finishedAt: timestamp('finished_at', { withTimezone: true }),\n})\n","import { uuid, timestamp } from 'drizzle-orm/pg-core'\nimport { tenants } from '../schema/spine'\n\n/**\n * Canonical tenant-scoping column: `tenant_id uuid NOT NULL REFERENCES\n * public.tenants(id) ON DELETE CASCADE`. Every Ring-1 plugin table uses this\n * so tenancy is identical everywhere (and RLS can assume the column exists).\n */\nexport const tenantId = () =>\n uuid('tenant_id')\n .notNull()\n .references(() => tenants.id, { onDelete: 'cascade' })\n\n/** Standard `created_at` / `updated_at` timestamptz pair with `now()` defaults. */\nexport const timestamps = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n}\n\n/** Just `created_at` (for append-only / event-style tables). */\nexport const createdAt = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from 'drizzle-orm/pg-core';
2
- export { tenants, people, orders, appointments, products, orderItems } from './schema/spine';
3
- export { tenantId, timestamps, createdAt } from './helpers';
2
+ export { tenants, people, orders, appointments, products, orderItems, plgConnections, plgSyncRuns } from './schema/spine';
3
+ export { tenantId, timestamps, createdAt } from './lib/helpers';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC5F,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { pgTable, uuid, timestamp } from 'drizzle-orm/pg-core';
1
+ import { pgTable, uuid, timestamp, jsonb, text, boolean, integer } from 'drizzle-orm/pg-core';
2
2
  export * from 'drizzle-orm/pg-core';
3
3
 
4
4
  // src/index.ts
@@ -20,6 +20,43 @@ var products = pgTable("products", {
20
20
  var orderItems = pgTable("order_items", {
21
21
  id: uuid("id").primaryKey()
22
22
  });
23
+ var plgConnections = pgTable("plg_connections", {
24
+ id: uuid("id").primaryKey(),
25
+ tenantId: uuid("tenant_id").notNull(),
26
+ connectorId: text("connector_id").notNull(),
27
+ instanceKey: text("instance_key").notNull(),
28
+ displayName: text("display_name"),
29
+ active: boolean("active").notNull(),
30
+ status: text("status").notNull(),
31
+ statusDetail: text("status_detail"),
32
+ settings: jsonb("settings").notNull(),
33
+ providerAccountKey: text("provider_account_key"),
34
+ cursors: jsonb("cursors").notNull(),
35
+ lastSyncAt: timestamp("last_sync_at", { withTimezone: true }),
36
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
37
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
38
+ });
39
+ var plgSyncRuns = pgTable("plg_sync_runs", {
40
+ id: uuid("id").primaryKey(),
41
+ tenantId: uuid("tenant_id").notNull(),
42
+ connectionId: uuid("connection_id").notNull().references(() => plgConnections.id, { onDelete: "cascade" }),
43
+ connectorId: text("connector_id").notNull(),
44
+ direction: text("direction").notNull(),
45
+ // `trigger_kind`, never `trigger`: the reserved word already cost one migration.
46
+ triggerKind: text("trigger_kind").notNull(),
47
+ status: text("status").notNull(),
48
+ stream: text("stream"),
49
+ fetched: integer("fetched").notNull(),
50
+ written: integer("written").notNull(),
51
+ stats: jsonb("stats").notNull(),
52
+ cursor: text("cursor"),
53
+ correlationId: uuid("correlation_id"),
54
+ // What the run has to say when it did NOT fail (031).
55
+ message: text("message"),
56
+ error: text("error"),
57
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
58
+ finishedAt: timestamp("finished_at", { withTimezone: true })
59
+ });
23
60
  var tenantId = () => uuid("tenant_id").notNull().references(() => tenants.id, { onDelete: "cascade" });
24
61
  var timestamps = {
25
62
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -29,6 +66,6 @@ var createdAt = {
29
66
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
30
67
  };
31
68
 
32
- export { appointments, createdAt, orderItems, orders, people, products, tenantId, tenants, timestamps };
69
+ export { appointments, createdAt, orderItems, orders, people, plgConnections, plgSyncRuns, products, tenantId, tenants, timestamps };
33
70
  //# sourceMappingURL=index.js.map
34
71
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema/spine.ts","../src/helpers.ts"],"names":["uuid"],"mappings":";;;;AAYO,IAAM,OAAA,GAAU,QAAQ,SAAA,EAAW;AAAA,EACxC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAAS,QAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAAS,QAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,YAAA,GAAe,QAAQ,cAAA,EAAgB;AAAA,EAClD,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,QAAA,GAAW,QAAQ,UAAA,EAAY;AAAA,EAC1C,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,UAAA,GAAa,QAAQ,aAAA,EAAe;AAAA,EAC/C,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AC1BM,IAAM,QAAA,GAAW,MACtBA,IAAAA,CAAK,WAAW,EACb,OAAA,EAAQ,CACR,UAAA,CAAW,MAAM,OAAA,CAAQ,EAAA,EAAI,EAAE,QAAA,EAAU,WAAW;AAGlD,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,SAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA,EAAW;AAAA,EAChF,SAAA,EAAW,SAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE;AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA,EAAW,SAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE","file":"index.js","sourcesContent":["import { pgTable, uuid } from 'drizzle-orm/pg-core'\n\n/**\n * Ring 0 — the core spine, declared as Drizzle *references* only.\n *\n * These tables are owned by the platform (@fayz-ai/saas core) and already exist\n * in every provisioned pool, directly in the `public` schema (industry-pool\n * model — no saas_core schema). We declare a minimal shape here purely so plugin\n * tables can express real foreign keys in TypeScript. They land in the Drizzle\n * *baseline* snapshot (never re-created), so only the `id` FK target is needed —\n * the live columns are authoritative.\n */\nexport const tenants = pgTable('tenants', {\n id: uuid('id').primaryKey(),\n})\n\nexport const people = pgTable('people', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orders = pgTable('orders', {\n id: uuid('id').primaryKey(),\n})\n\nexport const appointments = pgTable('appointments', {\n id: uuid('id').primaryKey(),\n})\n\nexport const products = pgTable('products', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orderItems = pgTable('order_items', {\n id: uuid('id').primaryKey(),\n})\n","import { uuid, timestamp } from 'drizzle-orm/pg-core'\nimport { tenants } from './schema/spine'\n\n/**\n * Canonical tenant-scoping column: `tenant_id uuid NOT NULL REFERENCES\n * public.tenants(id) ON DELETE CASCADE`. Every Ring-1 plugin table uses this\n * so tenancy is identical everywhere (and RLS can assume the column exists).\n */\nexport const tenantId = () =>\n uuid('tenant_id')\n .notNull()\n .references(() => tenants.id, { onDelete: 'cascade' })\n\n/** Standard `created_at` / `updated_at` timestamptz pair with `now()` defaults. */\nexport const timestamps = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n}\n\n/** Just `created_at` (for append-only / event-style tables). */\nexport const createdAt = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n}\n"]}
1
+ {"version":3,"sources":["../src/schema/spine.ts","../src/lib/helpers.ts"],"names":["uuid","timestamp"],"mappings":";;;;AAYO,IAAM,OAAA,GAAU,QAAQ,SAAA,EAAW;AAAA,EACxC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAAS,QAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,MAAA,GAAS,QAAQ,QAAA,EAAU;AAAA,EACtC,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,YAAA,GAAe,QAAQ,cAAA,EAAgB;AAAA,EAClD,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,QAAA,GAAW,QAAQ,UAAA,EAAY;AAAA,EAC1C,EAAA,EAAI,IAAA,CAAK,IAAI,CAAA,CAAE,UAAA;AACjB,CAAC;AAEM,IAAM,UAAA,GAAa,QAAQ,aAAA,EAAe;AAAA,E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c,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA,EAAW;AAAA,EAChF,SAAA,EAAWA,SAAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE;AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA,EAAWA,SAAAA,CAAU,YAAA,EAAc,EAAE,YAAA,EAAc,MAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,UAAA;AACvE","file":"index.js","sourcesContent":["import { boolean, integer, jsonb, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core'\n\n/**\n * Ring 0 — the core spine, declared as Drizzle *references* only.\n *\n * These tables are owned by the platform (@fayz-ai/admin core) and already exist\n * in every provisioned pool, directly in the `public` schema (industry-pool\n * model — no saas_core schema). We declare a minimal shape here purely so plugin\n * tables can express real foreign keys in TypeScript. They land in the Drizzle\n * *baseline* snapshot (never re-created), so only the `id` FK target is needed —\n * the live columns are authoritative.\n */\nexport const tenants = pgTable('tenants', {\n id: uuid('id').primaryKey(),\n})\n\nexport const people = pgTable('people', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orders = pgTable('orders', {\n id: uuid('id').primaryKey(),\n})\n\nexport const appointments = pgTable('appointments', {\n id: uuid('id').primaryKey(),\n})\n\nexport const products = pgTable('products', {\n id: uuid('id').primaryKey(),\n})\n\nexport const orderItems = pgTable('order_items', {\n id: uuid('id').primaryKey(),\n})\n\n/**\n * The connector spine — `plg_connections` / `plg_sync_runs` (migration 029).\n *\n * Declared in full rather than as a bare `id`, because unlike the Ring 0 tables\n * above these two are OURS: 029 is the authority, and a plugin that wants a real\n * FK to a connection (Google Calendar's channel table is the first) has nothing\n * to point at without this. The columns are therefore kept in agreement with\n * 029 by hand — the migration ships the table, this declares its shape.\n *\n * Deliberately NOT in the migration-generating schema set: 029 already creates\n * these, with RLS, grants and a partial index Drizzle would not reproduce.\n */\nexport const plgConnections = pgTable('plg_connections', {\n id: uuid('id').primaryKey(),\n tenantId: uuid('tenant_id').notNull(),\n connectorId: text('connector_id').notNull(),\n instanceKey: text('instance_key').notNull(),\n displayName: text('display_name'),\n active: boolean('active').notNull(),\n status: text('status').notNull(),\n statusDetail: text('status_detail'),\n settings: jsonb('settings').notNull(),\n providerAccountKey: text('provider_account_key'),\n cursors: jsonb('cursors').notNull(),\n lastSyncAt: timestamp('last_sync_at', { withTimezone: true }),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull(),\n})\n\nexport const plgSyncRuns = pgTable('plg_sync_runs', {\n id: uuid('id').primaryKey(),\n tenantId: uuid('tenant_id').notNull(),\n connectionId: uuid('connection_id')\n .notNull()\n .references(() => plgConnections.id, { onDelete: 'cascade' }),\n connectorId: text('connector_id').notNull(),\n direction: text('direction').notNull(),\n // `trigger_kind`, never `trigger`: the reserved word already cost one migration.\n triggerKind: text('trigger_kind').notNull(),\n status: text('status').notNull(),\n stream: text('stream'),\n fetched: integer('fetched').notNull(),\n written: integer('written').notNull(),\n stats: jsonb('stats').notNull(),\n cursor: text('cursor'),\n correlationId: uuid('correlation_id'),\n // What the run has to say when it did NOT fail (031).\n message: text('message'),\n error: text('error'),\n startedAt: timestamp('started_at', { withTimezone: true }).notNull(),\n finishedAt: timestamp('finished_at', { withTimezone: true }),\n})\n","import { uuid, timestamp } from 'drizzle-orm/pg-core'\nimport { tenants } from '../schema/spine'\n\n/**\n * Canonical tenant-scoping column: `tenant_id uuid NOT NULL REFERENCES\n * public.tenants(id) ON DELETE CASCADE`. Every Ring-1 plugin table uses this\n * so tenancy is identical everywhere (and RLS can assume the column exists).\n */\nexport const tenantId = () =>\n uuid('tenant_id')\n .notNull()\n .references(() => tenants.id, { onDelete: 'cascade' })\n\n/** Standard `created_at` / `updated_at` timestamptz pair with `now()` defaults. */\nexport const timestamps = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n}\n\n/** Just `created_at` (for append-only / event-style tables). */\nexport const createdAt = {\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,sGAGqC,CAAA;AAE1D,mFAAmF;AACnF,eAAO,MAAM,UAAU;;;CAGtB,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,SAAS;;CAErB,CAAA"}