integrate-sdk 0.9.55 → 0.9.58

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 (63) hide show
  1. package/dist/adapters/index.js +2440 -31
  2. package/dist/adapters/solid-start.js +2440 -31
  3. package/dist/adapters/svelte-kit.js +2440 -31
  4. package/dist/ai/anthropic.d.ts.map +1 -1
  5. package/dist/ai/anthropic.js +11 -2
  6. package/dist/ai/google.d.ts.map +1 -1
  7. package/dist/ai/google.js +11 -2
  8. package/dist/ai/index.js +16 -7
  9. package/dist/ai/openai.d.ts.map +1 -1
  10. package/dist/ai/openai.js +11 -2
  11. package/dist/ai/utils.d.ts +21 -0
  12. package/dist/ai/utils.d.ts.map +1 -1
  13. package/dist/ai/utils.js +10 -0
  14. package/dist/ai/vercel-ai.d.ts.map +1 -1
  15. package/dist/ai/vercel-ai.js +10 -1
  16. package/dist/database/adapters/drizzle.d.ts +23 -0
  17. package/dist/database/adapters/drizzle.d.ts.map +1 -0
  18. package/dist/database/adapters/drizzle.js +646 -0
  19. package/dist/database/adapters/mongodb.d.ts +17 -0
  20. package/dist/database/adapters/mongodb.d.ts.map +1 -0
  21. package/dist/database/adapters/mongodb.js +643 -0
  22. package/dist/database/adapters/prisma.d.ts +18 -0
  23. package/dist/database/adapters/prisma.d.ts.map +1 -0
  24. package/dist/database/adapters/prisma.js +679 -0
  25. package/dist/database/index.d.ts +9 -0
  26. package/dist/database/index.d.ts.map +1 -0
  27. package/dist/database/index.js +1167 -0
  28. package/dist/index.js +77 -31
  29. package/dist/integrations.js +77 -31
  30. package/dist/server.js +3633 -42
  31. package/dist/src/ai/anthropic.d.ts.map +1 -1
  32. package/dist/src/ai/google.d.ts.map +1 -1
  33. package/dist/src/ai/openai.d.ts.map +1 -1
  34. package/dist/src/ai/utils.d.ts +21 -0
  35. package/dist/src/ai/utils.d.ts.map +1 -1
  36. package/dist/src/ai/vercel-ai.d.ts.map +1 -1
  37. package/dist/src/client.d.ts +4 -2
  38. package/dist/src/client.d.ts.map +1 -1
  39. package/dist/src/config/types.d.ts +44 -1
  40. package/dist/src/config/types.d.ts.map +1 -1
  41. package/dist/src/database/adapters/drizzle.d.ts +23 -0
  42. package/dist/src/database/adapters/drizzle.d.ts.map +1 -0
  43. package/dist/src/database/adapters/mongodb.d.ts +17 -0
  44. package/dist/src/database/adapters/mongodb.d.ts.map +1 -0
  45. package/dist/src/database/adapters/prisma.d.ts +18 -0
  46. package/dist/src/database/adapters/prisma.d.ts.map +1 -0
  47. package/dist/src/database/factory.d.ts +9 -0
  48. package/dist/src/database/factory.d.ts.map +1 -0
  49. package/dist/src/database/index.d.ts +9 -0
  50. package/dist/src/database/index.d.ts.map +1 -0
  51. package/dist/src/database/schemas/drizzle.d.ts +508 -0
  52. package/dist/src/database/schemas/drizzle.d.ts.map +1 -0
  53. package/dist/src/database/token-store.d.ts +28 -0
  54. package/dist/src/database/token-store.d.ts.map +1 -0
  55. package/dist/src/database/trigger-store.d.ts +23 -0
  56. package/dist/src/database/trigger-store.d.ts.map +1 -0
  57. package/dist/src/database/types.d.ts +132 -0
  58. package/dist/src/database/types.d.ts.map +1 -0
  59. package/dist/src/integrations/integration-docs-metadata.d.ts +40 -0
  60. package/dist/src/integrations/integration-docs-metadata.d.ts.map +1 -0
  61. package/dist/src/server.d.ts +4 -3
  62. package/dist/src/server.d.ts.map +1 -1
  63. package/package.json +32 -5
@@ -2729,6 +2729,27 @@ class HttpSessionTransport {
2729
2729
  // ../client.ts
2730
2730
  init_integration_summary();
2731
2731
  init_library_metadata();
2732
+
2733
+ // ../database/token-store.ts
2734
+ var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
2735
+ var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
2736
+ async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
2737
+ if (!context.userId || configuredIntegrationIds.length === 0) {
2738
+ return [];
2739
+ }
2740
+ const connected = [];
2741
+ await Promise.all(configuredIntegrationIds.map(async (provider) => {
2742
+ try {
2743
+ const token = await getProviderToken(provider, undefined, context);
2744
+ if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
2745
+ connected.push(provider);
2746
+ }
2747
+ } catch {}
2748
+ }));
2749
+ return connected.sort();
2750
+ }
2751
+
2752
+ // ../client.ts
2732
2753
  init_errors();
2733
2754
  init_logger();
2734
2755
 
@@ -4594,20 +4615,32 @@ class MCPClientBase {
4594
4615
  getEnabledTools() {
4595
4616
  return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
4596
4617
  }
4597
- async getEnabledToolsAsync() {
4598
- if (this.isConnected() && this.availableTools.size > 0) {
4599
- return this.getEnabledTools();
4618
+ async getEnabledToolsAsync(options) {
4619
+ const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
4620
+ if (targetIntegrationIds.size === 0) {
4621
+ return [];
4600
4622
  }
4601
- if (this.availableTools.size > 0) {
4602
- return this.getEnabledTools();
4623
+ const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
4624
+ const hasCompleteCache = () => {
4625
+ for (const integration of this.integrations) {
4626
+ if (!targetIntegrationIds.has(integration.id))
4627
+ continue;
4628
+ for (const toolName of integration.tools) {
4629
+ if (!this.enabledToolNames.has(toolName))
4630
+ continue;
4631
+ if (!this.availableTools.has(toolName))
4632
+ return false;
4633
+ }
4634
+ }
4635
+ return this.availableTools.size > 0;
4636
+ };
4637
+ if (this.availableTools.size > 0 && hasCompleteCache()) {
4638
+ return filterToTargets(this.getEnabledTools());
4603
4639
  }
4604
4640
  const tools = [];
4605
- const integrationIds = new Set;
4606
- for (const integration of this.integrations) {
4607
- integrationIds.add(integration.id);
4608
- }
4609
4641
  const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
4610
- const integrationToolsResults = await parallelWithLimit2(Array.from(integrationIds), async (integrationId) => {
4642
+ const concurrency = options?.fetchConcurrency ?? 8;
4643
+ const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
4611
4644
  try {
4612
4645
  const response = await this.callServerToolInternal("list_tools_by_integration", {
4613
4646
  integration: integrationId
@@ -4618,25 +4651,14 @@ class MCPClientBase {
4618
4651
  if (item.type === "text" && item.text) {
4619
4652
  try {
4620
4653
  const parsed = JSON.parse(item.text);
4621
- if (Array.isArray(parsed)) {
4622
- for (const tool of parsed) {
4623
- if (tool.name && tool.inputSchema) {
4624
- integrationTools.push({
4625
- name: tool.name,
4626
- description: tool.description,
4627
- inputSchema: tool.inputSchema
4628
- });
4629
- }
4630
- }
4631
- } else if (parsed.tools && Array.isArray(parsed.tools)) {
4632
- for (const tool of parsed.tools) {
4633
- if (tool.name && tool.inputSchema) {
4634
- integrationTools.push({
4635
- name: tool.name,
4636
- description: tool.description,
4637
- inputSchema: tool.inputSchema
4638
- });
4639
- }
4654
+ const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
4655
+ for (const tool of parsedTools) {
4656
+ if (tool.name && tool.inputSchema) {
4657
+ integrationTools.push({
4658
+ name: tool.name,
4659
+ description: tool.description,
4660
+ inputSchema: tool.inputSchema
4661
+ });
4640
4662
  }
4641
4663
  }
4642
4664
  } catch {}
@@ -4648,14 +4670,40 @@ class MCPClientBase {
4648
4670
  logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
4649
4671
  return [];
4650
4672
  }
4651
- }, 3);
4673
+ }, concurrency);
4652
4674
  for (const integrationTools of integrationToolsResults) {
4653
4675
  tools.push(...integrationTools);
4654
4676
  }
4655
4677
  for (const tool of tools) {
4656
4678
  this.availableTools.set(tool.name, tool);
4657
4679
  }
4658
- return tools.filter((tool) => this.enabledToolNames.has(tool.name));
4680
+ return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
4681
+ }
4682
+ async resolveTargetIntegrationIds(options) {
4683
+ const configuredIds = this.integrations.map((integration) => integration.id);
4684
+ const configuredSet = new Set(configuredIds);
4685
+ if (options?.integrationIds && options.integrationIds.length > 0) {
4686
+ return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
4687
+ }
4688
+ if (options?.connectedOnly && options.context?.userId) {
4689
+ const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
4690
+ return new Set(connected);
4691
+ }
4692
+ return configuredSet;
4693
+ }
4694
+ filterToolsToIntegrations(tools, integrationIds) {
4695
+ if (integrationIds.size === 0) {
4696
+ return [];
4697
+ }
4698
+ const allowedNames = new Set;
4699
+ for (const integration of this.integrations) {
4700
+ if (!integrationIds.has(integration.id))
4701
+ continue;
4702
+ for (const toolName of integration.tools) {
4703
+ allowedNames.add(toolName);
4704
+ }
4705
+ }
4706
+ return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
4659
4707
  }
4660
4708
  getOAuthConfig(integrationId) {
4661
4709
  const integration = this.integrations.find((p) => p.id === integrationId);
@@ -5535,7 +5583,2368 @@ var logger199 = createLogger("Zoho Writer");
5535
5583
  // ../integrations/zoho_sprints.ts
5536
5584
  init_logger();
5537
5585
  var logger200 = createLogger("Zoho Sprints");
5586
+ // ../../node_modules/drizzle-orm/entity.js
5587
+ var entityKind = Symbol.for("drizzle:entityKind");
5588
+ var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
5589
+ function is(value, type) {
5590
+ if (!value || typeof value !== "object") {
5591
+ return false;
5592
+ }
5593
+ if (value instanceof type) {
5594
+ return true;
5595
+ }
5596
+ if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
5597
+ throw new Error(`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
5598
+ }
5599
+ let cls = Object.getPrototypeOf(value).constructor;
5600
+ if (cls) {
5601
+ while (cls) {
5602
+ if (entityKind in cls && cls[entityKind] === type[entityKind]) {
5603
+ return true;
5604
+ }
5605
+ cls = Object.getPrototypeOf(cls);
5606
+ }
5607
+ }
5608
+ return false;
5609
+ }
5610
+
5611
+ // ../../node_modules/drizzle-orm/column.js
5612
+ class Column {
5613
+ constructor(table, config) {
5614
+ this.table = table;
5615
+ this.config = config;
5616
+ this.name = config.name;
5617
+ this.keyAsName = config.keyAsName;
5618
+ this.notNull = config.notNull;
5619
+ this.default = config.default;
5620
+ this.defaultFn = config.defaultFn;
5621
+ this.onUpdateFn = config.onUpdateFn;
5622
+ this.hasDefault = config.hasDefault;
5623
+ this.primary = config.primaryKey;
5624
+ this.isUnique = config.isUnique;
5625
+ this.uniqueName = config.uniqueName;
5626
+ this.uniqueType = config.uniqueType;
5627
+ this.dataType = config.dataType;
5628
+ this.columnType = config.columnType;
5629
+ this.generated = config.generated;
5630
+ this.generatedIdentity = config.generatedIdentity;
5631
+ }
5632
+ static [entityKind] = "Column";
5633
+ name;
5634
+ keyAsName;
5635
+ primary;
5636
+ notNull;
5637
+ default;
5638
+ defaultFn;
5639
+ onUpdateFn;
5640
+ hasDefault;
5641
+ isUnique;
5642
+ uniqueName;
5643
+ uniqueType;
5644
+ dataType;
5645
+ columnType;
5646
+ enumValues = undefined;
5647
+ generated = undefined;
5648
+ generatedIdentity = undefined;
5649
+ config;
5650
+ mapFromDriverValue(value) {
5651
+ return value;
5652
+ }
5653
+ mapToDriverValue(value) {
5654
+ return value;
5655
+ }
5656
+ shouldDisableInsert() {
5657
+ return this.config.generated !== undefined && this.config.generated.type !== "byDefault";
5658
+ }
5659
+ }
5660
+
5661
+ // ../../node_modules/drizzle-orm/column-builder.js
5662
+ class ColumnBuilder {
5663
+ static [entityKind] = "ColumnBuilder";
5664
+ config;
5665
+ constructor(name, dataType, columnType) {
5666
+ this.config = {
5667
+ name,
5668
+ keyAsName: name === "",
5669
+ notNull: false,
5670
+ default: undefined,
5671
+ hasDefault: false,
5672
+ primaryKey: false,
5673
+ isUnique: false,
5674
+ uniqueName: undefined,
5675
+ uniqueType: undefined,
5676
+ dataType,
5677
+ columnType,
5678
+ generated: undefined
5679
+ };
5680
+ }
5681
+ $type() {
5682
+ return this;
5683
+ }
5684
+ notNull() {
5685
+ this.config.notNull = true;
5686
+ return this;
5687
+ }
5688
+ default(value) {
5689
+ this.config.default = value;
5690
+ this.config.hasDefault = true;
5691
+ return this;
5692
+ }
5693
+ $defaultFn(fn) {
5694
+ this.config.defaultFn = fn;
5695
+ this.config.hasDefault = true;
5696
+ return this;
5697
+ }
5698
+ $default = this.$defaultFn;
5699
+ $onUpdateFn(fn) {
5700
+ this.config.onUpdateFn = fn;
5701
+ this.config.hasDefault = true;
5702
+ return this;
5703
+ }
5704
+ $onUpdate = this.$onUpdateFn;
5705
+ primaryKey() {
5706
+ this.config.primaryKey = true;
5707
+ this.config.notNull = true;
5708
+ return this;
5709
+ }
5710
+ setName(name) {
5711
+ if (this.config.name !== "")
5712
+ return;
5713
+ this.config.name = name;
5714
+ }
5715
+ }
5716
+
5717
+ // ../../node_modules/drizzle-orm/table.utils.js
5718
+ var TableName = Symbol.for("drizzle:Name");
5719
+
5720
+ // ../../node_modules/drizzle-orm/pg-core/foreign-keys.js
5721
+ class ForeignKeyBuilder {
5722
+ static [entityKind] = "PgForeignKeyBuilder";
5723
+ reference;
5724
+ _onUpdate = "no action";
5725
+ _onDelete = "no action";
5726
+ constructor(config, actions) {
5727
+ this.reference = () => {
5728
+ const { name, columns, foreignColumns } = config();
5729
+ return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
5730
+ };
5731
+ if (actions) {
5732
+ this._onUpdate = actions.onUpdate;
5733
+ this._onDelete = actions.onDelete;
5734
+ }
5735
+ }
5736
+ onUpdate(action) {
5737
+ this._onUpdate = action === undefined ? "no action" : action;
5738
+ return this;
5739
+ }
5740
+ onDelete(action) {
5741
+ this._onDelete = action === undefined ? "no action" : action;
5742
+ return this;
5743
+ }
5744
+ build(table) {
5745
+ return new ForeignKey(table, this);
5746
+ }
5747
+ }
5748
+
5749
+ class ForeignKey {
5750
+ constructor(table, builder) {
5751
+ this.table = table;
5752
+ this.reference = builder.reference;
5753
+ this.onUpdate = builder._onUpdate;
5754
+ this.onDelete = builder._onDelete;
5755
+ }
5756
+ static [entityKind] = "PgForeignKey";
5757
+ reference;
5758
+ onUpdate;
5759
+ onDelete;
5760
+ getName() {
5761
+ const { name, columns, foreignColumns } = this.reference();
5762
+ const columnNames = columns.map((column) => column.name);
5763
+ const foreignColumnNames = foreignColumns.map((column) => column.name);
5764
+ const chunks = [
5765
+ this.table[TableName],
5766
+ ...columnNames,
5767
+ foreignColumns[0].table[TableName],
5768
+ ...foreignColumnNames
5769
+ ];
5770
+ return name ?? `${chunks.join("_")}_fk`;
5771
+ }
5772
+ }
5773
+
5774
+ // ../../node_modules/drizzle-orm/tracing-utils.js
5775
+ function iife(fn, ...args) {
5776
+ return fn(...args);
5777
+ }
5778
+
5779
+ // ../../node_modules/drizzle-orm/pg-core/unique-constraint.js
5780
+ function uniqueKeyName(table, columns) {
5781
+ return `${table[TableName]}_${columns.join("_")}_unique`;
5782
+ }
5783
+
5784
+ // ../../node_modules/drizzle-orm/pg-core/utils/array.js
5785
+ function parsePgArrayValue(arrayString, startFrom, inQuotes) {
5786
+ for (let i = startFrom;i < arrayString.length; i++) {
5787
+ const char = arrayString[i];
5788
+ if (char === "\\") {
5789
+ i++;
5790
+ continue;
5791
+ }
5792
+ if (char === '"') {
5793
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
5794
+ }
5795
+ if (inQuotes) {
5796
+ continue;
5797
+ }
5798
+ if (char === "," || char === "}") {
5799
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
5800
+ }
5801
+ }
5802
+ return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
5803
+ }
5804
+ function parsePgNestedArray(arrayString, startFrom = 0) {
5805
+ const result = [];
5806
+ let i = startFrom;
5807
+ let lastCharIsComma = false;
5808
+ while (i < arrayString.length) {
5809
+ const char = arrayString[i];
5810
+ if (char === ",") {
5811
+ if (lastCharIsComma || i === startFrom) {
5812
+ result.push("");
5813
+ }
5814
+ lastCharIsComma = true;
5815
+ i++;
5816
+ continue;
5817
+ }
5818
+ lastCharIsComma = false;
5819
+ if (char === "\\") {
5820
+ i += 2;
5821
+ continue;
5822
+ }
5823
+ if (char === '"') {
5824
+ const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
5825
+ result.push(value2);
5826
+ i = startFrom2;
5827
+ continue;
5828
+ }
5829
+ if (char === "}") {
5830
+ return [result, i + 1];
5831
+ }
5832
+ if (char === "{") {
5833
+ const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
5834
+ result.push(value2);
5835
+ i = startFrom2;
5836
+ continue;
5837
+ }
5838
+ const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
5839
+ result.push(value);
5840
+ i = newStartFrom;
5841
+ }
5842
+ return [result, i];
5843
+ }
5844
+ function parsePgArray(arrayString) {
5845
+ const [result] = parsePgNestedArray(arrayString, 1);
5846
+ return result;
5847
+ }
5848
+ function makePgArray(array2) {
5849
+ return `{${array2.map((item) => {
5850
+ if (Array.isArray(item)) {
5851
+ return makePgArray(item);
5852
+ }
5853
+ if (typeof item === "string") {
5854
+ return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
5855
+ }
5856
+ return `${item}`;
5857
+ }).join(",")}}`;
5858
+ }
5859
+
5860
+ // ../../node_modules/drizzle-orm/pg-core/columns/common.js
5861
+ class PgColumnBuilder extends ColumnBuilder {
5862
+ foreignKeyConfigs = [];
5863
+ static [entityKind] = "PgColumnBuilder";
5864
+ array(size) {
5865
+ return new PgArrayBuilder(this.config.name, this, size);
5866
+ }
5867
+ references(ref, actions = {}) {
5868
+ this.foreignKeyConfigs.push({ ref, actions });
5869
+ return this;
5870
+ }
5871
+ unique(name, config) {
5872
+ this.config.isUnique = true;
5873
+ this.config.uniqueName = name;
5874
+ this.config.uniqueType = config?.nulls;
5875
+ return this;
5876
+ }
5877
+ generatedAlwaysAs(as) {
5878
+ this.config.generated = {
5879
+ as,
5880
+ type: "always",
5881
+ mode: "stored"
5882
+ };
5883
+ return this;
5884
+ }
5885
+ buildForeignKeys(column, table) {
5886
+ return this.foreignKeyConfigs.map(({ ref, actions }) => {
5887
+ return iife((ref2, actions2) => {
5888
+ const builder = new ForeignKeyBuilder(() => {
5889
+ const foreignColumn = ref2();
5890
+ return { columns: [column], foreignColumns: [foreignColumn] };
5891
+ });
5892
+ if (actions2.onUpdate) {
5893
+ builder.onUpdate(actions2.onUpdate);
5894
+ }
5895
+ if (actions2.onDelete) {
5896
+ builder.onDelete(actions2.onDelete);
5897
+ }
5898
+ return builder.build(table);
5899
+ }, ref, actions);
5900
+ });
5901
+ }
5902
+ buildExtraConfigColumn(table) {
5903
+ return new ExtraConfigColumn(table, this.config);
5904
+ }
5905
+ }
5906
+
5907
+ class PgColumn extends Column {
5908
+ constructor(table, config) {
5909
+ if (!config.uniqueName) {
5910
+ config.uniqueName = uniqueKeyName(table, [config.name]);
5911
+ }
5912
+ super(table, config);
5913
+ this.table = table;
5914
+ }
5915
+ static [entityKind] = "PgColumn";
5916
+ }
5917
+
5918
+ class ExtraConfigColumn extends PgColumn {
5919
+ static [entityKind] = "ExtraConfigColumn";
5920
+ getSQLType() {
5921
+ return this.getSQLType();
5922
+ }
5923
+ indexConfig = {
5924
+ order: this.config.order ?? "asc",
5925
+ nulls: this.config.nulls ?? "last",
5926
+ opClass: this.config.opClass
5927
+ };
5928
+ defaultConfig = {
5929
+ order: "asc",
5930
+ nulls: "last",
5931
+ opClass: undefined
5932
+ };
5933
+ asc() {
5934
+ this.indexConfig.order = "asc";
5935
+ return this;
5936
+ }
5937
+ desc() {
5938
+ this.indexConfig.order = "desc";
5939
+ return this;
5940
+ }
5941
+ nullsFirst() {
5942
+ this.indexConfig.nulls = "first";
5943
+ return this;
5944
+ }
5945
+ nullsLast() {
5946
+ this.indexConfig.nulls = "last";
5947
+ return this;
5948
+ }
5949
+ op(opClass) {
5950
+ this.indexConfig.opClass = opClass;
5951
+ return this;
5952
+ }
5953
+ }
5954
+
5955
+ class IndexedColumn {
5956
+ static [entityKind] = "IndexedColumn";
5957
+ constructor(name, keyAsName, type, indexConfig) {
5958
+ this.name = name;
5959
+ this.keyAsName = keyAsName;
5960
+ this.type = type;
5961
+ this.indexConfig = indexConfig;
5962
+ }
5963
+ name;
5964
+ keyAsName;
5965
+ type;
5966
+ indexConfig;
5967
+ }
5968
+
5969
+ class PgArrayBuilder extends PgColumnBuilder {
5970
+ static [entityKind] = "PgArrayBuilder";
5971
+ constructor(name, baseBuilder, size) {
5972
+ super(name, "array", "PgArray");
5973
+ this.config.baseBuilder = baseBuilder;
5974
+ this.config.size = size;
5975
+ }
5976
+ build(table) {
5977
+ const baseColumn = this.config.baseBuilder.build(table);
5978
+ return new PgArray(table, this.config, baseColumn);
5979
+ }
5980
+ }
5981
+
5982
+ class PgArray extends PgColumn {
5983
+ constructor(table, config, baseColumn, range) {
5984
+ super(table, config);
5985
+ this.baseColumn = baseColumn;
5986
+ this.range = range;
5987
+ this.size = config.size;
5988
+ }
5989
+ size;
5990
+ static [entityKind] = "PgArray";
5991
+ getSQLType() {
5992
+ return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
5993
+ }
5994
+ mapFromDriverValue(value) {
5995
+ if (typeof value === "string") {
5996
+ value = parsePgArray(value);
5997
+ }
5998
+ return value.map((v) => this.baseColumn.mapFromDriverValue(v));
5999
+ }
6000
+ mapToDriverValue(value, isNestedArray = false) {
6001
+ const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
6002
+ if (isNestedArray)
6003
+ return a;
6004
+ return makePgArray(a);
6005
+ }
6006
+ }
6007
+
6008
+ // ../../node_modules/drizzle-orm/pg-core/columns/enum.js
6009
+ class PgEnumObjectColumn extends PgColumn {
6010
+ static [entityKind] = "PgEnumObjectColumn";
6011
+ enum;
6012
+ enumValues = this.config.enum.enumValues;
6013
+ constructor(table, config) {
6014
+ super(table, config);
6015
+ this.enum = config.enum;
6016
+ }
6017
+ getSQLType() {
6018
+ return this.enum.enumName;
6019
+ }
6020
+ }
6021
+ var isPgEnumSym = Symbol.for("drizzle:isPgEnum");
6022
+ function isPgEnum(obj) {
6023
+ return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
6024
+ }
6025
+ class PgEnumColumn extends PgColumn {
6026
+ static [entityKind] = "PgEnumColumn";
6027
+ enum = this.config.enum;
6028
+ enumValues = this.config.enum.enumValues;
6029
+ constructor(table, config) {
6030
+ super(table, config);
6031
+ this.enum = config.enum;
6032
+ }
6033
+ getSQLType() {
6034
+ return this.enum.enumName;
6035
+ }
6036
+ }
6037
+
6038
+ // ../../node_modules/drizzle-orm/subquery.js
6039
+ class Subquery {
6040
+ static [entityKind] = "Subquery";
6041
+ constructor(sql, fields, alias, isWith = false, usedTables = []) {
6042
+ this._ = {
6043
+ brand: "Subquery",
6044
+ sql,
6045
+ selectedFields: fields,
6046
+ alias,
6047
+ isWith,
6048
+ usedTables
6049
+ };
6050
+ }
6051
+ }
6052
+
6053
+ // ../../node_modules/drizzle-orm/version.js
6054
+ var version = "0.44.7";
6055
+
6056
+ // ../../node_modules/drizzle-orm/tracing.js
6057
+ var otel;
6058
+ var rawTracer;
6059
+ var tracer = {
6060
+ startActiveSpan(name, fn) {
6061
+ if (!otel) {
6062
+ return fn();
6063
+ }
6064
+ if (!rawTracer) {
6065
+ rawTracer = otel.trace.getTracer("drizzle-orm", version);
6066
+ }
6067
+ return iife((otel2, rawTracer2) => rawTracer2.startActiveSpan(name, (span) => {
6068
+ try {
6069
+ return fn(span);
6070
+ } catch (e) {
6071
+ span.setStatus({
6072
+ code: otel2.SpanStatusCode.ERROR,
6073
+ message: e instanceof Error ? e.message : "Unknown error"
6074
+ });
6075
+ throw e;
6076
+ } finally {
6077
+ span.end();
6078
+ }
6079
+ }), otel, rawTracer);
6080
+ }
6081
+ };
6082
+
6083
+ // ../../node_modules/drizzle-orm/view-common.js
6084
+ var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
6085
+
6086
+ // ../../node_modules/drizzle-orm/table.js
6087
+ var Schema = Symbol.for("drizzle:Schema");
6088
+ var Columns = Symbol.for("drizzle:Columns");
6089
+ var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
6090
+ var OriginalName = Symbol.for("drizzle:OriginalName");
6091
+ var BaseName = Symbol.for("drizzle:BaseName");
6092
+ var IsAlias = Symbol.for("drizzle:IsAlias");
6093
+ var ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
6094
+ var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
6095
+
6096
+ class Table {
6097
+ static [entityKind] = "Table";
6098
+ static Symbol = {
6099
+ Name: TableName,
6100
+ Schema,
6101
+ OriginalName,
6102
+ Columns,
6103
+ ExtraConfigColumns,
6104
+ BaseName,
6105
+ IsAlias,
6106
+ ExtraConfigBuilder
6107
+ };
6108
+ [TableName];
6109
+ [OriginalName];
6110
+ [Schema];
6111
+ [Columns];
6112
+ [ExtraConfigColumns];
6113
+ [BaseName];
6114
+ [IsAlias] = false;
6115
+ [IsDrizzleTable] = true;
6116
+ [ExtraConfigBuilder] = undefined;
6117
+ constructor(name, schema, baseName) {
6118
+ this[TableName] = this[OriginalName] = name;
6119
+ this[Schema] = schema;
6120
+ this[BaseName] = baseName;
6121
+ }
6122
+ }
6123
+
6124
+ // ../../node_modules/drizzle-orm/sql/sql.js
6125
+ function isSQLWrapper(value) {
6126
+ return value !== null && value !== undefined && typeof value.getSQL === "function";
6127
+ }
6128
+ function mergeQueries(queries) {
6129
+ const result = { sql: "", params: [] };
6130
+ for (const query of queries) {
6131
+ result.sql += query.sql;
6132
+ result.params.push(...query.params);
6133
+ if (query.typings?.length) {
6134
+ if (!result.typings) {
6135
+ result.typings = [];
6136
+ }
6137
+ result.typings.push(...query.typings);
6138
+ }
6139
+ }
6140
+ return result;
6141
+ }
6142
+
6143
+ class StringChunk {
6144
+ static [entityKind] = "StringChunk";
6145
+ value;
6146
+ constructor(value) {
6147
+ this.value = Array.isArray(value) ? value : [value];
6148
+ }
6149
+ getSQL() {
6150
+ return new SQL([this]);
6151
+ }
6152
+ }
6153
+
6154
+ class SQL {
6155
+ constructor(queryChunks) {
6156
+ this.queryChunks = queryChunks;
6157
+ for (const chunk of queryChunks) {
6158
+ if (is(chunk, Table)) {
6159
+ const schemaName = chunk[Table.Symbol.Schema];
6160
+ this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
6161
+ }
6162
+ }
6163
+ }
6164
+ static [entityKind] = "SQL";
6165
+ decoder = noopDecoder;
6166
+ shouldInlineParams = false;
6167
+ usedTables = [];
6168
+ append(query) {
6169
+ this.queryChunks.push(...query.queryChunks);
6170
+ return this;
6171
+ }
6172
+ toQuery(config) {
6173
+ return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
6174
+ const query = this.buildQueryFromSourceParams(this.queryChunks, config);
6175
+ span?.setAttributes({
6176
+ "drizzle.query.text": query.sql,
6177
+ "drizzle.query.params": JSON.stringify(query.params)
6178
+ });
6179
+ return query;
6180
+ });
6181
+ }
6182
+ buildQueryFromSourceParams(chunks, _config) {
6183
+ const config = Object.assign({}, _config, {
6184
+ inlineParams: _config.inlineParams || this.shouldInlineParams,
6185
+ paramStartIndex: _config.paramStartIndex || { value: 0 }
6186
+ });
6187
+ const {
6188
+ casing,
6189
+ escapeName,
6190
+ escapeParam,
6191
+ prepareTyping,
6192
+ inlineParams,
6193
+ paramStartIndex
6194
+ } = config;
6195
+ return mergeQueries(chunks.map((chunk) => {
6196
+ if (is(chunk, StringChunk)) {
6197
+ return { sql: chunk.value.join(""), params: [] };
6198
+ }
6199
+ if (is(chunk, Name)) {
6200
+ return { sql: escapeName(chunk.value), params: [] };
6201
+ }
6202
+ if (chunk === undefined) {
6203
+ return { sql: "", params: [] };
6204
+ }
6205
+ if (Array.isArray(chunk)) {
6206
+ const result = [new StringChunk("(")];
6207
+ for (const [i, p] of chunk.entries()) {
6208
+ result.push(p);
6209
+ if (i < chunk.length - 1) {
6210
+ result.push(new StringChunk(", "));
6211
+ }
6212
+ }
6213
+ result.push(new StringChunk(")"));
6214
+ return this.buildQueryFromSourceParams(result, config);
6215
+ }
6216
+ if (is(chunk, SQL)) {
6217
+ return this.buildQueryFromSourceParams(chunk.queryChunks, {
6218
+ ...config,
6219
+ inlineParams: inlineParams || chunk.shouldInlineParams
6220
+ });
6221
+ }
6222
+ if (is(chunk, Table)) {
6223
+ const schemaName = chunk[Table.Symbol.Schema];
6224
+ const tableName = chunk[Table.Symbol.Name];
6225
+ return {
6226
+ sql: schemaName === undefined || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
6227
+ params: []
6228
+ };
6229
+ }
6230
+ if (is(chunk, Column)) {
6231
+ const columnName = casing.getColumnCasing(chunk);
6232
+ if (_config.invokeSource === "indexes") {
6233
+ return { sql: escapeName(columnName), params: [] };
6234
+ }
6235
+ const schemaName = chunk.table[Table.Symbol.Schema];
6236
+ return {
6237
+ sql: chunk.table[IsAlias] || schemaName === undefined ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
6238
+ params: []
6239
+ };
6240
+ }
6241
+ if (is(chunk, View)) {
6242
+ const schemaName = chunk[ViewBaseConfig].schema;
6243
+ const viewName = chunk[ViewBaseConfig].name;
6244
+ return {
6245
+ sql: schemaName === undefined || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
6246
+ params: []
6247
+ };
6248
+ }
6249
+ if (is(chunk, Param)) {
6250
+ if (is(chunk.value, Placeholder)) {
6251
+ return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
6252
+ }
6253
+ const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
6254
+ if (is(mappedValue, SQL)) {
6255
+ return this.buildQueryFromSourceParams([mappedValue], config);
6256
+ }
6257
+ if (inlineParams) {
6258
+ return { sql: this.mapInlineParam(mappedValue, config), params: [] };
6259
+ }
6260
+ let typings = ["none"];
6261
+ if (prepareTyping) {
6262
+ typings = [prepareTyping(chunk.encoder)];
6263
+ }
6264
+ return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
6265
+ }
6266
+ if (is(chunk, Placeholder)) {
6267
+ return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
6268
+ }
6269
+ if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== undefined) {
6270
+ return { sql: escapeName(chunk.fieldAlias), params: [] };
6271
+ }
6272
+ if (is(chunk, Subquery)) {
6273
+ if (chunk._.isWith) {
6274
+ return { sql: escapeName(chunk._.alias), params: [] };
6275
+ }
6276
+ return this.buildQueryFromSourceParams([
6277
+ new StringChunk("("),
6278
+ chunk._.sql,
6279
+ new StringChunk(") "),
6280
+ new Name(chunk._.alias)
6281
+ ], config);
6282
+ }
6283
+ if (isPgEnum(chunk)) {
6284
+ if (chunk.schema) {
6285
+ return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
6286
+ }
6287
+ return { sql: escapeName(chunk.enumName), params: [] };
6288
+ }
6289
+ if (isSQLWrapper(chunk)) {
6290
+ if (chunk.shouldOmitSQLParens?.()) {
6291
+ return this.buildQueryFromSourceParams([chunk.getSQL()], config);
6292
+ }
6293
+ return this.buildQueryFromSourceParams([
6294
+ new StringChunk("("),
6295
+ chunk.getSQL(),
6296
+ new StringChunk(")")
6297
+ ], config);
6298
+ }
6299
+ if (inlineParams) {
6300
+ return { sql: this.mapInlineParam(chunk, config), params: [] };
6301
+ }
6302
+ return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
6303
+ }));
6304
+ }
6305
+ mapInlineParam(chunk, { escapeString }) {
6306
+ if (chunk === null) {
6307
+ return "null";
6308
+ }
6309
+ if (typeof chunk === "number" || typeof chunk === "boolean") {
6310
+ return chunk.toString();
6311
+ }
6312
+ if (typeof chunk === "string") {
6313
+ return escapeString(chunk);
6314
+ }
6315
+ if (typeof chunk === "object") {
6316
+ const mappedValueAsString = chunk.toString();
6317
+ if (mappedValueAsString === "[object Object]") {
6318
+ return escapeString(JSON.stringify(chunk));
6319
+ }
6320
+ return escapeString(mappedValueAsString);
6321
+ }
6322
+ throw new Error("Unexpected param value: " + chunk);
6323
+ }
6324
+ getSQL() {
6325
+ return this;
6326
+ }
6327
+ as(alias) {
6328
+ if (alias === undefined) {
6329
+ return this;
6330
+ }
6331
+ return new SQL.Aliased(this, alias);
6332
+ }
6333
+ mapWith(decoder) {
6334
+ this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
6335
+ return this;
6336
+ }
6337
+ inlineParams() {
6338
+ this.shouldInlineParams = true;
6339
+ return this;
6340
+ }
6341
+ if(condition) {
6342
+ return condition ? this : undefined;
6343
+ }
6344
+ }
6345
+
6346
+ class Name {
6347
+ constructor(value) {
6348
+ this.value = value;
6349
+ }
6350
+ static [entityKind] = "Name";
6351
+ brand;
6352
+ getSQL() {
6353
+ return new SQL([this]);
6354
+ }
6355
+ }
6356
+ var noopDecoder = {
6357
+ mapFromDriverValue: (value) => value
6358
+ };
6359
+ var noopEncoder = {
6360
+ mapToDriverValue: (value) => value
6361
+ };
6362
+ var noopMapper = {
6363
+ ...noopDecoder,
6364
+ ...noopEncoder
6365
+ };
6366
+
6367
+ class Param {
6368
+ constructor(value, encoder = noopEncoder) {
6369
+ this.value = value;
6370
+ this.encoder = encoder;
6371
+ }
6372
+ static [entityKind] = "Param";
6373
+ brand;
6374
+ getSQL() {
6375
+ return new SQL([this]);
6376
+ }
6377
+ }
6378
+ function sql(strings, ...params) {
6379
+ const queryChunks = [];
6380
+ if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
6381
+ queryChunks.push(new StringChunk(strings[0]));
6382
+ }
6383
+ for (const [paramIndex, param2] of params.entries()) {
6384
+ queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
6385
+ }
6386
+ return new SQL(queryChunks);
6387
+ }
6388
+ ((sql2) => {
6389
+ function empty() {
6390
+ return new SQL([]);
6391
+ }
6392
+ sql2.empty = empty;
6393
+ function fromList(list) {
6394
+ return new SQL(list);
6395
+ }
6396
+ sql2.fromList = fromList;
6397
+ function raw(str) {
6398
+ return new SQL([new StringChunk(str)]);
6399
+ }
6400
+ sql2.raw = raw;
6401
+ function join(chunks, separator) {
6402
+ const result = [];
6403
+ for (const [i, chunk] of chunks.entries()) {
6404
+ if (i > 0 && separator !== undefined) {
6405
+ result.push(separator);
6406
+ }
6407
+ result.push(chunk);
6408
+ }
6409
+ return new SQL(result);
6410
+ }
6411
+ sql2.join = join;
6412
+ function identifier(value) {
6413
+ return new Name(value);
6414
+ }
6415
+ sql2.identifier = identifier;
6416
+ function placeholder2(name2) {
6417
+ return new Placeholder(name2);
6418
+ }
6419
+ sql2.placeholder = placeholder2;
6420
+ function param2(value, encoder) {
6421
+ return new Param(value, encoder);
6422
+ }
6423
+ sql2.param = param2;
6424
+ })(sql || (sql = {}));
6425
+ ((SQL2) => {
6426
+
6427
+ class Aliased {
6428
+ constructor(sql2, fieldAlias) {
6429
+ this.sql = sql2;
6430
+ this.fieldAlias = fieldAlias;
6431
+ }
6432
+ static [entityKind] = "SQL.Aliased";
6433
+ isSelectionField = false;
6434
+ getSQL() {
6435
+ return this.sql;
6436
+ }
6437
+ clone() {
6438
+ return new Aliased(this.sql, this.fieldAlias);
6439
+ }
6440
+ }
6441
+ SQL2.Aliased = Aliased;
6442
+ })(SQL || (SQL = {}));
6443
+
6444
+ class Placeholder {
6445
+ constructor(name2) {
6446
+ this.name = name2;
6447
+ }
6448
+ static [entityKind] = "Placeholder";
6449
+ getSQL() {
6450
+ return new SQL([this]);
6451
+ }
6452
+ }
6453
+ var IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
6454
+
6455
+ class View {
6456
+ static [entityKind] = "View";
6457
+ [ViewBaseConfig];
6458
+ [IsDrizzleView] = true;
6459
+ constructor({ name: name2, schema, selectedFields, query }) {
6460
+ this[ViewBaseConfig] = {
6461
+ name: name2,
6462
+ originalName: name2,
6463
+ schema,
6464
+ selectedFields,
6465
+ query,
6466
+ isExisting: !query,
6467
+ isAlias: false
6468
+ };
6469
+ }
6470
+ getSQL() {
6471
+ return new SQL([this]);
6472
+ }
6473
+ }
6474
+ Column.prototype.getSQL = function() {
6475
+ return new SQL([this]);
6476
+ };
6477
+ Table.prototype.getSQL = function() {
6478
+ return new SQL([this]);
6479
+ };
6480
+ Subquery.prototype.getSQL = function() {
6481
+ return new SQL([this]);
6482
+ };
5538
6483
 
6484
+ // ../../node_modules/drizzle-orm/utils.js
6485
+ function getColumnNameAndConfig(a, b) {
6486
+ return {
6487
+ name: typeof a === "string" && a.length > 0 ? a : "",
6488
+ config: typeof a === "object" ? a : b
6489
+ };
6490
+ }
6491
+ var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
6492
+
6493
+ // ../../node_modules/drizzle-orm/pg-core/columns/int.common.js
6494
+ class PgIntColumnBaseBuilder extends PgColumnBuilder {
6495
+ static [entityKind] = "PgIntColumnBaseBuilder";
6496
+ generatedAlwaysAsIdentity(sequence) {
6497
+ if (sequence) {
6498
+ const { name, ...options } = sequence;
6499
+ this.config.generatedIdentity = {
6500
+ type: "always",
6501
+ sequenceName: name,
6502
+ sequenceOptions: options
6503
+ };
6504
+ } else {
6505
+ this.config.generatedIdentity = {
6506
+ type: "always"
6507
+ };
6508
+ }
6509
+ this.config.hasDefault = true;
6510
+ this.config.notNull = true;
6511
+ return this;
6512
+ }
6513
+ generatedByDefaultAsIdentity(sequence) {
6514
+ if (sequence) {
6515
+ const { name, ...options } = sequence;
6516
+ this.config.generatedIdentity = {
6517
+ type: "byDefault",
6518
+ sequenceName: name,
6519
+ sequenceOptions: options
6520
+ };
6521
+ } else {
6522
+ this.config.generatedIdentity = {
6523
+ type: "byDefault"
6524
+ };
6525
+ }
6526
+ this.config.hasDefault = true;
6527
+ this.config.notNull = true;
6528
+ return this;
6529
+ }
6530
+ }
6531
+
6532
+ // ../../node_modules/drizzle-orm/pg-core/columns/bigint.js
6533
+ class PgBigInt53Builder extends PgIntColumnBaseBuilder {
6534
+ static [entityKind] = "PgBigInt53Builder";
6535
+ constructor(name) {
6536
+ super(name, "number", "PgBigInt53");
6537
+ }
6538
+ build(table) {
6539
+ return new PgBigInt53(table, this.config);
6540
+ }
6541
+ }
6542
+
6543
+ class PgBigInt53 extends PgColumn {
6544
+ static [entityKind] = "PgBigInt53";
6545
+ getSQLType() {
6546
+ return "bigint";
6547
+ }
6548
+ mapFromDriverValue(value) {
6549
+ if (typeof value === "number") {
6550
+ return value;
6551
+ }
6552
+ return Number(value);
6553
+ }
6554
+ }
6555
+
6556
+ class PgBigInt64Builder extends PgIntColumnBaseBuilder {
6557
+ static [entityKind] = "PgBigInt64Builder";
6558
+ constructor(name) {
6559
+ super(name, "bigint", "PgBigInt64");
6560
+ }
6561
+ build(table) {
6562
+ return new PgBigInt64(table, this.config);
6563
+ }
6564
+ }
6565
+
6566
+ class PgBigInt64 extends PgColumn {
6567
+ static [entityKind] = "PgBigInt64";
6568
+ getSQLType() {
6569
+ return "bigint";
6570
+ }
6571
+ mapFromDriverValue(value) {
6572
+ return BigInt(value);
6573
+ }
6574
+ }
6575
+ function bigint2(a, b) {
6576
+ const { name, config } = getColumnNameAndConfig(a, b);
6577
+ if (config.mode === "number") {
6578
+ return new PgBigInt53Builder(name);
6579
+ }
6580
+ return new PgBigInt64Builder(name);
6581
+ }
6582
+
6583
+ // ../../node_modules/drizzle-orm/pg-core/columns/bigserial.js
6584
+ class PgBigSerial53Builder extends PgColumnBuilder {
6585
+ static [entityKind] = "PgBigSerial53Builder";
6586
+ constructor(name) {
6587
+ super(name, "number", "PgBigSerial53");
6588
+ this.config.hasDefault = true;
6589
+ this.config.notNull = true;
6590
+ }
6591
+ build(table) {
6592
+ return new PgBigSerial53(table, this.config);
6593
+ }
6594
+ }
6595
+
6596
+ class PgBigSerial53 extends PgColumn {
6597
+ static [entityKind] = "PgBigSerial53";
6598
+ getSQLType() {
6599
+ return "bigserial";
6600
+ }
6601
+ mapFromDriverValue(value) {
6602
+ if (typeof value === "number") {
6603
+ return value;
6604
+ }
6605
+ return Number(value);
6606
+ }
6607
+ }
6608
+
6609
+ class PgBigSerial64Builder extends PgColumnBuilder {
6610
+ static [entityKind] = "PgBigSerial64Builder";
6611
+ constructor(name) {
6612
+ super(name, "bigint", "PgBigSerial64");
6613
+ this.config.hasDefault = true;
6614
+ }
6615
+ build(table) {
6616
+ return new PgBigSerial64(table, this.config);
6617
+ }
6618
+ }
6619
+
6620
+ class PgBigSerial64 extends PgColumn {
6621
+ static [entityKind] = "PgBigSerial64";
6622
+ getSQLType() {
6623
+ return "bigserial";
6624
+ }
6625
+ mapFromDriverValue(value) {
6626
+ return BigInt(value);
6627
+ }
6628
+ }
6629
+ function bigserial(a, b) {
6630
+ const { name, config } = getColumnNameAndConfig(a, b);
6631
+ if (config.mode === "number") {
6632
+ return new PgBigSerial53Builder(name);
6633
+ }
6634
+ return new PgBigSerial64Builder(name);
6635
+ }
6636
+
6637
+ // ../../node_modules/drizzle-orm/pg-core/columns/boolean.js
6638
+ class PgBooleanBuilder extends PgColumnBuilder {
6639
+ static [entityKind] = "PgBooleanBuilder";
6640
+ constructor(name) {
6641
+ super(name, "boolean", "PgBoolean");
6642
+ }
6643
+ build(table) {
6644
+ return new PgBoolean(table, this.config);
6645
+ }
6646
+ }
6647
+
6648
+ class PgBoolean extends PgColumn {
6649
+ static [entityKind] = "PgBoolean";
6650
+ getSQLType() {
6651
+ return "boolean";
6652
+ }
6653
+ }
6654
+ function boolean2(name) {
6655
+ return new PgBooleanBuilder(name ?? "");
6656
+ }
6657
+
6658
+ // ../../node_modules/drizzle-orm/pg-core/columns/char.js
6659
+ class PgCharBuilder extends PgColumnBuilder {
6660
+ static [entityKind] = "PgCharBuilder";
6661
+ constructor(name, config) {
6662
+ super(name, "string", "PgChar");
6663
+ this.config.length = config.length;
6664
+ this.config.enumValues = config.enum;
6665
+ }
6666
+ build(table) {
6667
+ return new PgChar(table, this.config);
6668
+ }
6669
+ }
6670
+
6671
+ class PgChar extends PgColumn {
6672
+ static [entityKind] = "PgChar";
6673
+ length = this.config.length;
6674
+ enumValues = this.config.enumValues;
6675
+ getSQLType() {
6676
+ return this.length === undefined ? `char` : `char(${this.length})`;
6677
+ }
6678
+ }
6679
+ function char(a, b = {}) {
6680
+ const { name, config } = getColumnNameAndConfig(a, b);
6681
+ return new PgCharBuilder(name, config);
6682
+ }
6683
+
6684
+ // ../../node_modules/drizzle-orm/pg-core/columns/cidr.js
6685
+ class PgCidrBuilder extends PgColumnBuilder {
6686
+ static [entityKind] = "PgCidrBuilder";
6687
+ constructor(name) {
6688
+ super(name, "string", "PgCidr");
6689
+ }
6690
+ build(table) {
6691
+ return new PgCidr(table, this.config);
6692
+ }
6693
+ }
6694
+
6695
+ class PgCidr extends PgColumn {
6696
+ static [entityKind] = "PgCidr";
6697
+ getSQLType() {
6698
+ return "cidr";
6699
+ }
6700
+ }
6701
+ function cidr(name) {
6702
+ return new PgCidrBuilder(name ?? "");
6703
+ }
6704
+
6705
+ // ../../node_modules/drizzle-orm/pg-core/columns/custom.js
6706
+ class PgCustomColumnBuilder extends PgColumnBuilder {
6707
+ static [entityKind] = "PgCustomColumnBuilder";
6708
+ constructor(name, fieldConfig, customTypeParams) {
6709
+ super(name, "custom", "PgCustomColumn");
6710
+ this.config.fieldConfig = fieldConfig;
6711
+ this.config.customTypeParams = customTypeParams;
6712
+ }
6713
+ build(table) {
6714
+ return new PgCustomColumn(table, this.config);
6715
+ }
6716
+ }
6717
+
6718
+ class PgCustomColumn extends PgColumn {
6719
+ static [entityKind] = "PgCustomColumn";
6720
+ sqlName;
6721
+ mapTo;
6722
+ mapFrom;
6723
+ constructor(table, config) {
6724
+ super(table, config);
6725
+ this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
6726
+ this.mapTo = config.customTypeParams.toDriver;
6727
+ this.mapFrom = config.customTypeParams.fromDriver;
6728
+ }
6729
+ getSQLType() {
6730
+ return this.sqlName;
6731
+ }
6732
+ mapFromDriverValue(value) {
6733
+ return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
6734
+ }
6735
+ mapToDriverValue(value) {
6736
+ return typeof this.mapTo === "function" ? this.mapTo(value) : value;
6737
+ }
6738
+ }
6739
+ function customType(customTypeParams) {
6740
+ return (a, b) => {
6741
+ const { name, config } = getColumnNameAndConfig(a, b);
6742
+ return new PgCustomColumnBuilder(name, config, customTypeParams);
6743
+ };
6744
+ }
6745
+
6746
+ // ../../node_modules/drizzle-orm/pg-core/columns/date.common.js
6747
+ class PgDateColumnBaseBuilder extends PgColumnBuilder {
6748
+ static [entityKind] = "PgDateColumnBaseBuilder";
6749
+ defaultNow() {
6750
+ return this.default(sql`now()`);
6751
+ }
6752
+ }
6753
+
6754
+ // ../../node_modules/drizzle-orm/pg-core/columns/date.js
6755
+ class PgDateBuilder extends PgDateColumnBaseBuilder {
6756
+ static [entityKind] = "PgDateBuilder";
6757
+ constructor(name) {
6758
+ super(name, "date", "PgDate");
6759
+ }
6760
+ build(table) {
6761
+ return new PgDate(table, this.config);
6762
+ }
6763
+ }
6764
+
6765
+ class PgDate extends PgColumn {
6766
+ static [entityKind] = "PgDate";
6767
+ getSQLType() {
6768
+ return "date";
6769
+ }
6770
+ mapFromDriverValue(value) {
6771
+ return new Date(value);
6772
+ }
6773
+ mapToDriverValue(value) {
6774
+ return value.toISOString();
6775
+ }
6776
+ }
6777
+
6778
+ class PgDateStringBuilder extends PgDateColumnBaseBuilder {
6779
+ static [entityKind] = "PgDateStringBuilder";
6780
+ constructor(name) {
6781
+ super(name, "string", "PgDateString");
6782
+ }
6783
+ build(table) {
6784
+ return new PgDateString(table, this.config);
6785
+ }
6786
+ }
6787
+
6788
+ class PgDateString extends PgColumn {
6789
+ static [entityKind] = "PgDateString";
6790
+ getSQLType() {
6791
+ return "date";
6792
+ }
6793
+ }
6794
+ function date2(a, b) {
6795
+ const { name, config } = getColumnNameAndConfig(a, b);
6796
+ if (config?.mode === "date") {
6797
+ return new PgDateBuilder(name);
6798
+ }
6799
+ return new PgDateStringBuilder(name);
6800
+ }
6801
+
6802
+ // ../../node_modules/drizzle-orm/pg-core/columns/double-precision.js
6803
+ class PgDoublePrecisionBuilder extends PgColumnBuilder {
6804
+ static [entityKind] = "PgDoublePrecisionBuilder";
6805
+ constructor(name) {
6806
+ super(name, "number", "PgDoublePrecision");
6807
+ }
6808
+ build(table) {
6809
+ return new PgDoublePrecision(table, this.config);
6810
+ }
6811
+ }
6812
+
6813
+ class PgDoublePrecision extends PgColumn {
6814
+ static [entityKind] = "PgDoublePrecision";
6815
+ getSQLType() {
6816
+ return "double precision";
6817
+ }
6818
+ mapFromDriverValue(value) {
6819
+ if (typeof value === "string") {
6820
+ return Number.parseFloat(value);
6821
+ }
6822
+ return value;
6823
+ }
6824
+ }
6825
+ function doublePrecision(name) {
6826
+ return new PgDoublePrecisionBuilder(name ?? "");
6827
+ }
6828
+
6829
+ // ../../node_modules/drizzle-orm/pg-core/columns/inet.js
6830
+ class PgInetBuilder extends PgColumnBuilder {
6831
+ static [entityKind] = "PgInetBuilder";
6832
+ constructor(name) {
6833
+ super(name, "string", "PgInet");
6834
+ }
6835
+ build(table) {
6836
+ return new PgInet(table, this.config);
6837
+ }
6838
+ }
6839
+
6840
+ class PgInet extends PgColumn {
6841
+ static [entityKind] = "PgInet";
6842
+ getSQLType() {
6843
+ return "inet";
6844
+ }
6845
+ }
6846
+ function inet(name) {
6847
+ return new PgInetBuilder(name ?? "");
6848
+ }
6849
+
6850
+ // ../../node_modules/drizzle-orm/pg-core/columns/integer.js
6851
+ class PgIntegerBuilder extends PgIntColumnBaseBuilder {
6852
+ static [entityKind] = "PgIntegerBuilder";
6853
+ constructor(name) {
6854
+ super(name, "number", "PgInteger");
6855
+ }
6856
+ build(table) {
6857
+ return new PgInteger(table, this.config);
6858
+ }
6859
+ }
6860
+
6861
+ class PgInteger extends PgColumn {
6862
+ static [entityKind] = "PgInteger";
6863
+ getSQLType() {
6864
+ return "integer";
6865
+ }
6866
+ mapFromDriverValue(value) {
6867
+ if (typeof value === "string") {
6868
+ return Number.parseInt(value);
6869
+ }
6870
+ return value;
6871
+ }
6872
+ }
6873
+ function integer(name) {
6874
+ return new PgIntegerBuilder(name ?? "");
6875
+ }
6876
+
6877
+ // ../../node_modules/drizzle-orm/pg-core/columns/interval.js
6878
+ class PgIntervalBuilder extends PgColumnBuilder {
6879
+ static [entityKind] = "PgIntervalBuilder";
6880
+ constructor(name, intervalConfig) {
6881
+ super(name, "string", "PgInterval");
6882
+ this.config.intervalConfig = intervalConfig;
6883
+ }
6884
+ build(table) {
6885
+ return new PgInterval(table, this.config);
6886
+ }
6887
+ }
6888
+
6889
+ class PgInterval extends PgColumn {
6890
+ static [entityKind] = "PgInterval";
6891
+ fields = this.config.intervalConfig.fields;
6892
+ precision = this.config.intervalConfig.precision;
6893
+ getSQLType() {
6894
+ const fields = this.fields ? ` ${this.fields}` : "";
6895
+ const precision = this.precision ? `(${this.precision})` : "";
6896
+ return `interval${fields}${precision}`;
6897
+ }
6898
+ }
6899
+ function interval(a, b = {}) {
6900
+ const { name, config } = getColumnNameAndConfig(a, b);
6901
+ return new PgIntervalBuilder(name, config);
6902
+ }
6903
+
6904
+ // ../../node_modules/drizzle-orm/pg-core/columns/json.js
6905
+ class PgJsonBuilder extends PgColumnBuilder {
6906
+ static [entityKind] = "PgJsonBuilder";
6907
+ constructor(name) {
6908
+ super(name, "json", "PgJson");
6909
+ }
6910
+ build(table) {
6911
+ return new PgJson(table, this.config);
6912
+ }
6913
+ }
6914
+
6915
+ class PgJson extends PgColumn {
6916
+ static [entityKind] = "PgJson";
6917
+ constructor(table, config) {
6918
+ super(table, config);
6919
+ }
6920
+ getSQLType() {
6921
+ return "json";
6922
+ }
6923
+ mapToDriverValue(value) {
6924
+ return JSON.stringify(value);
6925
+ }
6926
+ mapFromDriverValue(value) {
6927
+ if (typeof value === "string") {
6928
+ try {
6929
+ return JSON.parse(value);
6930
+ } catch {
6931
+ return value;
6932
+ }
6933
+ }
6934
+ return value;
6935
+ }
6936
+ }
6937
+ function json(name) {
6938
+ return new PgJsonBuilder(name ?? "");
6939
+ }
6940
+
6941
+ // ../../node_modules/drizzle-orm/pg-core/columns/jsonb.js
6942
+ class PgJsonbBuilder extends PgColumnBuilder {
6943
+ static [entityKind] = "PgJsonbBuilder";
6944
+ constructor(name) {
6945
+ super(name, "json", "PgJsonb");
6946
+ }
6947
+ build(table) {
6948
+ return new PgJsonb(table, this.config);
6949
+ }
6950
+ }
6951
+
6952
+ class PgJsonb extends PgColumn {
6953
+ static [entityKind] = "PgJsonb";
6954
+ constructor(table, config) {
6955
+ super(table, config);
6956
+ }
6957
+ getSQLType() {
6958
+ return "jsonb";
6959
+ }
6960
+ mapToDriverValue(value) {
6961
+ return JSON.stringify(value);
6962
+ }
6963
+ mapFromDriverValue(value) {
6964
+ if (typeof value === "string") {
6965
+ try {
6966
+ return JSON.parse(value);
6967
+ } catch {
6968
+ return value;
6969
+ }
6970
+ }
6971
+ return value;
6972
+ }
6973
+ }
6974
+ function jsonb(name) {
6975
+ return new PgJsonbBuilder(name ?? "");
6976
+ }
6977
+
6978
+ // ../../node_modules/drizzle-orm/pg-core/columns/line.js
6979
+ class PgLineBuilder extends PgColumnBuilder {
6980
+ static [entityKind] = "PgLineBuilder";
6981
+ constructor(name) {
6982
+ super(name, "array", "PgLine");
6983
+ }
6984
+ build(table) {
6985
+ return new PgLineTuple(table, this.config);
6986
+ }
6987
+ }
6988
+
6989
+ class PgLineTuple extends PgColumn {
6990
+ static [entityKind] = "PgLine";
6991
+ getSQLType() {
6992
+ return "line";
6993
+ }
6994
+ mapFromDriverValue(value) {
6995
+ const [a, b, c] = value.slice(1, -1).split(",");
6996
+ return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c)];
6997
+ }
6998
+ mapToDriverValue(value) {
6999
+ return `{${value[0]},${value[1]},${value[2]}}`;
7000
+ }
7001
+ }
7002
+
7003
+ class PgLineABCBuilder extends PgColumnBuilder {
7004
+ static [entityKind] = "PgLineABCBuilder";
7005
+ constructor(name) {
7006
+ super(name, "json", "PgLineABC");
7007
+ }
7008
+ build(table) {
7009
+ return new PgLineABC(table, this.config);
7010
+ }
7011
+ }
7012
+
7013
+ class PgLineABC extends PgColumn {
7014
+ static [entityKind] = "PgLineABC";
7015
+ getSQLType() {
7016
+ return "line";
7017
+ }
7018
+ mapFromDriverValue(value) {
7019
+ const [a, b, c] = value.slice(1, -1).split(",");
7020
+ return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c) };
7021
+ }
7022
+ mapToDriverValue(value) {
7023
+ return `{${value.a},${value.b},${value.c}}`;
7024
+ }
7025
+ }
7026
+ function line(a, b) {
7027
+ const { name, config } = getColumnNameAndConfig(a, b);
7028
+ if (!config?.mode || config.mode === "tuple") {
7029
+ return new PgLineBuilder(name);
7030
+ }
7031
+ return new PgLineABCBuilder(name);
7032
+ }
7033
+
7034
+ // ../../node_modules/drizzle-orm/pg-core/columns/macaddr.js
7035
+ class PgMacaddrBuilder extends PgColumnBuilder {
7036
+ static [entityKind] = "PgMacaddrBuilder";
7037
+ constructor(name) {
7038
+ super(name, "string", "PgMacaddr");
7039
+ }
7040
+ build(table) {
7041
+ return new PgMacaddr(table, this.config);
7042
+ }
7043
+ }
7044
+
7045
+ class PgMacaddr extends PgColumn {
7046
+ static [entityKind] = "PgMacaddr";
7047
+ getSQLType() {
7048
+ return "macaddr";
7049
+ }
7050
+ }
7051
+ function macaddr(name) {
7052
+ return new PgMacaddrBuilder(name ?? "");
7053
+ }
7054
+
7055
+ // ../../node_modules/drizzle-orm/pg-core/columns/macaddr8.js
7056
+ class PgMacaddr8Builder extends PgColumnBuilder {
7057
+ static [entityKind] = "PgMacaddr8Builder";
7058
+ constructor(name) {
7059
+ super(name, "string", "PgMacaddr8");
7060
+ }
7061
+ build(table) {
7062
+ return new PgMacaddr8(table, this.config);
7063
+ }
7064
+ }
7065
+
7066
+ class PgMacaddr8 extends PgColumn {
7067
+ static [entityKind] = "PgMacaddr8";
7068
+ getSQLType() {
7069
+ return "macaddr8";
7070
+ }
7071
+ }
7072
+ function macaddr8(name) {
7073
+ return new PgMacaddr8Builder(name ?? "");
7074
+ }
7075
+
7076
+ // ../../node_modules/drizzle-orm/pg-core/columns/numeric.js
7077
+ class PgNumericBuilder extends PgColumnBuilder {
7078
+ static [entityKind] = "PgNumericBuilder";
7079
+ constructor(name, precision, scale) {
7080
+ super(name, "string", "PgNumeric");
7081
+ this.config.precision = precision;
7082
+ this.config.scale = scale;
7083
+ }
7084
+ build(table) {
7085
+ return new PgNumeric(table, this.config);
7086
+ }
7087
+ }
7088
+
7089
+ class PgNumeric extends PgColumn {
7090
+ static [entityKind] = "PgNumeric";
7091
+ precision;
7092
+ scale;
7093
+ constructor(table, config) {
7094
+ super(table, config);
7095
+ this.precision = config.precision;
7096
+ this.scale = config.scale;
7097
+ }
7098
+ mapFromDriverValue(value) {
7099
+ if (typeof value === "string")
7100
+ return value;
7101
+ return String(value);
7102
+ }
7103
+ getSQLType() {
7104
+ if (this.precision !== undefined && this.scale !== undefined) {
7105
+ return `numeric(${this.precision}, ${this.scale})`;
7106
+ } else if (this.precision === undefined) {
7107
+ return "numeric";
7108
+ } else {
7109
+ return `numeric(${this.precision})`;
7110
+ }
7111
+ }
7112
+ }
7113
+
7114
+ class PgNumericNumberBuilder extends PgColumnBuilder {
7115
+ static [entityKind] = "PgNumericNumberBuilder";
7116
+ constructor(name, precision, scale) {
7117
+ super(name, "number", "PgNumericNumber");
7118
+ this.config.precision = precision;
7119
+ this.config.scale = scale;
7120
+ }
7121
+ build(table) {
7122
+ return new PgNumericNumber(table, this.config);
7123
+ }
7124
+ }
7125
+
7126
+ class PgNumericNumber extends PgColumn {
7127
+ static [entityKind] = "PgNumericNumber";
7128
+ precision;
7129
+ scale;
7130
+ constructor(table, config) {
7131
+ super(table, config);
7132
+ this.precision = config.precision;
7133
+ this.scale = config.scale;
7134
+ }
7135
+ mapFromDriverValue(value) {
7136
+ if (typeof value === "number")
7137
+ return value;
7138
+ return Number(value);
7139
+ }
7140
+ mapToDriverValue = String;
7141
+ getSQLType() {
7142
+ if (this.precision !== undefined && this.scale !== undefined) {
7143
+ return `numeric(${this.precision}, ${this.scale})`;
7144
+ } else if (this.precision === undefined) {
7145
+ return "numeric";
7146
+ } else {
7147
+ return `numeric(${this.precision})`;
7148
+ }
7149
+ }
7150
+ }
7151
+
7152
+ class PgNumericBigIntBuilder extends PgColumnBuilder {
7153
+ static [entityKind] = "PgNumericBigIntBuilder";
7154
+ constructor(name, precision, scale) {
7155
+ super(name, "bigint", "PgNumericBigInt");
7156
+ this.config.precision = precision;
7157
+ this.config.scale = scale;
7158
+ }
7159
+ build(table) {
7160
+ return new PgNumericBigInt(table, this.config);
7161
+ }
7162
+ }
7163
+
7164
+ class PgNumericBigInt extends PgColumn {
7165
+ static [entityKind] = "PgNumericBigInt";
7166
+ precision;
7167
+ scale;
7168
+ constructor(table, config) {
7169
+ super(table, config);
7170
+ this.precision = config.precision;
7171
+ this.scale = config.scale;
7172
+ }
7173
+ mapFromDriverValue = BigInt;
7174
+ mapToDriverValue = String;
7175
+ getSQLType() {
7176
+ if (this.precision !== undefined && this.scale !== undefined) {
7177
+ return `numeric(${this.precision}, ${this.scale})`;
7178
+ } else if (this.precision === undefined) {
7179
+ return "numeric";
7180
+ } else {
7181
+ return `numeric(${this.precision})`;
7182
+ }
7183
+ }
7184
+ }
7185
+ function numeric(a, b) {
7186
+ const { name, config } = getColumnNameAndConfig(a, b);
7187
+ const mode = config?.mode;
7188
+ return mode === "number" ? new PgNumericNumberBuilder(name, config?.precision, config?.scale) : mode === "bigint" ? new PgNumericBigIntBuilder(name, config?.precision, config?.scale) : new PgNumericBuilder(name, config?.precision, config?.scale);
7189
+ }
7190
+
7191
+ // ../../node_modules/drizzle-orm/pg-core/columns/point.js
7192
+ class PgPointTupleBuilder extends PgColumnBuilder {
7193
+ static [entityKind] = "PgPointTupleBuilder";
7194
+ constructor(name) {
7195
+ super(name, "array", "PgPointTuple");
7196
+ }
7197
+ build(table) {
7198
+ return new PgPointTuple(table, this.config);
7199
+ }
7200
+ }
7201
+
7202
+ class PgPointTuple extends PgColumn {
7203
+ static [entityKind] = "PgPointTuple";
7204
+ getSQLType() {
7205
+ return "point";
7206
+ }
7207
+ mapFromDriverValue(value) {
7208
+ if (typeof value === "string") {
7209
+ const [x, y] = value.slice(1, -1).split(",");
7210
+ return [Number.parseFloat(x), Number.parseFloat(y)];
7211
+ }
7212
+ return [value.x, value.y];
7213
+ }
7214
+ mapToDriverValue(value) {
7215
+ return `(${value[0]},${value[1]})`;
7216
+ }
7217
+ }
7218
+
7219
+ class PgPointObjectBuilder extends PgColumnBuilder {
7220
+ static [entityKind] = "PgPointObjectBuilder";
7221
+ constructor(name) {
7222
+ super(name, "json", "PgPointObject");
7223
+ }
7224
+ build(table) {
7225
+ return new PgPointObject(table, this.config);
7226
+ }
7227
+ }
7228
+
7229
+ class PgPointObject extends PgColumn {
7230
+ static [entityKind] = "PgPointObject";
7231
+ getSQLType() {
7232
+ return "point";
7233
+ }
7234
+ mapFromDriverValue(value) {
7235
+ if (typeof value === "string") {
7236
+ const [x, y] = value.slice(1, -1).split(",");
7237
+ return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
7238
+ }
7239
+ return value;
7240
+ }
7241
+ mapToDriverValue(value) {
7242
+ return `(${value.x},${value.y})`;
7243
+ }
7244
+ }
7245
+ function point(a, b) {
7246
+ const { name, config } = getColumnNameAndConfig(a, b);
7247
+ if (!config?.mode || config.mode === "tuple") {
7248
+ return new PgPointTupleBuilder(name);
7249
+ }
7250
+ return new PgPointObjectBuilder(name);
7251
+ }
7252
+
7253
+ // ../../node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
7254
+ function hexToBytes(hex) {
7255
+ const bytes = [];
7256
+ for (let c = 0;c < hex.length; c += 2) {
7257
+ bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
7258
+ }
7259
+ return new Uint8Array(bytes);
7260
+ }
7261
+ function bytesToFloat64(bytes, offset) {
7262
+ const buffer = new ArrayBuffer(8);
7263
+ const view = new DataView(buffer);
7264
+ for (let i = 0;i < 8; i++) {
7265
+ view.setUint8(i, bytes[offset + i]);
7266
+ }
7267
+ return view.getFloat64(0, true);
7268
+ }
7269
+ function parseEWKB(hex) {
7270
+ const bytes = hexToBytes(hex);
7271
+ let offset = 0;
7272
+ const byteOrder = bytes[offset];
7273
+ offset += 1;
7274
+ const view = new DataView(bytes.buffer);
7275
+ const geomType = view.getUint32(offset, byteOrder === 1);
7276
+ offset += 4;
7277
+ let _srid;
7278
+ if (geomType & 536870912) {
7279
+ _srid = view.getUint32(offset, byteOrder === 1);
7280
+ offset += 4;
7281
+ }
7282
+ if ((geomType & 65535) === 1) {
7283
+ const x = bytesToFloat64(bytes, offset);
7284
+ offset += 8;
7285
+ const y = bytesToFloat64(bytes, offset);
7286
+ offset += 8;
7287
+ return [x, y];
7288
+ }
7289
+ throw new Error("Unsupported geometry type");
7290
+ }
7291
+
7292
+ // ../../node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
7293
+ class PgGeometryBuilder extends PgColumnBuilder {
7294
+ static [entityKind] = "PgGeometryBuilder";
7295
+ constructor(name) {
7296
+ super(name, "array", "PgGeometry");
7297
+ }
7298
+ build(table) {
7299
+ return new PgGeometry(table, this.config);
7300
+ }
7301
+ }
7302
+
7303
+ class PgGeometry extends PgColumn {
7304
+ static [entityKind] = "PgGeometry";
7305
+ getSQLType() {
7306
+ return "geometry(point)";
7307
+ }
7308
+ mapFromDriverValue(value) {
7309
+ return parseEWKB(value);
7310
+ }
7311
+ mapToDriverValue(value) {
7312
+ return `point(${value[0]} ${value[1]})`;
7313
+ }
7314
+ }
7315
+
7316
+ class PgGeometryObjectBuilder extends PgColumnBuilder {
7317
+ static [entityKind] = "PgGeometryObjectBuilder";
7318
+ constructor(name) {
7319
+ super(name, "json", "PgGeometryObject");
7320
+ }
7321
+ build(table) {
7322
+ return new PgGeometryObject(table, this.config);
7323
+ }
7324
+ }
7325
+
7326
+ class PgGeometryObject extends PgColumn {
7327
+ static [entityKind] = "PgGeometryObject";
7328
+ getSQLType() {
7329
+ return "geometry(point)";
7330
+ }
7331
+ mapFromDriverValue(value) {
7332
+ const parsed = parseEWKB(value);
7333
+ return { x: parsed[0], y: parsed[1] };
7334
+ }
7335
+ mapToDriverValue(value) {
7336
+ return `point(${value.x} ${value.y})`;
7337
+ }
7338
+ }
7339
+ function geometry(a, b) {
7340
+ const { name, config } = getColumnNameAndConfig(a, b);
7341
+ if (!config?.mode || config.mode === "tuple") {
7342
+ return new PgGeometryBuilder(name);
7343
+ }
7344
+ return new PgGeometryObjectBuilder(name);
7345
+ }
7346
+
7347
+ // ../../node_modules/drizzle-orm/pg-core/columns/real.js
7348
+ class PgRealBuilder extends PgColumnBuilder {
7349
+ static [entityKind] = "PgRealBuilder";
7350
+ constructor(name, length) {
7351
+ super(name, "number", "PgReal");
7352
+ this.config.length = length;
7353
+ }
7354
+ build(table) {
7355
+ return new PgReal(table, this.config);
7356
+ }
7357
+ }
7358
+
7359
+ class PgReal extends PgColumn {
7360
+ static [entityKind] = "PgReal";
7361
+ constructor(table, config) {
7362
+ super(table, config);
7363
+ }
7364
+ getSQLType() {
7365
+ return "real";
7366
+ }
7367
+ mapFromDriverValue = (value) => {
7368
+ if (typeof value === "string") {
7369
+ return Number.parseFloat(value);
7370
+ }
7371
+ return value;
7372
+ };
7373
+ }
7374
+ function real(name) {
7375
+ return new PgRealBuilder(name ?? "");
7376
+ }
7377
+
7378
+ // ../../node_modules/drizzle-orm/pg-core/columns/serial.js
7379
+ class PgSerialBuilder extends PgColumnBuilder {
7380
+ static [entityKind] = "PgSerialBuilder";
7381
+ constructor(name) {
7382
+ super(name, "number", "PgSerial");
7383
+ this.config.hasDefault = true;
7384
+ this.config.notNull = true;
7385
+ }
7386
+ build(table) {
7387
+ return new PgSerial(table, this.config);
7388
+ }
7389
+ }
7390
+
7391
+ class PgSerial extends PgColumn {
7392
+ static [entityKind] = "PgSerial";
7393
+ getSQLType() {
7394
+ return "serial";
7395
+ }
7396
+ }
7397
+ function serial(name) {
7398
+ return new PgSerialBuilder(name ?? "");
7399
+ }
7400
+
7401
+ // ../../node_modules/drizzle-orm/pg-core/columns/smallint.js
7402
+ class PgSmallIntBuilder extends PgIntColumnBaseBuilder {
7403
+ static [entityKind] = "PgSmallIntBuilder";
7404
+ constructor(name) {
7405
+ super(name, "number", "PgSmallInt");
7406
+ }
7407
+ build(table) {
7408
+ return new PgSmallInt(table, this.config);
7409
+ }
7410
+ }
7411
+
7412
+ class PgSmallInt extends PgColumn {
7413
+ static [entityKind] = "PgSmallInt";
7414
+ getSQLType() {
7415
+ return "smallint";
7416
+ }
7417
+ mapFromDriverValue = (value) => {
7418
+ if (typeof value === "string") {
7419
+ return Number(value);
7420
+ }
7421
+ return value;
7422
+ };
7423
+ }
7424
+ function smallint(name) {
7425
+ return new PgSmallIntBuilder(name ?? "");
7426
+ }
7427
+
7428
+ // ../../node_modules/drizzle-orm/pg-core/columns/smallserial.js
7429
+ class PgSmallSerialBuilder extends PgColumnBuilder {
7430
+ static [entityKind] = "PgSmallSerialBuilder";
7431
+ constructor(name) {
7432
+ super(name, "number", "PgSmallSerial");
7433
+ this.config.hasDefault = true;
7434
+ this.config.notNull = true;
7435
+ }
7436
+ build(table) {
7437
+ return new PgSmallSerial(table, this.config);
7438
+ }
7439
+ }
7440
+
7441
+ class PgSmallSerial extends PgColumn {
7442
+ static [entityKind] = "PgSmallSerial";
7443
+ getSQLType() {
7444
+ return "smallserial";
7445
+ }
7446
+ }
7447
+ function smallserial(name) {
7448
+ return new PgSmallSerialBuilder(name ?? "");
7449
+ }
7450
+
7451
+ // ../../node_modules/drizzle-orm/pg-core/columns/text.js
7452
+ class PgTextBuilder extends PgColumnBuilder {
7453
+ static [entityKind] = "PgTextBuilder";
7454
+ constructor(name, config) {
7455
+ super(name, "string", "PgText");
7456
+ this.config.enumValues = config.enum;
7457
+ }
7458
+ build(table) {
7459
+ return new PgText(table, this.config);
7460
+ }
7461
+ }
7462
+
7463
+ class PgText extends PgColumn {
7464
+ static [entityKind] = "PgText";
7465
+ enumValues = this.config.enumValues;
7466
+ getSQLType() {
7467
+ return "text";
7468
+ }
7469
+ }
7470
+ function text(a, b = {}) {
7471
+ const { name, config } = getColumnNameAndConfig(a, b);
7472
+ return new PgTextBuilder(name, config);
7473
+ }
7474
+
7475
+ // ../../node_modules/drizzle-orm/pg-core/columns/time.js
7476
+ class PgTimeBuilder extends PgDateColumnBaseBuilder {
7477
+ constructor(name, withTimezone, precision) {
7478
+ super(name, "string", "PgTime");
7479
+ this.withTimezone = withTimezone;
7480
+ this.precision = precision;
7481
+ this.config.withTimezone = withTimezone;
7482
+ this.config.precision = precision;
7483
+ }
7484
+ static [entityKind] = "PgTimeBuilder";
7485
+ build(table) {
7486
+ return new PgTime(table, this.config);
7487
+ }
7488
+ }
7489
+
7490
+ class PgTime extends PgColumn {
7491
+ static [entityKind] = "PgTime";
7492
+ withTimezone;
7493
+ precision;
7494
+ constructor(table, config) {
7495
+ super(table, config);
7496
+ this.withTimezone = config.withTimezone;
7497
+ this.precision = config.precision;
7498
+ }
7499
+ getSQLType() {
7500
+ const precision = this.precision === undefined ? "" : `(${this.precision})`;
7501
+ return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
7502
+ }
7503
+ }
7504
+ function time(a, b = {}) {
7505
+ const { name, config } = getColumnNameAndConfig(a, b);
7506
+ return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
7507
+ }
7508
+
7509
+ // ../../node_modules/drizzle-orm/pg-core/columns/timestamp.js
7510
+ class PgTimestampBuilder extends PgDateColumnBaseBuilder {
7511
+ static [entityKind] = "PgTimestampBuilder";
7512
+ constructor(name, withTimezone, precision) {
7513
+ super(name, "date", "PgTimestamp");
7514
+ this.config.withTimezone = withTimezone;
7515
+ this.config.precision = precision;
7516
+ }
7517
+ build(table) {
7518
+ return new PgTimestamp(table, this.config);
7519
+ }
7520
+ }
7521
+
7522
+ class PgTimestamp extends PgColumn {
7523
+ static [entityKind] = "PgTimestamp";
7524
+ withTimezone;
7525
+ precision;
7526
+ constructor(table, config) {
7527
+ super(table, config);
7528
+ this.withTimezone = config.withTimezone;
7529
+ this.precision = config.precision;
7530
+ }
7531
+ getSQLType() {
7532
+ const precision = this.precision === undefined ? "" : ` (${this.precision})`;
7533
+ return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
7534
+ }
7535
+ mapFromDriverValue = (value) => {
7536
+ return new Date(this.withTimezone ? value : value + "+0000");
7537
+ };
7538
+ mapToDriverValue = (value) => {
7539
+ return value.toISOString();
7540
+ };
7541
+ }
7542
+
7543
+ class PgTimestampStringBuilder extends PgDateColumnBaseBuilder {
7544
+ static [entityKind] = "PgTimestampStringBuilder";
7545
+ constructor(name, withTimezone, precision) {
7546
+ super(name, "string", "PgTimestampString");
7547
+ this.config.withTimezone = withTimezone;
7548
+ this.config.precision = precision;
7549
+ }
7550
+ build(table) {
7551
+ return new PgTimestampString(table, this.config);
7552
+ }
7553
+ }
7554
+
7555
+ class PgTimestampString extends PgColumn {
7556
+ static [entityKind] = "PgTimestampString";
7557
+ withTimezone;
7558
+ precision;
7559
+ constructor(table, config) {
7560
+ super(table, config);
7561
+ this.withTimezone = config.withTimezone;
7562
+ this.precision = config.precision;
7563
+ }
7564
+ getSQLType() {
7565
+ const precision = this.precision === undefined ? "" : `(${this.precision})`;
7566
+ return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
7567
+ }
7568
+ }
7569
+ function timestamp(a, b = {}) {
7570
+ const { name, config } = getColumnNameAndConfig(a, b);
7571
+ if (config?.mode === "string") {
7572
+ return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
7573
+ }
7574
+ return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
7575
+ }
7576
+
7577
+ // ../../node_modules/drizzle-orm/pg-core/columns/uuid.js
7578
+ class PgUUIDBuilder extends PgColumnBuilder {
7579
+ static [entityKind] = "PgUUIDBuilder";
7580
+ constructor(name) {
7581
+ super(name, "string", "PgUUID");
7582
+ }
7583
+ defaultRandom() {
7584
+ return this.default(sql`gen_random_uuid()`);
7585
+ }
7586
+ build(table) {
7587
+ return new PgUUID(table, this.config);
7588
+ }
7589
+ }
7590
+
7591
+ class PgUUID extends PgColumn {
7592
+ static [entityKind] = "PgUUID";
7593
+ getSQLType() {
7594
+ return "uuid";
7595
+ }
7596
+ }
7597
+ function uuid(name) {
7598
+ return new PgUUIDBuilder(name ?? "");
7599
+ }
7600
+
7601
+ // ../../node_modules/drizzle-orm/pg-core/columns/varchar.js
7602
+ class PgVarcharBuilder extends PgColumnBuilder {
7603
+ static [entityKind] = "PgVarcharBuilder";
7604
+ constructor(name, config) {
7605
+ super(name, "string", "PgVarchar");
7606
+ this.config.length = config.length;
7607
+ this.config.enumValues = config.enum;
7608
+ }
7609
+ build(table) {
7610
+ return new PgVarchar(table, this.config);
7611
+ }
7612
+ }
7613
+
7614
+ class PgVarchar extends PgColumn {
7615
+ static [entityKind] = "PgVarchar";
7616
+ length = this.config.length;
7617
+ enumValues = this.config.enumValues;
7618
+ getSQLType() {
7619
+ return this.length === undefined ? `varchar` : `varchar(${this.length})`;
7620
+ }
7621
+ }
7622
+ function varchar(a, b = {}) {
7623
+ const { name, config } = getColumnNameAndConfig(a, b);
7624
+ return new PgVarcharBuilder(name, config);
7625
+ }
7626
+
7627
+ // ../../node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
7628
+ class PgBinaryVectorBuilder extends PgColumnBuilder {
7629
+ static [entityKind] = "PgBinaryVectorBuilder";
7630
+ constructor(name, config) {
7631
+ super(name, "string", "PgBinaryVector");
7632
+ this.config.dimensions = config.dimensions;
7633
+ }
7634
+ build(table) {
7635
+ return new PgBinaryVector(table, this.config);
7636
+ }
7637
+ }
7638
+
7639
+ class PgBinaryVector extends PgColumn {
7640
+ static [entityKind] = "PgBinaryVector";
7641
+ dimensions = this.config.dimensions;
7642
+ getSQLType() {
7643
+ return `bit(${this.dimensions})`;
7644
+ }
7645
+ }
7646
+ function bit(a, b) {
7647
+ const { name, config } = getColumnNameAndConfig(a, b);
7648
+ return new PgBinaryVectorBuilder(name, config);
7649
+ }
7650
+
7651
+ // ../../node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
7652
+ class PgHalfVectorBuilder extends PgColumnBuilder {
7653
+ static [entityKind] = "PgHalfVectorBuilder";
7654
+ constructor(name, config) {
7655
+ super(name, "array", "PgHalfVector");
7656
+ this.config.dimensions = config.dimensions;
7657
+ }
7658
+ build(table) {
7659
+ return new PgHalfVector(table, this.config);
7660
+ }
7661
+ }
7662
+
7663
+ class PgHalfVector extends PgColumn {
7664
+ static [entityKind] = "PgHalfVector";
7665
+ dimensions = this.config.dimensions;
7666
+ getSQLType() {
7667
+ return `halfvec(${this.dimensions})`;
7668
+ }
7669
+ mapToDriverValue(value) {
7670
+ return JSON.stringify(value);
7671
+ }
7672
+ mapFromDriverValue(value) {
7673
+ return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
7674
+ }
7675
+ }
7676
+ function halfvec(a, b) {
7677
+ const { name, config } = getColumnNameAndConfig(a, b);
7678
+ return new PgHalfVectorBuilder(name, config);
7679
+ }
7680
+
7681
+ // ../../node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
7682
+ class PgSparseVectorBuilder extends PgColumnBuilder {
7683
+ static [entityKind] = "PgSparseVectorBuilder";
7684
+ constructor(name, config) {
7685
+ super(name, "string", "PgSparseVector");
7686
+ this.config.dimensions = config.dimensions;
7687
+ }
7688
+ build(table) {
7689
+ return new PgSparseVector(table, this.config);
7690
+ }
7691
+ }
7692
+
7693
+ class PgSparseVector extends PgColumn {
7694
+ static [entityKind] = "PgSparseVector";
7695
+ dimensions = this.config.dimensions;
7696
+ getSQLType() {
7697
+ return `sparsevec(${this.dimensions})`;
7698
+ }
7699
+ }
7700
+ function sparsevec(a, b) {
7701
+ const { name, config } = getColumnNameAndConfig(a, b);
7702
+ return new PgSparseVectorBuilder(name, config);
7703
+ }
7704
+
7705
+ // ../../node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
7706
+ class PgVectorBuilder extends PgColumnBuilder {
7707
+ static [entityKind] = "PgVectorBuilder";
7708
+ constructor(name, config) {
7709
+ super(name, "array", "PgVector");
7710
+ this.config.dimensions = config.dimensions;
7711
+ }
7712
+ build(table) {
7713
+ return new PgVector(table, this.config);
7714
+ }
7715
+ }
7716
+
7717
+ class PgVector extends PgColumn {
7718
+ static [entityKind] = "PgVector";
7719
+ dimensions = this.config.dimensions;
7720
+ getSQLType() {
7721
+ return `vector(${this.dimensions})`;
7722
+ }
7723
+ mapToDriverValue(value) {
7724
+ return JSON.stringify(value);
7725
+ }
7726
+ mapFromDriverValue(value) {
7727
+ return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
7728
+ }
7729
+ }
7730
+ function vector(a, b) {
7731
+ const { name, config } = getColumnNameAndConfig(a, b);
7732
+ return new PgVectorBuilder(name, config);
7733
+ }
7734
+
7735
+ // ../../node_modules/drizzle-orm/pg-core/columns/all.js
7736
+ function getPgColumnBuilders() {
7737
+ return {
7738
+ bigint: bigint2,
7739
+ bigserial,
7740
+ boolean: boolean2,
7741
+ char,
7742
+ cidr,
7743
+ customType,
7744
+ date: date2,
7745
+ doublePrecision,
7746
+ inet,
7747
+ integer,
7748
+ interval,
7749
+ json,
7750
+ jsonb,
7751
+ line,
7752
+ macaddr,
7753
+ macaddr8,
7754
+ numeric,
7755
+ point,
7756
+ geometry,
7757
+ real,
7758
+ serial,
7759
+ smallint,
7760
+ smallserial,
7761
+ text,
7762
+ time,
7763
+ timestamp,
7764
+ uuid,
7765
+ varchar,
7766
+ bit,
7767
+ halfvec,
7768
+ sparsevec,
7769
+ vector
7770
+ };
7771
+ }
7772
+
7773
+ // ../../node_modules/drizzle-orm/pg-core/table.js
7774
+ var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
7775
+ var EnableRLS = Symbol.for("drizzle:EnableRLS");
7776
+
7777
+ class PgTable extends Table {
7778
+ static [entityKind] = "PgTable";
7779
+ static Symbol = Object.assign({}, Table.Symbol, {
7780
+ InlineForeignKeys,
7781
+ EnableRLS
7782
+ });
7783
+ [InlineForeignKeys] = [];
7784
+ [EnableRLS] = false;
7785
+ [Table.Symbol.ExtraConfigBuilder] = undefined;
7786
+ [Table.Symbol.ExtraConfigColumns] = {};
7787
+ }
7788
+ function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
7789
+ const rawTable = new PgTable(name, schema, baseName);
7790
+ const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
7791
+ const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
7792
+ const colBuilder = colBuilderBase;
7793
+ colBuilder.setName(name2);
7794
+ const column = colBuilder.build(rawTable);
7795
+ rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
7796
+ return [name2, column];
7797
+ }));
7798
+ const builtColumnsForExtraConfig = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
7799
+ const colBuilder = colBuilderBase;
7800
+ colBuilder.setName(name2);
7801
+ const column = colBuilder.buildExtraConfigColumn(rawTable);
7802
+ return [name2, column];
7803
+ }));
7804
+ const table = Object.assign(rawTable, builtColumns);
7805
+ table[Table.Symbol.Columns] = builtColumns;
7806
+ table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
7807
+ if (extraConfig) {
7808
+ table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
7809
+ }
7810
+ return Object.assign(table, {
7811
+ enableRLS: () => {
7812
+ table[PgTable.Symbol.EnableRLS] = true;
7813
+ return table;
7814
+ }
7815
+ });
7816
+ }
7817
+ var pgTable = (name, columns, extraConfig) => {
7818
+ return pgTableWithSchema(name, columns, extraConfig, undefined);
7819
+ };
7820
+ // ../../node_modules/drizzle-orm/pg-core/indexes.js
7821
+ class IndexBuilderOn {
7822
+ constructor(unique, name) {
7823
+ this.unique = unique;
7824
+ this.name = name;
7825
+ }
7826
+ static [entityKind] = "PgIndexBuilderOn";
7827
+ on(...columns) {
7828
+ return new IndexBuilder(columns.map((it) => {
7829
+ if (is(it, SQL)) {
7830
+ return it;
7831
+ }
7832
+ it = it;
7833
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
7834
+ it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
7835
+ return clonedIndexedColumn;
7836
+ }), this.unique, false, this.name);
7837
+ }
7838
+ onOnly(...columns) {
7839
+ return new IndexBuilder(columns.map((it) => {
7840
+ if (is(it, SQL)) {
7841
+ return it;
7842
+ }
7843
+ it = it;
7844
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
7845
+ it.indexConfig = it.defaultConfig;
7846
+ return clonedIndexedColumn;
7847
+ }), this.unique, true, this.name);
7848
+ }
7849
+ using(method, ...columns) {
7850
+ return new IndexBuilder(columns.map((it) => {
7851
+ if (is(it, SQL)) {
7852
+ return it;
7853
+ }
7854
+ it = it;
7855
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
7856
+ it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
7857
+ return clonedIndexedColumn;
7858
+ }), this.unique, true, this.name, method);
7859
+ }
7860
+ }
7861
+
7862
+ class IndexBuilder {
7863
+ static [entityKind] = "PgIndexBuilder";
7864
+ config;
7865
+ constructor(columns, unique, only, name, method = "btree") {
7866
+ this.config = {
7867
+ name,
7868
+ columns,
7869
+ unique,
7870
+ only,
7871
+ method
7872
+ };
7873
+ }
7874
+ concurrently() {
7875
+ this.config.concurrently = true;
7876
+ return this;
7877
+ }
7878
+ with(obj) {
7879
+ this.config.with = obj;
7880
+ return this;
7881
+ }
7882
+ where(condition) {
7883
+ this.config.where = condition;
7884
+ return this;
7885
+ }
7886
+ build(table) {
7887
+ return new Index(this.config, table);
7888
+ }
7889
+ }
7890
+
7891
+ class Index {
7892
+ static [entityKind] = "PgIndex";
7893
+ config;
7894
+ constructor(config, table) {
7895
+ this.config = { ...config, table };
7896
+ }
7897
+ }
7898
+ function index(name) {
7899
+ return new IndexBuilderOn(false, name);
7900
+ }
7901
+ function uniqueIndex(name) {
7902
+ return new IndexBuilderOn(true, name);
7903
+ }
7904
+
7905
+ // ../database/schemas/drizzle.ts
7906
+ var integrateProviderToken = pgTable("provider_token", {
7907
+ id: text("id").primaryKey(),
7908
+ userId: text("user_id").notNull(),
7909
+ provider: text("provider").notNull(),
7910
+ accountEmail: text("account_email"),
7911
+ accountId: text("account_id"),
7912
+ accessToken: text("access_token").notNull(),
7913
+ refreshToken: text("refresh_token"),
7914
+ tokenType: text("token_type").notNull().default("Bearer"),
7915
+ expiresAt: timestamp("expires_at"),
7916
+ scope: text("scope"),
7917
+ createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
7918
+ updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
7919
+ }, (table) => [
7920
+ index("provider_token_user_id_idx").on(table.userId),
7921
+ index("provider_token_provider_idx").on(table.provider),
7922
+ index("provider_token_user_provider_idx").on(table.userId, table.provider),
7923
+ uniqueIndex("provider_token_user_provider_account_email_uidx").on(table.userId, table.provider, table.accountEmail)
7924
+ ]);
7925
+ var integrateTrigger = pgTable("trigger", {
7926
+ id: text("id").primaryKey(),
7927
+ userId: text("user_id"),
7928
+ name: text("name"),
7929
+ description: text("description"),
7930
+ toolName: text("tool_name").notNull(),
7931
+ toolArguments: jsonb("tool_arguments").notNull(),
7932
+ scheduleType: text("schedule_type").notNull(),
7933
+ scheduleValue: text("schedule_value").notNull(),
7934
+ status: text("status").notNull().default("active"),
7935
+ provider: text("provider"),
7936
+ lastRunAt: timestamp("last_run_at", { mode: "date", precision: 3 }),
7937
+ nextRunAt: timestamp("next_run_at", { mode: "date", precision: 3 }),
7938
+ runCount: integer("run_count").notNull().default(0),
7939
+ lastError: text("last_error"),
7940
+ lastResult: jsonb("last_result"),
7941
+ createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
7942
+ updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
7943
+ }, (table) => [
7944
+ index("trigger_user_id_idx").on(table.userId),
7945
+ index("trigger_status_idx").on(table.status),
7946
+ index("trigger_next_run_at_idx").on(table.nextRunAt)
7947
+ ]);
5539
7948
  // ../server.ts
5540
7949
  var SERVER_LOG_CONTEXT3 = "server";
5541
7950
  var logger201 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);