@storyshelf/db-sqlite 0.6.2 → 0.8.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.
Files changed (93) hide show
  1. package/README.md +9 -9
  2. package/dist/better-sqlite3.d.mts +0 -2
  3. package/dist/better-sqlite3.mjs +8 -4
  4. package/dist/better-sqlite3.mjs.map +1 -1
  5. package/dist/bun-sqlite.d.mts +0 -2
  6. package/dist/bun-sqlite.mjs +8 -4
  7. package/dist/bun-sqlite.mjs.map +1 -1
  8. package/dist/d1.d.mts +0 -2
  9. package/dist/d1.mjs +6 -5
  10. package/dist/d1.mjs.map +1 -1
  11. package/dist/ddl.d.mts +10 -4
  12. package/dist/ddl.mjs +247 -16
  13. package/dist/ddl.mjs.map +1 -1
  14. package/dist/drizzle-factory.d.mts +0 -2
  15. package/dist/drizzle-factory.mjs +6 -3
  16. package/dist/drizzle-factory.mjs.map +1 -1
  17. package/dist/ensure-db-dir.mjs +2 -4
  18. package/dist/ensure-db-dir.mjs.map +1 -1
  19. package/dist/index.d.mts +4 -3
  20. package/dist/index.mjs +9 -5
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/schema/baseline.d.mts +87 -13
  23. package/dist/schema/baseline.mjs +6 -3
  24. package/dist/schema/baseline.mjs.map +1 -1
  25. package/dist/schema/{status-config.d.mts → build-component.d.mts} +41 -36
  26. package/dist/schema/build-component.mjs +21 -0
  27. package/dist/schema/build-component.mjs.map +1 -0
  28. package/dist/schema/build-review.d.mts +127 -0
  29. package/dist/schema/build-review.mjs +19 -0
  30. package/dist/schema/build-review.mjs.map +1 -0
  31. package/dist/schema/build.d.mts +81 -25
  32. package/dist/schema/build.mjs +5 -2
  33. package/dist/schema/build.mjs.map +1 -1
  34. package/dist/schema/capture-attempt.d.mts +25 -27
  35. package/dist/schema/capture-attempt.mjs +1 -2
  36. package/dist/schema/capture-job.d.mts +357 -0
  37. package/dist/schema/capture-job.mjs +37 -0
  38. package/dist/schema/capture-job.mjs.map +1 -0
  39. package/dist/schema/capture-shard.d.mts +279 -0
  40. package/dist/schema/capture-shard.mjs +27 -0
  41. package/dist/schema/capture-shard.mjs.map +1 -0
  42. package/dist/schema/comment.d.mts +31 -13
  43. package/dist/schema/comment.mjs +4 -4
  44. package/dist/schema/comment.mjs.map +1 -1
  45. package/dist/schema/connection.d.mts +189 -0
  46. package/dist/schema/connection.mjs +25 -0
  47. package/dist/schema/connection.mjs.map +1 -0
  48. package/dist/schema/content-refs.d.mts +0 -2
  49. package/dist/schema/content-refs.mjs +1 -2
  50. package/dist/schema/design.d.mts +647 -0
  51. package/dist/schema/design.mjs +48 -0
  52. package/dist/schema/design.mjs.map +1 -0
  53. package/dist/schema/insight.d.mts +687 -0
  54. package/dist/schema/insight.mjs +52 -0
  55. package/dist/schema/insight.mjs.map +1 -0
  56. package/dist/schema/label.d.mts +15 -17
  57. package/dist/schema/label.mjs +1 -2
  58. package/dist/schema/member.d.mts +7 -9
  59. package/dist/schema/member.mjs +1 -2
  60. package/dist/schema/notification.d.mts +58 -20
  61. package/dist/schema/notification.mjs +3 -2
  62. package/dist/schema/notification.mjs.map +1 -1
  63. package/dist/schema/project-group-mapping.d.mts +6 -8
  64. package/dist/schema/project-group-mapping.mjs +1 -2
  65. package/dist/schema/project.d.mts +132 -2
  66. package/dist/schema/project.mjs +9 -3
  67. package/dist/schema/project.mjs.map +1 -1
  68. package/dist/schema/site-setting.d.mts +107 -0
  69. package/dist/schema/site-setting.mjs +16 -0
  70. package/dist/schema/site-setting.mjs.map +1 -0
  71. package/dist/schema/snapshot.d.mts +203 -27
  72. package/dist/schema/snapshot.mjs +15 -3
  73. package/dist/schema/snapshot.mjs.map +1 -1
  74. package/dist/schema/token.d.mts +8 -10
  75. package/dist/schema/token.mjs +1 -2
  76. package/dist/schema/usage.d.mts +291 -0
  77. package/dist/schema/usage.mjs +29 -0
  78. package/dist/schema/usage.mjs.map +1 -0
  79. package/dist/schema/user-invite.d.mts +7 -9
  80. package/dist/schema/user-invite.mjs +1 -2
  81. package/dist/schema/user.d.mts +0 -2
  82. package/dist/schema/user.mjs +1 -2
  83. package/dist/schema/webhook.d.mts +8 -10
  84. package/dist/schema/webhook.mjs +1 -2
  85. package/dist/schema.d.mts +24 -5
  86. package/dist/schema.mjs +26 -6
  87. package/dist/schema.mjs.map +1 -1
  88. package/dist/turso.d.mts +2 -4
  89. package/dist/turso.mjs +20 -8
  90. package/dist/turso.mjs.map +1 -1
  91. package/package.json +7 -7
  92. package/dist/schema/status-config.mjs +0 -20
  93. package/dist/schema/status-config.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","names":["projectsTable","projectStatusConfigsTable","buildsTable","captureAttemptsTable","captureLogsTable","snapshotsTable","baselinesTable","commentsTable","labelTypesTable","buildLabelsTable","tokensTable","webhooksTable","notificationChannelsTable","notificationSubscriptionsTable","usersTable","userInviteTokensTable","projectMembersTable","projectGroupMappingsTable","contentRefsTable"],"sources":["../src/schema/index.ts"],"sourcesContent":["/**\n * Database schema: table handles, row types, and the schema object passed\n * to the database client.\n *\n * Table handles are available on the `schema` object with full type\n * inference (`schema.builds`, …); exact column types live on the narrow\n * per-entity definitions, and the row interfaces are pinned to them by\n * `schema-types.test.ts`.\n */\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { baselines as baselinesTable } from \"./baseline.ts\";\nimport { builds as buildsTable } from \"./build.ts\";\nimport {\n captureAttempts as captureAttemptsTable,\n captureLogs as captureLogsTable,\n} from \"./capture-attempt.ts\";\nimport { comments as commentsTable } from \"./comment.ts\";\nimport { contentRefs as contentRefsTable } from \"./content-refs.ts\";\nimport { buildLabels as buildLabelsTable, labelTypes as labelTypesTable } from \"./label.ts\";\nimport { projectMembers as projectMembersTable } from \"./member.ts\";\nimport {\n notificationChannels as notificationChannelsTable,\n notificationSubscriptions as notificationSubscriptionsTable,\n} from \"./notification.ts\";\nimport { projectGroupMappings as projectGroupMappingsTable } from \"./project-group-mapping.ts\";\nimport { projects as projectsTable } from \"./project.ts\";\nimport { snapshots as snapshotsTable } from \"./snapshot.ts\";\nimport { projectStatusConfigs as projectStatusConfigsTable } from \"./status-config.ts\";\nimport { tokens as tokensTable } from \"./token.ts\";\nimport { userInviteTokens as userInviteTokensTable } from \"./user-invite.ts\";\nimport { users as usersTable } from \"./user.ts\";\nimport { webhooks as webhooksTable } from \"./webhook.ts\";\n\nexport { builds } from \"./build.ts\";\nexport { captureAttempts, captureLogs } from \"./capture-attempt.ts\";\nexport { baselines } from \"./baseline.ts\";\nexport { comments } from \"./comment.ts\";\nexport { buildLabels, labelTypes } from \"./label.ts\";\nexport { projectMembers } from \"./member.ts\";\nexport { notificationChannels, notificationSubscriptions } from \"./notification.ts\";\nexport { projectGroupMappings } from \"./project-group-mapping.ts\";\nexport { projects } from \"./project.ts\";\nexport { snapshots } from \"./snapshot.ts\";\nexport { projectStatusConfigs } from \"./status-config.ts\";\nexport { tokens } from \"./token.ts\";\nexport { users } from \"./user.ts\";\nexport { userInviteTokens } from \"./user-invite.ts\";\nexport { webhooks } from \"./webhook.ts\";\nexport { contentRefs } from \"./content-refs.ts\";\n\n/** A capture attempt and its log lines for a single build run. */\nexport type { CaptureAttempt, CaptureLog } from \"./capture-attempt.ts\";\n/** Build row as stored in the `builds` table. */\nexport type { Build } from \"./build.ts\";\n/** Review comment row as stored in the `comments` table. */\nexport type { Comment } from \"./comment.ts\";\n/** Build label and label type rows. */\nexport type { BuildLabel, LabelType } from \"./label.ts\";\n/** Project membership row linking a user to a project role. */\nexport type { ProjectMember } from \"./member.ts\";\n/** Identity-provider group to project-role mapping row. */\nexport type { ProjectGroupMapping } from \"./project-group-mapping.ts\";\n/** Project row and its embedded Storybook metadata. */\nexport type { Project, StorybookMeta } from \"./project.ts\";\n/** Per-project git provider status-check configuration row. */\nexport type { ProjectStatusConfig } from \"./status-config.ts\";\n/** Snapshot row capturing a single story at one viewport. */\nexport type { Snapshot } from \"./snapshot.ts\";\n/** CI token row (stores only the hash). */\nexport type { Token } from \"./token.ts\";\n/** User row for authenticated identities. */\nexport type { User } from \"./user.ts\";\n/** One-time invite token for local accounts. */\nexport type { UserInviteToken } from \"./user-invite.ts\";\n/** Webhook subscription row. */\nexport type { Webhook } from \"./webhook.ts\";\n/** Notification channel and subscription rows. */\nexport type { NotificationChannel, NotificationSubscription } from \"./notification.ts\";\n/** Content ref row for deduplicated assets. */\nexport type { ContentRef } from \"./content-refs.ts\";\n\n/** Full Drizzle schema object passed to the database client. */\nexport const schema: {\n projects: AnySQLiteTable;\n projectStatusConfigs: AnySQLiteTable;\n builds: AnySQLiteTable;\n captureAttempts: AnySQLiteTable;\n captureLogs: AnySQLiteTable;\n snapshots: AnySQLiteTable;\n baselines: AnySQLiteTable;\n comments: AnySQLiteTable;\n labelTypes: AnySQLiteTable;\n buildLabels: AnySQLiteTable;\n tokens: AnySQLiteTable;\n webhooks: AnySQLiteTable;\n notificationChannels: AnySQLiteTable;\n notificationSubscriptions: AnySQLiteTable;\n users: AnySQLiteTable;\n userInviteTokens: AnySQLiteTable;\n projectMembers: AnySQLiteTable;\n projectGroupMappings: AnySQLiteTable;\n contentRefs: AnySQLiteTable;\n} = {\n projects: projectsTable,\n projectStatusConfigs: projectStatusConfigsTable,\n builds: buildsTable,\n captureAttempts: captureAttemptsTable,\n captureLogs: captureLogsTable,\n snapshots: snapshotsTable,\n baselines: baselinesTable,\n comments: commentsTable,\n labelTypes: labelTypesTable,\n buildLabels: buildLabelsTable,\n tokens: tokensTable,\n webhooks: webhooksTable,\n notificationChannels: notificationChannelsTable,\n notificationSubscriptions: notificationSubscriptionsTable,\n users: usersTable,\n userInviteTokens: userInviteTokensTable,\n projectMembers: projectMembersTable,\n projectGroupMappings: projectGroupMappingsTable,\n contentRefs: contentRefsTable,\n};\n\n/** The full database schema type. */\nexport type Schema = typeof schema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkFA,MAAa,SAoBT;CACQA;CACYC;CACdC;CACSC;CACJC;CACFC;CACAC;CACDC;CACEC;CACCC;CACLC;CACEC;CACYC;CACKC;CACpBC;CACWC;CACFC;CACMC;CACTC;AACf"}
1
+ {"version":3,"file":"schema.mjs","names":["projectsTable","buildsTable","captureAttemptsTable","captureLogsTable","captureShardsTable","captureJobsTable","buildComponentsTable","buildReviewsTable","siteSettingsTable","snapshotsTable","baselinesTable","commentsTable","labelTypesTable","buildLabelsTable","projectLinksTable","designLinksTable","designCredentialsTable","userConnectionsTable","designNodesTable","buildPackageUsageTable","tokensTable","webhooksTable","insightsTable","aiUsageTable","aiBudgetAlertsTable","notificationChannelsTable","notificationSubscriptionsTable","usersTable","userInviteTokensTable","projectMembersTable","projectGroupMappingsTable","contentRefsTable"],"sources":["../src/schema/index.ts"],"sourcesContent":["/**\n * Database schema: table handles, row types, and the schema object passed\n * to the database client.\n *\n * Table handles are available on the `schema` object with full type\n * inference (`schema.builds`, …); exact column types live on the narrow\n * per-entity definitions, and the row interfaces are pinned to them by\n * `schema-types.test.ts`.\n */\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { baselines as baselinesTable } from \"./baseline.ts\";\nimport { buildComponents as buildComponentsTable } from \"./build-component.ts\";\nimport { buildReviews as buildReviewsTable } from \"./build-review.ts\";\nimport { builds as buildsTable } from \"./build.ts\";\nimport {\n captureAttempts as captureAttemptsTable,\n captureLogs as captureLogsTable,\n} from \"./capture-attempt.ts\";\nimport { captureJobs as captureJobsTable } from \"./capture-job.ts\";\nimport { captureShards as captureShardsTable } from \"./capture-shard.ts\";\nimport { comments as commentsTable } from \"./comment.ts\";\nimport { userConnections as userConnectionsTable } from \"./connection.ts\";\nimport { contentRefs as contentRefsTable } from \"./content-refs.ts\";\nimport {\n designLinks as designLinksTable,\n designCredentials as designCredentialsTable,\n designNodes as designNodesTable,\n} from \"./design.ts\";\nimport {\n aiBudgetAlerts as aiBudgetAlertsTable,\n aiUsage as aiUsageTable,\n insights as insightsTable,\n} from \"./insight.ts\";\nimport { buildLabels as buildLabelsTable, labelTypes as labelTypesTable } from \"./label.ts\";\nimport { projectMembers as projectMembersTable } from \"./member.ts\";\nimport {\n notificationChannels as notificationChannelsTable,\n notificationSubscriptions as notificationSubscriptionsTable,\n} from \"./notification.ts\";\nimport { projectGroupMappings as projectGroupMappingsTable } from \"./project-group-mapping.ts\";\nimport { projects as projectsTable } from \"./project.ts\";\nimport { siteSettings as siteSettingsTable } from \"./site-setting.ts\";\nimport { snapshots as snapshotsTable } from \"./snapshot.ts\";\nimport { tokens as tokensTable } from \"./token.ts\";\nimport {\n buildPackageUsage as buildPackageUsageTable,\n projectLinks as projectLinksTable,\n} from \"./usage.ts\";\nimport { userInviteTokens as userInviteTokensTable } from \"./user-invite.ts\";\nimport { users as usersTable } from \"./user.ts\";\nimport { webhooks as webhooksTable } from \"./webhook.ts\";\n\nexport { builds } from \"./build.ts\";\nexport { captureAttempts, captureLogs } from \"./capture-attempt.ts\";\nexport { captureJobs } from \"./capture-job.ts\";\nexport { buildComponents } from \"./build-component.ts\";\nexport { buildReviews } from \"./build-review.ts\";\nexport { siteSettings } from \"./site-setting.ts\";\nexport { captureShards } from \"./capture-shard.ts\";\nexport { baselines } from \"./baseline.ts\";\nexport { comments } from \"./comment.ts\";\nexport { buildLabels, labelTypes } from \"./label.ts\";\nexport { projectMembers } from \"./member.ts\";\nexport { buildPackageUsage, projectLinks } from \"./usage.ts\";\nexport { userConnections } from \"./connection.ts\";\nexport { designCredentials, designLinks, designNodes } from \"./design.ts\";\nexport { aiBudgetAlerts, aiUsage, insights } from \"./insight.ts\";\nexport { notificationChannels, notificationSubscriptions } from \"./notification.ts\";\nexport { projectGroupMappings } from \"./project-group-mapping.ts\";\nexport { projects } from \"./project.ts\";\nexport { snapshots } from \"./snapshot.ts\";\nexport { tokens } from \"./token.ts\";\nexport { users } from \"./user.ts\";\nexport { userInviteTokens } from \"./user-invite.ts\";\nexport { webhooks } from \"./webhook.ts\";\nexport { contentRefs } from \"./content-refs.ts\";\n\n/** A capture attempt and its log lines for a single build run. */\nexport type { CaptureAttempt, CaptureLog } from \"./capture-attempt.ts\";\n/** Build row as stored in the `builds` table. */\nexport type { Build } from \"./build.ts\";\n/** Review comment row as stored in the `comments` table. */\nexport type { Comment } from \"./comment.ts\";\n/** Build label and label type rows. */\nexport type { BuildLabel, LabelType } from \"./label.ts\";\n/** A user's OAuth connection to an external service. */\nexport type { UserConnection } from \"./connection.ts\";\n/** Design link, provider credential and cached design node rows. */\nexport type { DesignCredential, DesignLink, DesignNode } from \"./design.ts\";\n/** Project link and per-build package usage rows. */\nexport type { BuildPackageUsage, ProjectLink } from \"./usage.ts\";\n/** Project membership row linking a user to a project role. */\nexport type { ProjectMember } from \"./member.ts\";\n/** Identity-provider group to project-role mapping row. */\nexport type { ProjectGroupMapping } from \"./project-group-mapping.ts\";\n/** Project row and its embedded Storybook metadata. */\nexport type { Project, StorybookMeta } from \"./project.ts\";\n/** Per-project git provider status-check configuration row. */\n/** Snapshot row capturing a single story at one viewport. */\nexport type { Snapshot } from \"./snapshot.ts\";\n/** CI token row (stores only the hash). */\nexport type { Token } from \"./token.ts\";\n/** User row for authenticated identities. */\nexport type { User } from \"./user.ts\";\n/** One-time invite token for local accounts. */\nexport type { UserInviteToken } from \"./user-invite.ts\";\n/** Webhook subscription row. */\nexport type { Webhook } from \"./webhook.ts\";\n/** Insight, AI usage and budget-alert rows. */\nexport type { AiBudgetAlert, AiUsage, Insight } from \"./insight.ts\";\n/** Notification channel and subscription rows. */\nexport type { NotificationChannel, NotificationSubscription } from \"./notification.ts\";\n/** Content ref row for deduplicated assets. */\nexport type { ContentRef } from \"./content-refs.ts\";\n\n/** Full Drizzle schema object passed to the database client. */\nexport const schema: {\n projects: AnySQLiteTable;\n builds: AnySQLiteTable;\n captureAttempts: AnySQLiteTable;\n captureLogs: AnySQLiteTable;\n captureShards: AnySQLiteTable;\n captureJobs: AnySQLiteTable;\n buildComponents: AnySQLiteTable;\n buildReviews: AnySQLiteTable;\n siteSettings: AnySQLiteTable;\n snapshots: AnySQLiteTable;\n baselines: AnySQLiteTable;\n comments: AnySQLiteTable;\n labelTypes: AnySQLiteTable;\n buildLabels: AnySQLiteTable;\n projectLinks: AnySQLiteTable;\n designLinks: AnySQLiteTable;\n designCredentials: AnySQLiteTable;\n userConnections: AnySQLiteTable;\n designNodes: AnySQLiteTable;\n buildPackageUsage: AnySQLiteTable;\n tokens: AnySQLiteTable;\n webhooks: AnySQLiteTable;\n insights: AnySQLiteTable;\n aiUsage: AnySQLiteTable;\n aiBudgetAlerts: AnySQLiteTable;\n notificationChannels: AnySQLiteTable;\n notificationSubscriptions: AnySQLiteTable;\n users: AnySQLiteTable;\n userInviteTokens: AnySQLiteTable;\n projectMembers: AnySQLiteTable;\n projectGroupMappings: AnySQLiteTable;\n contentRefs: AnySQLiteTable;\n} = {\n projects: projectsTable,\n builds: buildsTable,\n captureAttempts: captureAttemptsTable,\n captureLogs: captureLogsTable,\n captureShards: captureShardsTable,\n captureJobs: captureJobsTable,\n buildComponents: buildComponentsTable,\n buildReviews: buildReviewsTable,\n siteSettings: siteSettingsTable,\n snapshots: snapshotsTable,\n baselines: baselinesTable,\n comments: commentsTable,\n labelTypes: labelTypesTable,\n buildLabels: buildLabelsTable,\n projectLinks: projectLinksTable,\n designLinks: designLinksTable,\n designCredentials: designCredentialsTable,\n userConnections: userConnectionsTable,\n designNodes: designNodesTable,\n buildPackageUsage: buildPackageUsageTable,\n tokens: tokensTable,\n webhooks: webhooksTable,\n insights: insightsTable,\n aiUsage: aiUsageTable,\n aiBudgetAlerts: aiBudgetAlertsTable,\n notificationChannels: notificationChannelsTable,\n notificationSubscriptions: notificationSubscriptionsTable,\n users: usersTable,\n userInviteTokens: userInviteTokensTable,\n projectMembers: projectMembersTable,\n projectGroupMappings: projectGroupMappingsTable,\n contentRefs: contentRefsTable,\n};\n\n/** The full database schema type. */\nexport type Schema = typeof schema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,SAiCT;CACQA;CACFC;CACSC;CACJC;CACEC;CACFC;CACIC;CACHC;CACAC;CACHC;CACAC;CACDC;CACEC;CACCC;CACCC;CACDC;CACMC;CACFC;CACJC;CACMC;CACXC;CACEC;CACAC;CACDC;CACOC;CACMC;CACKC;CACpBC;CACWC;CACFC;CACMC;CACTC;AACf"}
package/dist/turso.d.mts CHANGED
@@ -1,9 +1,8 @@
1
1
  import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
- import { createClient } from "@libsql/client";
4
3
  import { DatabaseAdapter } from "@storyshelf/core/adapter/database";
5
- //#region src/turso.d.ts
6
- type LibsqlClient = ReturnType<typeof createClient>;
4
+ import { Client } from "@libsql/client";
5
+ type LibsqlClient = Client;
7
6
  /**
8
7
  * Options for creating a Turso-backed DatabaseAdapter.
9
8
  *
@@ -27,6 +26,5 @@ interface TursoDatabaseOptions {
27
26
  * @returns A DatabaseAdapter backed by the Turso database.
28
27
  */
29
28
  declare function createTursoDatabase(options: TursoDatabaseOptions): DatabaseAdapter;
30
- //#endregion
31
29
  export { TursoDatabaseOptions, createTursoDatabase };
32
30
  //# sourceMappingURL=turso.d.mts.map
package/dist/turso.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- import { DDL, tableColumns } from "./ddl.mjs";
4
+ import { DDL, IDENTITY_STATEMENTS, tableColumns } from "./ddl.mjs";
5
5
  import { createDrizzleAdapter } from "./drizzle-factory.mjs";
6
6
  import { schema } from "./schema.mjs";
7
- import { createClient } from "@libsql/client";
8
- import { drizzle } from "drizzle-orm/libsql";
9
- //#region src/turso.ts
7
+ import { createRequire } from "node:module";
8
+ import * as drizzleLibsqlCore from "drizzle-orm/libsql/driver-core";
9
+ // src/turso.ts
10
10
  /**
11
11
  * Turso/libSQL preset for the SQLite database adapter.
12
12
  *
@@ -15,6 +15,7 @@ import { drizzle } from "drizzle-orm/libsql";
15
15
  * `wss://`, or embedded replica via `syncUrl`). Requires the optional
16
16
  * `@libsql/client` peer (`nub add @libsql/client`).
17
17
  */
18
+ const construct = drizzleLibsqlCore.construct;
18
19
  /**
19
20
  * Create a Turso/libSQL-backed DatabaseAdapter using Drizzle ORM.
20
21
  *
@@ -24,11 +25,11 @@ import { drizzle } from "drizzle-orm/libsql";
24
25
  */
25
26
  function createTursoDatabase(options) {
26
27
  const { client, owned } = resolveClient(options);
27
- const db = drizzle(client, { schema });
28
+ const db = construct(client, { schema });
28
29
  return createDrizzleAdapter(db, {
29
30
  metadata: {
30
31
  name: "Turso",
31
- version: globalThis.__PKG_VERSION__ ?? "0.0.0",
32
+ version: "0.8.0",
32
33
  description: "Turso/libSQL database adapter",
33
34
  kind: "turso",
34
35
  category: "database"
@@ -59,7 +60,7 @@ function resolveClient(options) {
59
60
  if (!url) throw new Error("createTursoDatabase: provide `url` (or `syncUrl` with a `file:` url) or a preconfigured `client`");
60
61
  if (!isSupportedUrl(url)) throw new Error(`createTursoDatabase: unsupported url "${url}" (expected libsql://, https://, wss://, file:, or :memory:)`);
61
62
  return {
62
- client: createClient({
63
+ client: createNodeClient({
63
64
  url,
64
65
  authToken: options.authToken,
65
66
  syncUrl: options.syncUrl,
@@ -68,10 +69,22 @@ function resolveClient(options) {
68
69
  owned: true
69
70
  };
70
71
  }
72
+ /**
73
+ * Load the default Node client only when a URL is used. Importing
74
+ * `@libsql/client` at module load pulls in its native addon, which makes a
75
+ * process that only injects a `sqlite3` client (tests, embedded replicas)
76
+ * crash on teardown under some Node versions.
77
+ */
78
+ let nodeCreateClient;
79
+ function createNodeClient(config) {
80
+ nodeCreateClient ??= createRequire(import.meta.url)("@libsql/client").createClient;
81
+ return nodeCreateClient(config);
82
+ }
71
83
  const WEBHOOK_SECRET_DROP = "ALTER TABLE webhooks DROP COLUMN secret";
72
84
  async function runMigrations(client) {
73
85
  await client.executeMultiple(DDL);
74
86
  await ensureColumns(client, DDL);
87
+ for (const statement of IDENTITY_STATEMENTS) await execIgnore(client, statement);
75
88
  await execIgnore(client, WEBHOOK_SECRET_DROP);
76
89
  await migrateCommentsTable(client);
77
90
  }
@@ -128,7 +141,6 @@ async function recreateCommentsTable(client) {
128
141
  await client.execute("CREATE INDEX IF NOT EXISTS comments_build_id_idx ON comments (build_id)");
129
142
  await client.execute("PRAGMA foreign_keys = ON");
130
143
  }
131
- //#endregion
132
144
  export { createTursoDatabase };
133
145
 
134
146
  //# sourceMappingURL=turso.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"turso.mjs","names":[],"sources":["../src/turso.ts"],"sourcesContent":["/**\n * Turso/libSQL preset for the SQLite database adapter.\n *\n * Same schema, DDL, and Drizzle factory as the `node:sqlite` default;\n * only the transport differs (`@libsql/client`: `file:`, `libsql://`,\n * `wss://`, or embedded replica via `syncUrl`). Requires the optional\n * `@libsql/client` peer (`nub add @libsql/client`).\n */\nimport { createClient } from \"@libsql/client\";\nimport type { DatabaseAdapter } from \"@storyshelf/core/adapter/database\";\nimport { drizzle } from \"drizzle-orm/libsql\";\nimport { DDL, tableColumns } from \"./ddl.ts\";\nimport { createDrizzleAdapter } from \"./drizzle-factory.ts\";\nimport { schema } from \"./schema/index.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\ntype LibsqlClient = ReturnType<typeof createClient>;\n\n/**\n * Options for creating a Turso-backed DatabaseAdapter.\n *\n * When `client` is supplied, all other connection options are ignored and\n * the caller owns the lifecycle of the client (teardown is a no-op). This\n * is the hook for embedded replicas with custom sync loops and hermetic\n * tests.\n */\nexport interface TursoDatabaseOptions {\n url?: string;\n authToken?: string;\n syncUrl?: string;\n syncInterval?: number;\n client?: LibsqlClient;\n}\n\n/**\n * Create a Turso/libSQL-backed DatabaseAdapter using Drizzle ORM.\n *\n * @param options - Either a connection `url` (plus `authToken`/`syncUrl`/\n * `syncInterval`) or a preconfigured libSQL `client`.\n * @returns A DatabaseAdapter backed by the Turso database.\n */\nexport function createTursoDatabase(options: TursoDatabaseOptions): DatabaseAdapter {\n const { client, owned } = resolveClient(options);\n const db = drizzle(client, { schema });\n\n return createDrizzleAdapter(db, {\n metadata: {\n name: \"Turso\",\n version: (globalThis as unknown as { __PKG_VERSION__?: string }).__PKG_VERSION__ ?? \"0.0.0\",\n description: \"Turso/libSQL database adapter\",\n kind: \"turso\",\n category: \"database\",\n },\n tables: schema,\n migrate: async () => {\n await runMigrations(client);\n },\n close: () => {\n if (owned) {\n client.close();\n }\n },\n ping: async () => {\n await client.execute(\"SELECT 1\");\n },\n });\n}\n\nconst SUPPORTED_URL = /^(?<proto>libsql|https?|wss?):\\/\\/|^file:|^:memory:/u;\n\nfunction isSupportedUrl(url: string): boolean {\n return SUPPORTED_URL.test(url);\n}\n\n/** Resolve the libSQL client, distinguishing caller-owned from owned. */\nfunction resolveClient(options: TursoDatabaseOptions): { client: LibsqlClient; owned: boolean } {\n if (options.client) {\n return { client: options.client, owned: false };\n }\n const url = options.url?.trim();\n if (!url) {\n throw new Error(\n \"createTursoDatabase: provide `url` (or `syncUrl` with a `file:` url) or a preconfigured `client`\",\n );\n }\n if (!isSupportedUrl(url)) {\n throw new Error(\n `createTursoDatabase: unsupported url \"${url}\" (expected libsql://, https://, wss://, file:, or :memory:)`,\n );\n }\n return {\n client: createClient({\n url,\n authToken: options.authToken,\n syncUrl: options.syncUrl,\n syncInterval: options.syncInterval,\n }),\n owned: true,\n };\n}\n\nconst WEBHOOK_SECRET_DROP = \"ALTER TABLE webhooks DROP COLUMN secret\";\n\nasync function runMigrations(client: LibsqlClient): Promise<void> {\n await client.executeMultiple(DDL);\n await ensureColumns(client, DDL);\n await execIgnore(client, WEBHOOK_SECRET_DROP);\n await migrateCommentsTable(client);\n}\n\n/** Add any DDL column missing from a volume created before it shipped. */\nasync function ensureColumns(client: LibsqlClient, ddl: string): Promise<void> {\n const inspected = await Promise.all(\n [...tableColumns(ddl)].map(async ([table, columns]) => {\n const result = await client.execute(`PRAGMA table_info(${table})`);\n const rows = result.rows as unknown as { name: unknown }[];\n const existing = new Set(rows.map((row) => String(row.name)));\n return { table, columns, existing };\n }),\n );\n const statements = inspected.flatMap(({ table, columns, existing }) =>\n columns\n .filter((column) => isMissing(column, existing))\n .map((column) => [table, column] as const),\n );\n await Promise.all(\n statements.map(async ([table, column]) => {\n await execIgnore(client, `ALTER TABLE ${table} ADD COLUMN ${column}`);\n }),\n );\n}\n\nfunction isMissing(column: string, existing: Set<string>): boolean {\n const [name] = column.split(/\\s+/u);\n return name !== undefined && !existing.has(name);\n}\n\nasync function execIgnore(client: LibsqlClient, sql: string): Promise<void> {\n try {\n await client.execute(sql);\n } catch {\n // idempotent — already migrated\n }\n}\n\nasync function migrateCommentsTable(client: LibsqlClient): Promise<void> {\n try {\n const result = await client.execute(\n \"SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'\",\n );\n const sql = (result.rows[0] as unknown as { sql: string } | undefined)?.sql;\n if (!sql?.includes(\"user_id TEXT NOT NULL REFERENCES users\")) {\n return;\n }\n await recreateCommentsTable(client);\n } catch {\n await execIgnore(client, \"PRAGMA foreign_keys = ON\");\n }\n}\n\nasync function recreateCommentsTable(client: LibsqlClient): Promise<void> {\n await client.execute(\"PRAGMA foreign_keys = OFF\");\n await client.execute(`\n CREATE TABLE comments_new (\n id TEXT PRIMARY KEY,\n project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,\n build_id TEXT NOT NULL REFERENCES builds(id) ON DELETE CASCADE,\n snapshot_id TEXT REFERENCES snapshots(id) ON DELETE CASCADE,\n user_id TEXT REFERENCES users(id) ON DELETE CASCADE,\n body TEXT NOT NULL,\n parent_id TEXT,\n resolved INTEGER NOT NULL DEFAULT 0,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL\n )\n `);\n await client.execute(\"INSERT INTO comments_new SELECT * FROM comments\");\n await client.execute(\"DROP TABLE comments\");\n await client.execute(\"ALTER TABLE comments_new RENAME TO comments\");\n await client.execute(\"CREATE INDEX IF NOT EXISTS comments_build_id_idx ON comments (build_id)\");\n await client.execute(\"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M,OAAO,QAAQ,0BAA0B;AACjD"}
1
+ {"version":3,"file":"turso.mjs","names":[],"sources":["../src/turso.ts"],"sourcesContent":["import type { Client } from \"@libsql/client\";\nimport type { DatabaseAdapter } from \"@storyshelf/core/adapter/database\";\nimport * as drizzleLibsqlCore from \"drizzle-orm/libsql/driver-core\";\n/**\n * Turso/libSQL preset for the SQLite database adapter.\n *\n * Same schema, DDL, and Drizzle factory as the `node:sqlite` default;\n * only the transport differs (`@libsql/client`: `file:`, `libsql://`,\n * `wss://`, or embedded replica via `syncUrl`). Requires the optional\n * `@libsql/client` peer (`nub add @libsql/client`).\n */\nimport { createRequire } from \"node:module\";\nimport { DDL, IDENTITY_STATEMENTS, tableColumns } from \"./ddl.ts\";\nimport { createDrizzleAdapter } from \"./drizzle-factory.ts\";\nimport { schema } from \"./schema/index.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\ntype LibsqlClient = Client;\ntype CreateClient = typeof import(\"@libsql/client\").createClient;\ntype Construct = (client: LibsqlClient, config: { schema: typeof schema }) => unknown;\n\n// `driver-core` exports `construct` at runtime but omits it from its typings.\nconst construct = (drizzleLibsqlCore as unknown as { construct: Construct }).construct;\n\n/**\n * Options for creating a Turso-backed DatabaseAdapter.\n *\n * When `client` is supplied, all other connection options are ignored and\n * the caller owns the lifecycle of the client (teardown is a no-op). This\n * is the hook for embedded replicas with custom sync loops and hermetic\n * tests.\n */\nexport interface TursoDatabaseOptions {\n url?: string;\n authToken?: string;\n syncUrl?: string;\n syncInterval?: number;\n client?: LibsqlClient;\n}\n\n/**\n * Create a Turso/libSQL-backed DatabaseAdapter using Drizzle ORM.\n *\n * @param options - Either a connection `url` (plus `authToken`/`syncUrl`/\n * `syncInterval`) or a preconfigured libSQL `client`.\n * @returns A DatabaseAdapter backed by the Turso database.\n */\nexport function createTursoDatabase(options: TursoDatabaseOptions): DatabaseAdapter {\n const { client, owned } = resolveClient(options);\n const db = construct(client, { schema });\n\n return createDrizzleAdapter(db, {\n metadata: {\n name: \"Turso\",\n version: typeof __PKG_VERSION__ === \"string\" ? __PKG_VERSION__ : \"0.0.0\",\n description: \"Turso/libSQL database adapter\",\n kind: \"turso\",\n category: \"database\",\n },\n tables: schema,\n migrate: async () => {\n await runMigrations(client);\n },\n close: () => {\n if (owned) {\n client.close();\n }\n },\n ping: async () => {\n await client.execute(\"SELECT 1\");\n },\n });\n}\n\nconst SUPPORTED_URL = /^(?<proto>libsql|https?|wss?):\\/\\/|^file:|^:memory:/u;\n\nfunction isSupportedUrl(url: string): boolean {\n return SUPPORTED_URL.test(url);\n}\n\n/** Resolve the libSQL client, distinguishing caller-owned from owned. */\nfunction resolveClient(options: TursoDatabaseOptions): { client: LibsqlClient; owned: boolean } {\n if (options.client) {\n return { client: options.client, owned: false };\n }\n const url = options.url?.trim();\n if (!url) {\n throw new Error(\n \"createTursoDatabase: provide `url` (or `syncUrl` with a `file:` url) or a preconfigured `client`\",\n );\n }\n if (!isSupportedUrl(url)) {\n throw new Error(\n `createTursoDatabase: unsupported url \"${url}\" (expected libsql://, https://, wss://, file:, or :memory:)`,\n );\n }\n return {\n client: createNodeClient({\n url,\n authToken: options.authToken,\n syncUrl: options.syncUrl,\n syncInterval: options.syncInterval,\n }),\n owned: true,\n };\n}\n\n/**\n * Load the default Node client only when a URL is used. Importing\n * `@libsql/client` at module load pulls in its native addon, which makes a\n * process that only injects a `sqlite3` client (tests, embedded replicas)\n * crash on teardown under some Node versions.\n */\nlet nodeCreateClient: CreateClient | undefined;\n\nfunction createNodeClient(config: Parameters<CreateClient>[0]): Client {\n nodeCreateClient ??= (\n createRequire(import.meta.url)(\"@libsql/client\") as { createClient: CreateClient }\n ).createClient;\n return nodeCreateClient(config);\n}\n\nconst WEBHOOK_SECRET_DROP = \"ALTER TABLE webhooks DROP COLUMN secret\";\n\nasync function runMigrations(client: LibsqlClient): Promise<void> {\n await client.executeMultiple(DDL);\n await ensureColumns(client, DDL);\n for (const statement of IDENTITY_STATEMENTS) {\n // oxlint-disable-next-line no-await-in-loop -- ordered: drop old indexes, then create new\n await execIgnore(client, statement);\n }\n await execIgnore(client, WEBHOOK_SECRET_DROP);\n await migrateCommentsTable(client);\n}\n\n/** Add any DDL column missing from a volume created before it shipped. */\nasync function ensureColumns(client: LibsqlClient, ddl: string): Promise<void> {\n const inspected = await Promise.all(\n [...tableColumns(ddl)].map(async ([table, columns]) => {\n const result = await client.execute(`PRAGMA table_info(${table})`);\n const rows = result.rows as unknown as { name: unknown }[];\n const existing = new Set(rows.map((row) => String(row.name)));\n return { table, columns, existing };\n }),\n );\n const statements = inspected.flatMap(({ table, columns, existing }) =>\n columns\n .filter((column) => isMissing(column, existing))\n .map((column) => [table, column] as const),\n );\n await Promise.all(\n statements.map(async ([table, column]) => {\n await execIgnore(client, `ALTER TABLE ${table} ADD COLUMN ${column}`);\n }),\n );\n}\n\nfunction isMissing(column: string, existing: Set<string>): boolean {\n const [name] = column.split(/\\s+/u);\n return name !== undefined && !existing.has(name);\n}\n\nasync function execIgnore(client: LibsqlClient, sql: string): Promise<void> {\n try {\n await client.execute(sql);\n } catch {\n // idempotent — already migrated\n }\n}\n\nasync function migrateCommentsTable(client: LibsqlClient): Promise<void> {\n try {\n const result = await client.execute(\n \"SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'\",\n );\n const sql = (result.rows[0] as unknown as { sql: string } | undefined)?.sql;\n if (!sql?.includes(\"user_id TEXT NOT NULL REFERENCES users\")) {\n return;\n }\n await recreateCommentsTable(client);\n } catch {\n await execIgnore(client, \"PRAGMA foreign_keys = ON\");\n }\n}\n\nasync function recreateCommentsTable(client: LibsqlClient): Promise<void> {\n await client.execute(\"PRAGMA foreign_keys = OFF\");\n await client.execute(`\n CREATE TABLE comments_new (\n id TEXT PRIMARY KEY,\n project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,\n build_id TEXT NOT NULL REFERENCES builds(id) ON DELETE CASCADE,\n snapshot_id TEXT REFERENCES snapshots(id) ON DELETE CASCADE,\n user_id TEXT REFERENCES users(id) ON DELETE CASCADE,\n body TEXT NOT NULL,\n parent_id TEXT,\n resolved INTEGER NOT NULL DEFAULT 0,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL\n )\n `);\n await client.execute(\"INSERT INTO comments_new SELECT * FROM comments\");\n await client.execute(\"DROP TABLE comments\");\n await client.execute(\"ALTER TABLE comments_new RENAME TO comments\");\n await client.execute(\"CREATE INDEX IF NOT EXISTS comments_build_id_idx ON comments (build_id)\");\n await client.execute(\"PRAGMA foreign_keys = ON\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAM,YAAa,kBAA0D;;;;;;;;AAyB7E,SAAgB,oBAAoB,SAAgD;CAClF,MAAM,EAAE,QAAQ,UAAU,cAAc,OAAO;CAC/C,MAAM,KAAK,UAAU,QAAQ,EAAE,OAAO,CAAC;CAEvC,OAAO,qBAAqB,IAAI;EAC9B,UAAU;GACR,MAAM;GACN,SAAA;GACA,aAAa;GACb,MAAM;GACN,UAAU;EACZ;EACA,QAAQ;EACR,SAAS,YAAY;GACnB,MAAM,cAAc,MAAM;EAC5B;EACA,aAAa;GACX,IAAI,OACF,OAAO,MAAM;EAEjB;EACA,MAAM,YAAY;GAChB,MAAM,OAAO,QAAQ,UAAU;EACjC;CACF,CAAC;AACH;AAEA,MAAM,gBAAgB;AAEtB,SAAS,eAAe,KAAsB;CAC5C,OAAO,cAAc,KAAK,GAAG;AAC/B;;AAGA,SAAS,cAAc,SAAyE;CAC9F,IAAI,QAAQ,QACV,OAAO;EAAE,QAAQ,QAAQ;EAAQ,OAAO;CAAM;CAEhD,MAAM,MAAM,QAAQ,KAAK,KAAK;CAC9B,IAAI,CAAC,KACH,MAAM,IAAI,MACR,kGACF;CAEF,IAAI,CAAC,eAAe,GAAG,GACrB,MAAM,IAAI,MACR,yCAAyC,IAAI,6DAC/C;CAEF,OAAO;EACL,QAAQ,iBAAiB;GACvB;GACA,WAAW,QAAQ;GACnB,SAAS,QAAQ;GACjB,cAA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AO,QAAQ,GAAG;CAC1B,QAAQ,CAER;AACF;AAEA,eAAe,qBAAqB,QAAqC;CACvE,IAAI;EAKF,IAAI,GADS,MAHQ,OAAO,QAC1B,sEACF,EAAA,CACoB,KAAK,EAAE,EAA6C,IAAA,EAC9D,SAAS,wCAAwC,GACzD;EAEF,MAAM,sBAAsB,MAAM;CACpC,QAAQ;EACN,MAAM,WAAW,QAAQ,0BAA0B;CACrD;AACF;AAEA,eAAe,sBAAsB,QAAqC;CACxE,MAAM,OAAO,QAAQ,2BAA2B;CAChD,MAAM,OAAO,QAAQ;;;;;;;;;;;;;GAapB;CACD,MAAM,OAAO,QAAQ,iDAAiD;CACtE,MAAM,OAAO,QAAQ,qBAAqB;CAC1C,MAAM,OAAO,QAAQ,6CAA6C;CAClE,MAAM,OAAO,QAAQ,yEAAyE;CAC9F,MAAM,OAAO,QAAQ,0BAA0B;AACjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyshelf/db-sqlite",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "description": "SQLite database adapter for StoryShelf (node:sqlite + Drizzle).",
5
5
  "keywords": [
6
6
  "database",
@@ -27,9 +27,6 @@
27
27
  "dist"
28
28
  ],
29
29
  "type": "module",
30
- "engines": {
31
- "node": ">=24"
32
- },
33
30
  "sideEffects": false,
34
31
  "types": "./dist/index.d.mts",
35
32
  "exports": {
@@ -90,8 +87,8 @@
90
87
  "prepublishOnly": "nub run build"
91
88
  },
92
89
  "dependencies": {
93
- "@storyshelf/core": "0.6.2",
94
- "drizzle-orm": "^0.44.0"
90
+ "@storyshelf/core": "0.8.0",
91
+ "drizzle-orm": "^0.45.4"
95
92
  },
96
93
  "devDependencies": {
97
94
  "@libsql/client": "^0.18.0",
@@ -103,7 +100,7 @@
103
100
  "oxlint-tsgolint": "^7.0.2001",
104
101
  "tsdown": "^0.22.14",
105
102
  "typescript": "^7.0.2",
106
- "vitest": "^5.0.0"
103
+ "vitest": "^5.0.5"
107
104
  },
108
105
  "peerDependencies": {
109
106
  "@libsql/client": "^0.18.0",
@@ -117,6 +114,9 @@
117
114
  "optional": true
118
115
  }
119
116
  },
117
+ "engines": {
118
+ "node": ">=24"
119
+ },
120
120
  "jsr": {
121
121
  "runtimeCompat": {
122
122
  "node": true,
@@ -1,20 +0,0 @@
1
- import "node:path";
2
- import "node:url";
3
- import.meta.url;
4
- import { projects } from "./project.mjs";
5
- import { sqliteTable, text } from "drizzle-orm/sqlite-core";
6
- //#region src/schema/status-config.ts
7
- /** Narrow `project_status_configs` table definition. */
8
- const projectStatusConfigs = sqliteTable("project_status_configs", {
9
- id: text("id").primaryKey(),
10
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
11
- provider: text("provider").notNull(),
12
- config: text("config").notNull(),
13
- tokenEncrypted: text("token_encrypted").notNull(),
14
- createdAt: text("created_at").notNull(),
15
- updatedAt: text("updated_at").notNull()
16
- });
17
- //#endregion
18
- export { projectStatusConfigs };
19
-
20
- //# sourceMappingURL=status-config.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-config.mjs","names":[],"sources":["../../src/schema/status-config.ts"],"sourcesContent":["import { sqliteTable, text } from \"drizzle-orm/sqlite-core\";\nimport { projects } from \"./project.ts\";\n\n/** Narrow `project_status_configs` table definition. */\nexport const projectStatusConfigs = sqliteTable(\"project_status_configs\", {\n id: text(\"id\").primaryKey(),\n projectId: text(\"project_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n provider: text(\"provider\").notNull(),\n config: text(\"config\").notNull(),\n tokenEncrypted: text(\"token_encrypted\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n});\n\n/** A project status-config row. */\nexport interface ProjectStatusConfig {\n id: string;\n projectId: string;\n provider: string;\n config: string;\n tokenEncrypted: string;\n createdAt: string;\n updatedAt: string;\n}\n"],"mappings":";;;;;;;AAIA,MAAa,uBAAuB,YAAY,0BAA0B;CACxE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,WAAW,KAAK,YAAY,CAAC,CAC1B,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,UAAU,KAAK,UAAU,CAAC,CAAC,QAAQ;CACnC,QAAQ,KAAK,QAAQ,CAAC,CAAC,QAAQ;CAC/B,gBAAgB,KAAK,iBAAiB,CAAC,CAAC,QAAQ;CAChD,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,CAAC"}