Text Generation
Transformers
Safetensors
GGUF
English
code
code-generation
multimodal
llama
conversational
Instructions to use mrsandip/Alfa-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrsandip/Alfa-Code with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrsandip/Alfa-Code")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrsandip/Alfa-Code", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mrsandip/Alfa-Code with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf mrsandip/Alfa-Code:Q4_0
Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use mrsandip/Alfa-Code with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrsandip/Alfa-Code" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- SGLang
How to use mrsandip/Alfa-Code with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mrsandip/Alfa-Code with Ollama:
ollama run hf.co/mrsandip/Alfa-Code:Q4_0
- Unsloth Desktop
- Docker Model Runner
How to use mrsandip/Alfa-Code with Docker Model Runner:
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Lemonade
How to use mrsandip/Alfa-Code with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mrsandip/Alfa-Code:Q4_0
Run and chat with the model
lemonade run user.Alfa-Code-Q4_0
List all available models
lemonade list
- Atomic Chat
Update (part 12)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.js +690 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.cjs +17 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.cts +129 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.ts +129 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.js +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.cjs +204 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.d.cts +151 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.d.ts +151 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.js +183 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.cjs +233 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.d.cts +107 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.d.ts +107 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.js +206 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/session.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.cjs +17 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.d.cts +18 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.d.ts +18 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.js +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.cjs +79 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.d.cts +92 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.d.ts +92 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.js +52 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/table.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.cjs +81 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.d.cts +23 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.d.ts +23 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.js +53 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.cjs +97 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.d.cts +30 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.d.ts +30 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.js +71 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/utils.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.cjs +33 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.d.cts +9 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.d.ts +9 -0
- e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.js +9 -0
.gitattributes
CHANGED
|
@@ -83,3 +83,5 @@ e-commerce/node_modules/@parcel/watcher-linux-x64-glibc/watcher.node filter=lfs
|
|
| 83 |
e-commerce/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 84 |
e-commerce/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 85 |
e-commerce/node_modules/@typescript/typescript-linux-x64/lib/tsc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 83 |
e-commerce/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 84 |
e-commerce/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 85 |
e-commerce/node_modules/@typescript/typescript-linux-x64/lib/tsc filter=lfs diff=lfs merge=lfs -text
|
| 86 |
+
e-commerce/node_modules/esbuild/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 87 |
+
e-commerce/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.js
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind, is } from "../../entity.js";
|
| 2 |
+
import { TypedQueryBuilder } from "../../query-builders/query-builder.js";
|
| 3 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 4 |
+
import { SelectionProxyHandler } from "../../selection-proxy.js";
|
| 5 |
+
import { SQL, View } from "../../sql/sql.js";
|
| 6 |
+
import { Subquery } from "../../subquery.js";
|
| 7 |
+
import { Table } from "../../table.js";
|
| 8 |
+
import {
|
| 9 |
+
applyMixins,
|
| 10 |
+
getTableColumns,
|
| 11 |
+
getTableLikeName,
|
| 12 |
+
haveSameKeys,
|
| 13 |
+
orderSelectedFields
|
| 14 |
+
} from "../../utils.js";
|
| 15 |
+
import { ViewBaseConfig } from "../../view-common.js";
|
| 16 |
+
import { extractUsedTable } from "../utils.js";
|
| 17 |
+
import { SQLiteViewBase } from "../view-base.js";
|
| 18 |
+
class SQLiteSelectBuilder {
|
| 19 |
+
static [entityKind] = "SQLiteSelectBuilder";
|
| 20 |
+
fields;
|
| 21 |
+
session;
|
| 22 |
+
dialect;
|
| 23 |
+
withList;
|
| 24 |
+
distinct;
|
| 25 |
+
constructor(config) {
|
| 26 |
+
this.fields = config.fields;
|
| 27 |
+
this.session = config.session;
|
| 28 |
+
this.dialect = config.dialect;
|
| 29 |
+
this.withList = config.withList;
|
| 30 |
+
this.distinct = config.distinct;
|
| 31 |
+
}
|
| 32 |
+
from(source) {
|
| 33 |
+
const isPartialSelect = !!this.fields;
|
| 34 |
+
let fields;
|
| 35 |
+
if (this.fields) {
|
| 36 |
+
fields = this.fields;
|
| 37 |
+
} else if (is(source, Subquery)) {
|
| 38 |
+
fields = Object.fromEntries(
|
| 39 |
+
Object.keys(source._.selectedFields).map((key) => [key, source[key]])
|
| 40 |
+
);
|
| 41 |
+
} else if (is(source, SQLiteViewBase)) {
|
| 42 |
+
fields = source[ViewBaseConfig].selectedFields;
|
| 43 |
+
} else if (is(source, SQL)) {
|
| 44 |
+
fields = {};
|
| 45 |
+
} else {
|
| 46 |
+
fields = getTableColumns(source);
|
| 47 |
+
}
|
| 48 |
+
return new SQLiteSelectBase({
|
| 49 |
+
table: source,
|
| 50 |
+
fields,
|
| 51 |
+
isPartialSelect,
|
| 52 |
+
session: this.session,
|
| 53 |
+
dialect: this.dialect,
|
| 54 |
+
withList: this.withList,
|
| 55 |
+
distinct: this.distinct
|
| 56 |
+
});
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
class SQLiteSelectQueryBuilderBase extends TypedQueryBuilder {
|
| 60 |
+
static [entityKind] = "SQLiteSelectQueryBuilder";
|
| 61 |
+
_;
|
| 62 |
+
/** @internal */
|
| 63 |
+
config;
|
| 64 |
+
joinsNotNullableMap;
|
| 65 |
+
tableName;
|
| 66 |
+
isPartialSelect;
|
| 67 |
+
session;
|
| 68 |
+
dialect;
|
| 69 |
+
cacheConfig = void 0;
|
| 70 |
+
usedTables = /* @__PURE__ */ new Set();
|
| 71 |
+
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
| 72 |
+
super();
|
| 73 |
+
this.config = {
|
| 74 |
+
withList,
|
| 75 |
+
table,
|
| 76 |
+
fields: { ...fields },
|
| 77 |
+
distinct,
|
| 78 |
+
setOperators: []
|
| 79 |
+
};
|
| 80 |
+
this.isPartialSelect = isPartialSelect;
|
| 81 |
+
this.session = session;
|
| 82 |
+
this.dialect = dialect;
|
| 83 |
+
this._ = {
|
| 84 |
+
selectedFields: fields,
|
| 85 |
+
config: this.config
|
| 86 |
+
};
|
| 87 |
+
this.tableName = getTableLikeName(table);
|
| 88 |
+
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
| 89 |
+
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
| 90 |
+
}
|
| 91 |
+
/** @internal */
|
| 92 |
+
getUsedTables() {
|
| 93 |
+
return [...this.usedTables];
|
| 94 |
+
}
|
| 95 |
+
createJoin(joinType) {
|
| 96 |
+
return (table, on) => {
|
| 97 |
+
const baseTableName = this.tableName;
|
| 98 |
+
const tableName = getTableLikeName(table);
|
| 99 |
+
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
| 100 |
+
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
| 101 |
+
throw new Error(`Alias "${tableName}" is already used in this query`);
|
| 102 |
+
}
|
| 103 |
+
if (!this.isPartialSelect) {
|
| 104 |
+
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") {
|
| 105 |
+
this.config.fields = {
|
| 106 |
+
[baseTableName]: this.config.fields
|
| 107 |
+
};
|
| 108 |
+
}
|
| 109 |
+
if (typeof tableName === "string" && !is(table, SQL)) {
|
| 110 |
+
const selection = is(table, Subquery) ? table._.selectedFields : is(table, View) ? table[ViewBaseConfig].selectedFields : table[Table.Symbol.Columns];
|
| 111 |
+
this.config.fields[tableName] = selection;
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
if (typeof on === "function") {
|
| 115 |
+
on = on(
|
| 116 |
+
new Proxy(
|
| 117 |
+
this.config.fields,
|
| 118 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 119 |
+
)
|
| 120 |
+
);
|
| 121 |
+
}
|
| 122 |
+
if (!this.config.joins) {
|
| 123 |
+
this.config.joins = [];
|
| 124 |
+
}
|
| 125 |
+
this.config.joins.push({ on, table, joinType, alias: tableName });
|
| 126 |
+
if (typeof tableName === "string") {
|
| 127 |
+
switch (joinType) {
|
| 128 |
+
case "left": {
|
| 129 |
+
this.joinsNotNullableMap[tableName] = false;
|
| 130 |
+
break;
|
| 131 |
+
}
|
| 132 |
+
case "right": {
|
| 133 |
+
this.joinsNotNullableMap = Object.fromEntries(
|
| 134 |
+
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
| 135 |
+
);
|
| 136 |
+
this.joinsNotNullableMap[tableName] = true;
|
| 137 |
+
break;
|
| 138 |
+
}
|
| 139 |
+
case "cross":
|
| 140 |
+
case "inner": {
|
| 141 |
+
this.joinsNotNullableMap[tableName] = true;
|
| 142 |
+
break;
|
| 143 |
+
}
|
| 144 |
+
case "full": {
|
| 145 |
+
this.joinsNotNullableMap = Object.fromEntries(
|
| 146 |
+
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
| 147 |
+
);
|
| 148 |
+
this.joinsNotNullableMap[tableName] = false;
|
| 149 |
+
break;
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
return this;
|
| 154 |
+
};
|
| 155 |
+
}
|
| 156 |
+
/**
|
| 157 |
+
* Executes a `left join` operation by adding another table to the current query.
|
| 158 |
+
*
|
| 159 |
+
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
| 160 |
+
*
|
| 161 |
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join}
|
| 162 |
+
*
|
| 163 |
+
* @param table the table to join.
|
| 164 |
+
* @param on the `on` clause.
|
| 165 |
+
*
|
| 166 |
+
* @example
|
| 167 |
+
*
|
| 168 |
+
* ```ts
|
| 169 |
+
* // Select all users and their pets
|
| 170 |
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
| 171 |
+
* .from(users)
|
| 172 |
+
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
| 173 |
+
*
|
| 174 |
+
* // Select userId and petId
|
| 175 |
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
| 176 |
+
* userId: users.id,
|
| 177 |
+
* petId: pets.id,
|
| 178 |
+
* })
|
| 179 |
+
* .from(users)
|
| 180 |
+
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
| 181 |
+
* ```
|
| 182 |
+
*/
|
| 183 |
+
leftJoin = this.createJoin("left");
|
| 184 |
+
/**
|
| 185 |
+
* Executes a `right join` operation by adding another table to the current query.
|
| 186 |
+
*
|
| 187 |
+
* Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.
|
| 188 |
+
*
|
| 189 |
+
* See docs: {@link https://orm.drizzle.team/docs/joins#right-join}
|
| 190 |
+
*
|
| 191 |
+
* @param table the table to join.
|
| 192 |
+
* @param on the `on` clause.
|
| 193 |
+
*
|
| 194 |
+
* @example
|
| 195 |
+
*
|
| 196 |
+
* ```ts
|
| 197 |
+
* // Select all users and their pets
|
| 198 |
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
| 199 |
+
* .from(users)
|
| 200 |
+
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
| 201 |
+
*
|
| 202 |
+
* // Select userId and petId
|
| 203 |
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
| 204 |
+
* userId: users.id,
|
| 205 |
+
* petId: pets.id,
|
| 206 |
+
* })
|
| 207 |
+
* .from(users)
|
| 208 |
+
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
| 209 |
+
* ```
|
| 210 |
+
*/
|
| 211 |
+
rightJoin = this.createJoin("right");
|
| 212 |
+
/**
|
| 213 |
+
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
| 214 |
+
*
|
| 215 |
+
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
| 216 |
+
*
|
| 217 |
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}
|
| 218 |
+
*
|
| 219 |
+
* @param table the table to join.
|
| 220 |
+
* @param on the `on` clause.
|
| 221 |
+
*
|
| 222 |
+
* @example
|
| 223 |
+
*
|
| 224 |
+
* ```ts
|
| 225 |
+
* // Select all users and their pets
|
| 226 |
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
| 227 |
+
* .from(users)
|
| 228 |
+
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
| 229 |
+
*
|
| 230 |
+
* // Select userId and petId
|
| 231 |
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
| 232 |
+
* userId: users.id,
|
| 233 |
+
* petId: pets.id,
|
| 234 |
+
* })
|
| 235 |
+
* .from(users)
|
| 236 |
+
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
| 237 |
+
* ```
|
| 238 |
+
*/
|
| 239 |
+
innerJoin = this.createJoin("inner");
|
| 240 |
+
/**
|
| 241 |
+
* Executes a `full join` operation by combining rows from two tables into a new table.
|
| 242 |
+
*
|
| 243 |
+
* Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
|
| 244 |
+
*
|
| 245 |
+
* See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
|
| 246 |
+
*
|
| 247 |
+
* @param table the table to join.
|
| 248 |
+
* @param on the `on` clause.
|
| 249 |
+
*
|
| 250 |
+
* @example
|
| 251 |
+
*
|
| 252 |
+
* ```ts
|
| 253 |
+
* // Select all users and their pets
|
| 254 |
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
| 255 |
+
* .from(users)
|
| 256 |
+
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
| 257 |
+
*
|
| 258 |
+
* // Select userId and petId
|
| 259 |
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
| 260 |
+
* userId: users.id,
|
| 261 |
+
* petId: pets.id,
|
| 262 |
+
* })
|
| 263 |
+
* .from(users)
|
| 264 |
+
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
| 265 |
+
* ```
|
| 266 |
+
*/
|
| 267 |
+
fullJoin = this.createJoin("full");
|
| 268 |
+
/**
|
| 269 |
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
| 270 |
+
*
|
| 271 |
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
| 272 |
+
*
|
| 273 |
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
| 274 |
+
*
|
| 275 |
+
* @param table the table to join.
|
| 276 |
+
*
|
| 277 |
+
* @example
|
| 278 |
+
*
|
| 279 |
+
* ```ts
|
| 280 |
+
* // Select all users, each user with every pet
|
| 281 |
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
| 282 |
+
* .from(users)
|
| 283 |
+
* .crossJoin(pets)
|
| 284 |
+
*
|
| 285 |
+
* // Select userId and petId
|
| 286 |
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
| 287 |
+
* userId: users.id,
|
| 288 |
+
* petId: pets.id,
|
| 289 |
+
* })
|
| 290 |
+
* .from(users)
|
| 291 |
+
* .crossJoin(pets)
|
| 292 |
+
* ```
|
| 293 |
+
*/
|
| 294 |
+
crossJoin = this.createJoin("cross");
|
| 295 |
+
createSetOperator(type, isAll) {
|
| 296 |
+
return (rightSelection) => {
|
| 297 |
+
const rightSelect = typeof rightSelection === "function" ? rightSelection(getSQLiteSetOperators()) : rightSelection;
|
| 298 |
+
if (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) {
|
| 299 |
+
throw new Error(
|
| 300 |
+
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
| 301 |
+
);
|
| 302 |
+
}
|
| 303 |
+
this.config.setOperators.push({ type, isAll, rightSelect });
|
| 304 |
+
return this;
|
| 305 |
+
};
|
| 306 |
+
}
|
| 307 |
+
/**
|
| 308 |
+
* Adds `union` set operator to the query.
|
| 309 |
+
*
|
| 310 |
+
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
| 311 |
+
*
|
| 312 |
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
| 313 |
+
*
|
| 314 |
+
* @example
|
| 315 |
+
*
|
| 316 |
+
* ```ts
|
| 317 |
+
* // Select all unique names from customers and users tables
|
| 318 |
+
* await db.select({ name: users.name })
|
| 319 |
+
* .from(users)
|
| 320 |
+
* .union(
|
| 321 |
+
* db.select({ name: customers.name }).from(customers)
|
| 322 |
+
* );
|
| 323 |
+
* // or
|
| 324 |
+
* import { union } from 'drizzle-orm/sqlite-core'
|
| 325 |
+
*
|
| 326 |
+
* await union(
|
| 327 |
+
* db.select({ name: users.name }).from(users),
|
| 328 |
+
* db.select({ name: customers.name }).from(customers)
|
| 329 |
+
* );
|
| 330 |
+
* ```
|
| 331 |
+
*/
|
| 332 |
+
union = this.createSetOperator("union", false);
|
| 333 |
+
/**
|
| 334 |
+
* Adds `union all` set operator to the query.
|
| 335 |
+
*
|
| 336 |
+
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
| 337 |
+
*
|
| 338 |
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
| 339 |
+
*
|
| 340 |
+
* @example
|
| 341 |
+
*
|
| 342 |
+
* ```ts
|
| 343 |
+
* // Select all transaction ids from both online and in-store sales
|
| 344 |
+
* await db.select({ transaction: onlineSales.transactionId })
|
| 345 |
+
* .from(onlineSales)
|
| 346 |
+
* .unionAll(
|
| 347 |
+
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
| 348 |
+
* );
|
| 349 |
+
* // or
|
| 350 |
+
* import { unionAll } from 'drizzle-orm/sqlite-core'
|
| 351 |
+
*
|
| 352 |
+
* await unionAll(
|
| 353 |
+
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
| 354 |
+
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
| 355 |
+
* );
|
| 356 |
+
* ```
|
| 357 |
+
*/
|
| 358 |
+
unionAll = this.createSetOperator("union", true);
|
| 359 |
+
/**
|
| 360 |
+
* Adds `intersect` set operator to the query.
|
| 361 |
+
*
|
| 362 |
+
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
| 363 |
+
*
|
| 364 |
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
| 365 |
+
*
|
| 366 |
+
* @example
|
| 367 |
+
*
|
| 368 |
+
* ```ts
|
| 369 |
+
* // Select course names that are offered in both departments A and B
|
| 370 |
+
* await db.select({ courseName: depA.courseName })
|
| 371 |
+
* .from(depA)
|
| 372 |
+
* .intersect(
|
| 373 |
+
* db.select({ courseName: depB.courseName }).from(depB)
|
| 374 |
+
* );
|
| 375 |
+
* // or
|
| 376 |
+
* import { intersect } from 'drizzle-orm/sqlite-core'
|
| 377 |
+
*
|
| 378 |
+
* await intersect(
|
| 379 |
+
* db.select({ courseName: depA.courseName }).from(depA),
|
| 380 |
+
* db.select({ courseName: depB.courseName }).from(depB)
|
| 381 |
+
* );
|
| 382 |
+
* ```
|
| 383 |
+
*/
|
| 384 |
+
intersect = this.createSetOperator("intersect", false);
|
| 385 |
+
/**
|
| 386 |
+
* Adds `except` set operator to the query.
|
| 387 |
+
*
|
| 388 |
+
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
| 389 |
+
*
|
| 390 |
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
| 391 |
+
*
|
| 392 |
+
* @example
|
| 393 |
+
*
|
| 394 |
+
* ```ts
|
| 395 |
+
* // Select all courses offered in department A but not in department B
|
| 396 |
+
* await db.select({ courseName: depA.courseName })
|
| 397 |
+
* .from(depA)
|
| 398 |
+
* .except(
|
| 399 |
+
* db.select({ courseName: depB.courseName }).from(depB)
|
| 400 |
+
* );
|
| 401 |
+
* // or
|
| 402 |
+
* import { except } from 'drizzle-orm/sqlite-core'
|
| 403 |
+
*
|
| 404 |
+
* await except(
|
| 405 |
+
* db.select({ courseName: depA.courseName }).from(depA),
|
| 406 |
+
* db.select({ courseName: depB.courseName }).from(depB)
|
| 407 |
+
* );
|
| 408 |
+
* ```
|
| 409 |
+
*/
|
| 410 |
+
except = this.createSetOperator("except", false);
|
| 411 |
+
/** @internal */
|
| 412 |
+
addSetOperators(setOperators) {
|
| 413 |
+
this.config.setOperators.push(...setOperators);
|
| 414 |
+
return this;
|
| 415 |
+
}
|
| 416 |
+
/**
|
| 417 |
+
* Adds a `where` clause to the query.
|
| 418 |
+
*
|
| 419 |
+
* Calling this method will select only those rows that fulfill a specified condition.
|
| 420 |
+
*
|
| 421 |
+
* See docs: {@link https://orm.drizzle.team/docs/select#filtering}
|
| 422 |
+
*
|
| 423 |
+
* @param where the `where` clause.
|
| 424 |
+
*
|
| 425 |
+
* @example
|
| 426 |
+
* You can use conditional operators and `sql function` to filter the rows to be selected.
|
| 427 |
+
*
|
| 428 |
+
* ```ts
|
| 429 |
+
* // Select all cars with green color
|
| 430 |
+
* await db.select().from(cars).where(eq(cars.color, 'green'));
|
| 431 |
+
* // or
|
| 432 |
+
* await db.select().from(cars).where(sql`${cars.color} = 'green'`)
|
| 433 |
+
* ```
|
| 434 |
+
*
|
| 435 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 436 |
+
*
|
| 437 |
+
* ```ts
|
| 438 |
+
* // Select all BMW cars with a green color
|
| 439 |
+
* await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 440 |
+
*
|
| 441 |
+
* // Select all cars with the green or blue color
|
| 442 |
+
* await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 443 |
+
* ```
|
| 444 |
+
*/
|
| 445 |
+
where(where) {
|
| 446 |
+
if (typeof where === "function") {
|
| 447 |
+
where = where(
|
| 448 |
+
new Proxy(
|
| 449 |
+
this.config.fields,
|
| 450 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 451 |
+
)
|
| 452 |
+
);
|
| 453 |
+
}
|
| 454 |
+
this.config.where = where;
|
| 455 |
+
return this;
|
| 456 |
+
}
|
| 457 |
+
/**
|
| 458 |
+
* Adds a `having` clause to the query.
|
| 459 |
+
*
|
| 460 |
+
* Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.
|
| 461 |
+
*
|
| 462 |
+
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
| 463 |
+
*
|
| 464 |
+
* @param having the `having` clause.
|
| 465 |
+
*
|
| 466 |
+
* @example
|
| 467 |
+
*
|
| 468 |
+
* ```ts
|
| 469 |
+
* // Select all brands with more than one car
|
| 470 |
+
* await db.select({
|
| 471 |
+
* brand: cars.brand,
|
| 472 |
+
* count: sql<number>`cast(count(${cars.id}) as int)`,
|
| 473 |
+
* })
|
| 474 |
+
* .from(cars)
|
| 475 |
+
* .groupBy(cars.brand)
|
| 476 |
+
* .having(({ count }) => gt(count, 1));
|
| 477 |
+
* ```
|
| 478 |
+
*/
|
| 479 |
+
having(having) {
|
| 480 |
+
if (typeof having === "function") {
|
| 481 |
+
having = having(
|
| 482 |
+
new Proxy(
|
| 483 |
+
this.config.fields,
|
| 484 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 485 |
+
)
|
| 486 |
+
);
|
| 487 |
+
}
|
| 488 |
+
this.config.having = having;
|
| 489 |
+
return this;
|
| 490 |
+
}
|
| 491 |
+
groupBy(...columns) {
|
| 492 |
+
if (typeof columns[0] === "function") {
|
| 493 |
+
const groupBy = columns[0](
|
| 494 |
+
new Proxy(
|
| 495 |
+
this.config.fields,
|
| 496 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
| 497 |
+
)
|
| 498 |
+
);
|
| 499 |
+
this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
|
| 500 |
+
} else {
|
| 501 |
+
this.config.groupBy = columns;
|
| 502 |
+
}
|
| 503 |
+
return this;
|
| 504 |
+
}
|
| 505 |
+
orderBy(...columns) {
|
| 506 |
+
if (typeof columns[0] === "function") {
|
| 507 |
+
const orderBy = columns[0](
|
| 508 |
+
new Proxy(
|
| 509 |
+
this.config.fields,
|
| 510 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
| 511 |
+
)
|
| 512 |
+
);
|
| 513 |
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
| 514 |
+
if (this.config.setOperators.length > 0) {
|
| 515 |
+
this.config.setOperators.at(-1).orderBy = orderByArray;
|
| 516 |
+
} else {
|
| 517 |
+
this.config.orderBy = orderByArray;
|
| 518 |
+
}
|
| 519 |
+
} else {
|
| 520 |
+
const orderByArray = columns;
|
| 521 |
+
if (this.config.setOperators.length > 0) {
|
| 522 |
+
this.config.setOperators.at(-1).orderBy = orderByArray;
|
| 523 |
+
} else {
|
| 524 |
+
this.config.orderBy = orderByArray;
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
return this;
|
| 528 |
+
}
|
| 529 |
+
/**
|
| 530 |
+
* Adds a `limit` clause to the query.
|
| 531 |
+
*
|
| 532 |
+
* Calling this method will set the maximum number of rows that will be returned by this query.
|
| 533 |
+
*
|
| 534 |
+
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
| 535 |
+
*
|
| 536 |
+
* @param limit the `limit` clause.
|
| 537 |
+
*
|
| 538 |
+
* @example
|
| 539 |
+
*
|
| 540 |
+
* ```ts
|
| 541 |
+
* // Get the first 10 people from this query.
|
| 542 |
+
* await db.select().from(people).limit(10);
|
| 543 |
+
* ```
|
| 544 |
+
*/
|
| 545 |
+
limit(limit) {
|
| 546 |
+
if (this.config.setOperators.length > 0) {
|
| 547 |
+
this.config.setOperators.at(-1).limit = limit;
|
| 548 |
+
} else {
|
| 549 |
+
this.config.limit = limit;
|
| 550 |
+
}
|
| 551 |
+
return this;
|
| 552 |
+
}
|
| 553 |
+
/**
|
| 554 |
+
* Adds an `offset` clause to the query.
|
| 555 |
+
*
|
| 556 |
+
* Calling this method will skip a number of rows when returning results from this query.
|
| 557 |
+
*
|
| 558 |
+
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
| 559 |
+
*
|
| 560 |
+
* @param offset the `offset` clause.
|
| 561 |
+
*
|
| 562 |
+
* @example
|
| 563 |
+
*
|
| 564 |
+
* ```ts
|
| 565 |
+
* // Get the 10th-20th people from this query.
|
| 566 |
+
* await db.select().from(people).offset(10).limit(10);
|
| 567 |
+
* ```
|
| 568 |
+
*/
|
| 569 |
+
offset(offset) {
|
| 570 |
+
if (this.config.setOperators.length > 0) {
|
| 571 |
+
this.config.setOperators.at(-1).offset = offset;
|
| 572 |
+
} else {
|
| 573 |
+
this.config.offset = offset;
|
| 574 |
+
}
|
| 575 |
+
return this;
|
| 576 |
+
}
|
| 577 |
+
/** @internal */
|
| 578 |
+
getSQL() {
|
| 579 |
+
return this.dialect.buildSelectQuery(this.config);
|
| 580 |
+
}
|
| 581 |
+
toSQL() {
|
| 582 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 583 |
+
return rest;
|
| 584 |
+
}
|
| 585 |
+
as(alias) {
|
| 586 |
+
const usedTables = [];
|
| 587 |
+
usedTables.push(...extractUsedTable(this.config.table));
|
| 588 |
+
if (this.config.joins) {
|
| 589 |
+
for (const it of this.config.joins) usedTables.push(...extractUsedTable(it.table));
|
| 590 |
+
}
|
| 591 |
+
return new Proxy(
|
| 592 |
+
new Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]),
|
| 593 |
+
new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
| 594 |
+
);
|
| 595 |
+
}
|
| 596 |
+
/** @internal */
|
| 597 |
+
getSelectedFields() {
|
| 598 |
+
return new Proxy(
|
| 599 |
+
this.config.fields,
|
| 600 |
+
new SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
| 601 |
+
);
|
| 602 |
+
}
|
| 603 |
+
$dynamic() {
|
| 604 |
+
return this;
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
class SQLiteSelectBase extends SQLiteSelectQueryBuilderBase {
|
| 608 |
+
static [entityKind] = "SQLiteSelect";
|
| 609 |
+
/** @internal */
|
| 610 |
+
_prepare(isOneTimeQuery = true) {
|
| 611 |
+
if (!this.session) {
|
| 612 |
+
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
| 613 |
+
}
|
| 614 |
+
const fieldsList = orderSelectedFields(this.config.fields);
|
| 615 |
+
const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
| 616 |
+
this.dialect.sqlToQuery(this.getSQL()),
|
| 617 |
+
fieldsList,
|
| 618 |
+
"all",
|
| 619 |
+
true,
|
| 620 |
+
void 0,
|
| 621 |
+
{
|
| 622 |
+
type: "select",
|
| 623 |
+
tables: [...this.usedTables]
|
| 624 |
+
},
|
| 625 |
+
this.cacheConfig
|
| 626 |
+
);
|
| 627 |
+
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
| 628 |
+
return query;
|
| 629 |
+
}
|
| 630 |
+
$withCache(config) {
|
| 631 |
+
this.cacheConfig = config === void 0 ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
|
| 632 |
+
return this;
|
| 633 |
+
}
|
| 634 |
+
prepare() {
|
| 635 |
+
return this._prepare(false);
|
| 636 |
+
}
|
| 637 |
+
run = (placeholderValues) => {
|
| 638 |
+
return this._prepare().run(placeholderValues);
|
| 639 |
+
};
|
| 640 |
+
all = (placeholderValues) => {
|
| 641 |
+
return this._prepare().all(placeholderValues);
|
| 642 |
+
};
|
| 643 |
+
get = (placeholderValues) => {
|
| 644 |
+
return this._prepare().get(placeholderValues);
|
| 645 |
+
};
|
| 646 |
+
values = (placeholderValues) => {
|
| 647 |
+
return this._prepare().values(placeholderValues);
|
| 648 |
+
};
|
| 649 |
+
async execute() {
|
| 650 |
+
return this.all();
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
applyMixins(SQLiteSelectBase, [QueryPromise]);
|
| 654 |
+
function createSetOperator(type, isAll) {
|
| 655 |
+
return (leftSelect, rightSelect, ...restSelects) => {
|
| 656 |
+
const setOperators = [rightSelect, ...restSelects].map((select) => ({
|
| 657 |
+
type,
|
| 658 |
+
isAll,
|
| 659 |
+
rightSelect: select
|
| 660 |
+
}));
|
| 661 |
+
for (const setOperator of setOperators) {
|
| 662 |
+
if (!haveSameKeys(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {
|
| 663 |
+
throw new Error(
|
| 664 |
+
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
| 665 |
+
);
|
| 666 |
+
}
|
| 667 |
+
}
|
| 668 |
+
return leftSelect.addSetOperators(setOperators);
|
| 669 |
+
};
|
| 670 |
+
}
|
| 671 |
+
const getSQLiteSetOperators = () => ({
|
| 672 |
+
union,
|
| 673 |
+
unionAll,
|
| 674 |
+
intersect,
|
| 675 |
+
except
|
| 676 |
+
});
|
| 677 |
+
const union = createSetOperator("union", false);
|
| 678 |
+
const unionAll = createSetOperator("union", true);
|
| 679 |
+
const intersect = createSetOperator("intersect", false);
|
| 680 |
+
const except = createSetOperator("except", false);
|
| 681 |
+
export {
|
| 682 |
+
SQLiteSelectBase,
|
| 683 |
+
SQLiteSelectBuilder,
|
| 684 |
+
SQLiteSelectQueryBuilderBase,
|
| 685 |
+
except,
|
| 686 |
+
intersect,
|
| 687 |
+
union,
|
| 688 |
+
unionAll
|
| 689 |
+
};
|
| 690 |
+
//# sourceMappingURL=select.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/sqlite-core/query-builders/select.ts"],"sourcesContent":["import type { CacheConfig, WithCacheConfig } from '~/cache/core/types.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type {\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n\tSetOperator,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { SQL, View } from '~/sql/sql.ts';\nimport type { ColumnsSelection, Placeholder, Query, SQLWrapper } from '~/sql/sql.ts';\nimport type { SQLiteColumn } from '~/sqlite-core/columns/index.ts';\nimport type { SQLiteDialect } from '~/sqlite-core/dialect.ts';\nimport type { SQLiteSession } from '~/sqlite-core/session.ts';\nimport type { SubqueryWithSelection } from '~/sqlite-core/subquery.ts';\nimport type { SQLiteTable } from '~/sqlite-core/table.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\tapplyMixins,\n\tgetTableColumns,\n\tgetTableLikeName,\n\thaveSameKeys,\n\torderSelectedFields,\n\ttype ValueOrArray,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport { SQLiteViewBase } from '../view-base.ts';\nimport type {\n\tAnySQLiteSelect,\n\tCreateSQLiteSelectFromBuilderMode,\n\tGetSQLiteSetOperators,\n\tSelectedFields,\n\tSetOperatorRightSelect,\n\tSQLiteCreateSetOperatorFn,\n\tSQLiteSelectConfig,\n\tSQLiteSelectCrossJoinFn,\n\tSQLiteSelectDynamic,\n\tSQLiteSelectExecute,\n\tSQLiteSelectHKT,\n\tSQLiteSelectHKTBase,\n\tSQLiteSelectJoinFn,\n\tSQLiteSelectPrepare,\n\tSQLiteSelectWithout,\n\tSQLiteSetOperatorExcludedMethods,\n\tSQLiteSetOperatorWithResult,\n} from './select.types.ts';\n\nexport class SQLiteSelectBuilder<\n\tTSelection extends SelectedFields | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTBuilderMode extends 'db' | 'qb' = 'db',\n> {\n\tstatic readonly [entityKind]: string = 'SQLiteSelectBuilder';\n\n\tprivate fields: TSelection;\n\tprivate session: SQLiteSession<any, any, any, any> | undefined;\n\tprivate dialect: SQLiteDialect;\n\tprivate withList: Subquery[] | undefined;\n\tprivate distinct: boolean | undefined;\n\n\tconstructor(\n\t\tconfig: {\n\t\t\tfields: TSelection;\n\t\t\tsession: SQLiteSession<any, any, any, any> | undefined;\n\t\t\tdialect: SQLiteDialect;\n\t\t\twithList?: Subquery[];\n\t\t\tdistinct?: boolean;\n\t\t},\n\t) {\n\t\tthis.fields = config.fields;\n\t\tthis.session = config.session;\n\t\tthis.dialect = config.dialect;\n\t\tthis.withList = config.withList;\n\t\tthis.distinct = config.distinct;\n\t}\n\n\tfrom<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(\n\t\tsource: TFrom,\n\t): CreateSQLiteSelectFromBuilderMode<\n\t\tTBuilderMode,\n\t\tGetSelectTableName<TFrom>,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,\n\t\tTSelection extends undefined ? 'single' : 'partial'\n\t> {\n\t\tconst isPartialSelect = !!this.fields;\n\n\t\tlet fields: SelectedFields;\n\t\tif (this.fields) {\n\t\t\tfields = this.fields;\n\t\t} else if (is(source, Subquery)) {\n\t\t\t// This is required to use the proxy handler to get the correct field values from the subquery\n\t\t\tfields = Object.fromEntries(\n\t\t\t\tObject.keys(source._.selectedFields).map((\n\t\t\t\t\tkey,\n\t\t\t\t) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),\n\t\t\t);\n\t\t} else if (is(source, SQLiteViewBase)) {\n\t\t\tfields = source[ViewBaseConfig].selectedFields as SelectedFields;\n\t\t} else if (is(source, SQL)) {\n\t\t\tfields = {};\n\t\t} else {\n\t\t\tfields = getTableColumns<SQLiteTable>(source);\n\t\t}\n\n\t\treturn new SQLiteSelectBase({\n\t\t\ttable: source,\n\t\t\tfields,\n\t\t\tisPartialSelect,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\twithList: this.withList,\n\t\t\tdistinct: this.distinct,\n\t\t}) as any;\n\t}\n}\n\nexport abstract class SQLiteSelectQueryBuilderBase<\n\tTHKT extends SQLiteSelectHKTBase,\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends TypedQueryBuilder<TSelectedFields, TResult> {\n\tstatic override readonly [entityKind]: string = 'SQLiteSelectQueryBuilder';\n\n\toverride readonly _: {\n\t\treadonly dialect: 'sqlite';\n\t\treadonly hkt: THKT;\n\t\treadonly tableName: TTableName;\n\t\treadonly resultType: TResultType;\n\t\treadonly runResult: TRunResult;\n\t\treadonly selection: TSelection;\n\t\treadonly selectMode: TSelectMode;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TResult;\n\t\treadonly selectedFields: TSelectedFields;\n\t\treadonly config: SQLiteSelectConfig;\n\t};\n\n\t/** @internal */\n\tconfig: SQLiteSelectConfig;\n\tprotected joinsNotNullableMap: Record<string, boolean>;\n\tprivate tableName: string | undefined;\n\tprivate isPartialSelect: boolean;\n\tprotected session: SQLiteSession<any, any, any, any> | undefined;\n\tprotected dialect: SQLiteDialect;\n\tprotected cacheConfig?: WithCacheConfig = undefined;\n\tprotected usedTables: Set<string> = new Set();\n\n\tconstructor(\n\t\t{ table, fields, isPartialSelect, session, dialect, withList, distinct }: {\n\t\t\ttable: SQLiteSelectConfig['table'];\n\t\t\tfields: SQLiteSelectConfig['fields'];\n\t\t\tisPartialSelect: boolean;\n\t\t\tsession: SQLiteSession<any, any, any, any> | undefined;\n\t\t\tdialect: SQLiteDialect;\n\t\t\twithList: Subquery[] | undefined;\n\t\t\tdistinct: boolean | undefined;\n\t\t},\n\t) {\n\t\tsuper();\n\t\tthis.config = {\n\t\t\twithList,\n\t\t\ttable,\n\t\t\tfields: { ...fields },\n\t\t\tdistinct,\n\t\t\tsetOperators: [],\n\t\t};\n\t\tthis.isPartialSelect = isPartialSelect;\n\t\tthis.session = session;\n\t\tthis.dialect = dialect;\n\t\tthis._ = {\n\t\t\tselectedFields: fields as TSelectedFields,\n\t\t\tconfig: this.config,\n\t\t} as this['_'];\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t\tfor (const item of extractUsedTable(table)) this.usedTables.add(item);\n\t}\n\n\t/** @internal */\n\tgetUsedTables() {\n\t\treturn [...this.usedTables];\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): 'cross' extends TJoinType ? SQLiteSelectCrossJoinFn<this, TDynamic>\n\t\t: SQLiteSelectJoinFn<this, TDynamic, TJoinType>\n\t{\n\t\treturn (\n\t\t\ttable: SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\t\t\ton?: ((aliases: TSelection) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst baseTableName = this.tableName;\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\t// store all tables used in a query\n\t\t\tfor (const item of extractUsedTable(table)) this.usedTables.add(item);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins?.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (!this.isPartialSelect) {\n\t\t\t\t// If this is the first join and this is not a partial select and we're not selecting from raw SQL, \"move\" the fields from the main table to the nested object\n\t\t\t\tif (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === 'string') {\n\t\t\t\t\tthis.config.fields = {\n\t\t\t\t\t\t[baseTableName]: this.config.fields,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (typeof tableName === 'string' && !is(table, SQL)) {\n\t\t\t\t\tconst selection = is(table, Subquery)\n\t\t\t\t\t\t? table._.selectedFields\n\t\t\t\t\t\t: is(table, View)\n\t\t\t\t\t\t? table[ViewBaseConfig].selectedFields\n\t\t\t\t\t\t: table[Table.Symbol.Columns];\n\t\t\t\t\tthis.config.fields[tableName] = selection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.fields,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as TSelection,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!this.config.joins) {\n\t\t\t\tthis.config.joins = [];\n\t\t\t}\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'cross':\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Executes a `left join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#left-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tleftJoin = this.createJoin('left');\n\n\t/**\n\t * Executes a `right join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#right-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\trightJoin = this.createJoin('right');\n\n\t/**\n\t * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.\n\t *\n\t * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tinnerJoin = this.createJoin('inner');\n\n\t/**\n\t * Executes a `full join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#full-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Executes a `cross join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}\n\t *\n\t * @param table the table to join.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users, each user with every pet\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .crossJoin(pets)\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .crossJoin(pets)\n\t * ```\n\t */\n\tcrossJoin = this.createJoin('cross');\n\n\tprivate createSetOperator(\n\t\ttype: SetOperator,\n\t\tisAll: boolean,\n\t): <TValue extends SQLiteSetOperatorWithResult<TResult>>(\n\t\trightSelection:\n\t\t\t| ((setOperators: GetSQLiteSetOperators) => SetOperatorRightSelect<TValue, TResult>)\n\t\t\t| SetOperatorRightSelect<TValue, TResult>,\n\t) => SQLiteSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tSQLiteSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\treturn (rightSelection) => {\n\t\t\tconst rightSelect = (typeof rightSelection === 'function'\n\t\t\t\t? rightSelection(getSQLiteSetOperators())\n\t\t\t\t: rightSelection) as TypedQueryBuilder<\n\t\t\t\t\tany,\n\t\t\t\t\tTResult\n\t\t\t\t>;\n\n\t\t\tif (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.setOperators.push({ type, isAll, rightSelect });\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Adds `union` set operator to the query.\n\t *\n\t * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all unique names from customers and users tables\n\t * await db.select({ name: users.name })\n\t * .from(users)\n\t * .union(\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * // or\n\t * import { union } from 'drizzle-orm/sqlite-core'\n\t *\n\t * await union(\n\t * db.select({ name: users.name }).from(users),\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * ```\n\t */\n\tunion = this.createSetOperator('union', false);\n\n\t/**\n\t * Adds `union all` set operator to the query.\n\t *\n\t * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all transaction ids from both online and in-store sales\n\t * await db.select({ transaction: onlineSales.transactionId })\n\t * .from(onlineSales)\n\t * .unionAll(\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * // or\n\t * import { unionAll } from 'drizzle-orm/sqlite-core'\n\t *\n\t * await unionAll(\n\t * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * ```\n\t */\n\tunionAll = this.createSetOperator('union', true);\n\n\t/**\n\t * Adds `intersect` set operator to the query.\n\t *\n\t * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select course names that are offered in both departments A and B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .intersect(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { intersect } from 'drizzle-orm/sqlite-core'\n\t *\n\t * await intersect(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\tintersect = this.createSetOperator('intersect', false);\n\n\t/**\n\t * Adds `except` set operator to the query.\n\t *\n\t * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all courses offered in department A but not in department B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .except(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { except } from 'drizzle-orm/sqlite-core'\n\t *\n\t * await except(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\texcept = this.createSetOperator('except', false);\n\n\t/** @internal */\n\taddSetOperators(setOperators: SQLiteSelectConfig['setOperators']): SQLiteSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tSQLiteSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\tthis.config.setOperators.push(...setOperators);\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `where` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#filtering}\n\t *\n\t * @param where the `where` clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be selected.\n\t *\n\t * ```ts\n\t * // Select all cars with green color\n\t * await db.select().from(cars).where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.select().from(cars).where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Select all BMW cars with a green color\n\t * await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Select all cars with the green or blue color\n\t * await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(\n\t\twhere: ((aliases: TSelection) => SQL | undefined) | SQL | undefined,\n\t): SQLiteSelectWithout<this, TDynamic, 'where'> {\n\t\tif (typeof where === 'function') {\n\t\t\twhere = where(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `having` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @param having the `having` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all brands with more than one car\n\t * await db.select({\n\t * \tbrand: cars.brand,\n\t * \tcount: sql<number>`cast(count(${cars.id}) as int)`,\n\t * })\n\t * .from(cars)\n\t * .groupBy(cars.brand)\n\t * .having(({ count }) => gt(count, 1));\n\t * ```\n\t */\n\thaving(\n\t\thaving: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined,\n\t): SQLiteSelectWithout<this, TDynamic, 'having'> {\n\t\tif (typeof having === 'function') {\n\t\t\thaving = having(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.having = having;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `group by` clause to the query.\n\t *\n\t * Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Group and count people by their last names\n\t * await db.select({\n\t * lastName: people.lastName,\n\t * count: sql<number>`cast(count(*) as int)`\n\t * })\n\t * .from(people)\n\t * .groupBy(people.lastName);\n\t * ```\n\t */\n\tgroupBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>,\n\t): SQLiteSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(...columns: (SQLiteColumn | SQL)[]): SQLiteSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>]\n\t\t\t| (SQLiteColumn | SQL | SQL.Aliased)[]\n\t): SQLiteSelectWithout<this, TDynamic, 'groupBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst groupBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t\tthis.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];\n\t\t} else {\n\t\t\tthis.config.groupBy = columns as (SQLiteColumn | SQL | SQL.Aliased)[];\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `order by` clause to the query.\n\t *\n\t * Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#order-by}\n\t *\n\t * @example\n\t *\n\t * ```\n\t * // Select cars ordered by year\n\t * await db.select().from(cars).orderBy(cars.year);\n\t * ```\n\t *\n\t * You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.\n\t *\n\t * ```ts\n\t * // Select cars ordered by year in descending order\n\t * await db.select().from(cars).orderBy(desc(cars.year));\n\t *\n\t * // Select cars ordered by year and price\n\t * await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));\n\t * ```\n\t */\n\torderBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>,\n\t): SQLiteSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (SQLiteColumn | SQL)[]): SQLiteSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>]\n\t\t\t| (SQLiteColumn | SQL | SQL.Aliased)[]\n\t): SQLiteSelectWithout<this, TDynamic, 'orderBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst orderBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t} else {\n\t\t\tconst orderByArray = columns as (SQLiteColumn | SQL | SQL.Aliased)[];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `limit` clause to the query.\n\t *\n\t * Calling this method will set the maximum number of rows that will be returned by this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param limit the `limit` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the first 10 people from this query.\n\t * await db.select().from(people).limit(10);\n\t * ```\n\t */\n\tlimit(limit: number | Placeholder): SQLiteSelectWithout<this, TDynamic, 'limit'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.limit = limit;\n\t\t} else {\n\t\t\tthis.config.limit = limit;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `offset` clause to the query.\n\t *\n\t * Calling this method will skip a number of rows when returning results from this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param offset the `offset` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the 10th-20th people from this query.\n\t * await db.select().from(people).offset(10).limit(10);\n\t * ```\n\t */\n\toffset(offset: number | Placeholder): SQLiteSelectWithout<this, TDynamic, 'offset'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.offset = offset;\n\t\t} else {\n\t\t\tthis.config.offset = offset;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildSelectQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\tas<TAlias extends string>(\n\t\talias: TAlias,\n\t): SubqueryWithSelection<this['_']['selectedFields'], TAlias> {\n\t\tconst usedTables: string[] = [];\n\t\tusedTables.push(...extractUsedTable(this.config.table));\n\t\tif (this.config.joins) { for (const it of this.config.joins) usedTables.push(...extractUsedTable(it.table)); }\n\n\t\treturn new Proxy(\n\t\t\tnew Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]),\n\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as SubqueryWithSelection<this['_']['selectedFields'], TAlias>;\n\t}\n\n\t/** @internal */\n\toverride getSelectedFields(): this['_']['selectedFields'] {\n\t\treturn new Proxy(\n\t\t\tthis.config.fields,\n\t\t\tnew SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as this['_']['selectedFields'];\n\t}\n\n\t$dynamic(): SQLiteSelectDynamic<this> {\n\t\treturn this;\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface SQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends\n\tSQLiteSelectQueryBuilderBase<\n\t\tSQLiteSelectHKT,\n\t\tTTableName,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection,\n\t\tTSelectMode,\n\t\tTNullabilityMap,\n\t\tTDynamic,\n\t\tTExcludedMethods,\n\t\tTResult,\n\t\tTSelectedFields\n\t>,\n\tQueryPromise<TResult>\n{}\n\nexport class SQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends SQLiteSelectQueryBuilderBase<\n\tSQLiteSelectHKT,\n\tTTableName,\n\tTResultType,\n\tTRunResult,\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\tTDynamic,\n\tTExcludedMethods,\n\tTResult,\n\tTSelectedFields\n> implements RunnableQuery<TResult, 'sqlite'>, SQLWrapper {\n\tstatic override readonly [entityKind]: string = 'SQLiteSelect';\n\n\t/** @internal */\n\t_prepare(isOneTimeQuery = true): SQLiteSelectPrepare<this> {\n\t\tif (!this.session) {\n\t\t\tthrow new Error('Cannot execute a query on a query builder. Please use a database instance instead.');\n\t\t}\n\t\tconst fieldsList = orderSelectedFields<SQLiteColumn>(this.config.fields);\n\t\tconst query = this.session[isOneTimeQuery ? 'prepareOneTimeQuery' : 'prepareQuery'](\n\t\t\tthis.dialect.sqlToQuery(this.getSQL()),\n\t\t\tfieldsList,\n\t\t\t'all',\n\t\t\ttrue,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttype: 'select',\n\t\t\t\ttables: [...this.usedTables],\n\t\t\t},\n\t\t\tthis.cacheConfig,\n\t\t);\n\t\tquery.joinsNotNullableMap = this.joinsNotNullableMap;\n\t\treturn query as ReturnType<this['prepare']>;\n\t}\n\n\t$withCache(config?: { config?: CacheConfig; tag?: string; autoInvalidate?: boolean } | false) {\n\t\tthis.cacheConfig = config === undefined\n\t\t\t? { config: {}, enable: true, autoInvalidate: true }\n\t\t\t: config === false\n\t\t\t? { enable: false }\n\t\t\t: { enable: true, autoInvalidate: true, ...config };\n\t\treturn this;\n\t}\n\n\tprepare(): SQLiteSelectPrepare<this> {\n\t\treturn this._prepare(false);\n\t}\n\n\trun: ReturnType<this['prepare']>['run'] = (placeholderValues) => {\n\t\treturn this._prepare().run(placeholderValues);\n\t};\n\n\tall: ReturnType<this['prepare']>['all'] = (placeholderValues) => {\n\t\treturn this._prepare().all(placeholderValues);\n\t};\n\n\tget: ReturnType<this['prepare']>['get'] = (placeholderValues) => {\n\t\treturn this._prepare().get(placeholderValues);\n\t};\n\n\tvalues: ReturnType<this['prepare']>['values'] = (placeholderValues) => {\n\t\treturn this._prepare().values(placeholderValues);\n\t};\n\n\tasync execute(): Promise<SQLiteSelectExecute<this>> {\n\t\treturn this.all() as SQLiteSelectExecute<this>;\n\t}\n}\n\napplyMixins(SQLiteSelectBase, [QueryPromise]);\n\nfunction createSetOperator(type: SetOperator, isAll: boolean): SQLiteCreateSetOperatorFn {\n\treturn (leftSelect, rightSelect, ...restSelects) => {\n\t\tconst setOperators = [rightSelect, ...restSelects].map((select) => ({\n\t\t\ttype,\n\t\t\tisAll,\n\t\t\trightSelect: select as AnySQLiteSelect,\n\t\t}));\n\n\t\tfor (const setOperator of setOperators) {\n\t\t\tif (!haveSameKeys((leftSelect as any).getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (leftSelect as AnySQLiteSelect).addSetOperators(setOperators) as any;\n\t};\n}\n\nconst getSQLiteSetOperators = () => ({\n\tunion,\n\tunionAll,\n\tintersect,\n\texcept,\n});\n\n/**\n * Adds `union` set operator to the query.\n *\n * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n *\n * @example\n *\n * ```ts\n * // Select all unique names from customers and users tables\n * import { union } from 'drizzle-orm/sqlite-core'\n *\n * await union(\n * db.select({ name: users.name }).from(users),\n * db.select({ name: customers.name }).from(customers)\n * );\n * // or\n * await db.select({ name: users.name })\n * .from(users)\n * .union(\n * db.select({ name: customers.name }).from(customers)\n * );\n * ```\n */\nexport const union = createSetOperator('union', false);\n\n/**\n * Adds `union all` set operator to the query.\n *\n * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n *\n * @example\n *\n * ```ts\n * // Select all transaction ids from both online and in-store sales\n * import { unionAll } from 'drizzle-orm/sqlite-core'\n *\n * await unionAll(\n * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * // or\n * await db.select({ transaction: onlineSales.transactionId })\n * .from(onlineSales)\n * .unionAll(\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * ```\n */\nexport const unionAll = createSetOperator('union', true);\n\n/**\n * Adds `intersect` set operator to the query.\n *\n * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n *\n * @example\n *\n * ```ts\n * // Select course names that are offered in both departments A and B\n * import { intersect } from 'drizzle-orm/sqlite-core'\n *\n * await intersect(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .intersect(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const intersect = createSetOperator('intersect', false);\n\n/**\n * Adds `except` set operator to the query.\n *\n * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n *\n * @example\n *\n * ```ts\n * // Select all courses offered in department A but not in department B\n * import { except } from 'drizzle-orm/sqlite-core'\n *\n * await except(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .except(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const except = createSetOperator('except', false);\n"],"mappings":"AACA,SAAS,YAAY,UAAU;AAC/B,SAAS,yBAAyB;AAWlC,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AACtC,SAAS,KAAK,YAAY;AAO1B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAqBxB,MAAM,oBAKX;AAAA,EACD,QAAiB,UAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,QAOC;AACD,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACtB,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AAAA,EACxB;AAAA,EAEA,KACC,QAQC;AACD,UAAM,kBAAkB,CAAC,CAAC,KAAK;AAE/B,QAAI;AACJ,QAAI,KAAK,QAAQ;AAChB,eAAS,KAAK;AAAA,IACf,WAAW,GAAG,QAAQ,QAAQ,GAAG;AAEhC,eAAS,OAAO;AAAA,QACf,OAAO,KAAK,OAAO,EAAE,cAAc,EAAE,IAAI,CACxC,QACI,CAAC,KAAK,OAAO,GAAqC,CAAsC,CAAC;AAAA,MAC/F;AAAA,IACD,WAAW,GAAG,QAAQ,cAAc,GAAG;AACtC,eAAS,OAAO,cAAc,EAAE;AAAA,IACjC,WAAW,GAAG,QAAQ,GAAG,GAAG;AAC3B,eAAS,CAAC;AAAA,IACX,OAAO;AACN,eAAS,gBAA6B,MAAM;AAAA,IAC7C;AAEA,WAAO,IAAI,iBAAiB;AAAA,MAC3B,OAAO;AAAA,MACP;AAAA,MAC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AACxG,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,WAAQ,WAA+B,gBAAgB,YAAY;AAAA,EACpE;AACD;AAEA,MAAM,wBAAwB,OAAO;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AA2BO,MAAM,QAAQ,kBAAkB,SAAS,KAAK;AA2B9C,MAAM,WAAW,kBAAkB,SAAS,IAAI;AA2BhD,MAAM,YAAY,kBAAkB,aAAa,KAAK;AA2BtD,MAAM,SAAS,kBAAkB,UAAU,KAAK;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __copyProps = (to, from, except, desc) => {
|
| 7 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 8 |
+
for (let key of __getOwnPropNames(from))
|
| 9 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 10 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 11 |
+
}
|
| 12 |
+
return to;
|
| 13 |
+
};
|
| 14 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 15 |
+
var select_types_exports = {};
|
| 16 |
+
module.exports = __toCommonJS(select_types_exports);
|
| 17 |
+
//# sourceMappingURL=select.types.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/sqlite-core/query-builders/select.types.ts"],"sourcesContent":["import type { ColumnsSelection, Placeholder, SQL, View } from '~/sql/sql.ts';\nimport type { SQLiteColumn } from '~/sqlite-core/columns/index.ts';\nimport type { SQLiteTable, SQLiteTableWithColumns } from '~/sqlite-core/table.ts';\nimport type { Assume, ValidateShape } from '~/utils.ts';\n\nimport type {\n\tSelectedFields as SelectFieldsBase,\n\tSelectedFieldsFlat as SelectFieldsFlatBase,\n\tSelectedFieldsOrdered as SelectFieldsOrderedBase,\n} from '~/operations.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type {\n\tAppendToNullabilityMap,\n\tAppendToResult,\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tJoinNullability,\n\tJoinType,\n\tMapColumnsToTableAlias,\n\tSelectMode,\n\tSelectResult,\n\tSetOperator,\n} from '~/query-builders/select.types.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport type { Table, UpdateTableConfig } from '~/table.ts';\nimport type { SQLitePreparedQuery } from '../session.ts';\nimport type { SQLiteViewBase } from '../view-base.ts';\nimport type { SQLiteViewWithSelection } from '../view.ts';\nimport type { SQLiteSelectBase, SQLiteSelectQueryBuilderBase } from './select.ts';\n\nexport interface SQLiteSelectJoinConfig {\n\ton: SQL | undefined;\n\ttable: SQLiteTable | Subquery | SQLiteViewBase | SQL;\n\talias: string | undefined;\n\tjoinType: JoinType;\n}\n\nexport type BuildAliasTable<TTable extends SQLiteTable | View, TAlias extends string> = TTable extends Table\n\t? SQLiteTableWithColumns<\n\t\tUpdateTableConfig<TTable['_']['config'], {\n\t\t\tname: TAlias;\n\t\t\tcolumns: MapColumnsToTableAlias<TTable['_']['columns'], TAlias, 'sqlite'>;\n\t\t}>\n\t>\n\t: TTable extends View ? SQLiteViewWithSelection<\n\t\t\tTAlias,\n\t\t\tTTable['_']['existing'],\n\t\t\tMapColumnsToTableAlias<TTable['_']['selectedFields'], TAlias, 'sqlite'>\n\t\t>\n\t: never;\n\nexport interface SQLiteSelectConfig {\n\twithList?: Subquery[];\n\tfields: Record<string, unknown>;\n\tfieldsFlat?: SelectedFieldsOrdered;\n\twhere?: SQL;\n\thaving?: SQL;\n\ttable: SQLiteTable | Subquery | SQLiteViewBase | SQL;\n\tlimit?: number | Placeholder;\n\toffset?: number | Placeholder;\n\tjoins?: SQLiteSelectJoinConfig[];\n\torderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];\n\tgroupBy?: (SQLiteColumn | SQL | SQL.Aliased)[];\n\tdistinct?: boolean;\n\tsetOperators: {\n\t\trightSelect: TypedQueryBuilder<any, any>;\n\t\ttype: SetOperator;\n\t\tisAll: boolean;\n\t\torderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];\n\t\tlimit?: number | Placeholder;\n\t\toffset?: number | Placeholder;\n\t}[];\n}\n\nexport type SQLiteSelectJoin<\n\tT extends AnySQLiteSelectQueryBuilder,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n\tTJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\tTJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>,\n> = T extends any ? SQLiteSelectWithout<\n\t\tSQLiteSelectKind<\n\t\t\tT['_']['hkt'],\n\t\t\tT['_']['tableName'],\n\t\t\tT['_']['resultType'],\n\t\t\tT['_']['runResult'],\n\t\t\tAppendToResult<\n\t\t\t\tT['_']['tableName'],\n\t\t\t\tT['_']['selection'],\n\t\t\t\tTJoinedName,\n\t\t\t\tTJoinedTable extends SQLiteTable ? TJoinedTable['_']['columns']\n\t\t\t\t\t: TJoinedTable extends Subquery | View ? Assume<TJoinedTable['_']['selectedFields'], SelectedFields>\n\t\t\t\t\t: never,\n\t\t\t\tT['_']['selectMode']\n\t\t\t>,\n\t\t\tT['_']['selectMode'] extends 'partial' ? T['_']['selectMode'] : 'multiple',\n\t\t\tAppendToNullabilityMap<T['_']['nullabilityMap'], TJoinedName, TJoinType>,\n\t\t\tT['_']['dynamic'],\n\t\t\tT['_']['excludedMethods']\n\t\t>,\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>\n\t: never;\n\nexport type SQLiteSelectJoinFn<\n\tT extends AnySQLiteSelectQueryBuilder,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n> = <\n\tTJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\tTJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>,\n>(\n\ttable: TJoinedTable,\n\ton: ((aliases: T['_']['selection']) => SQL | undefined) | SQL | undefined,\n) => SQLiteSelectJoin<T, TDynamic, TJoinType, TJoinedTable, TJoinedName>;\n\nexport type SQLiteSelectCrossJoinFn<\n\tT extends AnySQLiteSelectQueryBuilder,\n\tTDynamic extends boolean,\n> = <\n\tTJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\tTJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>,\n>(table: TJoinedTable) => SQLiteSelectJoin<T, TDynamic, 'cross', TJoinedTable, TJoinedName>;\n\nexport type SelectedFieldsFlat = SelectFieldsFlatBase<SQLiteColumn>;\n\nexport type SelectedFields = SelectFieldsBase<SQLiteColumn, SQLiteTable>;\n\nexport type SelectedFieldsOrdered = SelectFieldsOrderedBase<SQLiteColumn>;\n\nexport interface SQLiteSelectHKTBase {\n\ttableName: string | undefined;\n\tresultType: 'sync' | 'async';\n\trunResult: unknown;\n\tselection: unknown;\n\tselectMode: SelectMode;\n\tnullabilityMap: unknown;\n\tdynamic: boolean;\n\texcludedMethods: string;\n\tresult: unknown;\n\tselectedFields: unknown;\n\t_type: unknown;\n}\n\nexport type SQLiteSelectKind<\n\tT extends SQLiteSelectHKTBase,\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability>,\n\tTDynamic extends boolean,\n\tTExcludedMethods extends string,\n\tTResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> = (T & {\n\ttableName: TTableName;\n\tresultType: TResultType;\n\trunResult: TRunResult;\n\tselection: TSelection;\n\tselectMode: TSelectMode;\n\tnullabilityMap: TNullabilityMap;\n\tdynamic: TDynamic;\n\texcludedMethods: TExcludedMethods;\n\tresult: TResult;\n\tselectedFields: TSelectedFields;\n})['_type'];\n\nexport interface SQLiteSelectQueryBuilderHKT extends SQLiteSelectHKTBase {\n\t_type: SQLiteSelectQueryBuilderBase<\n\t\tSQLiteSelectQueryBuilderHKT,\n\t\tthis['tableName'],\n\t\tthis['resultType'],\n\t\tthis['runResult'],\n\t\tAssume<this['selection'], ColumnsSelection>,\n\t\tthis['selectMode'],\n\t\tAssume<this['nullabilityMap'], Record<string, JoinNullability>>,\n\t\tthis['dynamic'],\n\t\tthis['excludedMethods'],\n\t\tAssume<this['result'], any[]>,\n\t\tAssume<this['selectedFields'], ColumnsSelection>\n\t>;\n}\n\nexport interface SQLiteSelectHKT extends SQLiteSelectHKTBase {\n\t_type: SQLiteSelectBase<\n\t\tthis['tableName'],\n\t\tthis['resultType'],\n\t\tthis['runResult'],\n\t\tAssume<this['selection'], ColumnsSelection>,\n\t\tthis['selectMode'],\n\t\tAssume<this['nullabilityMap'], Record<string, JoinNullability>>,\n\t\tthis['dynamic'],\n\t\tthis['excludedMethods'],\n\t\tAssume<this['result'], any[]>,\n\t\tAssume<this['selectedFields'], ColumnsSelection>\n\t>;\n}\n\nexport type SQLiteSetOperatorExcludedMethods =\n\t| 'config'\n\t| 'leftJoin'\n\t| 'rightJoin'\n\t| 'innerJoin'\n\t| 'fullJoin'\n\t| 'where'\n\t| 'having'\n\t| 'groupBy';\n\nexport type CreateSQLiteSelectFromBuilderMode<\n\tTBuilderMode extends 'db' | 'qb',\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n> = TBuilderMode extends 'db' ? SQLiteSelectBase<\n\t\tTTableName,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection,\n\t\tTSelectMode\n\t>\n\t: SQLiteSelectQueryBuilderBase<\n\t\tSQLiteSelectQueryBuilderHKT,\n\t\tTTableName,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection,\n\t\tTSelectMode\n\t>;\n\nexport type SQLiteSelectWithout<\n\tT extends AnySQLiteSelectQueryBuilder,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n\tTResetExcluded extends boolean = false,\n> = TDynamic extends true ? T : Omit<\n\tSQLiteSelectKind<\n\t\tT['_']['hkt'],\n\t\tT['_']['tableName'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['selection'],\n\t\tT['_']['selectMode'],\n\t\tT['_']['nullabilityMap'],\n\t\tTDynamic,\n\t\tTResetExcluded extends true ? K : T['_']['excludedMethods'] | K,\n\t\tT['_']['result'],\n\t\tT['_']['selectedFields']\n\t>,\n\tTResetExcluded extends true ? K : T['_']['excludedMethods'] | K\n>;\n\nexport type SQLiteSelectExecute<T extends AnySQLiteSelect> = T['_']['result'];\n\nexport type SQLiteSelectPrepare<T extends AnySQLiteSelect> = SQLitePreparedQuery<\n\t{\n\t\ttype: T['_']['resultType'];\n\t\trun: T['_']['runResult'];\n\t\tall: T['_']['result'];\n\t\tget: T['_']['result'][number] | undefined;\n\t\tvalues: any[][];\n\t\texecute: SQLiteSelectExecute<T>;\n\t}\n>;\n\nexport type SQLiteSelectDynamic<T extends AnySQLiteSelectQueryBuilder> = SQLiteSelectKind<\n\tT['_']['hkt'],\n\tT['_']['tableName'],\n\tT['_']['resultType'],\n\tT['_']['runResult'],\n\tT['_']['selection'],\n\tT['_']['selectMode'],\n\tT['_']['nullabilityMap'],\n\ttrue,\n\tnever,\n\tT['_']['result'],\n\tT['_']['selectedFields']\n>;\n\nexport type SQLiteSelectQueryBuilder<\n\tTHKT extends SQLiteSelectHKTBase = SQLiteSelectQueryBuilderHKT,\n\tTTableName extends string | undefined = string | undefined,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTSelection extends ColumnsSelection = ColumnsSelection,\n\tTSelectMode extends SelectMode = SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>,\n\tTResult extends any[] = unknown[],\n\tTSelectedFields extends ColumnsSelection = ColumnsSelection,\n> = SQLiteSelectQueryBuilderBase<\n\tTHKT,\n\tTTableName,\n\tTResultType,\n\tTRunResult,\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\ttrue,\n\tnever,\n\tTResult,\n\tTSelectedFields\n>;\n\nexport type AnySQLiteSelectQueryBuilder = SQLiteSelectQueryBuilderBase<\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany\n>;\n\nexport type AnySQLiteSetOperatorInterface = SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, any>;\n\nexport interface SQLiteSetOperatorInterface<\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> {\n\t_: {\n\t\treadonly hkt: SQLiteSelectHKTBase;\n\t\treadonly tableName: TTableName;\n\t\treadonly resultType: TResultType;\n\t\treadonly runResult: TRunResult;\n\t\treadonly selection: TSelection;\n\t\treadonly selectMode: TSelectMode;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TResult;\n\t\treadonly selectedFields: TSelectedFields;\n\t};\n}\n\nexport type SQLiteSetOperatorWithResult<TResult extends any[]> = SQLiteSetOperatorInterface<\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tany,\n\tTResult,\n\tany\n>;\n\nexport type SQLiteSelect<\n\tTTableName extends string | undefined = string | undefined,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTSelection extends ColumnsSelection = Record<string, any>,\n\tTSelectMode extends SelectMode = SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>,\n> = SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, never>;\n\nexport type AnySQLiteSelect = SQLiteSelectBase<any, any, any, any, any, any, any, any, any, any>;\n\nexport type SQLiteSetOperator<\n\tTTableName extends string | undefined = string | undefined,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTSelection extends ColumnsSelection = Record<string, any>,\n\tTSelectMode extends SelectMode = SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>,\n> = SQLiteSelectBase<\n\tTTableName,\n\tTResultType,\n\tTRunResult,\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\ttrue,\n\tSQLiteSetOperatorExcludedMethods\n>;\n\nexport type SetOperatorRightSelect<\n\tTValue extends SQLiteSetOperatorWithResult<TResult>,\n\tTResult extends any[],\n> = TValue extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any>\n\t? ValidateShape<\n\t\tTValueResult[number],\n\t\tTResult[number],\n\t\tTypedQueryBuilder<any, TValueResult>\n\t>\n\t: TValue;\n\nexport type SetOperatorRestSelect<\n\tTValue extends readonly SQLiteSetOperatorWithResult<TResult>[],\n\tTResult extends any[],\n> = TValue extends [infer First, ...infer Rest]\n\t? First extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any>\n\t\t? Rest extends AnySQLiteSetOperatorInterface[] ? [\n\t\t\t\tValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>>,\n\t\t\t\t...SetOperatorRestSelect<Rest, TResult>,\n\t\t\t]\n\t\t: ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>[]>\n\t: never\n\t: TValue;\n\nexport type SQLiteCreateSetOperatorFn = <\n\tTTableName extends string | undefined,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTSelection extends ColumnsSelection,\n\tTValue extends SQLiteSetOperatorWithResult<TResult>,\n\tTRest extends SQLiteSetOperatorWithResult<TResult>[],\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n>(\n\tleftSelect: SQLiteSetOperatorInterface<\n\t\tTTableName,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection,\n\t\tTSelectMode,\n\t\tTNullabilityMap,\n\t\tTDynamic,\n\t\tTExcludedMethods,\n\t\tTResult,\n\t\tTSelectedFields\n\t>,\n\trightSelect: SetOperatorRightSelect<TValue, TResult>,\n\t...restSelects: SetOperatorRestSelect<TRest, TResult>\n) => SQLiteSelectWithout<\n\tSQLiteSelectBase<\n\t\tTTableName,\n\t\tTResultType,\n\t\tTRunResult,\n\t\tTSelection,\n\t\tTSelectMode,\n\t\tTNullabilityMap,\n\t\tTDynamic,\n\t\tTExcludedMethods,\n\t\tTResult,\n\t\tTSelectedFields\n\t>,\n\tfalse,\n\tSQLiteSetOperatorExcludedMethods,\n\ttrue\n>;\n\nexport type GetSQLiteSetOperators = {\n\tunion: SQLiteCreateSetOperatorFn;\n\tintersect: SQLiteCreateSetOperatorFn;\n\texcept: SQLiteCreateSetOperatorFn;\n\tunionAll: SQLiteCreateSetOperatorFn;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.cts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ColumnsSelection, Placeholder, SQL, View } from "../../sql/sql.cjs";
|
| 2 |
+
import type { SQLiteColumn } from "../columns/index.cjs";
|
| 3 |
+
import type { SQLiteTable, SQLiteTableWithColumns } from "../table.cjs";
|
| 4 |
+
import type { Assume, ValidateShape } from "../../utils.cjs";
|
| 5 |
+
import type { SelectedFields as SelectFieldsBase, SelectedFieldsFlat as SelectFieldsFlatBase, SelectedFieldsOrdered as SelectFieldsOrderedBase } from "../../operations.cjs";
|
| 6 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.cjs";
|
| 7 |
+
import type { AppendToNullabilityMap, AppendToResult, BuildSubquerySelection, GetSelectTableName, JoinNullability, JoinType, MapColumnsToTableAlias, SelectMode, SelectResult, SetOperator } from "../../query-builders/select.types.cjs";
|
| 8 |
+
import type { Subquery } from "../../subquery.cjs";
|
| 9 |
+
import type { Table, UpdateTableConfig } from "../../table.cjs";
|
| 10 |
+
import type { SQLitePreparedQuery } from "../session.cjs";
|
| 11 |
+
import type { SQLiteViewBase } from "../view-base.cjs";
|
| 12 |
+
import type { SQLiteViewWithSelection } from "../view.cjs";
|
| 13 |
+
import type { SQLiteSelectBase, SQLiteSelectQueryBuilderBase } from "./select.cjs";
|
| 14 |
+
export interface SQLiteSelectJoinConfig {
|
| 15 |
+
on: SQL | undefined;
|
| 16 |
+
table: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 17 |
+
alias: string | undefined;
|
| 18 |
+
joinType: JoinType;
|
| 19 |
+
}
|
| 20 |
+
export type BuildAliasTable<TTable extends SQLiteTable | View, TAlias extends string> = TTable extends Table ? SQLiteTableWithColumns<UpdateTableConfig<TTable['_']['config'], {
|
| 21 |
+
name: TAlias;
|
| 22 |
+
columns: MapColumnsToTableAlias<TTable['_']['columns'], TAlias, 'sqlite'>;
|
| 23 |
+
}>> : TTable extends View ? SQLiteViewWithSelection<TAlias, TTable['_']['existing'], MapColumnsToTableAlias<TTable['_']['selectedFields'], TAlias, 'sqlite'>> : never;
|
| 24 |
+
export interface SQLiteSelectConfig {
|
| 25 |
+
withList?: Subquery[];
|
| 26 |
+
fields: Record<string, unknown>;
|
| 27 |
+
fieldsFlat?: SelectedFieldsOrdered;
|
| 28 |
+
where?: SQL;
|
| 29 |
+
having?: SQL;
|
| 30 |
+
table: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 31 |
+
limit?: number | Placeholder;
|
| 32 |
+
offset?: number | Placeholder;
|
| 33 |
+
joins?: SQLiteSelectJoinConfig[];
|
| 34 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 35 |
+
groupBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 36 |
+
distinct?: boolean;
|
| 37 |
+
setOperators: {
|
| 38 |
+
rightSelect: TypedQueryBuilder<any, any>;
|
| 39 |
+
type: SetOperator;
|
| 40 |
+
isAll: boolean;
|
| 41 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 42 |
+
limit?: number | Placeholder;
|
| 43 |
+
offset?: number | Placeholder;
|
| 44 |
+
}[];
|
| 45 |
+
}
|
| 46 |
+
export type SQLiteSelectJoin<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, TJoinType extends JoinType, TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>> = T extends any ? SQLiteSelectWithout<SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], AppendToResult<T['_']['tableName'], T['_']['selection'], TJoinedName, TJoinedTable extends SQLiteTable ? TJoinedTable['_']['columns'] : TJoinedTable extends Subquery | View ? Assume<TJoinedTable['_']['selectedFields'], SelectedFields> : never, T['_']['selectMode']>, T['_']['selectMode'] extends 'partial' ? T['_']['selectMode'] : 'multiple', AppendToNullabilityMap<T['_']['nullabilityMap'], TJoinedName, TJoinType>, T['_']['dynamic'], T['_']['excludedMethods']>, TDynamic, T['_']['excludedMethods']> : never;
|
| 47 |
+
export type SQLiteSelectJoinFn<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, TJoinType extends JoinType> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: ((aliases: T['_']['selection']) => SQL | undefined) | SQL | undefined) => SQLiteSelectJoin<T, TDynamic, TJoinType, TJoinedTable, TJoinedName>;
|
| 48 |
+
export type SQLiteSelectCrossJoinFn<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable) => SQLiteSelectJoin<T, TDynamic, 'cross', TJoinedTable, TJoinedName>;
|
| 49 |
+
export type SelectedFieldsFlat = SelectFieldsFlatBase<SQLiteColumn>;
|
| 50 |
+
export type SelectedFields = SelectFieldsBase<SQLiteColumn, SQLiteTable>;
|
| 51 |
+
export type SelectedFieldsOrdered = SelectFieldsOrderedBase<SQLiteColumn>;
|
| 52 |
+
export interface SQLiteSelectHKTBase {
|
| 53 |
+
tableName: string | undefined;
|
| 54 |
+
resultType: 'sync' | 'async';
|
| 55 |
+
runResult: unknown;
|
| 56 |
+
selection: unknown;
|
| 57 |
+
selectMode: SelectMode;
|
| 58 |
+
nullabilityMap: unknown;
|
| 59 |
+
dynamic: boolean;
|
| 60 |
+
excludedMethods: string;
|
| 61 |
+
result: unknown;
|
| 62 |
+
selectedFields: unknown;
|
| 63 |
+
_type: unknown;
|
| 64 |
+
}
|
| 65 |
+
export type SQLiteSelectKind<T extends SQLiteSelectHKTBase, TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability>, TDynamic extends boolean, TExcludedMethods extends string, TResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>> = (T & {
|
| 66 |
+
tableName: TTableName;
|
| 67 |
+
resultType: TResultType;
|
| 68 |
+
runResult: TRunResult;
|
| 69 |
+
selection: TSelection;
|
| 70 |
+
selectMode: TSelectMode;
|
| 71 |
+
nullabilityMap: TNullabilityMap;
|
| 72 |
+
dynamic: TDynamic;
|
| 73 |
+
excludedMethods: TExcludedMethods;
|
| 74 |
+
result: TResult;
|
| 75 |
+
selectedFields: TSelectedFields;
|
| 76 |
+
})['_type'];
|
| 77 |
+
export interface SQLiteSelectQueryBuilderHKT extends SQLiteSelectHKTBase {
|
| 78 |
+
_type: SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, this['tableName'], this['resultType'], this['runResult'], Assume<this['selection'], ColumnsSelection>, this['selectMode'], Assume<this['nullabilityMap'], Record<string, JoinNullability>>, this['dynamic'], this['excludedMethods'], Assume<this['result'], any[]>, Assume<this['selectedFields'], ColumnsSelection>>;
|
| 79 |
+
}
|
| 80 |
+
export interface SQLiteSelectHKT extends SQLiteSelectHKTBase {
|
| 81 |
+
_type: SQLiteSelectBase<this['tableName'], this['resultType'], this['runResult'], Assume<this['selection'], ColumnsSelection>, this['selectMode'], Assume<this['nullabilityMap'], Record<string, JoinNullability>>, this['dynamic'], this['excludedMethods'], Assume<this['result'], any[]>, Assume<this['selectedFields'], ColumnsSelection>>;
|
| 82 |
+
}
|
| 83 |
+
export type SQLiteSetOperatorExcludedMethods = 'config' | 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin' | 'where' | 'having' | 'groupBy';
|
| 84 |
+
export type CreateSQLiteSelectFromBuilderMode<TBuilderMode extends 'db' | 'qb', TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode> = TBuilderMode extends 'db' ? SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode> : SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, TTableName, TResultType, TRunResult, TSelection, TSelectMode>;
|
| 85 |
+
export type SQLiteSelectWithout<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, K extends keyof T & string, TResetExcluded extends boolean = false> = TDynamic extends true ? T : Omit<SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], T['_']['selection'], T['_']['selectMode'], T['_']['nullabilityMap'], TDynamic, TResetExcluded extends true ? K : T['_']['excludedMethods'] | K, T['_']['result'], T['_']['selectedFields']>, TResetExcluded extends true ? K : T['_']['excludedMethods'] | K>;
|
| 86 |
+
export type SQLiteSelectExecute<T extends AnySQLiteSelect> = T['_']['result'];
|
| 87 |
+
export type SQLiteSelectPrepare<T extends AnySQLiteSelect> = SQLitePreparedQuery<{
|
| 88 |
+
type: T['_']['resultType'];
|
| 89 |
+
run: T['_']['runResult'];
|
| 90 |
+
all: T['_']['result'];
|
| 91 |
+
get: T['_']['result'][number] | undefined;
|
| 92 |
+
values: any[][];
|
| 93 |
+
execute: SQLiteSelectExecute<T>;
|
| 94 |
+
}>;
|
| 95 |
+
export type SQLiteSelectDynamic<T extends AnySQLiteSelectQueryBuilder> = SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], T['_']['selection'], T['_']['selectMode'], T['_']['nullabilityMap'], true, never, T['_']['result'], T['_']['selectedFields']>;
|
| 96 |
+
export type SQLiteSelectQueryBuilder<THKT extends SQLiteSelectHKTBase = SQLiteSelectQueryBuilderHKT, TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = ColumnsSelection, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>, TResult extends any[] = unknown[], TSelectedFields extends ColumnsSelection = ColumnsSelection> = SQLiteSelectQueryBuilderBase<THKT, TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, never, TResult, TSelectedFields>;
|
| 97 |
+
export type AnySQLiteSelectQueryBuilder = SQLiteSelectQueryBuilderBase<any, any, any, any, any, any, any, any, any, any, any>;
|
| 98 |
+
export type AnySQLiteSetOperatorInterface = SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, any>;
|
| 99 |
+
export interface SQLiteSetOperatorInterface<TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> {
|
| 100 |
+
_: {
|
| 101 |
+
readonly hkt: SQLiteSelectHKTBase;
|
| 102 |
+
readonly tableName: TTableName;
|
| 103 |
+
readonly resultType: TResultType;
|
| 104 |
+
readonly runResult: TRunResult;
|
| 105 |
+
readonly selection: TSelection;
|
| 106 |
+
readonly selectMode: TSelectMode;
|
| 107 |
+
readonly nullabilityMap: TNullabilityMap;
|
| 108 |
+
readonly dynamic: TDynamic;
|
| 109 |
+
readonly excludedMethods: TExcludedMethods;
|
| 110 |
+
readonly result: TResult;
|
| 111 |
+
readonly selectedFields: TSelectedFields;
|
| 112 |
+
};
|
| 113 |
+
}
|
| 114 |
+
export type SQLiteSetOperatorWithResult<TResult extends any[]> = SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, TResult, any>;
|
| 115 |
+
export type SQLiteSelect<TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = Record<string, any>, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>> = SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, never>;
|
| 116 |
+
export type AnySQLiteSelect = SQLiteSelectBase<any, any, any, any, any, any, any, any, any, any>;
|
| 117 |
+
export type SQLiteSetOperator<TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = Record<string, any>, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>> = SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, SQLiteSetOperatorExcludedMethods>;
|
| 118 |
+
export type SetOperatorRightSelect<TValue extends SQLiteSetOperatorWithResult<TResult>, TResult extends any[]> = TValue extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any> ? ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>> : TValue;
|
| 119 |
+
export type SetOperatorRestSelect<TValue extends readonly SQLiteSetOperatorWithResult<TResult>[], TResult extends any[]> = TValue extends [infer First, ...infer Rest] ? First extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any> ? Rest extends AnySQLiteSetOperatorInterface[] ? [
|
| 120 |
+
ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>>,
|
| 121 |
+
...SetOperatorRestSelect<Rest, TResult>
|
| 122 |
+
] : ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>[]> : never : TValue;
|
| 123 |
+
export type SQLiteCreateSetOperatorFn = <TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TValue extends SQLiteSetOperatorWithResult<TResult>, TRest extends SQLiteSetOperatorWithResult<TResult>[], TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>>(leftSelect: SQLiteSetOperatorInterface<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>, rightSelect: SetOperatorRightSelect<TValue, TResult>, ...restSelects: SetOperatorRestSelect<TRest, TResult>) => SQLiteSelectWithout<SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>, false, SQLiteSetOperatorExcludedMethods, true>;
|
| 124 |
+
export type GetSQLiteSetOperators = {
|
| 125 |
+
union: SQLiteCreateSetOperatorFn;
|
| 126 |
+
intersect: SQLiteCreateSetOperatorFn;
|
| 127 |
+
except: SQLiteCreateSetOperatorFn;
|
| 128 |
+
unionAll: SQLiteCreateSetOperatorFn;
|
| 129 |
+
};
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ColumnsSelection, Placeholder, SQL, View } from "../../sql/sql.js";
|
| 2 |
+
import type { SQLiteColumn } from "../columns/index.js";
|
| 3 |
+
import type { SQLiteTable, SQLiteTableWithColumns } from "../table.js";
|
| 4 |
+
import type { Assume, ValidateShape } from "../../utils.js";
|
| 5 |
+
import type { SelectedFields as SelectFieldsBase, SelectedFieldsFlat as SelectFieldsFlatBase, SelectedFieldsOrdered as SelectFieldsOrderedBase } from "../../operations.js";
|
| 6 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.js";
|
| 7 |
+
import type { AppendToNullabilityMap, AppendToResult, BuildSubquerySelection, GetSelectTableName, JoinNullability, JoinType, MapColumnsToTableAlias, SelectMode, SelectResult, SetOperator } from "../../query-builders/select.types.js";
|
| 8 |
+
import type { Subquery } from "../../subquery.js";
|
| 9 |
+
import type { Table, UpdateTableConfig } from "../../table.js";
|
| 10 |
+
import type { SQLitePreparedQuery } from "../session.js";
|
| 11 |
+
import type { SQLiteViewBase } from "../view-base.js";
|
| 12 |
+
import type { SQLiteViewWithSelection } from "../view.js";
|
| 13 |
+
import type { SQLiteSelectBase, SQLiteSelectQueryBuilderBase } from "./select.js";
|
| 14 |
+
export interface SQLiteSelectJoinConfig {
|
| 15 |
+
on: SQL | undefined;
|
| 16 |
+
table: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 17 |
+
alias: string | undefined;
|
| 18 |
+
joinType: JoinType;
|
| 19 |
+
}
|
| 20 |
+
export type BuildAliasTable<TTable extends SQLiteTable | View, TAlias extends string> = TTable extends Table ? SQLiteTableWithColumns<UpdateTableConfig<TTable['_']['config'], {
|
| 21 |
+
name: TAlias;
|
| 22 |
+
columns: MapColumnsToTableAlias<TTable['_']['columns'], TAlias, 'sqlite'>;
|
| 23 |
+
}>> : TTable extends View ? SQLiteViewWithSelection<TAlias, TTable['_']['existing'], MapColumnsToTableAlias<TTable['_']['selectedFields'], TAlias, 'sqlite'>> : never;
|
| 24 |
+
export interface SQLiteSelectConfig {
|
| 25 |
+
withList?: Subquery[];
|
| 26 |
+
fields: Record<string, unknown>;
|
| 27 |
+
fieldsFlat?: SelectedFieldsOrdered;
|
| 28 |
+
where?: SQL;
|
| 29 |
+
having?: SQL;
|
| 30 |
+
table: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 31 |
+
limit?: number | Placeholder;
|
| 32 |
+
offset?: number | Placeholder;
|
| 33 |
+
joins?: SQLiteSelectJoinConfig[];
|
| 34 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 35 |
+
groupBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 36 |
+
distinct?: boolean;
|
| 37 |
+
setOperators: {
|
| 38 |
+
rightSelect: TypedQueryBuilder<any, any>;
|
| 39 |
+
type: SetOperator;
|
| 40 |
+
isAll: boolean;
|
| 41 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 42 |
+
limit?: number | Placeholder;
|
| 43 |
+
offset?: number | Placeholder;
|
| 44 |
+
}[];
|
| 45 |
+
}
|
| 46 |
+
export type SQLiteSelectJoin<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, TJoinType extends JoinType, TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>> = T extends any ? SQLiteSelectWithout<SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], AppendToResult<T['_']['tableName'], T['_']['selection'], TJoinedName, TJoinedTable extends SQLiteTable ? TJoinedTable['_']['columns'] : TJoinedTable extends Subquery | View ? Assume<TJoinedTable['_']['selectedFields'], SelectedFields> : never, T['_']['selectMode']>, T['_']['selectMode'] extends 'partial' ? T['_']['selectMode'] : 'multiple', AppendToNullabilityMap<T['_']['nullabilityMap'], TJoinedName, TJoinType>, T['_']['dynamic'], T['_']['excludedMethods']>, TDynamic, T['_']['excludedMethods']> : never;
|
| 47 |
+
export type SQLiteSelectJoinFn<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, TJoinType extends JoinType> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: ((aliases: T['_']['selection']) => SQL | undefined) | SQL | undefined) => SQLiteSelectJoin<T, TDynamic, TJoinType, TJoinedTable, TJoinedName>;
|
| 48 |
+
export type SQLiteSelectCrossJoinFn<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable) => SQLiteSelectJoin<T, TDynamic, 'cross', TJoinedTable, TJoinedName>;
|
| 49 |
+
export type SelectedFieldsFlat = SelectFieldsFlatBase<SQLiteColumn>;
|
| 50 |
+
export type SelectedFields = SelectFieldsBase<SQLiteColumn, SQLiteTable>;
|
| 51 |
+
export type SelectedFieldsOrdered = SelectFieldsOrderedBase<SQLiteColumn>;
|
| 52 |
+
export interface SQLiteSelectHKTBase {
|
| 53 |
+
tableName: string | undefined;
|
| 54 |
+
resultType: 'sync' | 'async';
|
| 55 |
+
runResult: unknown;
|
| 56 |
+
selection: unknown;
|
| 57 |
+
selectMode: SelectMode;
|
| 58 |
+
nullabilityMap: unknown;
|
| 59 |
+
dynamic: boolean;
|
| 60 |
+
excludedMethods: string;
|
| 61 |
+
result: unknown;
|
| 62 |
+
selectedFields: unknown;
|
| 63 |
+
_type: unknown;
|
| 64 |
+
}
|
| 65 |
+
export type SQLiteSelectKind<T extends SQLiteSelectHKTBase, TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability>, TDynamic extends boolean, TExcludedMethods extends string, TResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>> = (T & {
|
| 66 |
+
tableName: TTableName;
|
| 67 |
+
resultType: TResultType;
|
| 68 |
+
runResult: TRunResult;
|
| 69 |
+
selection: TSelection;
|
| 70 |
+
selectMode: TSelectMode;
|
| 71 |
+
nullabilityMap: TNullabilityMap;
|
| 72 |
+
dynamic: TDynamic;
|
| 73 |
+
excludedMethods: TExcludedMethods;
|
| 74 |
+
result: TResult;
|
| 75 |
+
selectedFields: TSelectedFields;
|
| 76 |
+
})['_type'];
|
| 77 |
+
export interface SQLiteSelectQueryBuilderHKT extends SQLiteSelectHKTBase {
|
| 78 |
+
_type: SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, this['tableName'], this['resultType'], this['runResult'], Assume<this['selection'], ColumnsSelection>, this['selectMode'], Assume<this['nullabilityMap'], Record<string, JoinNullability>>, this['dynamic'], this['excludedMethods'], Assume<this['result'], any[]>, Assume<this['selectedFields'], ColumnsSelection>>;
|
| 79 |
+
}
|
| 80 |
+
export interface SQLiteSelectHKT extends SQLiteSelectHKTBase {
|
| 81 |
+
_type: SQLiteSelectBase<this['tableName'], this['resultType'], this['runResult'], Assume<this['selection'], ColumnsSelection>, this['selectMode'], Assume<this['nullabilityMap'], Record<string, JoinNullability>>, this['dynamic'], this['excludedMethods'], Assume<this['result'], any[]>, Assume<this['selectedFields'], ColumnsSelection>>;
|
| 82 |
+
}
|
| 83 |
+
export type SQLiteSetOperatorExcludedMethods = 'config' | 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin' | 'where' | 'having' | 'groupBy';
|
| 84 |
+
export type CreateSQLiteSelectFromBuilderMode<TBuilderMode extends 'db' | 'qb', TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode> = TBuilderMode extends 'db' ? SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode> : SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, TTableName, TResultType, TRunResult, TSelection, TSelectMode>;
|
| 85 |
+
export type SQLiteSelectWithout<T extends AnySQLiteSelectQueryBuilder, TDynamic extends boolean, K extends keyof T & string, TResetExcluded extends boolean = false> = TDynamic extends true ? T : Omit<SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], T['_']['selection'], T['_']['selectMode'], T['_']['nullabilityMap'], TDynamic, TResetExcluded extends true ? K : T['_']['excludedMethods'] | K, T['_']['result'], T['_']['selectedFields']>, TResetExcluded extends true ? K : T['_']['excludedMethods'] | K>;
|
| 86 |
+
export type SQLiteSelectExecute<T extends AnySQLiteSelect> = T['_']['result'];
|
| 87 |
+
export type SQLiteSelectPrepare<T extends AnySQLiteSelect> = SQLitePreparedQuery<{
|
| 88 |
+
type: T['_']['resultType'];
|
| 89 |
+
run: T['_']['runResult'];
|
| 90 |
+
all: T['_']['result'];
|
| 91 |
+
get: T['_']['result'][number] | undefined;
|
| 92 |
+
values: any[][];
|
| 93 |
+
execute: SQLiteSelectExecute<T>;
|
| 94 |
+
}>;
|
| 95 |
+
export type SQLiteSelectDynamic<T extends AnySQLiteSelectQueryBuilder> = SQLiteSelectKind<T['_']['hkt'], T['_']['tableName'], T['_']['resultType'], T['_']['runResult'], T['_']['selection'], T['_']['selectMode'], T['_']['nullabilityMap'], true, never, T['_']['result'], T['_']['selectedFields']>;
|
| 96 |
+
export type SQLiteSelectQueryBuilder<THKT extends SQLiteSelectHKTBase = SQLiteSelectQueryBuilderHKT, TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = ColumnsSelection, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>, TResult extends any[] = unknown[], TSelectedFields extends ColumnsSelection = ColumnsSelection> = SQLiteSelectQueryBuilderBase<THKT, TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, never, TResult, TSelectedFields>;
|
| 97 |
+
export type AnySQLiteSelectQueryBuilder = SQLiteSelectQueryBuilderBase<any, any, any, any, any, any, any, any, any, any, any>;
|
| 98 |
+
export type AnySQLiteSetOperatorInterface = SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, any>;
|
| 99 |
+
export interface SQLiteSetOperatorInterface<TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> {
|
| 100 |
+
_: {
|
| 101 |
+
readonly hkt: SQLiteSelectHKTBase;
|
| 102 |
+
readonly tableName: TTableName;
|
| 103 |
+
readonly resultType: TResultType;
|
| 104 |
+
readonly runResult: TRunResult;
|
| 105 |
+
readonly selection: TSelection;
|
| 106 |
+
readonly selectMode: TSelectMode;
|
| 107 |
+
readonly nullabilityMap: TNullabilityMap;
|
| 108 |
+
readonly dynamic: TDynamic;
|
| 109 |
+
readonly excludedMethods: TExcludedMethods;
|
| 110 |
+
readonly result: TResult;
|
| 111 |
+
readonly selectedFields: TSelectedFields;
|
| 112 |
+
};
|
| 113 |
+
}
|
| 114 |
+
export type SQLiteSetOperatorWithResult<TResult extends any[]> = SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, TResult, any>;
|
| 115 |
+
export type SQLiteSelect<TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = Record<string, any>, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>> = SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, never>;
|
| 116 |
+
export type AnySQLiteSelect = SQLiteSelectBase<any, any, any, any, any, any, any, any, any, any>;
|
| 117 |
+
export type SQLiteSetOperator<TTableName extends string | undefined = string | undefined, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TSelection extends ColumnsSelection = Record<string, any>, TSelectMode extends SelectMode = SelectMode, TNullabilityMap extends Record<string, JoinNullability> = Record<string, JoinNullability>> = SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, true, SQLiteSetOperatorExcludedMethods>;
|
| 118 |
+
export type SetOperatorRightSelect<TValue extends SQLiteSetOperatorWithResult<TResult>, TResult extends any[]> = TValue extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any> ? ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>> : TValue;
|
| 119 |
+
export type SetOperatorRestSelect<TValue extends readonly SQLiteSetOperatorWithResult<TResult>[], TResult extends any[]> = TValue extends [infer First, ...infer Rest] ? First extends SQLiteSetOperatorInterface<any, any, any, any, any, any, any, any, infer TValueResult, any> ? Rest extends AnySQLiteSetOperatorInterface[] ? [
|
| 120 |
+
ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>>,
|
| 121 |
+
...SetOperatorRestSelect<Rest, TResult>
|
| 122 |
+
] : ValidateShape<TValueResult[number], TResult[number], TypedQueryBuilder<any, TValueResult>[]> : never : TValue;
|
| 123 |
+
export type SQLiteCreateSetOperatorFn = <TTableName extends string | undefined, TResultType extends 'sync' | 'async', TRunResult, TSelection extends ColumnsSelection, TValue extends SQLiteSetOperatorWithResult<TResult>, TRest extends SQLiteSetOperatorWithResult<TResult>[], TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>>(leftSelect: SQLiteSetOperatorInterface<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>, rightSelect: SetOperatorRightSelect<TValue, TResult>, ...restSelects: SetOperatorRestSelect<TRest, TResult>) => SQLiteSelectWithout<SQLiteSelectBase<TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>, false, SQLiteSetOperatorExcludedMethods, true>;
|
| 124 |
+
export type GetSQLiteSetOperators = {
|
| 125 |
+
union: SQLiteCreateSetOperatorFn;
|
| 126 |
+
intersect: SQLiteCreateSetOperatorFn;
|
| 127 |
+
except: SQLiteCreateSetOperatorFn;
|
| 128 |
+
unionAll: SQLiteCreateSetOperatorFn;
|
| 129 |
+
};
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
//# sourceMappingURL=select.types.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var update_exports = {};
|
| 20 |
+
__export(update_exports, {
|
| 21 |
+
SQLiteUpdateBase: () => SQLiteUpdateBase,
|
| 22 |
+
SQLiteUpdateBuilder: () => SQLiteUpdateBuilder
|
| 23 |
+
});
|
| 24 |
+
module.exports = __toCommonJS(update_exports);
|
| 25 |
+
var import_entity = require("../../entity.cjs");
|
| 26 |
+
var import_query_promise = require("../../query-promise.cjs");
|
| 27 |
+
var import_selection_proxy = require("../../selection-proxy.cjs");
|
| 28 |
+
var import_table = require("../table.cjs");
|
| 29 |
+
var import_subquery = require("../../subquery.cjs");
|
| 30 |
+
var import_table2 = require("../../table.cjs");
|
| 31 |
+
var import_utils = require("../../utils.cjs");
|
| 32 |
+
var import_view_common = require("../../view-common.cjs");
|
| 33 |
+
var import_utils2 = require("../utils.cjs");
|
| 34 |
+
var import_view_base = require("../view-base.cjs");
|
| 35 |
+
class SQLiteUpdateBuilder {
|
| 36 |
+
constructor(table, session, dialect, withList) {
|
| 37 |
+
this.table = table;
|
| 38 |
+
this.session = session;
|
| 39 |
+
this.dialect = dialect;
|
| 40 |
+
this.withList = withList;
|
| 41 |
+
}
|
| 42 |
+
static [import_entity.entityKind] = "SQLiteUpdateBuilder";
|
| 43 |
+
set(values) {
|
| 44 |
+
return new SQLiteUpdateBase(
|
| 45 |
+
this.table,
|
| 46 |
+
(0, import_utils.mapUpdateSet)(this.table, values),
|
| 47 |
+
this.session,
|
| 48 |
+
this.dialect,
|
| 49 |
+
this.withList
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
class SQLiteUpdateBase extends import_query_promise.QueryPromise {
|
| 54 |
+
constructor(table, set, session, dialect, withList) {
|
| 55 |
+
super();
|
| 56 |
+
this.session = session;
|
| 57 |
+
this.dialect = dialect;
|
| 58 |
+
this.config = { set, table, withList, joins: [] };
|
| 59 |
+
}
|
| 60 |
+
static [import_entity.entityKind] = "SQLiteUpdate";
|
| 61 |
+
/** @internal */
|
| 62 |
+
config;
|
| 63 |
+
from(source) {
|
| 64 |
+
this.config.from = source;
|
| 65 |
+
return this;
|
| 66 |
+
}
|
| 67 |
+
createJoin(joinType) {
|
| 68 |
+
return (table, on) => {
|
| 69 |
+
const tableName = (0, import_utils.getTableLikeName)(table);
|
| 70 |
+
if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) {
|
| 71 |
+
throw new Error(`Alias "${tableName}" is already used in this query`);
|
| 72 |
+
}
|
| 73 |
+
if (typeof on === "function") {
|
| 74 |
+
const from = this.config.from ? (0, import_entity.is)(table, import_table.SQLiteTable) ? table[import_table2.Table.Symbol.Columns] : (0, import_entity.is)(table, import_subquery.Subquery) ? table._.selectedFields : (0, import_entity.is)(table, import_view_base.SQLiteViewBase) ? table[import_view_common.ViewBaseConfig].selectedFields : void 0 : void 0;
|
| 75 |
+
on = on(
|
| 76 |
+
new Proxy(
|
| 77 |
+
this.config.table[import_table2.Table.Symbol.Columns],
|
| 78 |
+
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 79 |
+
),
|
| 80 |
+
from && new Proxy(
|
| 81 |
+
from,
|
| 82 |
+
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 83 |
+
)
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
this.config.joins.push({ on, table, joinType, alias: tableName });
|
| 87 |
+
return this;
|
| 88 |
+
};
|
| 89 |
+
}
|
| 90 |
+
leftJoin = this.createJoin("left");
|
| 91 |
+
rightJoin = this.createJoin("right");
|
| 92 |
+
innerJoin = this.createJoin("inner");
|
| 93 |
+
fullJoin = this.createJoin("full");
|
| 94 |
+
/**
|
| 95 |
+
* Adds a 'where' clause to the query.
|
| 96 |
+
*
|
| 97 |
+
* Calling this method will update only those rows that fulfill a specified condition.
|
| 98 |
+
*
|
| 99 |
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
| 100 |
+
*
|
| 101 |
+
* @param where the 'where' clause.
|
| 102 |
+
*
|
| 103 |
+
* @example
|
| 104 |
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
| 105 |
+
*
|
| 106 |
+
* ```ts
|
| 107 |
+
* // Update all cars with green color
|
| 108 |
+
* db.update(cars).set({ color: 'red' })
|
| 109 |
+
* .where(eq(cars.color, 'green'));
|
| 110 |
+
* // or
|
| 111 |
+
* db.update(cars).set({ color: 'red' })
|
| 112 |
+
* .where(sql`${cars.color} = 'green'`)
|
| 113 |
+
* ```
|
| 114 |
+
*
|
| 115 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 116 |
+
*
|
| 117 |
+
* ```ts
|
| 118 |
+
* // Update all BMW cars with a green color
|
| 119 |
+
* db.update(cars).set({ color: 'red' })
|
| 120 |
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 121 |
+
*
|
| 122 |
+
* // Update all cars with the green or blue color
|
| 123 |
+
* db.update(cars).set({ color: 'red' })
|
| 124 |
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 125 |
+
* ```
|
| 126 |
+
*/
|
| 127 |
+
where(where) {
|
| 128 |
+
this.config.where = where;
|
| 129 |
+
return this;
|
| 130 |
+
}
|
| 131 |
+
orderBy(...columns) {
|
| 132 |
+
if (typeof columns[0] === "function") {
|
| 133 |
+
const orderBy = columns[0](
|
| 134 |
+
new Proxy(
|
| 135 |
+
this.config.table[import_table2.Table.Symbol.Columns],
|
| 136 |
+
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
| 137 |
+
)
|
| 138 |
+
);
|
| 139 |
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
| 140 |
+
this.config.orderBy = orderByArray;
|
| 141 |
+
} else {
|
| 142 |
+
const orderByArray = columns;
|
| 143 |
+
this.config.orderBy = orderByArray;
|
| 144 |
+
}
|
| 145 |
+
return this;
|
| 146 |
+
}
|
| 147 |
+
limit(limit) {
|
| 148 |
+
this.config.limit = limit;
|
| 149 |
+
return this;
|
| 150 |
+
}
|
| 151 |
+
returning(fields = this.config.table[import_table.SQLiteTable.Symbol.Columns]) {
|
| 152 |
+
this.config.returning = (0, import_utils.orderSelectedFields)(fields);
|
| 153 |
+
return this;
|
| 154 |
+
}
|
| 155 |
+
/** @internal */
|
| 156 |
+
getSQL() {
|
| 157 |
+
return this.dialect.buildUpdateQuery(this.config);
|
| 158 |
+
}
|
| 159 |
+
toSQL() {
|
| 160 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 161 |
+
return rest;
|
| 162 |
+
}
|
| 163 |
+
/** @internal */
|
| 164 |
+
_prepare(isOneTimeQuery = true) {
|
| 165 |
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
| 166 |
+
this.dialect.sqlToQuery(this.getSQL()),
|
| 167 |
+
this.config.returning,
|
| 168 |
+
this.config.returning ? "all" : "run",
|
| 169 |
+
true,
|
| 170 |
+
void 0,
|
| 171 |
+
{
|
| 172 |
+
type: "insert",
|
| 173 |
+
tables: (0, import_utils2.extractUsedTable)(this.config.table)
|
| 174 |
+
}
|
| 175 |
+
);
|
| 176 |
+
}
|
| 177 |
+
prepare() {
|
| 178 |
+
return this._prepare(false);
|
| 179 |
+
}
|
| 180 |
+
run = (placeholderValues) => {
|
| 181 |
+
return this._prepare().run(placeholderValues);
|
| 182 |
+
};
|
| 183 |
+
all = (placeholderValues) => {
|
| 184 |
+
return this._prepare().all(placeholderValues);
|
| 185 |
+
};
|
| 186 |
+
get = (placeholderValues) => {
|
| 187 |
+
return this._prepare().get(placeholderValues);
|
| 188 |
+
};
|
| 189 |
+
values = (placeholderValues) => {
|
| 190 |
+
return this._prepare().values(placeholderValues);
|
| 191 |
+
};
|
| 192 |
+
async execute() {
|
| 193 |
+
return this.config.returning ? this.all() : this.run();
|
| 194 |
+
}
|
| 195 |
+
$dynamic() {
|
| 196 |
+
return this;
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 200 |
+
0 && (module.exports = {
|
| 201 |
+
SQLiteUpdateBase,
|
| 202 |
+
SQLiteUpdateBuilder
|
| 203 |
+
});
|
| 204 |
+
//# sourceMappingURL=update.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/sqlite-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { JoinType, SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { SQLiteDialect } from '~/sqlite-core/dialect.ts';\nimport type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { SQLiteTable } from '~/sqlite-core/table.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\ttype DrizzleTypeError,\n\tgetTableLikeName,\n\tmapUpdateSet,\n\torderSelectedFields,\n\ttype UpdateSet,\n\ttype ValueOrArray,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { SQLiteColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport { SQLiteViewBase } from '../view-base.ts';\nimport type { SelectedFields, SelectedFieldsOrdered, SQLiteSelectJoinConfig } from './select.types.ts';\n\nexport interface SQLiteUpdateConfig {\n\twhere?: SQL | undefined;\n\tlimit?: number | Placeholder;\n\torderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];\n\tset: UpdateSet;\n\ttable: SQLiteTable;\n\tfrom?: SQLiteTable | Subquery | SQLiteViewBase | SQL;\n\tjoins: SQLiteSelectJoinConfig[];\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type SQLiteUpdateSetSource<TTable extends SQLiteTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key], 'query'>\n\t\t\t| SQL\n\t\t\t| SQLiteColumn\n\t\t\t| undefined;\n\t}\n\t& {};\n\nexport class SQLiteUpdateBuilder<\n\tTTable extends SQLiteTable,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n> {\n\tstatic readonly [entityKind]: string = 'SQLiteUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprotected table: TTable,\n\t\tprotected session: SQLiteSession<any, any, any, any>,\n\t\tprotected dialect: SQLiteDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tset(\n\t\tvalues: SQLiteUpdateSetSource<TTable>,\n\t): SQLiteUpdateWithout<\n\t\tSQLiteUpdateBase<TTable, TResultType, TRunResult>,\n\t\tfalse,\n\t\t'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'\n\t> {\n\t\treturn new SQLiteUpdateBase(\n\t\t\tthis.table,\n\t\t\tmapUpdateSet(this.table, values),\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t) as any;\n\t}\n}\n\nexport type SQLiteUpdateWithout<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tT['_']['returning'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type SQLiteUpdateWithJoins<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n> = TDynamic extends true ? T : Omit<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tTFrom,\n\t\tT['_']['returning'],\n\t\tTDynamic,\n\t\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n\t>,\n\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n>;\n\nexport type SQLiteUpdateReturningAll<T extends AnySQLiteUpdate, TDynamic extends boolean> = SQLiteUpdateWithout<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tT['_']['table']['$inferSelect'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type SQLiteUpdateReturning<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFields,\n> = SQLiteUpdateWithout<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tSelectResultFields<TSelectedFields>,\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type SQLiteUpdateExecute<T extends AnySQLiteUpdate> = T['_']['returning'] extends undefined ? T['_']['runResult']\n\t: T['_']['returning'][];\n\nexport type SQLiteUpdatePrepare<T extends AnySQLiteUpdate> = SQLitePreparedQuery<\n\t{\n\t\ttype: T['_']['resultType'];\n\t\trun: T['_']['runResult'];\n\t\tall: T['_']['returning'] extends undefined ? DrizzleTypeError<'.all() cannot be used without .returning()'>\n\t\t\t: T['_']['returning'][];\n\t\tget: T['_']['returning'] extends undefined ? DrizzleTypeError<'.get() cannot be used without .returning()'>\n\t\t\t: T['_']['returning'];\n\t\tvalues: T['_']['returning'] extends undefined ? DrizzleTypeError<'.values() cannot be used without .returning()'>\n\t\t\t: any[][];\n\t\texecute: SQLiteUpdateExecute<T>;\n\t}\n>;\n\nexport type SQLiteUpdateJoinFn<\n\tT extends AnySQLiteUpdate,\n> = <\n\tTJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n>(\n\ttable: TJoinedTable,\n\ton:\n\t\t| (\n\t\t\t(\n\t\t\t\tupdateTable: T['_']['table']['_']['columns'],\n\t\t\t\tfrom: T['_']['from'] extends SQLiteTable ? T['_']['from']['_']['columns']\n\t\t\t\t\t: T['_']['from'] extends Subquery | SQLiteViewBase ? T['_']['from']['_']['selectedFields']\n\t\t\t\t\t: never,\n\t\t\t) => SQL | undefined\n\t\t)\n\t\t| SQL\n\t\t| undefined,\n) => T;\n\nexport type SQLiteUpdateDynamic<T extends AnySQLiteUpdate> = SQLiteUpdate<\n\tT['_']['table'],\n\tT['_']['resultType'],\n\tT['_']['runResult'],\n\tT['_']['returning']\n>;\n\nexport type SQLiteUpdate<\n\tTTable extends SQLiteTable = SQLiteTable,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = any,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = SQLiteUpdateBase<TTable, TResultType, TRunResult, TFrom, TReturning, true, never>;\n\nexport type AnySQLiteUpdate = SQLiteUpdateBase<any, any, any, any, any, any, any>;\n\nexport interface SQLiteUpdateBase<\n\tTTable extends SQLiteTable = SQLiteTable,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends SQLWrapper, QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> {\n\treadonly _: {\n\t\treadonly dialect: 'sqlite';\n\t\treadonly table: TTable;\n\t\treadonly resultType: TResultType;\n\t\treadonly runResult: TRunResult;\n\t\treadonly from: TFrom;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? TRunResult : TReturning[];\n\t};\n}\n\nexport class SQLiteUpdateBase<\n\tTTable extends SQLiteTable = SQLiteTable,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning = undefined,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]>\n\timplements RunnableQuery<TReturning extends undefined ? TRunResult : TReturning[], 'sqlite'>, SQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteUpdate';\n\n\t/** @internal */\n\tconfig: SQLiteUpdateConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: SQLiteSession<any, any, any, any>,\n\t\tprivate dialect: SQLiteDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList, joins: [] };\n\t}\n\n\tfrom<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(\n\t\tsource: TFrom,\n\t): SQLiteUpdateWithJoins<this, TDynamic, TFrom> {\n\t\tthis.config.from = source;\n\t\treturn this as any;\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): SQLiteUpdateJoinFn<this> {\n\t\treturn ((\n\t\t\ttable: SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\t\t\ton: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\tconst from = this.config.from\n\t\t\t\t\t? is(table, SQLiteTable)\n\t\t\t\t\t\t? table[Table.Symbol.Columns]\n\t\t\t\t\t\t: is(table, Subquery)\n\t\t\t\t\t\t? table._.selectedFields\n\t\t\t\t\t\t: is(table, SQLiteViewBase)\n\t\t\t\t\t\t? table[ViewBaseConfig].selectedFields\n\t\t\t\t\t\t: undefined\n\t\t\t\t\t: undefined;\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t\tfrom && new Proxy(\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\treturn this as any;\n\t\t}) as any;\n\t}\n\n\tleftJoin = this.createJoin('left');\n\n\trightJoin = this.createJoin('right');\n\n\tinnerJoin = this.createJoin('inner');\n\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Adds a 'where' clause to the query.\n\t *\n\t * Calling this method will update only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param where the 'where' clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be updated.\n\t *\n\t * ```ts\n\t * // Update all cars with green color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Update all BMW cars with a green color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Update all cars with the green or blue color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): SQLiteUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\torderBy(\n\t\tbuilder: (updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>,\n\t): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>]\n\t\t\t| (SQLiteColumn | SQL | SQL.Aliased)[]\n\t): SQLiteUpdateWithout<this, TDynamic, 'orderBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst orderBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as any,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t} else {\n\t\t\tconst orderByArray = columns as (SQLiteColumn | SQL | SQL.Aliased)[];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\tlimit(limit: number | Placeholder): SQLiteUpdateWithout<this, TDynamic, 'limit'> {\n\t\tthis.config.limit = limit;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `returning` clause to the query.\n\t *\n\t * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Update all cars with the green color and return all fields\n\t * const updatedCars: Car[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Update all cars with the green color and return only their id and brand fields\n\t * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): SQLiteUpdateReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFields>(\n\t\tfields: TSelectedFields,\n\t): SQLiteUpdateReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields: SelectedFields = this.config.table[SQLiteTable.Symbol.Columns],\n\t): SQLiteUpdateWithout<AnySQLiteUpdate, TDynamic, 'returning'> {\n\t\tthis.config.returning = orderSelectedFields<SQLiteColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildUpdateQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\t/** @internal */\n\t_prepare(isOneTimeQuery = true): SQLiteUpdatePrepare<this> {\n\t\treturn this.session[isOneTimeQuery ? 'prepareOneTimeQuery' : 'prepareQuery'](\n\t\t\tthis.dialect.sqlToQuery(this.getSQL()),\n\t\t\tthis.config.returning,\n\t\t\tthis.config.returning ? 'all' : 'run',\n\t\t\ttrue,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttype: 'insert',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t},\n\t\t) as SQLiteUpdatePrepare<this>;\n\t}\n\n\tprepare(): SQLiteUpdatePrepare<this> {\n\t\treturn this._prepare(false);\n\t}\n\n\trun: ReturnType<this['prepare']>['run'] = (placeholderValues) => {\n\t\treturn this._prepare().run(placeholderValues);\n\t};\n\n\tall: ReturnType<this['prepare']>['all'] = (placeholderValues) => {\n\t\treturn this._prepare().all(placeholderValues);\n\t};\n\n\tget: ReturnType<this['prepare']>['get'] = (placeholderValues) => {\n\t\treturn this._prepare().get(placeholderValues);\n\t};\n\n\tvalues: ReturnType<this['prepare']>['values'] = (placeholderValues) => {\n\t\treturn this._prepare().values(placeholderValues);\n\t};\n\n\toverride async execute(): Promise<SQLiteUpdateExecute<this>> {\n\t\treturn (this.config.returning ? this.all() : this.run()) as SQLiteUpdateExecute<this>;\n\t}\n\n\t$dynamic(): SQLiteUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAE/B,2BAA6B;AAE7B,6BAAsC;AAItC,mBAA4B;AAC5B,sBAAyB;AACzB,IAAAA,gBAAsB;AACtB,mBAOO;AACP,yBAA+B;AAE/B,IAAAC,gBAAiC;AACjC,uBAA+B;AAyBxB,MAAM,oBAIX;AAAA,EAOD,YACW,OACA,SACA,SACF,UACP;AAJS;AACA;AACA;AACF;AAAA,EACN;AAAA,EAXH,QAAiB,wBAAU,IAAY;AAAA,EAavC,IACC,QAKC;AACD,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,UACL,2BAAa,KAAK,OAAO,MAAM;AAAA,MAC/B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AAAA,EACD;AACD;AA+IO,MAAM,yBAWH,kCAEV;AAAA,EAMC,YACC,OACA,KACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,KAAK,OAAO,UAAU,OAAO,CAAC,EAAE;AAAA,EACjD;AAAA,EAdA,QAA0B,wBAAU,IAAY;AAAA;AAAA,EAGhD;AAA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { GetColumnData } from "../../column.cjs";
|
| 2 |
+
import { entityKind } from "../../entity.cjs";
|
| 3 |
+
import type { SelectResultFields } from "../../query-builders/select.types.cjs";
|
| 4 |
+
import { QueryPromise } from "../../query-promise.cjs";
|
| 5 |
+
import type { RunnableQuery } from "../../runnable-query.cjs";
|
| 6 |
+
import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.cjs";
|
| 7 |
+
import type { SQLiteDialect } from "../dialect.cjs";
|
| 8 |
+
import type { SQLitePreparedQuery, SQLiteSession } from "../session.cjs";
|
| 9 |
+
import { SQLiteTable } from "../table.cjs";
|
| 10 |
+
import { Subquery } from "../../subquery.cjs";
|
| 11 |
+
import { type DrizzleTypeError, type UpdateSet, type ValueOrArray } from "../../utils.cjs";
|
| 12 |
+
import type { SQLiteColumn } from "../columns/common.cjs";
|
| 13 |
+
import { SQLiteViewBase } from "../view-base.cjs";
|
| 14 |
+
import type { SelectedFields, SelectedFieldsOrdered, SQLiteSelectJoinConfig } from "./select.types.cjs";
|
| 15 |
+
export interface SQLiteUpdateConfig {
|
| 16 |
+
where?: SQL | undefined;
|
| 17 |
+
limit?: number | Placeholder;
|
| 18 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 19 |
+
set: UpdateSet;
|
| 20 |
+
table: SQLiteTable;
|
| 21 |
+
from?: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 22 |
+
joins: SQLiteSelectJoinConfig[];
|
| 23 |
+
returning?: SelectedFieldsOrdered;
|
| 24 |
+
withList?: Subquery[];
|
| 25 |
+
}
|
| 26 |
+
export type SQLiteUpdateSetSource<TTable extends SQLiteTable> = {
|
| 27 |
+
[Key in keyof TTable['$inferInsert']]?: GetColumnData<TTable['_']['columns'][Key], 'query'> | SQL | SQLiteColumn | undefined;
|
| 28 |
+
} & {};
|
| 29 |
+
export declare class SQLiteUpdateBuilder<TTable extends SQLiteTable, TResultType extends 'sync' | 'async', TRunResult> {
|
| 30 |
+
protected table: TTable;
|
| 31 |
+
protected session: SQLiteSession<any, any, any, any>;
|
| 32 |
+
protected dialect: SQLiteDialect;
|
| 33 |
+
private withList?;
|
| 34 |
+
static readonly [entityKind]: string;
|
| 35 |
+
readonly _: {
|
| 36 |
+
readonly table: TTable;
|
| 37 |
+
};
|
| 38 |
+
constructor(table: TTable, session: SQLiteSession<any, any, any, any>, dialect: SQLiteDialect, withList?: Subquery[] | undefined);
|
| 39 |
+
set(values: SQLiteUpdateSetSource<TTable>): SQLiteUpdateWithout<SQLiteUpdateBase<TTable, TResultType, TRunResult>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>;
|
| 40 |
+
}
|
| 41 |
+
export type SQLiteUpdateWithout<T extends AnySQLiteUpdate, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 42 |
+
export type SQLiteUpdateWithJoins<T extends AnySQLiteUpdate, TDynamic extends boolean, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL> = TDynamic extends true ? T : Omit<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], TFrom, T['_']['returning'], TDynamic, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>;
|
| 43 |
+
export type SQLiteUpdateReturningAll<T extends AnySQLiteUpdate, TDynamic extends boolean> = SQLiteUpdateWithout<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 44 |
+
export type SQLiteUpdateReturning<T extends AnySQLiteUpdate, TDynamic extends boolean, TSelectedFields extends SelectedFields> = SQLiteUpdateWithout<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 45 |
+
export type SQLiteUpdateExecute<T extends AnySQLiteUpdate> = T['_']['returning'] extends undefined ? T['_']['runResult'] : T['_']['returning'][];
|
| 46 |
+
export type SQLiteUpdatePrepare<T extends AnySQLiteUpdate> = SQLitePreparedQuery<{
|
| 47 |
+
type: T['_']['resultType'];
|
| 48 |
+
run: T['_']['runResult'];
|
| 49 |
+
all: T['_']['returning'] extends undefined ? DrizzleTypeError<'.all() cannot be used without .returning()'> : T['_']['returning'][];
|
| 50 |
+
get: T['_']['returning'] extends undefined ? DrizzleTypeError<'.get() cannot be used without .returning()'> : T['_']['returning'];
|
| 51 |
+
values: T['_']['returning'] extends undefined ? DrizzleTypeError<'.values() cannot be used without .returning()'> : any[][];
|
| 52 |
+
execute: SQLiteUpdateExecute<T>;
|
| 53 |
+
}>;
|
| 54 |
+
export type SQLiteUpdateJoinFn<T extends AnySQLiteUpdate> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(table: TJoinedTable, on: ((updateTable: T['_']['table']['_']['columns'], from: T['_']['from'] extends SQLiteTable ? T['_']['from']['_']['columns'] : T['_']['from'] extends Subquery | SQLiteViewBase ? T['_']['from']['_']['selectedFields'] : never) => SQL | undefined) | SQL | undefined) => T;
|
| 55 |
+
export type SQLiteUpdateDynamic<T extends AnySQLiteUpdate> = SQLiteUpdate<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['returning']>;
|
| 56 |
+
export type SQLiteUpdate<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = any, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = SQLiteUpdateBase<TTable, TResultType, TRunResult, TFrom, TReturning, true, never>;
|
| 57 |
+
export type AnySQLiteUpdate = SQLiteUpdateBase<any, any, any, any, any, any, any>;
|
| 58 |
+
export interface SQLiteUpdateBase<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends SQLWrapper, QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> {
|
| 59 |
+
readonly _: {
|
| 60 |
+
readonly dialect: 'sqlite';
|
| 61 |
+
readonly table: TTable;
|
| 62 |
+
readonly resultType: TResultType;
|
| 63 |
+
readonly runResult: TRunResult;
|
| 64 |
+
readonly from: TFrom;
|
| 65 |
+
readonly returning: TReturning;
|
| 66 |
+
readonly dynamic: TDynamic;
|
| 67 |
+
readonly excludedMethods: TExcludedMethods;
|
| 68 |
+
readonly result: TReturning extends undefined ? TRunResult : TReturning[];
|
| 69 |
+
};
|
| 70 |
+
}
|
| 71 |
+
export declare class SQLiteUpdateBase<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> implements RunnableQuery<TReturning extends undefined ? TRunResult : TReturning[], 'sqlite'>, SQLWrapper {
|
| 72 |
+
private session;
|
| 73 |
+
private dialect;
|
| 74 |
+
static readonly [entityKind]: string;
|
| 75 |
+
constructor(table: TTable, set: UpdateSet, session: SQLiteSession<any, any, any, any>, dialect: SQLiteDialect, withList?: Subquery[]);
|
| 76 |
+
from<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(source: TFrom): SQLiteUpdateWithJoins<this, TDynamic, TFrom>;
|
| 77 |
+
private createJoin;
|
| 78 |
+
leftJoin: SQLiteUpdateJoinFn<this>;
|
| 79 |
+
rightJoin: SQLiteUpdateJoinFn<this>;
|
| 80 |
+
innerJoin: SQLiteUpdateJoinFn<this>;
|
| 81 |
+
fullJoin: SQLiteUpdateJoinFn<this>;
|
| 82 |
+
/**
|
| 83 |
+
* Adds a 'where' clause to the query.
|
| 84 |
+
*
|
| 85 |
+
* Calling this method will update only those rows that fulfill a specified condition.
|
| 86 |
+
*
|
| 87 |
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
| 88 |
+
*
|
| 89 |
+
* @param where the 'where' clause.
|
| 90 |
+
*
|
| 91 |
+
* @example
|
| 92 |
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
| 93 |
+
*
|
| 94 |
+
* ```ts
|
| 95 |
+
* // Update all cars with green color
|
| 96 |
+
* db.update(cars).set({ color: 'red' })
|
| 97 |
+
* .where(eq(cars.color, 'green'));
|
| 98 |
+
* // or
|
| 99 |
+
* db.update(cars).set({ color: 'red' })
|
| 100 |
+
* .where(sql`${cars.color} = 'green'`)
|
| 101 |
+
* ```
|
| 102 |
+
*
|
| 103 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 104 |
+
*
|
| 105 |
+
* ```ts
|
| 106 |
+
* // Update all BMW cars with a green color
|
| 107 |
+
* db.update(cars).set({ color: 'red' })
|
| 108 |
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 109 |
+
*
|
| 110 |
+
* // Update all cars with the green or blue color
|
| 111 |
+
* db.update(cars).set({ color: 'red' })
|
| 112 |
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 113 |
+
* ```
|
| 114 |
+
*/
|
| 115 |
+
where(where: SQL | undefined): SQLiteUpdateWithout<this, TDynamic, 'where'>;
|
| 116 |
+
orderBy(builder: (updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
|
| 117 |
+
orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
|
| 118 |
+
limit(limit: number | Placeholder): SQLiteUpdateWithout<this, TDynamic, 'limit'>;
|
| 119 |
+
/**
|
| 120 |
+
* Adds a `returning` clause to the query.
|
| 121 |
+
*
|
| 122 |
+
* Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.
|
| 123 |
+
*
|
| 124 |
+
* See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}
|
| 125 |
+
*
|
| 126 |
+
* @example
|
| 127 |
+
* ```ts
|
| 128 |
+
* // Update all cars with the green color and return all fields
|
| 129 |
+
* const updatedCars: Car[] = await db.update(cars)
|
| 130 |
+
* .set({ color: 'red' })
|
| 131 |
+
* .where(eq(cars.color, 'green'))
|
| 132 |
+
* .returning();
|
| 133 |
+
*
|
| 134 |
+
* // Update all cars with the green color and return only their id and brand fields
|
| 135 |
+
* const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)
|
| 136 |
+
* .set({ color: 'red' })
|
| 137 |
+
* .where(eq(cars.color, 'green'))
|
| 138 |
+
* .returning({ id: cars.id, brand: cars.brand });
|
| 139 |
+
* ```
|
| 140 |
+
*/
|
| 141 |
+
returning(): SQLiteUpdateReturningAll<this, TDynamic>;
|
| 142 |
+
returning<TSelectedFields extends SelectedFields>(fields: TSelectedFields): SQLiteUpdateReturning<this, TDynamic, TSelectedFields>;
|
| 143 |
+
toSQL(): Query;
|
| 144 |
+
prepare(): SQLiteUpdatePrepare<this>;
|
| 145 |
+
run: ReturnType<this['prepare']>['run'];
|
| 146 |
+
all: ReturnType<this['prepare']>['all'];
|
| 147 |
+
get: ReturnType<this['prepare']>['get'];
|
| 148 |
+
values: ReturnType<this['prepare']>['values'];
|
| 149 |
+
execute(): Promise<SQLiteUpdateExecute<this>>;
|
| 150 |
+
$dynamic(): SQLiteUpdateDynamic<this>;
|
| 151 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { GetColumnData } from "../../column.js";
|
| 2 |
+
import { entityKind } from "../../entity.js";
|
| 3 |
+
import type { SelectResultFields } from "../../query-builders/select.types.js";
|
| 4 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 5 |
+
import type { RunnableQuery } from "../../runnable-query.js";
|
| 6 |
+
import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.js";
|
| 7 |
+
import type { SQLiteDialect } from "../dialect.js";
|
| 8 |
+
import type { SQLitePreparedQuery, SQLiteSession } from "../session.js";
|
| 9 |
+
import { SQLiteTable } from "../table.js";
|
| 10 |
+
import { Subquery } from "../../subquery.js";
|
| 11 |
+
import { type DrizzleTypeError, type UpdateSet, type ValueOrArray } from "../../utils.js";
|
| 12 |
+
import type { SQLiteColumn } from "../columns/common.js";
|
| 13 |
+
import { SQLiteViewBase } from "../view-base.js";
|
| 14 |
+
import type { SelectedFields, SelectedFieldsOrdered, SQLiteSelectJoinConfig } from "./select.types.js";
|
| 15 |
+
export interface SQLiteUpdateConfig {
|
| 16 |
+
where?: SQL | undefined;
|
| 17 |
+
limit?: number | Placeholder;
|
| 18 |
+
orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
|
| 19 |
+
set: UpdateSet;
|
| 20 |
+
table: SQLiteTable;
|
| 21 |
+
from?: SQLiteTable | Subquery | SQLiteViewBase | SQL;
|
| 22 |
+
joins: SQLiteSelectJoinConfig[];
|
| 23 |
+
returning?: SelectedFieldsOrdered;
|
| 24 |
+
withList?: Subquery[];
|
| 25 |
+
}
|
| 26 |
+
export type SQLiteUpdateSetSource<TTable extends SQLiteTable> = {
|
| 27 |
+
[Key in keyof TTable['$inferInsert']]?: GetColumnData<TTable['_']['columns'][Key], 'query'> | SQL | SQLiteColumn | undefined;
|
| 28 |
+
} & {};
|
| 29 |
+
export declare class SQLiteUpdateBuilder<TTable extends SQLiteTable, TResultType extends 'sync' | 'async', TRunResult> {
|
| 30 |
+
protected table: TTable;
|
| 31 |
+
protected session: SQLiteSession<any, any, any, any>;
|
| 32 |
+
protected dialect: SQLiteDialect;
|
| 33 |
+
private withList?;
|
| 34 |
+
static readonly [entityKind]: string;
|
| 35 |
+
readonly _: {
|
| 36 |
+
readonly table: TTable;
|
| 37 |
+
};
|
| 38 |
+
constructor(table: TTable, session: SQLiteSession<any, any, any, any>, dialect: SQLiteDialect, withList?: Subquery[] | undefined);
|
| 39 |
+
set(values: SQLiteUpdateSetSource<TTable>): SQLiteUpdateWithout<SQLiteUpdateBase<TTable, TResultType, TRunResult>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>;
|
| 40 |
+
}
|
| 41 |
+
export type SQLiteUpdateWithout<T extends AnySQLiteUpdate, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 42 |
+
export type SQLiteUpdateWithJoins<T extends AnySQLiteUpdate, TDynamic extends boolean, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL> = TDynamic extends true ? T : Omit<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], TFrom, T['_']['returning'], TDynamic, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>;
|
| 43 |
+
export type SQLiteUpdateReturningAll<T extends AnySQLiteUpdate, TDynamic extends boolean> = SQLiteUpdateWithout<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 44 |
+
export type SQLiteUpdateReturning<T extends AnySQLiteUpdate, TDynamic extends boolean, TSelectedFields extends SelectedFields> = SQLiteUpdateWithout<SQLiteUpdateBase<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['from'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 45 |
+
export type SQLiteUpdateExecute<T extends AnySQLiteUpdate> = T['_']['returning'] extends undefined ? T['_']['runResult'] : T['_']['returning'][];
|
| 46 |
+
export type SQLiteUpdatePrepare<T extends AnySQLiteUpdate> = SQLitePreparedQuery<{
|
| 47 |
+
type: T['_']['resultType'];
|
| 48 |
+
run: T['_']['runResult'];
|
| 49 |
+
all: T['_']['returning'] extends undefined ? DrizzleTypeError<'.all() cannot be used without .returning()'> : T['_']['returning'][];
|
| 50 |
+
get: T['_']['returning'] extends undefined ? DrizzleTypeError<'.get() cannot be used without .returning()'> : T['_']['returning'];
|
| 51 |
+
values: T['_']['returning'] extends undefined ? DrizzleTypeError<'.values() cannot be used without .returning()'> : any[][];
|
| 52 |
+
execute: SQLiteUpdateExecute<T>;
|
| 53 |
+
}>;
|
| 54 |
+
export type SQLiteUpdateJoinFn<T extends AnySQLiteUpdate> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(table: TJoinedTable, on: ((updateTable: T['_']['table']['_']['columns'], from: T['_']['from'] extends SQLiteTable ? T['_']['from']['_']['columns'] : T['_']['from'] extends Subquery | SQLiteViewBase ? T['_']['from']['_']['selectedFields'] : never) => SQL | undefined) | SQL | undefined) => T;
|
| 55 |
+
export type SQLiteUpdateDynamic<T extends AnySQLiteUpdate> = SQLiteUpdate<T['_']['table'], T['_']['resultType'], T['_']['runResult'], T['_']['returning']>;
|
| 56 |
+
export type SQLiteUpdate<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = any, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = SQLiteUpdateBase<TTable, TResultType, TRunResult, TFrom, TReturning, true, never>;
|
| 57 |
+
export type AnySQLiteUpdate = SQLiteUpdateBase<any, any, any, any, any, any, any>;
|
| 58 |
+
export interface SQLiteUpdateBase<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends SQLWrapper, QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> {
|
| 59 |
+
readonly _: {
|
| 60 |
+
readonly dialect: 'sqlite';
|
| 61 |
+
readonly table: TTable;
|
| 62 |
+
readonly resultType: TResultType;
|
| 63 |
+
readonly runResult: TRunResult;
|
| 64 |
+
readonly from: TFrom;
|
| 65 |
+
readonly returning: TReturning;
|
| 66 |
+
readonly dynamic: TDynamic;
|
| 67 |
+
readonly excludedMethods: TExcludedMethods;
|
| 68 |
+
readonly result: TReturning extends undefined ? TRunResult : TReturning[];
|
| 69 |
+
};
|
| 70 |
+
}
|
| 71 |
+
export declare class SQLiteUpdateBase<TTable extends SQLiteTable = SQLiteTable, TResultType extends 'sync' | 'async' = 'sync' | 'async', TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> implements RunnableQuery<TReturning extends undefined ? TRunResult : TReturning[], 'sqlite'>, SQLWrapper {
|
| 72 |
+
private session;
|
| 73 |
+
private dialect;
|
| 74 |
+
static readonly [entityKind]: string;
|
| 75 |
+
constructor(table: TTable, set: UpdateSet, session: SQLiteSession<any, any, any, any>, dialect: SQLiteDialect, withList?: Subquery[]);
|
| 76 |
+
from<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(source: TFrom): SQLiteUpdateWithJoins<this, TDynamic, TFrom>;
|
| 77 |
+
private createJoin;
|
| 78 |
+
leftJoin: SQLiteUpdateJoinFn<this>;
|
| 79 |
+
rightJoin: SQLiteUpdateJoinFn<this>;
|
| 80 |
+
innerJoin: SQLiteUpdateJoinFn<this>;
|
| 81 |
+
fullJoin: SQLiteUpdateJoinFn<this>;
|
| 82 |
+
/**
|
| 83 |
+
* Adds a 'where' clause to the query.
|
| 84 |
+
*
|
| 85 |
+
* Calling this method will update only those rows that fulfill a specified condition.
|
| 86 |
+
*
|
| 87 |
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
| 88 |
+
*
|
| 89 |
+
* @param where the 'where' clause.
|
| 90 |
+
*
|
| 91 |
+
* @example
|
| 92 |
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
| 93 |
+
*
|
| 94 |
+
* ```ts
|
| 95 |
+
* // Update all cars with green color
|
| 96 |
+
* db.update(cars).set({ color: 'red' })
|
| 97 |
+
* .where(eq(cars.color, 'green'));
|
| 98 |
+
* // or
|
| 99 |
+
* db.update(cars).set({ color: 'red' })
|
| 100 |
+
* .where(sql`${cars.color} = 'green'`)
|
| 101 |
+
* ```
|
| 102 |
+
*
|
| 103 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 104 |
+
*
|
| 105 |
+
* ```ts
|
| 106 |
+
* // Update all BMW cars with a green color
|
| 107 |
+
* db.update(cars).set({ color: 'red' })
|
| 108 |
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 109 |
+
*
|
| 110 |
+
* // Update all cars with the green or blue color
|
| 111 |
+
* db.update(cars).set({ color: 'red' })
|
| 112 |
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 113 |
+
* ```
|
| 114 |
+
*/
|
| 115 |
+
where(where: SQL | undefined): SQLiteUpdateWithout<this, TDynamic, 'where'>;
|
| 116 |
+
orderBy(builder: (updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
|
| 117 |
+
orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
|
| 118 |
+
limit(limit: number | Placeholder): SQLiteUpdateWithout<this, TDynamic, 'limit'>;
|
| 119 |
+
/**
|
| 120 |
+
* Adds a `returning` clause to the query.
|
| 121 |
+
*
|
| 122 |
+
* Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.
|
| 123 |
+
*
|
| 124 |
+
* See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}
|
| 125 |
+
*
|
| 126 |
+
* @example
|
| 127 |
+
* ```ts
|
| 128 |
+
* // Update all cars with the green color and return all fields
|
| 129 |
+
* const updatedCars: Car[] = await db.update(cars)
|
| 130 |
+
* .set({ color: 'red' })
|
| 131 |
+
* .where(eq(cars.color, 'green'))
|
| 132 |
+
* .returning();
|
| 133 |
+
*
|
| 134 |
+
* // Update all cars with the green color and return only their id and brand fields
|
| 135 |
+
* const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)
|
| 136 |
+
* .set({ color: 'red' })
|
| 137 |
+
* .where(eq(cars.color, 'green'))
|
| 138 |
+
* .returning({ id: cars.id, brand: cars.brand });
|
| 139 |
+
* ```
|
| 140 |
+
*/
|
| 141 |
+
returning(): SQLiteUpdateReturningAll<this, TDynamic>;
|
| 142 |
+
returning<TSelectedFields extends SelectedFields>(fields: TSelectedFields): SQLiteUpdateReturning<this, TDynamic, TSelectedFields>;
|
| 143 |
+
toSQL(): Query;
|
| 144 |
+
prepare(): SQLiteUpdatePrepare<this>;
|
| 145 |
+
run: ReturnType<this['prepare']>['run'];
|
| 146 |
+
all: ReturnType<this['prepare']>['all'];
|
| 147 |
+
get: ReturnType<this['prepare']>['get'];
|
| 148 |
+
values: ReturnType<this['prepare']>['values'];
|
| 149 |
+
execute(): Promise<SQLiteUpdateExecute<this>>;
|
| 150 |
+
$dynamic(): SQLiteUpdateDynamic<this>;
|
| 151 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind, is } from "../../entity.js";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 3 |
+
import { SelectionProxyHandler } from "../../selection-proxy.js";
|
| 4 |
+
import { SQLiteTable } from "../table.js";
|
| 5 |
+
import { Subquery } from "../../subquery.js";
|
| 6 |
+
import { Table } from "../../table.js";
|
| 7 |
+
import {
|
| 8 |
+
getTableLikeName,
|
| 9 |
+
mapUpdateSet,
|
| 10 |
+
orderSelectedFields
|
| 11 |
+
} from "../../utils.js";
|
| 12 |
+
import { ViewBaseConfig } from "../../view-common.js";
|
| 13 |
+
import { extractUsedTable } from "../utils.js";
|
| 14 |
+
import { SQLiteViewBase } from "../view-base.js";
|
| 15 |
+
class SQLiteUpdateBuilder {
|
| 16 |
+
constructor(table, session, dialect, withList) {
|
| 17 |
+
this.table = table;
|
| 18 |
+
this.session = session;
|
| 19 |
+
this.dialect = dialect;
|
| 20 |
+
this.withList = withList;
|
| 21 |
+
}
|
| 22 |
+
static [entityKind] = "SQLiteUpdateBuilder";
|
| 23 |
+
set(values) {
|
| 24 |
+
return new SQLiteUpdateBase(
|
| 25 |
+
this.table,
|
| 26 |
+
mapUpdateSet(this.table, values),
|
| 27 |
+
this.session,
|
| 28 |
+
this.dialect,
|
| 29 |
+
this.withList
|
| 30 |
+
);
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
class SQLiteUpdateBase extends QueryPromise {
|
| 34 |
+
constructor(table, set, session, dialect, withList) {
|
| 35 |
+
super();
|
| 36 |
+
this.session = session;
|
| 37 |
+
this.dialect = dialect;
|
| 38 |
+
this.config = { set, table, withList, joins: [] };
|
| 39 |
+
}
|
| 40 |
+
static [entityKind] = "SQLiteUpdate";
|
| 41 |
+
/** @internal */
|
| 42 |
+
config;
|
| 43 |
+
from(source) {
|
| 44 |
+
this.config.from = source;
|
| 45 |
+
return this;
|
| 46 |
+
}
|
| 47 |
+
createJoin(joinType) {
|
| 48 |
+
return (table, on) => {
|
| 49 |
+
const tableName = getTableLikeName(table);
|
| 50 |
+
if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) {
|
| 51 |
+
throw new Error(`Alias "${tableName}" is already used in this query`);
|
| 52 |
+
}
|
| 53 |
+
if (typeof on === "function") {
|
| 54 |
+
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
| 55 |
+
on = on(
|
| 56 |
+
new Proxy(
|
| 57 |
+
this.config.table[Table.Symbol.Columns],
|
| 58 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 59 |
+
),
|
| 60 |
+
from && new Proxy(
|
| 61 |
+
from,
|
| 62 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
| 63 |
+
)
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
this.config.joins.push({ on, table, joinType, alias: tableName });
|
| 67 |
+
return this;
|
| 68 |
+
};
|
| 69 |
+
}
|
| 70 |
+
leftJoin = this.createJoin("left");
|
| 71 |
+
rightJoin = this.createJoin("right");
|
| 72 |
+
innerJoin = this.createJoin("inner");
|
| 73 |
+
fullJoin = this.createJoin("full");
|
| 74 |
+
/**
|
| 75 |
+
* Adds a 'where' clause to the query.
|
| 76 |
+
*
|
| 77 |
+
* Calling this method will update only those rows that fulfill a specified condition.
|
| 78 |
+
*
|
| 79 |
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
| 80 |
+
*
|
| 81 |
+
* @param where the 'where' clause.
|
| 82 |
+
*
|
| 83 |
+
* @example
|
| 84 |
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
| 85 |
+
*
|
| 86 |
+
* ```ts
|
| 87 |
+
* // Update all cars with green color
|
| 88 |
+
* db.update(cars).set({ color: 'red' })
|
| 89 |
+
* .where(eq(cars.color, 'green'));
|
| 90 |
+
* // or
|
| 91 |
+
* db.update(cars).set({ color: 'red' })
|
| 92 |
+
* .where(sql`${cars.color} = 'green'`)
|
| 93 |
+
* ```
|
| 94 |
+
*
|
| 95 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 96 |
+
*
|
| 97 |
+
* ```ts
|
| 98 |
+
* // Update all BMW cars with a green color
|
| 99 |
+
* db.update(cars).set({ color: 'red' })
|
| 100 |
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 101 |
+
*
|
| 102 |
+
* // Update all cars with the green or blue color
|
| 103 |
+
* db.update(cars).set({ color: 'red' })
|
| 104 |
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 105 |
+
* ```
|
| 106 |
+
*/
|
| 107 |
+
where(where) {
|
| 108 |
+
this.config.where = where;
|
| 109 |
+
return this;
|
| 110 |
+
}
|
| 111 |
+
orderBy(...columns) {
|
| 112 |
+
if (typeof columns[0] === "function") {
|
| 113 |
+
const orderBy = columns[0](
|
| 114 |
+
new Proxy(
|
| 115 |
+
this.config.table[Table.Symbol.Columns],
|
| 116 |
+
new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
| 117 |
+
)
|
| 118 |
+
);
|
| 119 |
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
| 120 |
+
this.config.orderBy = orderByArray;
|
| 121 |
+
} else {
|
| 122 |
+
const orderByArray = columns;
|
| 123 |
+
this.config.orderBy = orderByArray;
|
| 124 |
+
}
|
| 125 |
+
return this;
|
| 126 |
+
}
|
| 127 |
+
limit(limit) {
|
| 128 |
+
this.config.limit = limit;
|
| 129 |
+
return this;
|
| 130 |
+
}
|
| 131 |
+
returning(fields = this.config.table[SQLiteTable.Symbol.Columns]) {
|
| 132 |
+
this.config.returning = orderSelectedFields(fields);
|
| 133 |
+
return this;
|
| 134 |
+
}
|
| 135 |
+
/** @internal */
|
| 136 |
+
getSQL() {
|
| 137 |
+
return this.dialect.buildUpdateQuery(this.config);
|
| 138 |
+
}
|
| 139 |
+
toSQL() {
|
| 140 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 141 |
+
return rest;
|
| 142 |
+
}
|
| 143 |
+
/** @internal */
|
| 144 |
+
_prepare(isOneTimeQuery = true) {
|
| 145 |
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
| 146 |
+
this.dialect.sqlToQuery(this.getSQL()),
|
| 147 |
+
this.config.returning,
|
| 148 |
+
this.config.returning ? "all" : "run",
|
| 149 |
+
true,
|
| 150 |
+
void 0,
|
| 151 |
+
{
|
| 152 |
+
type: "insert",
|
| 153 |
+
tables: extractUsedTable(this.config.table)
|
| 154 |
+
}
|
| 155 |
+
);
|
| 156 |
+
}
|
| 157 |
+
prepare() {
|
| 158 |
+
return this._prepare(false);
|
| 159 |
+
}
|
| 160 |
+
run = (placeholderValues) => {
|
| 161 |
+
return this._prepare().run(placeholderValues);
|
| 162 |
+
};
|
| 163 |
+
all = (placeholderValues) => {
|
| 164 |
+
return this._prepare().all(placeholderValues);
|
| 165 |
+
};
|
| 166 |
+
get = (placeholderValues) => {
|
| 167 |
+
return this._prepare().get(placeholderValues);
|
| 168 |
+
};
|
| 169 |
+
values = (placeholderValues) => {
|
| 170 |
+
return this._prepare().values(placeholderValues);
|
| 171 |
+
};
|
| 172 |
+
async execute() {
|
| 173 |
+
return this.config.returning ? this.all() : this.run();
|
| 174 |
+
}
|
| 175 |
+
$dynamic() {
|
| 176 |
+
return this;
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
export {
|
| 180 |
+
SQLiteUpdateBase,
|
| 181 |
+
SQLiteUpdateBuilder
|
| 182 |
+
};
|
| 183 |
+
//# sourceMappingURL=update.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/query-builders/update.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/sqlite-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { JoinType, SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { SQLiteDialect } from '~/sqlite-core/dialect.ts';\nimport type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { SQLiteTable } from '~/sqlite-core/table.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\ttype DrizzleTypeError,\n\tgetTableLikeName,\n\tmapUpdateSet,\n\torderSelectedFields,\n\ttype UpdateSet,\n\ttype ValueOrArray,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { SQLiteColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport { SQLiteViewBase } from '../view-base.ts';\nimport type { SelectedFields, SelectedFieldsOrdered, SQLiteSelectJoinConfig } from './select.types.ts';\n\nexport interface SQLiteUpdateConfig {\n\twhere?: SQL | undefined;\n\tlimit?: number | Placeholder;\n\torderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];\n\tset: UpdateSet;\n\ttable: SQLiteTable;\n\tfrom?: SQLiteTable | Subquery | SQLiteViewBase | SQL;\n\tjoins: SQLiteSelectJoinConfig[];\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type SQLiteUpdateSetSource<TTable extends SQLiteTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key], 'query'>\n\t\t\t| SQL\n\t\t\t| SQLiteColumn\n\t\t\t| undefined;\n\t}\n\t& {};\n\nexport class SQLiteUpdateBuilder<\n\tTTable extends SQLiteTable,\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n> {\n\tstatic readonly [entityKind]: string = 'SQLiteUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprotected table: TTable,\n\t\tprotected session: SQLiteSession<any, any, any, any>,\n\t\tprotected dialect: SQLiteDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tset(\n\t\tvalues: SQLiteUpdateSetSource<TTable>,\n\t): SQLiteUpdateWithout<\n\t\tSQLiteUpdateBase<TTable, TResultType, TRunResult>,\n\t\tfalse,\n\t\t'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'\n\t> {\n\t\treturn new SQLiteUpdateBase(\n\t\t\tthis.table,\n\t\t\tmapUpdateSet(this.table, values),\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t) as any;\n\t}\n}\n\nexport type SQLiteUpdateWithout<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tT['_']['returning'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type SQLiteUpdateWithJoins<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n> = TDynamic extends true ? T : Omit<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tTFrom,\n\t\tT['_']['returning'],\n\t\tTDynamic,\n\t\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n\t>,\n\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n>;\n\nexport type SQLiteUpdateReturningAll<T extends AnySQLiteUpdate, TDynamic extends boolean> = SQLiteUpdateWithout<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tT['_']['table']['$inferSelect'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type SQLiteUpdateReturning<\n\tT extends AnySQLiteUpdate,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFields,\n> = SQLiteUpdateWithout<\n\tSQLiteUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['resultType'],\n\t\tT['_']['runResult'],\n\t\tT['_']['from'],\n\t\tSelectResultFields<TSelectedFields>,\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type SQLiteUpdateExecute<T extends AnySQLiteUpdate> = T['_']['returning'] extends undefined ? T['_']['runResult']\n\t: T['_']['returning'][];\n\nexport type SQLiteUpdatePrepare<T extends AnySQLiteUpdate> = SQLitePreparedQuery<\n\t{\n\t\ttype: T['_']['resultType'];\n\t\trun: T['_']['runResult'];\n\t\tall: T['_']['returning'] extends undefined ? DrizzleTypeError<'.all() cannot be used without .returning()'>\n\t\t\t: T['_']['returning'][];\n\t\tget: T['_']['returning'] extends undefined ? DrizzleTypeError<'.get() cannot be used without .returning()'>\n\t\t\t: T['_']['returning'];\n\t\tvalues: T['_']['returning'] extends undefined ? DrizzleTypeError<'.values() cannot be used without .returning()'>\n\t\t\t: any[][];\n\t\texecute: SQLiteUpdateExecute<T>;\n\t}\n>;\n\nexport type SQLiteUpdateJoinFn<\n\tT extends AnySQLiteUpdate,\n> = <\n\tTJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL,\n>(\n\ttable: TJoinedTable,\n\ton:\n\t\t| (\n\t\t\t(\n\t\t\t\tupdateTable: T['_']['table']['_']['columns'],\n\t\t\t\tfrom: T['_']['from'] extends SQLiteTable ? T['_']['from']['_']['columns']\n\t\t\t\t\t: T['_']['from'] extends Subquery | SQLiteViewBase ? T['_']['from']['_']['selectedFields']\n\t\t\t\t\t: never,\n\t\t\t) => SQL | undefined\n\t\t)\n\t\t| SQL\n\t\t| undefined,\n) => T;\n\nexport type SQLiteUpdateDynamic<T extends AnySQLiteUpdate> = SQLiteUpdate<\n\tT['_']['table'],\n\tT['_']['resultType'],\n\tT['_']['runResult'],\n\tT['_']['returning']\n>;\n\nexport type SQLiteUpdate<\n\tTTable extends SQLiteTable = SQLiteTable,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = any,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = SQLiteUpdateBase<TTable, TResultType, TRunResult, TFrom, TReturning, true, never>;\n\nexport type AnySQLiteUpdate = SQLiteUpdateBase<any, any, any, any, any, any, any>;\n\nexport interface SQLiteUpdateBase<\n\tTTable extends SQLiteTable = SQLiteTable,\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends SQLWrapper, QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]> {\n\treadonly _: {\n\t\treadonly dialect: 'sqlite';\n\t\treadonly table: TTable;\n\t\treadonly resultType: TResultType;\n\t\treadonly runResult: TRunResult;\n\t\treadonly from: TFrom;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? TRunResult : TReturning[];\n\t};\n}\n\nexport class SQLiteUpdateBase<\n\tTTable extends SQLiteTable = SQLiteTable,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTResultType extends 'sync' | 'async' = 'sync' | 'async',\n\tTRunResult = unknown,\n\tTFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined,\n\tTReturning = undefined,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<TReturning extends undefined ? TRunResult : TReturning[]>\n\timplements RunnableQuery<TReturning extends undefined ? TRunResult : TReturning[], 'sqlite'>, SQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteUpdate';\n\n\t/** @internal */\n\tconfig: SQLiteUpdateConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: SQLiteSession<any, any, any, any>,\n\t\tprivate dialect: SQLiteDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList, joins: [] };\n\t}\n\n\tfrom<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(\n\t\tsource: TFrom,\n\t): SQLiteUpdateWithJoins<this, TDynamic, TFrom> {\n\t\tthis.config.from = source;\n\t\treturn this as any;\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): SQLiteUpdateJoinFn<this> {\n\t\treturn ((\n\t\t\ttable: SQLiteTable | Subquery | SQLiteViewBase | SQL,\n\t\t\ton: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\tconst from = this.config.from\n\t\t\t\t\t? is(table, SQLiteTable)\n\t\t\t\t\t\t? table[Table.Symbol.Columns]\n\t\t\t\t\t\t: is(table, Subquery)\n\t\t\t\t\t\t? table._.selectedFields\n\t\t\t\t\t\t: is(table, SQLiteViewBase)\n\t\t\t\t\t\t? table[ViewBaseConfig].selectedFields\n\t\t\t\t\t\t: undefined\n\t\t\t\t\t: undefined;\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t\tfrom && new Proxy(\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\treturn this as any;\n\t\t}) as any;\n\t}\n\n\tleftJoin = this.createJoin('left');\n\n\trightJoin = this.createJoin('right');\n\n\tinnerJoin = this.createJoin('inner');\n\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Adds a 'where' clause to the query.\n\t *\n\t * Calling this method will update only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param where the 'where' clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be updated.\n\t *\n\t * ```ts\n\t * // Update all cars with green color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Update all BMW cars with a green color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Update all cars with the green or blue color\n\t * db.update(cars).set({ color: 'red' })\n\t * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): SQLiteUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\torderBy(\n\t\tbuilder: (updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>,\n\t): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>]\n\t\t\t| (SQLiteColumn | SQL | SQL.Aliased)[]\n\t): SQLiteUpdateWithout<this, TDynamic, 'orderBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst orderBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as any,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t} else {\n\t\t\tconst orderByArray = columns as (SQLiteColumn | SQL | SQL.Aliased)[];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\tlimit(limit: number | Placeholder): SQLiteUpdateWithout<this, TDynamic, 'limit'> {\n\t\tthis.config.limit = limit;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `returning` clause to the query.\n\t *\n\t * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Update all cars with the green color and return all fields\n\t * const updatedCars: Car[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Update all cars with the green color and return only their id and brand fields\n\t * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): SQLiteUpdateReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFields>(\n\t\tfields: TSelectedFields,\n\t): SQLiteUpdateReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields: SelectedFields = this.config.table[SQLiteTable.Symbol.Columns],\n\t): SQLiteUpdateWithout<AnySQLiteUpdate, TDynamic, 'returning'> {\n\t\tthis.config.returning = orderSelectedFields<SQLiteColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildUpdateQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\t/** @internal */\n\t_prepare(isOneTimeQuery = true): SQLiteUpdatePrepare<this> {\n\t\treturn this.session[isOneTimeQuery ? 'prepareOneTimeQuery' : 'prepareQuery'](\n\t\t\tthis.dialect.sqlToQuery(this.getSQL()),\n\t\t\tthis.config.returning,\n\t\t\tthis.config.returning ? 'all' : 'run',\n\t\t\ttrue,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttype: 'insert',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t},\n\t\t) as SQLiteUpdatePrepare<this>;\n\t}\n\n\tprepare(): SQLiteUpdatePrepare<this> {\n\t\treturn this._prepare(false);\n\t}\n\n\trun: ReturnType<this['prepare']>['run'] = (placeholderValues) => {\n\t\treturn this._prepare().run(placeholderValues);\n\t};\n\n\tall: ReturnType<this['prepare']>['all'] = (placeholderValues) => {\n\t\treturn this._prepare().all(placeholderValues);\n\t};\n\n\tget: ReturnType<this['prepare']>['get'] = (placeholderValues) => {\n\t\treturn this._prepare().get(placeholderValues);\n\t};\n\n\tvalues: ReturnType<this['prepare']>['values'] = (placeholderValues) => {\n\t\treturn this._prepare().values(placeholderValues);\n\t};\n\n\toverride async execute(): Promise<SQLiteUpdateExecute<this>> {\n\t\treturn (this.config.returning ? this.all() : this.run()) as SQLiteUpdateExecute<this>;\n\t}\n\n\t$dynamic(): SQLiteUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":"AACA,SAAS,YAAY,UAAU;AAE/B,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AAItC,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB;AAA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var session_exports = {};
|
| 20 |
+
__export(session_exports, {
|
| 21 |
+
ExecuteResultSync: () => ExecuteResultSync,
|
| 22 |
+
SQLitePreparedQuery: () => SQLitePreparedQuery,
|
| 23 |
+
SQLiteSession: () => SQLiteSession,
|
| 24 |
+
SQLiteTransaction: () => SQLiteTransaction
|
| 25 |
+
});
|
| 26 |
+
module.exports = __toCommonJS(session_exports);
|
| 27 |
+
var import_cache = require("../cache/core/cache.cjs");
|
| 28 |
+
var import_entity = require("../entity.cjs");
|
| 29 |
+
var import_errors = require("../errors.cjs");
|
| 30 |
+
var import_query_promise = require("../query-promise.cjs");
|
| 31 |
+
var import_db = require("./db.cjs");
|
| 32 |
+
class ExecuteResultSync extends import_query_promise.QueryPromise {
|
| 33 |
+
constructor(resultCb) {
|
| 34 |
+
super();
|
| 35 |
+
this.resultCb = resultCb;
|
| 36 |
+
}
|
| 37 |
+
static [import_entity.entityKind] = "ExecuteResultSync";
|
| 38 |
+
async execute() {
|
| 39 |
+
return this.resultCb();
|
| 40 |
+
}
|
| 41 |
+
sync() {
|
| 42 |
+
return this.resultCb();
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
class SQLitePreparedQuery {
|
| 46 |
+
constructor(mode, executeMethod, query, cache, queryMetadata, cacheConfig) {
|
| 47 |
+
this.mode = mode;
|
| 48 |
+
this.executeMethod = executeMethod;
|
| 49 |
+
this.query = query;
|
| 50 |
+
this.cache = cache;
|
| 51 |
+
this.queryMetadata = queryMetadata;
|
| 52 |
+
this.cacheConfig = cacheConfig;
|
| 53 |
+
if (cache && cache.strategy() === "all" && cacheConfig === void 0) {
|
| 54 |
+
this.cacheConfig = { enable: true, autoInvalidate: true };
|
| 55 |
+
}
|
| 56 |
+
if (!this.cacheConfig?.enable) {
|
| 57 |
+
this.cacheConfig = void 0;
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
static [import_entity.entityKind] = "PreparedQuery";
|
| 61 |
+
/** @internal */
|
| 62 |
+
joinsNotNullableMap;
|
| 63 |
+
/** @internal */
|
| 64 |
+
async queryWithCache(queryString, params, query) {
|
| 65 |
+
if (this.cache === void 0 || (0, import_entity.is)(this.cache, import_cache.NoopCache) || this.queryMetadata === void 0) {
|
| 66 |
+
try {
|
| 67 |
+
return await query();
|
| 68 |
+
} catch (e) {
|
| 69 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
if (this.cacheConfig && !this.cacheConfig.enable) {
|
| 73 |
+
try {
|
| 74 |
+
return await query();
|
| 75 |
+
} catch (e) {
|
| 76 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
if ((this.queryMetadata.type === "insert" || this.queryMetadata.type === "update" || this.queryMetadata.type === "delete") && this.queryMetadata.tables.length > 0) {
|
| 80 |
+
try {
|
| 81 |
+
const [res] = await Promise.all([
|
| 82 |
+
query(),
|
| 83 |
+
this.cache.onMutate({ tables: this.queryMetadata.tables })
|
| 84 |
+
]);
|
| 85 |
+
return res;
|
| 86 |
+
} catch (e) {
|
| 87 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
if (!this.cacheConfig) {
|
| 91 |
+
try {
|
| 92 |
+
return await query();
|
| 93 |
+
} catch (e) {
|
| 94 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
if (this.queryMetadata.type === "select") {
|
| 98 |
+
const fromCache = await this.cache.get(
|
| 99 |
+
this.cacheConfig.tag ?? (await (0, import_cache.hashQuery)(queryString, params)),
|
| 100 |
+
this.queryMetadata.tables,
|
| 101 |
+
this.cacheConfig.tag !== void 0,
|
| 102 |
+
this.cacheConfig.autoInvalidate
|
| 103 |
+
);
|
| 104 |
+
if (fromCache === void 0) {
|
| 105 |
+
let result;
|
| 106 |
+
try {
|
| 107 |
+
result = await query();
|
| 108 |
+
} catch (e) {
|
| 109 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 110 |
+
}
|
| 111 |
+
await this.cache.put(
|
| 112 |
+
this.cacheConfig.tag ?? (await (0, import_cache.hashQuery)(queryString, params)),
|
| 113 |
+
result,
|
| 114 |
+
// make sure we send tables that were used in a query only if user wants to invalidate it on each write
|
| 115 |
+
this.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [],
|
| 116 |
+
this.cacheConfig.tag !== void 0,
|
| 117 |
+
this.cacheConfig.config
|
| 118 |
+
);
|
| 119 |
+
return result;
|
| 120 |
+
}
|
| 121 |
+
return fromCache;
|
| 122 |
+
}
|
| 123 |
+
try {
|
| 124 |
+
return await query();
|
| 125 |
+
} catch (e) {
|
| 126 |
+
throw new import_errors.DrizzleQueryError(queryString, params, e);
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
getQuery() {
|
| 130 |
+
return this.query;
|
| 131 |
+
}
|
| 132 |
+
mapRunResult(result, _isFromBatch) {
|
| 133 |
+
return result;
|
| 134 |
+
}
|
| 135 |
+
mapAllResult(_result, _isFromBatch) {
|
| 136 |
+
throw new Error("Not implemented");
|
| 137 |
+
}
|
| 138 |
+
mapGetResult(_result, _isFromBatch) {
|
| 139 |
+
throw new Error("Not implemented");
|
| 140 |
+
}
|
| 141 |
+
execute(placeholderValues) {
|
| 142 |
+
if (this.mode === "async") {
|
| 143 |
+
return this[this.executeMethod](placeholderValues);
|
| 144 |
+
}
|
| 145 |
+
return new ExecuteResultSync(() => this[this.executeMethod](placeholderValues));
|
| 146 |
+
}
|
| 147 |
+
mapResult(response, isFromBatch) {
|
| 148 |
+
switch (this.executeMethod) {
|
| 149 |
+
case "run": {
|
| 150 |
+
return this.mapRunResult(response, isFromBatch);
|
| 151 |
+
}
|
| 152 |
+
case "all": {
|
| 153 |
+
return this.mapAllResult(response, isFromBatch);
|
| 154 |
+
}
|
| 155 |
+
case "get": {
|
| 156 |
+
return this.mapGetResult(response, isFromBatch);
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
class SQLiteSession {
|
| 162 |
+
constructor(dialect) {
|
| 163 |
+
this.dialect = dialect;
|
| 164 |
+
}
|
| 165 |
+
static [import_entity.entityKind] = "SQLiteSession";
|
| 166 |
+
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
| 167 |
+
return this.prepareQuery(
|
| 168 |
+
query,
|
| 169 |
+
fields,
|
| 170 |
+
executeMethod,
|
| 171 |
+
isResponseInArrayMode,
|
| 172 |
+
customResultMapper,
|
| 173 |
+
queryMetadata,
|
| 174 |
+
cacheConfig
|
| 175 |
+
);
|
| 176 |
+
}
|
| 177 |
+
run(query) {
|
| 178 |
+
const staticQuery = this.dialect.sqlToQuery(query);
|
| 179 |
+
try {
|
| 180 |
+
return this.prepareOneTimeQuery(staticQuery, void 0, "run", false).run();
|
| 181 |
+
} catch (err) {
|
| 182 |
+
throw new import_errors.DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
/** @internal */
|
| 186 |
+
extractRawRunValueFromBatchResult(result) {
|
| 187 |
+
return result;
|
| 188 |
+
}
|
| 189 |
+
all(query) {
|
| 190 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).all();
|
| 191 |
+
}
|
| 192 |
+
/** @internal */
|
| 193 |
+
extractRawAllValueFromBatchResult(_result) {
|
| 194 |
+
throw new Error("Not implemented");
|
| 195 |
+
}
|
| 196 |
+
get(query) {
|
| 197 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).get();
|
| 198 |
+
}
|
| 199 |
+
/** @internal */
|
| 200 |
+
extractRawGetValueFromBatchResult(_result) {
|
| 201 |
+
throw new Error("Not implemented");
|
| 202 |
+
}
|
| 203 |
+
values(query) {
|
| 204 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).values();
|
| 205 |
+
}
|
| 206 |
+
async count(sql) {
|
| 207 |
+
const result = await this.values(sql);
|
| 208 |
+
return result[0][0];
|
| 209 |
+
}
|
| 210 |
+
/** @internal */
|
| 211 |
+
extractRawValuesValueFromBatchResult(_result) {
|
| 212 |
+
throw new Error("Not implemented");
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
class SQLiteTransaction extends import_db.BaseSQLiteDatabase {
|
| 216 |
+
constructor(resultType, dialect, session, schema, nestedIndex = 0) {
|
| 217 |
+
super(resultType, dialect, session, schema);
|
| 218 |
+
this.schema = schema;
|
| 219 |
+
this.nestedIndex = nestedIndex;
|
| 220 |
+
}
|
| 221 |
+
static [import_entity.entityKind] = "SQLiteTransaction";
|
| 222 |
+
rollback() {
|
| 223 |
+
throw new import_errors.TransactionRollbackError();
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 227 |
+
0 && (module.exports = {
|
| 228 |
+
ExecuteResultSync,
|
| 229 |
+
SQLitePreparedQuery,
|
| 230 |
+
SQLiteSession,
|
| 231 |
+
SQLiteTransaction
|
| 232 |
+
});
|
| 233 |
+
//# sourceMappingURL=session.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/session.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/session.ts"],"sourcesContent":["import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';\nimport type { WithCacheConfig } from '~/cache/core/types.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { DrizzleError, DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { TablesRelationalConfig } from '~/relations.ts';\nimport type { PreparedQuery } from '~/session.ts';\nimport type { Query, SQL } from '~/sql/sql.ts';\nimport type { SQLiteAsyncDialect, SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { BaseSQLiteDatabase } from './db.ts';\nimport type { SQLiteRaw } from './query-builders/raw.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport interface PreparedQueryConfig {\n\ttype: 'sync' | 'async';\n\trun: unknown;\n\tall: unknown;\n\tget: unknown;\n\tvalues: unknown;\n\texecute: unknown;\n}\n\nexport class ExecuteResultSync<T> extends QueryPromise<T> {\n\tstatic override readonly [entityKind]: string = 'ExecuteResultSync';\n\n\tconstructor(private resultCb: () => T) {\n\t\tsuper();\n\t}\n\n\toverride async execute(): Promise<T> {\n\t\treturn this.resultCb();\n\t}\n\n\tsync(): T {\n\t\treturn this.resultCb();\n\t}\n}\n\nexport type ExecuteResult<TType extends 'sync' | 'async', TResult> = TType extends 'async' ? Promise<TResult>\n\t: ExecuteResultSync<TResult>;\n\nexport abstract class SQLitePreparedQuery<T extends PreparedQueryConfig> implements PreparedQuery {\n\tstatic readonly [entityKind]: string = 'PreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tconstructor(\n\t\tprivate mode: 'sync' | 'async',\n\t\tprivate executeMethod: SQLiteExecuteMethod,\n\t\tprotected query: Query,\n\t\tprivate cache?: Cache,\n\t\t// per query related metadata\n\t\tprivate queryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t} | undefined,\n\t\t// config that was passed through $withCache\n\t\tprivate cacheConfig?: WithCacheConfig,\n\t) {\n\t\t// it means that no $withCache options were passed and it should be just enabled\n\t\tif (cache && cache.strategy() === 'all' && cacheConfig === undefined) {\n\t\t\tthis.cacheConfig = { enable: true, autoInvalidate: true };\n\t\t}\n\t\tif (!this.cacheConfig?.enable) {\n\t\t\tthis.cacheConfig = undefined;\n\t\t}\n\t}\n\n\t/** @internal */\n\tprotected async queryWithCache<T>(\n\t\tqueryString: string,\n\t\tparams: any[],\n\t\tquery: () => Promise<T>,\n\t): Promise<T> {\n\t\tif (this.cache === undefined || is(this.cache, NoopCache) || this.queryMetadata === undefined) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// don't do any mutations, if globally is false\n\t\tif (this.cacheConfig && !this.cacheConfig.enable) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// For mutate queries, we should query the database, wait for a response, and then perform invalidation\n\t\tif (\n\t\t\t(\n\t\t\t\tthis.queryMetadata.type === 'insert' || this.queryMetadata.type === 'update'\n\t\t\t\t|| this.queryMetadata.type === 'delete'\n\t\t\t) && this.queryMetadata.tables.length > 0\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst [res] = await Promise.all([\n\t\t\t\t\tquery(),\n\t\t\t\t\tthis.cache.onMutate({ tables: this.queryMetadata.tables }),\n\t\t\t\t]);\n\t\t\t\treturn res;\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// don't do any reads if globally disabled\n\t\tif (!this.cacheConfig) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\tif (this.queryMetadata.type === 'select') {\n\t\t\tconst fromCache = await this.cache.get(\n\t\t\t\tthis.cacheConfig.tag ?? await hashQuery(queryString, params),\n\t\t\t\tthis.queryMetadata.tables,\n\t\t\t\tthis.cacheConfig.tag !== undefined,\n\t\t\t\tthis.cacheConfig.autoInvalidate,\n\t\t\t);\n\t\t\tif (fromCache === undefined) {\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await query();\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t\t}\n\n\t\t\t\t// put actual key\n\t\t\t\tawait this.cache.put(\n\t\t\t\t\tthis.cacheConfig.tag ?? await hashQuery(queryString, params),\n\t\t\t\t\tresult,\n\t\t\t\t\t// make sure we send tables that were used in a query only if user wants to invalidate it on each write\n\t\t\t\t\tthis.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [],\n\t\t\t\t\tthis.cacheConfig.tag !== undefined,\n\t\t\t\t\tthis.cacheConfig.config,\n\t\t\t\t);\n\t\t\t\t// put flag if we should invalidate or not\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn fromCache as unknown as T;\n\t\t}\n\t\ttry {\n\t\t\treturn await query();\n\t\t} catch (e) {\n\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t}\n\t}\n\n\tgetQuery(): Query {\n\t\treturn this.query;\n\t}\n\n\tabstract run(placeholderValues?: Record<string, unknown>): Result<T['type'], T['run']>;\n\n\tmapRunResult(result: unknown, _isFromBatch?: boolean): unknown {\n\t\treturn result;\n\t}\n\n\tabstract all(placeholderValues?: Record<string, unknown>): Result<T['type'], T['all']>;\n\n\tmapAllResult(_result: unknown, _isFromBatch?: boolean): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tabstract get(placeholderValues?: Record<string, unknown>): Result<T['type'], T['get']>;\n\n\tmapGetResult(_result: unknown, _isFromBatch?: boolean): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tabstract values(placeholderValues?: Record<string, unknown>): Result<T['type'], T['values']>;\n\n\texecute(placeholderValues?: Record<string, unknown>): ExecuteResult<T['type'], T['execute']> {\n\t\tif (this.mode === 'async') {\n\t\t\treturn this[this.executeMethod](placeholderValues) as ExecuteResult<T['type'], T['execute']>;\n\t\t}\n\t\treturn new ExecuteResultSync(() => this[this.executeMethod](placeholderValues));\n\t}\n\n\tmapResult(response: unknown, isFromBatch?: boolean) {\n\t\tswitch (this.executeMethod) {\n\t\t\tcase 'run': {\n\t\t\t\treturn this.mapRunResult(response, isFromBatch);\n\t\t\t}\n\t\t\tcase 'all': {\n\t\t\t\treturn this.mapAllResult(response, isFromBatch);\n\t\t\t}\n\t\t\tcase 'get': {\n\t\t\t\treturn this.mapGetResult(response, isFromBatch);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @internal */\n\tabstract isResponseInArrayMode(): boolean;\n}\n\nexport interface SQLiteTransactionConfig {\n\tbehavior?: 'deferred' | 'immediate' | 'exclusive';\n}\n\nexport type SQLiteExecuteMethod = 'run' | 'all' | 'get';\n\nexport abstract class SQLiteSession<\n\tTResultKind extends 'sync' | 'async',\n\tTRunResult,\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> {\n\tstatic readonly [entityKind]: string = 'SQLiteSession';\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly dialect: { sync: SQLiteSyncDialect; async: SQLiteAsyncDialect }[TResultKind],\n\t) {}\n\n\tabstract prepareQuery(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown,\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): SQLitePreparedQuery<PreparedQueryConfig & { type: TResultKind }>;\n\n\tprepareOneTimeQuery(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown,\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): SQLitePreparedQuery<PreparedQueryConfig & { type: TResultKind }> {\n\t\treturn this.prepareQuery(\n\t\t\tquery,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t\tqueryMetadata,\n\t\t\tcacheConfig,\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>,\n\t\tconfig?: SQLiteTransactionConfig,\n\t): Result<TResultKind, T>;\n\n\trun(query: SQL): Result<TResultKind, TRunResult> {\n\t\tconst staticQuery = this.dialect.sqlToQuery(query);\n\t\ttry {\n\t\t\treturn this.prepareOneTimeQuery(staticQuery, undefined, 'run', false).run() as Result<TResultKind, TRunResult>;\n\t\t} catch (err) {\n\t\t\tthrow new DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });\n\t\t}\n\t}\n\n\t/** @internal */\n\textractRawRunValueFromBatchResult(result: unknown) {\n\t\treturn result;\n\t}\n\n\tall<T = unknown>(query: SQL): Result<TResultKind, T[]> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).all() as Result<\n\t\t\tTResultKind,\n\t\t\tT[]\n\t\t>;\n\t}\n\n\t/** @internal */\n\textractRawAllValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tget<T = unknown>(query: SQL): Result<TResultKind, T> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).get() as Result<\n\t\t\tTResultKind,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/** @internal */\n\textractRawGetValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tvalues<T extends any[] = unknown[]>(\n\t\tquery: SQL,\n\t): Result<TResultKind, T[]> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).values() as Result<\n\t\t\tTResultKind,\n\t\t\tT[]\n\t\t>;\n\t}\n\n\tasync count(sql: SQL) {\n\t\tconst result = await this.values(sql) as [[number]];\n\n\t\treturn result[0][0];\n\t}\n\n\t/** @internal */\n\textractRawValuesValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n}\n\nexport type Result<TKind extends 'sync' | 'async', TResult> = { sync: TResult; async: Promise<TResult> }[TKind];\n\nexport type DBResult<TKind extends 'sync' | 'async', TResult> = { sync: TResult; async: SQLiteRaw<TResult> }[TKind];\n\nexport abstract class SQLiteTransaction<\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends BaseSQLiteDatabase<TResultType, TRunResult, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteTransaction';\n\n\tconstructor(\n\t\tresultType: TResultType,\n\t\tdialect: { sync: SQLiteSyncDialect; async: SQLiteAsyncDialect }[TResultType],\n\t\tsession: SQLiteSession<TResultType, TRunResult, TFullSchema, TSchema>,\n\t\tprotected schema: {\n\t\t\tfullSchema: Record<string, unknown>;\n\t\t\tschema: TSchema;\n\t\t\ttableNamesMap: Record<string, string>;\n\t\t} | undefined,\n\t\tprotected readonly nestedIndex = 0,\n\t) {\n\t\tsuper(resultType, dialect, session, schema);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiD;AAEjD,oBAA+B;AAC/B,oBAA0E;AAC1E,2BAA6B;AAK7B,gBAAmC;AAa5B,MAAM,0BAA6B,kCAAgB;AAAA,EAGzD,YAAoB,UAAmB;AACtC,UAAM;AADa;AAAA,EAEpB;AAAA,EAJA,QAA0B,wBAAU,IAAY;AAAA,EAMhD,MAAe,UAAsB;AACpC,WAAO,KAAK,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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { type Cache } from "../cache/core/cache.cjs";
|
| 2 |
+
import type { WithCacheConfig } from "../cache/core/types.cjs";
|
| 3 |
+
import { entityKind } from "../entity.cjs";
|
| 4 |
+
import { QueryPromise } from "../query-promise.cjs";
|
| 5 |
+
import type { TablesRelationalConfig } from "../relations.cjs";
|
| 6 |
+
import type { PreparedQuery } from "../session.cjs";
|
| 7 |
+
import type { Query, SQL } from "../sql/sql.cjs";
|
| 8 |
+
import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "./dialect.cjs";
|
| 9 |
+
import { BaseSQLiteDatabase } from "./db.cjs";
|
| 10 |
+
import type { SQLiteRaw } from "./query-builders/raw.cjs";
|
| 11 |
+
import type { SelectedFieldsOrdered } from "./query-builders/select.types.cjs";
|
| 12 |
+
export interface PreparedQueryConfig {
|
| 13 |
+
type: 'sync' | 'async';
|
| 14 |
+
run: unknown;
|
| 15 |
+
all: unknown;
|
| 16 |
+
get: unknown;
|
| 17 |
+
values: unknown;
|
| 18 |
+
execute: unknown;
|
| 19 |
+
}
|
| 20 |
+
export declare class ExecuteResultSync<T> extends QueryPromise<T> {
|
| 21 |
+
private resultCb;
|
| 22 |
+
static readonly [entityKind]: string;
|
| 23 |
+
constructor(resultCb: () => T);
|
| 24 |
+
execute(): Promise<T>;
|
| 25 |
+
sync(): T;
|
| 26 |
+
}
|
| 27 |
+
export type ExecuteResult<TType extends 'sync' | 'async', TResult> = TType extends 'async' ? Promise<TResult> : ExecuteResultSync<TResult>;
|
| 28 |
+
export declare abstract class SQLitePreparedQuery<T extends PreparedQueryConfig> implements PreparedQuery {
|
| 29 |
+
private mode;
|
| 30 |
+
private executeMethod;
|
| 31 |
+
protected query: Query;
|
| 32 |
+
private cache?;
|
| 33 |
+
private queryMetadata?;
|
| 34 |
+
private cacheConfig?;
|
| 35 |
+
static readonly [entityKind]: string;
|
| 36 |
+
constructor(mode: 'sync' | 'async', executeMethod: SQLiteExecuteMethod, query: Query, cache?: Cache | undefined, queryMetadata?: {
|
| 37 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 38 |
+
tables: string[];
|
| 39 |
+
} | undefined, cacheConfig?: WithCacheConfig | undefined);
|
| 40 |
+
getQuery(): Query;
|
| 41 |
+
abstract run(placeholderValues?: Record<string, unknown>): Result<T['type'], T['run']>;
|
| 42 |
+
mapRunResult(result: unknown, _isFromBatch?: boolean): unknown;
|
| 43 |
+
abstract all(placeholderValues?: Record<string, unknown>): Result<T['type'], T['all']>;
|
| 44 |
+
mapAllResult(_result: unknown, _isFromBatch?: boolean): unknown;
|
| 45 |
+
abstract get(placeholderValues?: Record<string, unknown>): Result<T['type'], T['get']>;
|
| 46 |
+
mapGetResult(_result: unknown, _isFromBatch?: boolean): unknown;
|
| 47 |
+
abstract values(placeholderValues?: Record<string, unknown>): Result<T['type'], T['values']>;
|
| 48 |
+
execute(placeholderValues?: Record<string, unknown>): ExecuteResult<T['type'], T['execute']>;
|
| 49 |
+
mapResult(response: unknown, isFromBatch?: boolean): unknown;
|
| 50 |
+
}
|
| 51 |
+
export interface SQLiteTransactionConfig {
|
| 52 |
+
behavior?: 'deferred' | 'immediate' | 'exclusive';
|
| 53 |
+
}
|
| 54 |
+
export type SQLiteExecuteMethod = 'run' | 'all' | 'get';
|
| 55 |
+
export declare abstract class SQLiteSession<TResultKind extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> {
|
| 56 |
+
static readonly [entityKind]: string;
|
| 57 |
+
constructor(
|
| 58 |
+
/** @internal */
|
| 59 |
+
dialect: {
|
| 60 |
+
sync: SQLiteSyncDialect;
|
| 61 |
+
async: SQLiteAsyncDialect;
|
| 62 |
+
}[TResultKind]);
|
| 63 |
+
abstract prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown, queryMetadata?: {
|
| 64 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 65 |
+
tables: string[];
|
| 66 |
+
}, cacheConfig?: WithCacheConfig): SQLitePreparedQuery<PreparedQueryConfig & {
|
| 67 |
+
type: TResultKind;
|
| 68 |
+
}>;
|
| 69 |
+
prepareOneTimeQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown, queryMetadata?: {
|
| 70 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 71 |
+
tables: string[];
|
| 72 |
+
}, cacheConfig?: WithCacheConfig): SQLitePreparedQuery<PreparedQueryConfig & {
|
| 73 |
+
type: TResultKind;
|
| 74 |
+
}>;
|
| 75 |
+
abstract transaction<T>(transaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>, config?: SQLiteTransactionConfig): Result<TResultKind, T>;
|
| 76 |
+
run(query: SQL): Result<TResultKind, TRunResult>;
|
| 77 |
+
all<T = unknown>(query: SQL): Result<TResultKind, T[]>;
|
| 78 |
+
get<T = unknown>(query: SQL): Result<TResultKind, T>;
|
| 79 |
+
values<T extends any[] = unknown[]>(query: SQL): Result<TResultKind, T[]>;
|
| 80 |
+
count(sql: SQL): Promise<number>;
|
| 81 |
+
}
|
| 82 |
+
export type Result<TKind extends 'sync' | 'async', TResult> = {
|
| 83 |
+
sync: TResult;
|
| 84 |
+
async: Promise<TResult>;
|
| 85 |
+
}[TKind];
|
| 86 |
+
export type DBResult<TKind extends 'sync' | 'async', TResult> = {
|
| 87 |
+
sync: TResult;
|
| 88 |
+
async: SQLiteRaw<TResult>;
|
| 89 |
+
}[TKind];
|
| 90 |
+
export declare abstract class SQLiteTransaction<TResultType extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends BaseSQLiteDatabase<TResultType, TRunResult, TFullSchema, TSchema> {
|
| 91 |
+
protected schema: {
|
| 92 |
+
fullSchema: Record<string, unknown>;
|
| 93 |
+
schema: TSchema;
|
| 94 |
+
tableNamesMap: Record<string, string>;
|
| 95 |
+
} | undefined;
|
| 96 |
+
protected readonly nestedIndex: number;
|
| 97 |
+
static readonly [entityKind]: string;
|
| 98 |
+
constructor(resultType: TResultType, dialect: {
|
| 99 |
+
sync: SQLiteSyncDialect;
|
| 100 |
+
async: SQLiteAsyncDialect;
|
| 101 |
+
}[TResultType], session: SQLiteSession<TResultType, TRunResult, TFullSchema, TSchema>, schema: {
|
| 102 |
+
fullSchema: Record<string, unknown>;
|
| 103 |
+
schema: TSchema;
|
| 104 |
+
tableNamesMap: Record<string, string>;
|
| 105 |
+
} | undefined, nestedIndex?: number);
|
| 106 |
+
rollback(): never;
|
| 107 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/session.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { type Cache } from "../cache/core/cache.js";
|
| 2 |
+
import type { WithCacheConfig } from "../cache/core/types.js";
|
| 3 |
+
import { entityKind } from "../entity.js";
|
| 4 |
+
import { QueryPromise } from "../query-promise.js";
|
| 5 |
+
import type { TablesRelationalConfig } from "../relations.js";
|
| 6 |
+
import type { PreparedQuery } from "../session.js";
|
| 7 |
+
import type { Query, SQL } from "../sql/sql.js";
|
| 8 |
+
import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "./dialect.js";
|
| 9 |
+
import { BaseSQLiteDatabase } from "./db.js";
|
| 10 |
+
import type { SQLiteRaw } from "./query-builders/raw.js";
|
| 11 |
+
import type { SelectedFieldsOrdered } from "./query-builders/select.types.js";
|
| 12 |
+
export interface PreparedQueryConfig {
|
| 13 |
+
type: 'sync' | 'async';
|
| 14 |
+
run: unknown;
|
| 15 |
+
all: unknown;
|
| 16 |
+
get: unknown;
|
| 17 |
+
values: unknown;
|
| 18 |
+
execute: unknown;
|
| 19 |
+
}
|
| 20 |
+
export declare class ExecuteResultSync<T> extends QueryPromise<T> {
|
| 21 |
+
private resultCb;
|
| 22 |
+
static readonly [entityKind]: string;
|
| 23 |
+
constructor(resultCb: () => T);
|
| 24 |
+
execute(): Promise<T>;
|
| 25 |
+
sync(): T;
|
| 26 |
+
}
|
| 27 |
+
export type ExecuteResult<TType extends 'sync' | 'async', TResult> = TType extends 'async' ? Promise<TResult> : ExecuteResultSync<TResult>;
|
| 28 |
+
export declare abstract class SQLitePreparedQuery<T extends PreparedQueryConfig> implements PreparedQuery {
|
| 29 |
+
private mode;
|
| 30 |
+
private executeMethod;
|
| 31 |
+
protected query: Query;
|
| 32 |
+
private cache?;
|
| 33 |
+
private queryMetadata?;
|
| 34 |
+
private cacheConfig?;
|
| 35 |
+
static readonly [entityKind]: string;
|
| 36 |
+
constructor(mode: 'sync' | 'async', executeMethod: SQLiteExecuteMethod, query: Query, cache?: Cache | undefined, queryMetadata?: {
|
| 37 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 38 |
+
tables: string[];
|
| 39 |
+
} | undefined, cacheConfig?: WithCacheConfig | undefined);
|
| 40 |
+
getQuery(): Query;
|
| 41 |
+
abstract run(placeholderValues?: Record<string, unknown>): Result<T['type'], T['run']>;
|
| 42 |
+
mapRunResult(result: unknown, _isFromBatch?: boolean): unknown;
|
| 43 |
+
abstract all(placeholderValues?: Record<string, unknown>): Result<T['type'], T['all']>;
|
| 44 |
+
mapAllResult(_result: unknown, _isFromBatch?: boolean): unknown;
|
| 45 |
+
abstract get(placeholderValues?: Record<string, unknown>): Result<T['type'], T['get']>;
|
| 46 |
+
mapGetResult(_result: unknown, _isFromBatch?: boolean): unknown;
|
| 47 |
+
abstract values(placeholderValues?: Record<string, unknown>): Result<T['type'], T['values']>;
|
| 48 |
+
execute(placeholderValues?: Record<string, unknown>): ExecuteResult<T['type'], T['execute']>;
|
| 49 |
+
mapResult(response: unknown, isFromBatch?: boolean): unknown;
|
| 50 |
+
}
|
| 51 |
+
export interface SQLiteTransactionConfig {
|
| 52 |
+
behavior?: 'deferred' | 'immediate' | 'exclusive';
|
| 53 |
+
}
|
| 54 |
+
export type SQLiteExecuteMethod = 'run' | 'all' | 'get';
|
| 55 |
+
export declare abstract class SQLiteSession<TResultKind extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> {
|
| 56 |
+
static readonly [entityKind]: string;
|
| 57 |
+
constructor(
|
| 58 |
+
/** @internal */
|
| 59 |
+
dialect: {
|
| 60 |
+
sync: SQLiteSyncDialect;
|
| 61 |
+
async: SQLiteAsyncDialect;
|
| 62 |
+
}[TResultKind]);
|
| 63 |
+
abstract prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown, queryMetadata?: {
|
| 64 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 65 |
+
tables: string[];
|
| 66 |
+
}, cacheConfig?: WithCacheConfig): SQLitePreparedQuery<PreparedQueryConfig & {
|
| 67 |
+
type: TResultKind;
|
| 68 |
+
}>;
|
| 69 |
+
prepareOneTimeQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown, queryMetadata?: {
|
| 70 |
+
type: 'select' | 'update' | 'delete' | 'insert';
|
| 71 |
+
tables: string[];
|
| 72 |
+
}, cacheConfig?: WithCacheConfig): SQLitePreparedQuery<PreparedQueryConfig & {
|
| 73 |
+
type: TResultKind;
|
| 74 |
+
}>;
|
| 75 |
+
abstract transaction<T>(transaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>, config?: SQLiteTransactionConfig): Result<TResultKind, T>;
|
| 76 |
+
run(query: SQL): Result<TResultKind, TRunResult>;
|
| 77 |
+
all<T = unknown>(query: SQL): Result<TResultKind, T[]>;
|
| 78 |
+
get<T = unknown>(query: SQL): Result<TResultKind, T>;
|
| 79 |
+
values<T extends any[] = unknown[]>(query: SQL): Result<TResultKind, T[]>;
|
| 80 |
+
count(sql: SQL): Promise<number>;
|
| 81 |
+
}
|
| 82 |
+
export type Result<TKind extends 'sync' | 'async', TResult> = {
|
| 83 |
+
sync: TResult;
|
| 84 |
+
async: Promise<TResult>;
|
| 85 |
+
}[TKind];
|
| 86 |
+
export type DBResult<TKind extends 'sync' | 'async', TResult> = {
|
| 87 |
+
sync: TResult;
|
| 88 |
+
async: SQLiteRaw<TResult>;
|
| 89 |
+
}[TKind];
|
| 90 |
+
export declare abstract class SQLiteTransaction<TResultType extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends BaseSQLiteDatabase<TResultType, TRunResult, TFullSchema, TSchema> {
|
| 91 |
+
protected schema: {
|
| 92 |
+
fullSchema: Record<string, unknown>;
|
| 93 |
+
schema: TSchema;
|
| 94 |
+
tableNamesMap: Record<string, string>;
|
| 95 |
+
} | undefined;
|
| 96 |
+
protected readonly nestedIndex: number;
|
| 97 |
+
static readonly [entityKind]: string;
|
| 98 |
+
constructor(resultType: TResultType, dialect: {
|
| 99 |
+
sync: SQLiteSyncDialect;
|
| 100 |
+
async: SQLiteAsyncDialect;
|
| 101 |
+
}[TResultType], session: SQLiteSession<TResultType, TRunResult, TFullSchema, TSchema>, schema: {
|
| 102 |
+
fullSchema: Record<string, unknown>;
|
| 103 |
+
schema: TSchema;
|
| 104 |
+
tableNamesMap: Record<string, string>;
|
| 105 |
+
} | undefined, nestedIndex?: number);
|
| 106 |
+
rollback(): never;
|
| 107 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/session.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { hashQuery, NoopCache } from "../cache/core/cache.js";
|
| 2 |
+
import { entityKind, is } from "../entity.js";
|
| 3 |
+
import { DrizzleError, DrizzleQueryError, TransactionRollbackError } from "../errors.js";
|
| 4 |
+
import { QueryPromise } from "../query-promise.js";
|
| 5 |
+
import { BaseSQLiteDatabase } from "./db.js";
|
| 6 |
+
class ExecuteResultSync extends QueryPromise {
|
| 7 |
+
constructor(resultCb) {
|
| 8 |
+
super();
|
| 9 |
+
this.resultCb = resultCb;
|
| 10 |
+
}
|
| 11 |
+
static [entityKind] = "ExecuteResultSync";
|
| 12 |
+
async execute() {
|
| 13 |
+
return this.resultCb();
|
| 14 |
+
}
|
| 15 |
+
sync() {
|
| 16 |
+
return this.resultCb();
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
class SQLitePreparedQuery {
|
| 20 |
+
constructor(mode, executeMethod, query, cache, queryMetadata, cacheConfig) {
|
| 21 |
+
this.mode = mode;
|
| 22 |
+
this.executeMethod = executeMethod;
|
| 23 |
+
this.query = query;
|
| 24 |
+
this.cache = cache;
|
| 25 |
+
this.queryMetadata = queryMetadata;
|
| 26 |
+
this.cacheConfig = cacheConfig;
|
| 27 |
+
if (cache && cache.strategy() === "all" && cacheConfig === void 0) {
|
| 28 |
+
this.cacheConfig = { enable: true, autoInvalidate: true };
|
| 29 |
+
}
|
| 30 |
+
if (!this.cacheConfig?.enable) {
|
| 31 |
+
this.cacheConfig = void 0;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
static [entityKind] = "PreparedQuery";
|
| 35 |
+
/** @internal */
|
| 36 |
+
joinsNotNullableMap;
|
| 37 |
+
/** @internal */
|
| 38 |
+
async queryWithCache(queryString, params, query) {
|
| 39 |
+
if (this.cache === void 0 || is(this.cache, NoopCache) || this.queryMetadata === void 0) {
|
| 40 |
+
try {
|
| 41 |
+
return await query();
|
| 42 |
+
} catch (e) {
|
| 43 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
if (this.cacheConfig && !this.cacheConfig.enable) {
|
| 47 |
+
try {
|
| 48 |
+
return await query();
|
| 49 |
+
} catch (e) {
|
| 50 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
if ((this.queryMetadata.type === "insert" || this.queryMetadata.type === "update" || this.queryMetadata.type === "delete") && this.queryMetadata.tables.length > 0) {
|
| 54 |
+
try {
|
| 55 |
+
const [res] = await Promise.all([
|
| 56 |
+
query(),
|
| 57 |
+
this.cache.onMutate({ tables: this.queryMetadata.tables })
|
| 58 |
+
]);
|
| 59 |
+
return res;
|
| 60 |
+
} catch (e) {
|
| 61 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
if (!this.cacheConfig) {
|
| 65 |
+
try {
|
| 66 |
+
return await query();
|
| 67 |
+
} catch (e) {
|
| 68 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
if (this.queryMetadata.type === "select") {
|
| 72 |
+
const fromCache = await this.cache.get(
|
| 73 |
+
this.cacheConfig.tag ?? (await hashQuery(queryString, params)),
|
| 74 |
+
this.queryMetadata.tables,
|
| 75 |
+
this.cacheConfig.tag !== void 0,
|
| 76 |
+
this.cacheConfig.autoInvalidate
|
| 77 |
+
);
|
| 78 |
+
if (fromCache === void 0) {
|
| 79 |
+
let result;
|
| 80 |
+
try {
|
| 81 |
+
result = await query();
|
| 82 |
+
} catch (e) {
|
| 83 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 84 |
+
}
|
| 85 |
+
await this.cache.put(
|
| 86 |
+
this.cacheConfig.tag ?? (await hashQuery(queryString, params)),
|
| 87 |
+
result,
|
| 88 |
+
// make sure we send tables that were used in a query only if user wants to invalidate it on each write
|
| 89 |
+
this.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [],
|
| 90 |
+
this.cacheConfig.tag !== void 0,
|
| 91 |
+
this.cacheConfig.config
|
| 92 |
+
);
|
| 93 |
+
return result;
|
| 94 |
+
}
|
| 95 |
+
return fromCache;
|
| 96 |
+
}
|
| 97 |
+
try {
|
| 98 |
+
return await query();
|
| 99 |
+
} catch (e) {
|
| 100 |
+
throw new DrizzleQueryError(queryString, params, e);
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
getQuery() {
|
| 104 |
+
return this.query;
|
| 105 |
+
}
|
| 106 |
+
mapRunResult(result, _isFromBatch) {
|
| 107 |
+
return result;
|
| 108 |
+
}
|
| 109 |
+
mapAllResult(_result, _isFromBatch) {
|
| 110 |
+
throw new Error("Not implemented");
|
| 111 |
+
}
|
| 112 |
+
mapGetResult(_result, _isFromBatch) {
|
| 113 |
+
throw new Error("Not implemented");
|
| 114 |
+
}
|
| 115 |
+
execute(placeholderValues) {
|
| 116 |
+
if (this.mode === "async") {
|
| 117 |
+
return this[this.executeMethod](placeholderValues);
|
| 118 |
+
}
|
| 119 |
+
return new ExecuteResultSync(() => this[this.executeMethod](placeholderValues));
|
| 120 |
+
}
|
| 121 |
+
mapResult(response, isFromBatch) {
|
| 122 |
+
switch (this.executeMethod) {
|
| 123 |
+
case "run": {
|
| 124 |
+
return this.mapRunResult(response, isFromBatch);
|
| 125 |
+
}
|
| 126 |
+
case "all": {
|
| 127 |
+
return this.mapAllResult(response, isFromBatch);
|
| 128 |
+
}
|
| 129 |
+
case "get": {
|
| 130 |
+
return this.mapGetResult(response, isFromBatch);
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
class SQLiteSession {
|
| 136 |
+
constructor(dialect) {
|
| 137 |
+
this.dialect = dialect;
|
| 138 |
+
}
|
| 139 |
+
static [entityKind] = "SQLiteSession";
|
| 140 |
+
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
| 141 |
+
return this.prepareQuery(
|
| 142 |
+
query,
|
| 143 |
+
fields,
|
| 144 |
+
executeMethod,
|
| 145 |
+
isResponseInArrayMode,
|
| 146 |
+
customResultMapper,
|
| 147 |
+
queryMetadata,
|
| 148 |
+
cacheConfig
|
| 149 |
+
);
|
| 150 |
+
}
|
| 151 |
+
run(query) {
|
| 152 |
+
const staticQuery = this.dialect.sqlToQuery(query);
|
| 153 |
+
try {
|
| 154 |
+
return this.prepareOneTimeQuery(staticQuery, void 0, "run", false).run();
|
| 155 |
+
} catch (err) {
|
| 156 |
+
throw new DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
/** @internal */
|
| 160 |
+
extractRawRunValueFromBatchResult(result) {
|
| 161 |
+
return result;
|
| 162 |
+
}
|
| 163 |
+
all(query) {
|
| 164 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).all();
|
| 165 |
+
}
|
| 166 |
+
/** @internal */
|
| 167 |
+
extractRawAllValueFromBatchResult(_result) {
|
| 168 |
+
throw new Error("Not implemented");
|
| 169 |
+
}
|
| 170 |
+
get(query) {
|
| 171 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).get();
|
| 172 |
+
}
|
| 173 |
+
/** @internal */
|
| 174 |
+
extractRawGetValueFromBatchResult(_result) {
|
| 175 |
+
throw new Error("Not implemented");
|
| 176 |
+
}
|
| 177 |
+
values(query) {
|
| 178 |
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).values();
|
| 179 |
+
}
|
| 180 |
+
async count(sql) {
|
| 181 |
+
const result = await this.values(sql);
|
| 182 |
+
return result[0][0];
|
| 183 |
+
}
|
| 184 |
+
/** @internal */
|
| 185 |
+
extractRawValuesValueFromBatchResult(_result) {
|
| 186 |
+
throw new Error("Not implemented");
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
class SQLiteTransaction extends BaseSQLiteDatabase {
|
| 190 |
+
constructor(resultType, dialect, session, schema, nestedIndex = 0) {
|
| 191 |
+
super(resultType, dialect, session, schema);
|
| 192 |
+
this.schema = schema;
|
| 193 |
+
this.nestedIndex = nestedIndex;
|
| 194 |
+
}
|
| 195 |
+
static [entityKind] = "SQLiteTransaction";
|
| 196 |
+
rollback() {
|
| 197 |
+
throw new TransactionRollbackError();
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
export {
|
| 201 |
+
ExecuteResultSync,
|
| 202 |
+
SQLitePreparedQuery,
|
| 203 |
+
SQLiteSession,
|
| 204 |
+
SQLiteTransaction
|
| 205 |
+
};
|
| 206 |
+
//# sourceMappingURL=session.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/session.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/session.ts"],"sourcesContent":["import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';\nimport type { WithCacheConfig } from '~/cache/core/types.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { DrizzleError, DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { TablesRelationalConfig } from '~/relations.ts';\nimport type { PreparedQuery } from '~/session.ts';\nimport type { Query, SQL } from '~/sql/sql.ts';\nimport type { SQLiteAsyncDialect, SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { BaseSQLiteDatabase } from './db.ts';\nimport type { SQLiteRaw } from './query-builders/raw.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport interface PreparedQueryConfig {\n\ttype: 'sync' | 'async';\n\trun: unknown;\n\tall: unknown;\n\tget: unknown;\n\tvalues: unknown;\n\texecute: unknown;\n}\n\nexport class ExecuteResultSync<T> extends QueryPromise<T> {\n\tstatic override readonly [entityKind]: string = 'ExecuteResultSync';\n\n\tconstructor(private resultCb: () => T) {\n\t\tsuper();\n\t}\n\n\toverride async execute(): Promise<T> {\n\t\treturn this.resultCb();\n\t}\n\n\tsync(): T {\n\t\treturn this.resultCb();\n\t}\n}\n\nexport type ExecuteResult<TType extends 'sync' | 'async', TResult> = TType extends 'async' ? Promise<TResult>\n\t: ExecuteResultSync<TResult>;\n\nexport abstract class SQLitePreparedQuery<T extends PreparedQueryConfig> implements PreparedQuery {\n\tstatic readonly [entityKind]: string = 'PreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tconstructor(\n\t\tprivate mode: 'sync' | 'async',\n\t\tprivate executeMethod: SQLiteExecuteMethod,\n\t\tprotected query: Query,\n\t\tprivate cache?: Cache,\n\t\t// per query related metadata\n\t\tprivate queryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t} | undefined,\n\t\t// config that was passed through $withCache\n\t\tprivate cacheConfig?: WithCacheConfig,\n\t) {\n\t\t// it means that no $withCache options were passed and it should be just enabled\n\t\tif (cache && cache.strategy() === 'all' && cacheConfig === undefined) {\n\t\t\tthis.cacheConfig = { enable: true, autoInvalidate: true };\n\t\t}\n\t\tif (!this.cacheConfig?.enable) {\n\t\t\tthis.cacheConfig = undefined;\n\t\t}\n\t}\n\n\t/** @internal */\n\tprotected async queryWithCache<T>(\n\t\tqueryString: string,\n\t\tparams: any[],\n\t\tquery: () => Promise<T>,\n\t): Promise<T> {\n\t\tif (this.cache === undefined || is(this.cache, NoopCache) || this.queryMetadata === undefined) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// don't do any mutations, if globally is false\n\t\tif (this.cacheConfig && !this.cacheConfig.enable) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// For mutate queries, we should query the database, wait for a response, and then perform invalidation\n\t\tif (\n\t\t\t(\n\t\t\t\tthis.queryMetadata.type === 'insert' || this.queryMetadata.type === 'update'\n\t\t\t\t|| this.queryMetadata.type === 'delete'\n\t\t\t) && this.queryMetadata.tables.length > 0\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst [res] = await Promise.all([\n\t\t\t\t\tquery(),\n\t\t\t\t\tthis.cache.onMutate({ tables: this.queryMetadata.tables }),\n\t\t\t\t]);\n\t\t\t\treturn res;\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// don't do any reads if globally disabled\n\t\tif (!this.cacheConfig) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\tif (this.queryMetadata.type === 'select') {\n\t\t\tconst fromCache = await this.cache.get(\n\t\t\t\tthis.cacheConfig.tag ?? await hashQuery(queryString, params),\n\t\t\t\tthis.queryMetadata.tables,\n\t\t\t\tthis.cacheConfig.tag !== undefined,\n\t\t\t\tthis.cacheConfig.autoInvalidate,\n\t\t\t);\n\t\t\tif (fromCache === undefined) {\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await query();\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t\t}\n\n\t\t\t\t// put actual key\n\t\t\t\tawait this.cache.put(\n\t\t\t\t\tthis.cacheConfig.tag ?? await hashQuery(queryString, params),\n\t\t\t\t\tresult,\n\t\t\t\t\t// make sure we send tables that were used in a query only if user wants to invalidate it on each write\n\t\t\t\t\tthis.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [],\n\t\t\t\t\tthis.cacheConfig.tag !== undefined,\n\t\t\t\t\tthis.cacheConfig.config,\n\t\t\t\t);\n\t\t\t\t// put flag if we should invalidate or not\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn fromCache as unknown as T;\n\t\t}\n\t\ttry {\n\t\t\treturn await query();\n\t\t} catch (e) {\n\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t}\n\t}\n\n\tgetQuery(): Query {\n\t\treturn this.query;\n\t}\n\n\tabstract run(placeholderValues?: Record<string, unknown>): Result<T['type'], T['run']>;\n\n\tmapRunResult(result: unknown, _isFromBatch?: boolean): unknown {\n\t\treturn result;\n\t}\n\n\tabstract all(placeholderValues?: Record<string, unknown>): Result<T['type'], T['all']>;\n\n\tmapAllResult(_result: unknown, _isFromBatch?: boolean): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tabstract get(placeholderValues?: Record<string, unknown>): Result<T['type'], T['get']>;\n\n\tmapGetResult(_result: unknown, _isFromBatch?: boolean): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tabstract values(placeholderValues?: Record<string, unknown>): Result<T['type'], T['values']>;\n\n\texecute(placeholderValues?: Record<string, unknown>): ExecuteResult<T['type'], T['execute']> {\n\t\tif (this.mode === 'async') {\n\t\t\treturn this[this.executeMethod](placeholderValues) as ExecuteResult<T['type'], T['execute']>;\n\t\t}\n\t\treturn new ExecuteResultSync(() => this[this.executeMethod](placeholderValues));\n\t}\n\n\tmapResult(response: unknown, isFromBatch?: boolean) {\n\t\tswitch (this.executeMethod) {\n\t\t\tcase 'run': {\n\t\t\t\treturn this.mapRunResult(response, isFromBatch);\n\t\t\t}\n\t\t\tcase 'all': {\n\t\t\t\treturn this.mapAllResult(response, isFromBatch);\n\t\t\t}\n\t\t\tcase 'get': {\n\t\t\t\treturn this.mapGetResult(response, isFromBatch);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @internal */\n\tabstract isResponseInArrayMode(): boolean;\n}\n\nexport interface SQLiteTransactionConfig {\n\tbehavior?: 'deferred' | 'immediate' | 'exclusive';\n}\n\nexport type SQLiteExecuteMethod = 'run' | 'all' | 'get';\n\nexport abstract class SQLiteSession<\n\tTResultKind extends 'sync' | 'async',\n\tTRunResult,\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> {\n\tstatic readonly [entityKind]: string = 'SQLiteSession';\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly dialect: { sync: SQLiteSyncDialect; async: SQLiteAsyncDialect }[TResultKind],\n\t) {}\n\n\tabstract prepareQuery(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown,\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): SQLitePreparedQuery<PreparedQueryConfig & { type: TResultKind }>;\n\n\tprepareOneTimeQuery(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown,\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): SQLitePreparedQuery<PreparedQueryConfig & { type: TResultKind }> {\n\t\treturn this.prepareQuery(\n\t\t\tquery,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t\tqueryMetadata,\n\t\t\tcacheConfig,\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>,\n\t\tconfig?: SQLiteTransactionConfig,\n\t): Result<TResultKind, T>;\n\n\trun(query: SQL): Result<TResultKind, TRunResult> {\n\t\tconst staticQuery = this.dialect.sqlToQuery(query);\n\t\ttry {\n\t\t\treturn this.prepareOneTimeQuery(staticQuery, undefined, 'run', false).run() as Result<TResultKind, TRunResult>;\n\t\t} catch (err) {\n\t\t\tthrow new DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });\n\t\t}\n\t}\n\n\t/** @internal */\n\textractRawRunValueFromBatchResult(result: unknown) {\n\t\treturn result;\n\t}\n\n\tall<T = unknown>(query: SQL): Result<TResultKind, T[]> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).all() as Result<\n\t\t\tTResultKind,\n\t\t\tT[]\n\t\t>;\n\t}\n\n\t/** @internal */\n\textractRawAllValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tget<T = unknown>(query: SQL): Result<TResultKind, T> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).get() as Result<\n\t\t\tTResultKind,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/** @internal */\n\textractRawGetValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n\n\tvalues<T extends any[] = unknown[]>(\n\t\tquery: SQL,\n\t): Result<TResultKind, T[]> {\n\t\treturn this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), undefined, 'run', false).values() as Result<\n\t\t\tTResultKind,\n\t\t\tT[]\n\t\t>;\n\t}\n\n\tasync count(sql: SQL) {\n\t\tconst result = await this.values(sql) as [[number]];\n\n\t\treturn result[0][0];\n\t}\n\n\t/** @internal */\n\textractRawValuesValueFromBatchResult(_result: unknown): unknown {\n\t\tthrow new Error('Not implemented');\n\t}\n}\n\nexport type Result<TKind extends 'sync' | 'async', TResult> = { sync: TResult; async: Promise<TResult> }[TKind];\n\nexport type DBResult<TKind extends 'sync' | 'async', TResult> = { sync: TResult; async: SQLiteRaw<TResult> }[TKind];\n\nexport abstract class SQLiteTransaction<\n\tTResultType extends 'sync' | 'async',\n\tTRunResult,\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends BaseSQLiteDatabase<TResultType, TRunResult, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteTransaction';\n\n\tconstructor(\n\t\tresultType: TResultType,\n\t\tdialect: { sync: SQLiteSyncDialect; async: SQLiteAsyncDialect }[TResultType],\n\t\tsession: SQLiteSession<TResultType, TRunResult, TFullSchema, TSchema>,\n\t\tprotected schema: {\n\t\t\tfullSchema: Record<string, unknown>;\n\t\t\tschema: TSchema;\n\t\t\ttableNamesMap: Record<string, string>;\n\t\t} | undefined,\n\t\tprotected readonly nestedIndex = 0,\n\t) {\n\t\tsuper(resultType, dialect, session, schema);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n}\n"],"mappings":"AAAA,SAAqB,WAAW,iBAAiB;AAEjD,SAAS,YAAY,UAAU;AAC/B,SAAS,cAAc,mBAAmB,gCAAgC;AAC1E,SAAS,oBAAoB;AAK7B,SAAS,0BAA0B;AAa5B,MAAM,0BAA6B,aAAgB;AAAA,EAGzD,YAAoB,UAAmB;AACtC,UAAM;AADa;AAAA,EAEpB;AAAA,EAJA,QAA0B,UAAU,IAAY;AAAA,EAMhD,MAAe,UAAsB;AACpC,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAU;AACT,WAAO,KAAK,SAAS;AAAA,EACtB;AACD;AAKO,MAAe,oBAA4E;AAAA,EAMjG,YACS,MACA,eACE,OACF,OAEA,eAKA,aACP;AAXO;AACA;AACE;AACF;AAEA;AAKA;AAGR,QAAI,SAAS,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,UAAM,IAAI,MAAM,iBAAiB;AAAA,EAClC;AAAA,EAEA,OACC,OAC2B;AAC3B,WAAO,KAAK,oBAAoB,KAAK,QAAQ,WAAW,KAAK,GAAG,QAAW,OAAO,KAAK,EAAE,OAAO;AAAA,EAIjG;AAAA,EAEA,MAAM,MAAM,KAAU;AACrB,UAAM,SAAS,MAAM,KAAK,OAAO,GAAG;AAEpC,WAAO,OAAO,CAAC,EAAE,CAAC;AAAA,EACnB;AAAA;AAAA,EAGA,qCAAqC,SAA2B;AAC/D,UAAM,IAAI,MAAM,iBAAiB;AAAA,EAClC;AACD;AAMO,MAAe,0BAKZ,mBAAkE;AAAA,EAG3E,YACC,YACA,SACA,SACU,QAKS,cAAc,GAChC;AACD,UAAM,YAAY,SAAS,SAAS,MAAM;AAPhC;AAKS;AAAA,EAGpB;AAAA,EAdA,QAA0B,UAAU,IAAY;AAAA,EAgBhD,WAAkB;AACjB,UAAM,IAAI,yBAAyB;AAAA,EACpC;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __copyProps = (to, from, except, desc) => {
|
| 7 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 8 |
+
for (let key of __getOwnPropNames(from))
|
| 9 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 10 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 11 |
+
}
|
| 12 |
+
return to;
|
| 13 |
+
};
|
| 14 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 15 |
+
var subquery_exports = {};
|
| 16 |
+
module.exports = __toCommonJS(subquery_exports);
|
| 17 |
+
//# sourceMappingURL=subquery.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/subquery.ts"],"sourcesContent":["import type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { AddAliasToSelection } from '~/query-builders/select.types.ts';\nimport type { ColumnsSelection, SQL } from '~/sql/sql.ts';\nimport type { Subquery, WithSubquery, WithSubqueryWithoutSelection } from '~/subquery.ts';\nimport type { QueryBuilder } from './query-builders/query-builder.ts';\n\nexport type SubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> =\n\t& Subquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'sqlite'>;\n\nexport type WithSubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> =\n\t& WithSubquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'sqlite'>;\n\nexport interface WithBuilder {\n\t<TAlias extends string>(alias: TAlias): {\n\t\tas: {\n\t\t\t<TSelection extends ColumnsSelection>(\n\t\t\t\tqb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),\n\t\t\t): WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t(\n\t\t\t\tqb: TypedQueryBuilder<undefined> | ((qb: QueryBuilder) => TypedQueryBuilder<undefined>),\n\t\t\t): WithSubqueryWithoutSelection<TAlias>;\n\t\t};\n\t};\n\t<TAlias extends string, TSelection extends ColumnsSelection>(alias: TAlias, selection: TSelection): {\n\t\tas: (qb: SQL | ((qb: QueryBuilder) => SQL)) => WithSubqueryWithSelection<TSelection, TAlias>;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.d.cts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TypedQueryBuilder } from "../query-builders/query-builder.cjs";
|
| 2 |
+
import type { AddAliasToSelection } from "../query-builders/select.types.cjs";
|
| 3 |
+
import type { ColumnsSelection, SQL } from "../sql/sql.cjs";
|
| 4 |
+
import type { Subquery, WithSubquery, WithSubqueryWithoutSelection } from "../subquery.cjs";
|
| 5 |
+
import type { QueryBuilder } from "./query-builders/query-builder.cjs";
|
| 6 |
+
export type SubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> = Subquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>> & AddAliasToSelection<TSelection, TAlias, 'sqlite'>;
|
| 7 |
+
export type WithSubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> = WithSubquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>> & AddAliasToSelection<TSelection, TAlias, 'sqlite'>;
|
| 8 |
+
export interface WithBuilder {
|
| 9 |
+
<TAlias extends string>(alias: TAlias): {
|
| 10 |
+
as: {
|
| 11 |
+
<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
|
| 12 |
+
(qb: TypedQueryBuilder<undefined> | ((qb: QueryBuilder) => TypedQueryBuilder<undefined>)): WithSubqueryWithoutSelection<TAlias>;
|
| 13 |
+
};
|
| 14 |
+
};
|
| 15 |
+
<TAlias extends string, TSelection extends ColumnsSelection>(alias: TAlias, selection: TSelection): {
|
| 16 |
+
as: (qb: SQL | ((qb: QueryBuilder) => SQL)) => WithSubqueryWithSelection<TSelection, TAlias>;
|
| 17 |
+
};
|
| 18 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TypedQueryBuilder } from "../query-builders/query-builder.js";
|
| 2 |
+
import type { AddAliasToSelection } from "../query-builders/select.types.js";
|
| 3 |
+
import type { ColumnsSelection, SQL } from "../sql/sql.js";
|
| 4 |
+
import type { Subquery, WithSubquery, WithSubqueryWithoutSelection } from "../subquery.js";
|
| 5 |
+
import type { QueryBuilder } from "./query-builders/query-builder.js";
|
| 6 |
+
export type SubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> = Subquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>> & AddAliasToSelection<TSelection, TAlias, 'sqlite'>;
|
| 7 |
+
export type WithSubqueryWithSelection<TSelection extends ColumnsSelection, TAlias extends string> = WithSubquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'sqlite'>> & AddAliasToSelection<TSelection, TAlias, 'sqlite'>;
|
| 8 |
+
export interface WithBuilder {
|
| 9 |
+
<TAlias extends string>(alias: TAlias): {
|
| 10 |
+
as: {
|
| 11 |
+
<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
|
| 12 |
+
(qb: TypedQueryBuilder<undefined> | ((qb: QueryBuilder) => TypedQueryBuilder<undefined>)): WithSubqueryWithoutSelection<TAlias>;
|
| 13 |
+
};
|
| 14 |
+
};
|
| 15 |
+
<TAlias extends string, TSelection extends ColumnsSelection>(alias: TAlias, selection: TSelection): {
|
| 16 |
+
as: (qb: SQL | ((qb: QueryBuilder) => SQL)) => WithSubqueryWithSelection<TSelection, TAlias>;
|
| 17 |
+
};
|
| 18 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
//# sourceMappingURL=subquery.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/subquery.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.cjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var table_exports = {};
|
| 20 |
+
__export(table_exports, {
|
| 21 |
+
InlineForeignKeys: () => InlineForeignKeys,
|
| 22 |
+
SQLiteTable: () => SQLiteTable,
|
| 23 |
+
sqliteTable: () => sqliteTable,
|
| 24 |
+
sqliteTableCreator: () => sqliteTableCreator
|
| 25 |
+
});
|
| 26 |
+
module.exports = __toCommonJS(table_exports);
|
| 27 |
+
var import_entity = require("../entity.cjs");
|
| 28 |
+
var import_table = require("../table.cjs");
|
| 29 |
+
var import_all = require("./columns/all.cjs");
|
| 30 |
+
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
| 31 |
+
class SQLiteTable extends import_table.Table {
|
| 32 |
+
static [import_entity.entityKind] = "SQLiteTable";
|
| 33 |
+
/** @internal */
|
| 34 |
+
static Symbol = Object.assign({}, import_table.Table.Symbol, {
|
| 35 |
+
InlineForeignKeys
|
| 36 |
+
});
|
| 37 |
+
/** @internal */
|
| 38 |
+
[import_table.Table.Symbol.Columns];
|
| 39 |
+
/** @internal */
|
| 40 |
+
[InlineForeignKeys] = [];
|
| 41 |
+
/** @internal */
|
| 42 |
+
[import_table.Table.Symbol.ExtraConfigBuilder] = void 0;
|
| 43 |
+
}
|
| 44 |
+
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
| 45 |
+
const rawTable = new SQLiteTable(name, schema, baseName);
|
| 46 |
+
const parsedColumns = typeof columns === "function" ? columns((0, import_all.getSQLiteColumnBuilders)()) : columns;
|
| 47 |
+
const builtColumns = Object.fromEntries(
|
| 48 |
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
| 49 |
+
const colBuilder = colBuilderBase;
|
| 50 |
+
colBuilder.setName(name2);
|
| 51 |
+
const column = colBuilder.build(rawTable);
|
| 52 |
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
| 53 |
+
return [name2, column];
|
| 54 |
+
})
|
| 55 |
+
);
|
| 56 |
+
const table = Object.assign(rawTable, builtColumns);
|
| 57 |
+
table[import_table.Table.Symbol.Columns] = builtColumns;
|
| 58 |
+
table[import_table.Table.Symbol.ExtraConfigColumns] = builtColumns;
|
| 59 |
+
if (extraConfig) {
|
| 60 |
+
table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
| 61 |
+
}
|
| 62 |
+
return table;
|
| 63 |
+
}
|
| 64 |
+
const sqliteTable = (name, columns, extraConfig) => {
|
| 65 |
+
return sqliteTableBase(name, columns, extraConfig);
|
| 66 |
+
};
|
| 67 |
+
function sqliteTableCreator(customizeTableName) {
|
| 68 |
+
return (name, columns, extraConfig) => {
|
| 69 |
+
return sqliteTableBase(customizeTableName(name), columns, extraConfig, void 0, name);
|
| 70 |
+
};
|
| 71 |
+
}
|
| 72 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 73 |
+
0 && (module.exports = {
|
| 74 |
+
InlineForeignKeys,
|
| 75 |
+
SQLiteTable,
|
| 76 |
+
sqliteTable,
|
| 77 |
+
sqliteTableCreator
|
| 78 |
+
});
|
| 79 |
+
//# sourceMappingURL=table.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/table.ts"],"sourcesContent":["import type { BuildColumns, BuildExtraConfigColumns } from '~/column-builder.ts';\nimport { entityKind } from '~/entity.ts';\nimport { Table, type TableConfig as TableConfigBase, type UpdateTableConfig } from '~/table.ts';\nimport type { CheckBuilder } from './checks.ts';\nimport { getSQLiteColumnBuilders, type SQLiteColumnBuilders } from './columns/all.ts';\nimport type { SQLiteColumn, SQLiteColumnBuilder, SQLiteColumnBuilderBase } from './columns/common.ts';\nimport type { ForeignKey, ForeignKeyBuilder } from './foreign-keys.ts';\nimport type { IndexBuilder } from './indexes.ts';\nimport type { PrimaryKeyBuilder } from './primary-keys.ts';\nimport type { UniqueConstraintBuilder } from './unique-constraint.ts';\n\nexport type SQLiteTableExtraConfigValue =\n\t| IndexBuilder\n\t| CheckBuilder\n\t| ForeignKeyBuilder\n\t| PrimaryKeyBuilder\n\t| UniqueConstraintBuilder;\n\nexport type SQLiteTableExtraConfig = Record<\n\tstring,\n\tSQLiteTableExtraConfigValue\n>;\n\nexport type TableConfig = TableConfigBase<SQLiteColumn<any>>;\n\n/** @internal */\nexport const InlineForeignKeys = Symbol.for('drizzle:SQLiteInlineForeignKeys');\n\nexport class SQLiteTable<T extends TableConfig = TableConfig> extends Table<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteTable';\n\n\t/** @internal */\n\tstatic override readonly Symbol = Object.assign({}, Table.Symbol, {\n\t\tInlineForeignKeys: InlineForeignKeys as typeof InlineForeignKeys,\n\t});\n\n\t/** @internal */\n\toverride [Table.Symbol.Columns]!: NonNullable<T['columns']>;\n\n\t/** @internal */\n\t[InlineForeignKeys]: ForeignKey[] = [];\n\n\t/** @internal */\n\toverride [Table.Symbol.ExtraConfigBuilder]:\n\t\t| ((self: Record<string, SQLiteColumn>) => SQLiteTableExtraConfig)\n\t\t| undefined = undefined;\n}\n\nexport type AnySQLiteTable<TPartial extends Partial<TableConfig> = {}> = SQLiteTable<\n\tUpdateTableConfig<TableConfig, TPartial>\n>;\n\nexport type SQLiteTableWithColumns<T extends TableConfig> =\n\t& SQLiteTable<T>\n\t& {\n\t\t[Key in keyof T['columns']]: T['columns'][Key];\n\t};\n\nexport interface SQLiteTableFn<TSchema extends string | undefined = undefined> {\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: TColumnsMap,\n\t\textraConfig?: (\n\t\t\tself: BuildColumns<TTableName, TColumnsMap, 'sqlite'>,\n\t\t) => SQLiteTableExtraConfigValue[],\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[],\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\t/**\n\t * @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object\n\t *\n\t * @example\n\t * Deprecated version:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => ({\n\t * \tidx: index('custom_name').on(t.id)\n\t * }));\n\t * ```\n\t *\n\t * New API:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => [\n\t * \tindex('custom_name').on(t.id)\n\t * ]);\n\t * ```\n\t */\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig,\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\n\t/**\n\t * @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object\n\t *\n\t * @example\n\t * Deprecated version:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => ({\n\t * \tidx: index('custom_name').on(t.id)\n\t * }));\n\t * ```\n\t *\n\t * New API:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => [\n\t * \tindex('custom_name').on(t.id)\n\t * ]);\n\t * ```\n\t */\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig,\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n}\n\nfunction sqliteTableBase<\n\tTTableName extends string,\n\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\tTSchema extends string | undefined,\n>(\n\tname: TTableName,\n\tcolumns: TColumnsMap | ((columnTypes: SQLiteColumnBuilders) => TColumnsMap),\n\textraConfig:\n\t\t| ((\n\t\t\tself: BuildColumns<TTableName, TColumnsMap, 'sqlite'>,\n\t\t) => SQLiteTableExtraConfig | SQLiteTableExtraConfigValue[])\n\t\t| undefined,\n\tschema?: TSchema,\n\tbaseName = name,\n): SQLiteTableWithColumns<{\n\tname: TTableName;\n\tschema: TSchema;\n\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\tdialect: 'sqlite';\n}> {\n\tconst rawTable = new SQLiteTable<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>(name, schema, baseName);\n\n\tconst parsedColumns: TColumnsMap = typeof columns === 'function' ? columns(getSQLiteColumnBuilders()) : columns;\n\n\tconst builtColumns = Object.fromEntries(\n\t\tObject.entries(parsedColumns).map(([name, colBuilderBase]) => {\n\t\t\tconst colBuilder = colBuilderBase as SQLiteColumnBuilder;\n\t\t\tcolBuilder.setName(name);\n\t\t\tconst column = colBuilder.build(rawTable);\n\t\t\trawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));\n\t\t\treturn [name, column];\n\t\t}),\n\t) as unknown as BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\n\tconst table = Object.assign(rawTable, builtColumns);\n\n\ttable[Table.Symbol.Columns] = builtColumns;\n\ttable[Table.Symbol.ExtraConfigColumns] = builtColumns as unknown as BuildExtraConfigColumns<\n\t\tTTableName,\n\t\tTColumnsMap,\n\t\t'sqlite'\n\t>;\n\n\tif (extraConfig) {\n\t\ttable[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig as (\n\t\t\tself: Record<string, SQLiteColumn>,\n\t\t) => SQLiteTableExtraConfig;\n\t}\n\n\treturn table;\n}\n\nexport const sqliteTable: SQLiteTableFn = (name, columns, extraConfig) => {\n\treturn sqliteTableBase(name, columns, extraConfig);\n};\n\nexport function sqliteTableCreator(customizeTableName: (name: string) => string): SQLiteTableFn {\n\treturn (name, columns, extraConfig) => {\n\t\treturn sqliteTableBase(customizeTableName(name) as typeof name, columns, extraConfig, undefined, name);\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAA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EO,SAAS,mBAAmB,oBAA6D;AAC/F,SAAO,CAAC,MAAM,SAAS,gBAAgB;AACtC,WAAO,gBAAgB,mBAAmB,IAAI,GAAkB,SAAS,aAAa,QAAW,IAAI;AAAA,EACtG;AACD;","names":["name"]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.d.cts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { BuildColumns } from "../column-builder.cjs";
|
| 2 |
+
import { entityKind } from "../entity.cjs";
|
| 3 |
+
import { Table, type TableConfig as TableConfigBase, type UpdateTableConfig } from "../table.cjs";
|
| 4 |
+
import type { CheckBuilder } from "./checks.cjs";
|
| 5 |
+
import { type SQLiteColumnBuilders } from "./columns/all.cjs";
|
| 6 |
+
import type { SQLiteColumn, SQLiteColumnBuilderBase } from "./columns/common.cjs";
|
| 7 |
+
import type { ForeignKeyBuilder } from "./foreign-keys.cjs";
|
| 8 |
+
import type { IndexBuilder } from "./indexes.cjs";
|
| 9 |
+
import type { PrimaryKeyBuilder } from "./primary-keys.cjs";
|
| 10 |
+
import type { UniqueConstraintBuilder } from "./unique-constraint.cjs";
|
| 11 |
+
export type SQLiteTableExtraConfigValue = IndexBuilder | CheckBuilder | ForeignKeyBuilder | PrimaryKeyBuilder | UniqueConstraintBuilder;
|
| 12 |
+
export type SQLiteTableExtraConfig = Record<string, SQLiteTableExtraConfigValue>;
|
| 13 |
+
export type TableConfig = TableConfigBase<SQLiteColumn<any>>;
|
| 14 |
+
export declare class SQLiteTable<T extends TableConfig = TableConfig> extends Table<T> {
|
| 15 |
+
static readonly [entityKind]: string;
|
| 16 |
+
}
|
| 17 |
+
export type AnySQLiteTable<TPartial extends Partial<TableConfig> = {}> = SQLiteTable<UpdateTableConfig<TableConfig, TPartial>>;
|
| 18 |
+
export type SQLiteTableWithColumns<T extends TableConfig> = SQLiteTable<T> & {
|
| 19 |
+
[Key in keyof T['columns']]: T['columns'][Key];
|
| 20 |
+
};
|
| 21 |
+
export interface SQLiteTableFn<TSchema extends string | undefined = undefined> {
|
| 22 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[]): SQLiteTableWithColumns<{
|
| 23 |
+
name: TTableName;
|
| 24 |
+
schema: TSchema;
|
| 25 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 26 |
+
dialect: 'sqlite';
|
| 27 |
+
}>;
|
| 28 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[]): SQLiteTableWithColumns<{
|
| 29 |
+
name: TTableName;
|
| 30 |
+
schema: TSchema;
|
| 31 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 32 |
+
dialect: 'sqlite';
|
| 33 |
+
}>;
|
| 34 |
+
/**
|
| 35 |
+
* @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object
|
| 36 |
+
*
|
| 37 |
+
* @example
|
| 38 |
+
* Deprecated version:
|
| 39 |
+
* ```ts
|
| 40 |
+
* export const users = sqliteTable("users", {
|
| 41 |
+
* id: int(),
|
| 42 |
+
* }, (t) => ({
|
| 43 |
+
* idx: index('custom_name').on(t.id)
|
| 44 |
+
* }));
|
| 45 |
+
* ```
|
| 46 |
+
*
|
| 47 |
+
* New API:
|
| 48 |
+
* ```ts
|
| 49 |
+
* export const users = sqliteTable("users", {
|
| 50 |
+
* id: int(),
|
| 51 |
+
* }, (t) => [
|
| 52 |
+
* index('custom_name').on(t.id)
|
| 53 |
+
* ]);
|
| 54 |
+
* ```
|
| 55 |
+
*/
|
| 56 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig): SQLiteTableWithColumns<{
|
| 57 |
+
name: TTableName;
|
| 58 |
+
schema: TSchema;
|
| 59 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 60 |
+
dialect: 'sqlite';
|
| 61 |
+
}>;
|
| 62 |
+
/**
|
| 63 |
+
* @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object
|
| 64 |
+
*
|
| 65 |
+
* @example
|
| 66 |
+
* Deprecated version:
|
| 67 |
+
* ```ts
|
| 68 |
+
* export const users = sqliteTable("users", {
|
| 69 |
+
* id: int(),
|
| 70 |
+
* }, (t) => ({
|
| 71 |
+
* idx: index('custom_name').on(t.id)
|
| 72 |
+
* }));
|
| 73 |
+
* ```
|
| 74 |
+
*
|
| 75 |
+
* New API:
|
| 76 |
+
* ```ts
|
| 77 |
+
* export const users = sqliteTable("users", {
|
| 78 |
+
* id: int(),
|
| 79 |
+
* }, (t) => [
|
| 80 |
+
* index('custom_name').on(t.id)
|
| 81 |
+
* ]);
|
| 82 |
+
* ```
|
| 83 |
+
*/
|
| 84 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig): SQLiteTableWithColumns<{
|
| 85 |
+
name: TTableName;
|
| 86 |
+
schema: TSchema;
|
| 87 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 88 |
+
dialect: 'sqlite';
|
| 89 |
+
}>;
|
| 90 |
+
}
|
| 91 |
+
export declare const sqliteTable: SQLiteTableFn;
|
| 92 |
+
export declare function sqliteTableCreator(customizeTableName: (name: string) => string): SQLiteTableFn;
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { BuildColumns } from "../column-builder.js";
|
| 2 |
+
import { entityKind } from "../entity.js";
|
| 3 |
+
import { Table, type TableConfig as TableConfigBase, type UpdateTableConfig } from "../table.js";
|
| 4 |
+
import type { CheckBuilder } from "./checks.js";
|
| 5 |
+
import { type SQLiteColumnBuilders } from "./columns/all.js";
|
| 6 |
+
import type { SQLiteColumn, SQLiteColumnBuilderBase } from "./columns/common.js";
|
| 7 |
+
import type { ForeignKeyBuilder } from "./foreign-keys.js";
|
| 8 |
+
import type { IndexBuilder } from "./indexes.js";
|
| 9 |
+
import type { PrimaryKeyBuilder } from "./primary-keys.js";
|
| 10 |
+
import type { UniqueConstraintBuilder } from "./unique-constraint.js";
|
| 11 |
+
export type SQLiteTableExtraConfigValue = IndexBuilder | CheckBuilder | ForeignKeyBuilder | PrimaryKeyBuilder | UniqueConstraintBuilder;
|
| 12 |
+
export type SQLiteTableExtraConfig = Record<string, SQLiteTableExtraConfigValue>;
|
| 13 |
+
export type TableConfig = TableConfigBase<SQLiteColumn<any>>;
|
| 14 |
+
export declare class SQLiteTable<T extends TableConfig = TableConfig> extends Table<T> {
|
| 15 |
+
static readonly [entityKind]: string;
|
| 16 |
+
}
|
| 17 |
+
export type AnySQLiteTable<TPartial extends Partial<TableConfig> = {}> = SQLiteTable<UpdateTableConfig<TableConfig, TPartial>>;
|
| 18 |
+
export type SQLiteTableWithColumns<T extends TableConfig> = SQLiteTable<T> & {
|
| 19 |
+
[Key in keyof T['columns']]: T['columns'][Key];
|
| 20 |
+
};
|
| 21 |
+
export interface SQLiteTableFn<TSchema extends string | undefined = undefined> {
|
| 22 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[]): SQLiteTableWithColumns<{
|
| 23 |
+
name: TTableName;
|
| 24 |
+
schema: TSchema;
|
| 25 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 26 |
+
dialect: 'sqlite';
|
| 27 |
+
}>;
|
| 28 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[]): SQLiteTableWithColumns<{
|
| 29 |
+
name: TTableName;
|
| 30 |
+
schema: TSchema;
|
| 31 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 32 |
+
dialect: 'sqlite';
|
| 33 |
+
}>;
|
| 34 |
+
/**
|
| 35 |
+
* @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object
|
| 36 |
+
*
|
| 37 |
+
* @example
|
| 38 |
+
* Deprecated version:
|
| 39 |
+
* ```ts
|
| 40 |
+
* export const users = sqliteTable("users", {
|
| 41 |
+
* id: int(),
|
| 42 |
+
* }, (t) => ({
|
| 43 |
+
* idx: index('custom_name').on(t.id)
|
| 44 |
+
* }));
|
| 45 |
+
* ```
|
| 46 |
+
*
|
| 47 |
+
* New API:
|
| 48 |
+
* ```ts
|
| 49 |
+
* export const users = sqliteTable("users", {
|
| 50 |
+
* id: int(),
|
| 51 |
+
* }, (t) => [
|
| 52 |
+
* index('custom_name').on(t.id)
|
| 53 |
+
* ]);
|
| 54 |
+
* ```
|
| 55 |
+
*/
|
| 56 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig): SQLiteTableWithColumns<{
|
| 57 |
+
name: TTableName;
|
| 58 |
+
schema: TSchema;
|
| 59 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 60 |
+
dialect: 'sqlite';
|
| 61 |
+
}>;
|
| 62 |
+
/**
|
| 63 |
+
* @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object
|
| 64 |
+
*
|
| 65 |
+
* @example
|
| 66 |
+
* Deprecated version:
|
| 67 |
+
* ```ts
|
| 68 |
+
* export const users = sqliteTable("users", {
|
| 69 |
+
* id: int(),
|
| 70 |
+
* }, (t) => ({
|
| 71 |
+
* idx: index('custom_name').on(t.id)
|
| 72 |
+
* }));
|
| 73 |
+
* ```
|
| 74 |
+
*
|
| 75 |
+
* New API:
|
| 76 |
+
* ```ts
|
| 77 |
+
* export const users = sqliteTable("users", {
|
| 78 |
+
* id: int(),
|
| 79 |
+
* }, (t) => [
|
| 80 |
+
* index('custom_name').on(t.id)
|
| 81 |
+
* ]);
|
| 82 |
+
* ```
|
| 83 |
+
*/
|
| 84 |
+
<TTableName extends string, TColumnsMap extends Record<string, SQLiteColumnBuilderBase>>(name: TTableName, columns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap, extraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig): SQLiteTableWithColumns<{
|
| 85 |
+
name: TTableName;
|
| 86 |
+
schema: TSchema;
|
| 87 |
+
columns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;
|
| 88 |
+
dialect: 'sqlite';
|
| 89 |
+
}>;
|
| 90 |
+
}
|
| 91 |
+
export declare const sqliteTable: SQLiteTableFn;
|
| 92 |
+
export declare function sqliteTableCreator(customizeTableName: (name: string) => string): SQLiteTableFn;
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import { Table } from "../table.js";
|
| 3 |
+
import { getSQLiteColumnBuilders } from "./columns/all.js";
|
| 4 |
+
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
| 5 |
+
class SQLiteTable extends Table {
|
| 6 |
+
static [entityKind] = "SQLiteTable";
|
| 7 |
+
/** @internal */
|
| 8 |
+
static Symbol = Object.assign({}, Table.Symbol, {
|
| 9 |
+
InlineForeignKeys
|
| 10 |
+
});
|
| 11 |
+
/** @internal */
|
| 12 |
+
[Table.Symbol.Columns];
|
| 13 |
+
/** @internal */
|
| 14 |
+
[InlineForeignKeys] = [];
|
| 15 |
+
/** @internal */
|
| 16 |
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
| 17 |
+
}
|
| 18 |
+
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
| 19 |
+
const rawTable = new SQLiteTable(name, schema, baseName);
|
| 20 |
+
const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
|
| 21 |
+
const builtColumns = Object.fromEntries(
|
| 22 |
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
| 23 |
+
const colBuilder = colBuilderBase;
|
| 24 |
+
colBuilder.setName(name2);
|
| 25 |
+
const column = colBuilder.build(rawTable);
|
| 26 |
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
| 27 |
+
return [name2, column];
|
| 28 |
+
})
|
| 29 |
+
);
|
| 30 |
+
const table = Object.assign(rawTable, builtColumns);
|
| 31 |
+
table[Table.Symbol.Columns] = builtColumns;
|
| 32 |
+
table[Table.Symbol.ExtraConfigColumns] = builtColumns;
|
| 33 |
+
if (extraConfig) {
|
| 34 |
+
table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
| 35 |
+
}
|
| 36 |
+
return table;
|
| 37 |
+
}
|
| 38 |
+
const sqliteTable = (name, columns, extraConfig) => {
|
| 39 |
+
return sqliteTableBase(name, columns, extraConfig);
|
| 40 |
+
};
|
| 41 |
+
function sqliteTableCreator(customizeTableName) {
|
| 42 |
+
return (name, columns, extraConfig) => {
|
| 43 |
+
return sqliteTableBase(customizeTableName(name), columns, extraConfig, void 0, name);
|
| 44 |
+
};
|
| 45 |
+
}
|
| 46 |
+
export {
|
| 47 |
+
InlineForeignKeys,
|
| 48 |
+
SQLiteTable,
|
| 49 |
+
sqliteTable,
|
| 50 |
+
sqliteTableCreator
|
| 51 |
+
};
|
| 52 |
+
//# sourceMappingURL=table.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/table.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/table.ts"],"sourcesContent":["import type { BuildColumns, BuildExtraConfigColumns } from '~/column-builder.ts';\nimport { entityKind } from '~/entity.ts';\nimport { Table, type TableConfig as TableConfigBase, type UpdateTableConfig } from '~/table.ts';\nimport type { CheckBuilder } from './checks.ts';\nimport { getSQLiteColumnBuilders, type SQLiteColumnBuilders } from './columns/all.ts';\nimport type { SQLiteColumn, SQLiteColumnBuilder, SQLiteColumnBuilderBase } from './columns/common.ts';\nimport type { ForeignKey, ForeignKeyBuilder } from './foreign-keys.ts';\nimport type { IndexBuilder } from './indexes.ts';\nimport type { PrimaryKeyBuilder } from './primary-keys.ts';\nimport type { UniqueConstraintBuilder } from './unique-constraint.ts';\n\nexport type SQLiteTableExtraConfigValue =\n\t| IndexBuilder\n\t| CheckBuilder\n\t| ForeignKeyBuilder\n\t| PrimaryKeyBuilder\n\t| UniqueConstraintBuilder;\n\nexport type SQLiteTableExtraConfig = Record<\n\tstring,\n\tSQLiteTableExtraConfigValue\n>;\n\nexport type TableConfig = TableConfigBase<SQLiteColumn<any>>;\n\n/** @internal */\nexport const InlineForeignKeys = Symbol.for('drizzle:SQLiteInlineForeignKeys');\n\nexport class SQLiteTable<T extends TableConfig = TableConfig> extends Table<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteTable';\n\n\t/** @internal */\n\tstatic override readonly Symbol = Object.assign({}, Table.Symbol, {\n\t\tInlineForeignKeys: InlineForeignKeys as typeof InlineForeignKeys,\n\t});\n\n\t/** @internal */\n\toverride [Table.Symbol.Columns]!: NonNullable<T['columns']>;\n\n\t/** @internal */\n\t[InlineForeignKeys]: ForeignKey[] = [];\n\n\t/** @internal */\n\toverride [Table.Symbol.ExtraConfigBuilder]:\n\t\t| ((self: Record<string, SQLiteColumn>) => SQLiteTableExtraConfig)\n\t\t| undefined = undefined;\n}\n\nexport type AnySQLiteTable<TPartial extends Partial<TableConfig> = {}> = SQLiteTable<\n\tUpdateTableConfig<TableConfig, TPartial>\n>;\n\nexport type SQLiteTableWithColumns<T extends TableConfig> =\n\t& SQLiteTable<T>\n\t& {\n\t\t[Key in keyof T['columns']]: T['columns'][Key];\n\t};\n\nexport interface SQLiteTableFn<TSchema extends string | undefined = undefined> {\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: TColumnsMap,\n\t\textraConfig?: (\n\t\t\tself: BuildColumns<TTableName, TColumnsMap, 'sqlite'>,\n\t\t) => SQLiteTableExtraConfigValue[],\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfigValue[],\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\t/**\n\t * @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object\n\t *\n\t * @example\n\t * Deprecated version:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => ({\n\t * \tidx: index('custom_name').on(t.id)\n\t * }));\n\t * ```\n\t *\n\t * New API:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => [\n\t * \tindex('custom_name').on(t.id)\n\t * ]);\n\t * ```\n\t */\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig,\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n\n\t/**\n\t * @deprecated The third parameter of sqliteTable is changing and will only accept an array instead of an object\n\t *\n\t * @example\n\t * Deprecated version:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => ({\n\t * \tidx: index('custom_name').on(t.id)\n\t * }));\n\t * ```\n\t *\n\t * New API:\n\t * ```ts\n\t * export const users = sqliteTable(\"users\", {\n\t * \tid: int(),\n\t * }, (t) => [\n\t * \tindex('custom_name').on(t.id)\n\t * ]);\n\t * ```\n\t */\n\t<\n\t\tTTableName extends string,\n\t\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\t>(\n\t\tname: TTableName,\n\t\tcolumns: (columnTypes: SQLiteColumnBuilders) => TColumnsMap,\n\t\textraConfig?: (self: BuildColumns<TTableName, TColumnsMap, 'sqlite'>) => SQLiteTableExtraConfig,\n\t): SQLiteTableWithColumns<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>;\n}\n\nfunction sqliteTableBase<\n\tTTableName extends string,\n\tTColumnsMap extends Record<string, SQLiteColumnBuilderBase>,\n\tTSchema extends string | undefined,\n>(\n\tname: TTableName,\n\tcolumns: TColumnsMap | ((columnTypes: SQLiteColumnBuilders) => TColumnsMap),\n\textraConfig:\n\t\t| ((\n\t\t\tself: BuildColumns<TTableName, TColumnsMap, 'sqlite'>,\n\t\t) => SQLiteTableExtraConfig | SQLiteTableExtraConfigValue[])\n\t\t| undefined,\n\tschema?: TSchema,\n\tbaseName = name,\n): SQLiteTableWithColumns<{\n\tname: TTableName;\n\tschema: TSchema;\n\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\tdialect: 'sqlite';\n}> {\n\tconst rawTable = new SQLiteTable<{\n\t\tname: TTableName;\n\t\tschema: TSchema;\n\t\tcolumns: BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\t\tdialect: 'sqlite';\n\t}>(name, schema, baseName);\n\n\tconst parsedColumns: TColumnsMap = typeof columns === 'function' ? columns(getSQLiteColumnBuilders()) : columns;\n\n\tconst builtColumns = Object.fromEntries(\n\t\tObject.entries(parsedColumns).map(([name, colBuilderBase]) => {\n\t\t\tconst colBuilder = colBuilderBase as SQLiteColumnBuilder;\n\t\t\tcolBuilder.setName(name);\n\t\t\tconst column = colBuilder.build(rawTable);\n\t\t\trawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));\n\t\t\treturn [name, column];\n\t\t}),\n\t) as unknown as BuildColumns<TTableName, TColumnsMap, 'sqlite'>;\n\n\tconst table = Object.assign(rawTable, builtColumns);\n\n\ttable[Table.Symbol.Columns] = builtColumns;\n\ttable[Table.Symbol.ExtraConfigColumns] = builtColumns as unknown as BuildExtraConfigColumns<\n\t\tTTableName,\n\t\tTColumnsMap,\n\t\t'sqlite'\n\t>;\n\n\tif (extraConfig) {\n\t\ttable[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig as (\n\t\t\tself: Record<string, SQLiteColumn>,\n\t\t) => SQLiteTableExtraConfig;\n\t}\n\n\treturn table;\n}\n\nexport const sqliteTable: SQLiteTableFn = (name, columns, extraConfig) => {\n\treturn sqliteTableBase(name, columns, extraConfig);\n};\n\nexport function sqliteTableCreator(customizeTableName: (name: string) => string): SQLiteTableFn {\n\treturn (name, columns, extraConfig) => {\n\t\treturn sqliteTableBase(customizeTableName(name) as typeof name, columns, extraConfig, undefined, name);\n\t};\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,aAA0E;AAEnF,SAAS,+BAA0D;AAsB5D,MAAM,oBAAoB,OAAO,IAAI,iCAAiC;AAEtE,MAAM,oBAAyD,MAAS;AAAA,EAC9E,QAA0B,UAAU,IAAY;AAAA;AAAA,EAGhD,OAAyB,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,QAAQ;AAAA,IACjE;AAAA,EACD,CAAC;AAAA;AAAA,EAGD,CAAU,MAAM,OAAO,OAAO;AAAA;AAAA,EAG9B,CAAC,iBAAiB,IAAkB,CAAC;AAAA;AAAA,EAGrC,CAAU,MAAM,OAAO,kBAAkB,IAE1B;AAChB;AAmHA,SAAS,gBAKR,MACA,SACA,aAKA,QACA,WAAW,MAMT;AACF,QAAM,WAAW,IAAI,YAKlB,MAAM,QAAQ,QAAQ;AAEzB,QAAM,gBAA6B,OAAO,YAAY,aAAa,QAAQ,wBAAwB,CAAC,IA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var unique_constraint_exports = {};
|
| 20 |
+
__export(unique_constraint_exports, {
|
| 21 |
+
UniqueConstraint: () => UniqueConstraint,
|
| 22 |
+
UniqueConstraintBuilder: () => UniqueConstraintBuilder,
|
| 23 |
+
UniqueOnConstraintBuilder: () => UniqueOnConstraintBuilder,
|
| 24 |
+
unique: () => unique,
|
| 25 |
+
uniqueKeyName: () => uniqueKeyName
|
| 26 |
+
});
|
| 27 |
+
module.exports = __toCommonJS(unique_constraint_exports);
|
| 28 |
+
var import_entity = require("../entity.cjs");
|
| 29 |
+
var import_table_utils = require("../table.utils.cjs");
|
| 30 |
+
function uniqueKeyName(table, columns) {
|
| 31 |
+
return `${table[import_table_utils.TableName]}_${columns.join("_")}_unique`;
|
| 32 |
+
}
|
| 33 |
+
function unique(name) {
|
| 34 |
+
return new UniqueOnConstraintBuilder(name);
|
| 35 |
+
}
|
| 36 |
+
class UniqueConstraintBuilder {
|
| 37 |
+
constructor(columns, name) {
|
| 38 |
+
this.name = name;
|
| 39 |
+
this.columns = columns;
|
| 40 |
+
}
|
| 41 |
+
static [import_entity.entityKind] = "SQLiteUniqueConstraintBuilder";
|
| 42 |
+
/** @internal */
|
| 43 |
+
columns;
|
| 44 |
+
/** @internal */
|
| 45 |
+
build(table) {
|
| 46 |
+
return new UniqueConstraint(table, this.columns, this.name);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
class UniqueOnConstraintBuilder {
|
| 50 |
+
static [import_entity.entityKind] = "SQLiteUniqueOnConstraintBuilder";
|
| 51 |
+
/** @internal */
|
| 52 |
+
name;
|
| 53 |
+
constructor(name) {
|
| 54 |
+
this.name = name;
|
| 55 |
+
}
|
| 56 |
+
on(...columns) {
|
| 57 |
+
return new UniqueConstraintBuilder(columns, this.name);
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
class UniqueConstraint {
|
| 61 |
+
constructor(table, columns, name) {
|
| 62 |
+
this.table = table;
|
| 63 |
+
this.columns = columns;
|
| 64 |
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
| 65 |
+
}
|
| 66 |
+
static [import_entity.entityKind] = "SQLiteUniqueConstraint";
|
| 67 |
+
columns;
|
| 68 |
+
name;
|
| 69 |
+
getName() {
|
| 70 |
+
return this.name;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 74 |
+
0 && (module.exports = {
|
| 75 |
+
UniqueConstraint,
|
| 76 |
+
UniqueConstraintBuilder,
|
| 77 |
+
UniqueOnConstraintBuilder,
|
| 78 |
+
unique,
|
| 79 |
+
uniqueKeyName
|
| 80 |
+
});
|
| 81 |
+
//# sourceMappingURL=unique-constraint.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/unique-constraint.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TableName } from '~/table.utils.ts';\nimport type { SQLiteColumn } from './columns/common.ts';\nimport type { SQLiteTable } from './table.ts';\n\nexport function uniqueKeyName(table: SQLiteTable, columns: string[]) {\n\treturn `${table[TableName]}_${columns.join('_')}_unique`;\n}\n\nexport function unique(name?: string): UniqueOnConstraintBuilder {\n\treturn new UniqueOnConstraintBuilder(name);\n}\n\nexport class UniqueConstraintBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueConstraintBuilder';\n\n\t/** @internal */\n\tcolumns: SQLiteColumn[];\n\n\tconstructor(\n\t\tcolumns: SQLiteColumn[],\n\t\tprivate name?: string,\n\t) {\n\t\tthis.columns = columns;\n\t}\n\n\t/** @internal */\n\tbuild(table: SQLiteTable): UniqueConstraint {\n\t\treturn new UniqueConstraint(table, this.columns, this.name);\n\t}\n}\n\nexport class UniqueOnConstraintBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueOnConstraintBuilder';\n\n\t/** @internal */\n\tname?: string;\n\n\tconstructor(\n\t\tname?: string,\n\t) {\n\t\tthis.name = name;\n\t}\n\n\ton(...columns: [SQLiteColumn, ...SQLiteColumn[]]) {\n\t\treturn new UniqueConstraintBuilder(columns, this.name);\n\t}\n}\n\nexport class UniqueConstraint {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueConstraint';\n\n\treadonly columns: SQLiteColumn[];\n\treadonly name?: string;\n\n\tconstructor(readonly table: SQLiteTable, columns: SQLiteColumn[], name?: string) {\n\t\tthis.columns = columns;\n\t\tthis.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));\n\t}\n\n\tget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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.cjs";
|
| 2 |
+
import type { SQLiteColumn } from "./columns/common.cjs";
|
| 3 |
+
import type { SQLiteTable } from "./table.cjs";
|
| 4 |
+
export declare function uniqueKeyName(table: SQLiteTable, columns: string[]): string;
|
| 5 |
+
export declare function unique(name?: string): UniqueOnConstraintBuilder;
|
| 6 |
+
export declare class UniqueConstraintBuilder {
|
| 7 |
+
private name?;
|
| 8 |
+
static readonly [entityKind]: string;
|
| 9 |
+
constructor(columns: SQLiteColumn[], name?: string | undefined);
|
| 10 |
+
}
|
| 11 |
+
export declare class UniqueOnConstraintBuilder {
|
| 12 |
+
static readonly [entityKind]: string;
|
| 13 |
+
constructor(name?: string);
|
| 14 |
+
on(...columns: [SQLiteColumn, ...SQLiteColumn[]]): UniqueConstraintBuilder;
|
| 15 |
+
}
|
| 16 |
+
export declare class UniqueConstraint {
|
| 17 |
+
readonly table: SQLiteTable;
|
| 18 |
+
static readonly [entityKind]: string;
|
| 19 |
+
readonly columns: SQLiteColumn[];
|
| 20 |
+
readonly name?: string;
|
| 21 |
+
constructor(table: SQLiteTable, columns: SQLiteColumn[], name?: string);
|
| 22 |
+
getName(): string | undefined;
|
| 23 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import type { SQLiteColumn } from "./columns/common.js";
|
| 3 |
+
import type { SQLiteTable } from "./table.js";
|
| 4 |
+
export declare function uniqueKeyName(table: SQLiteTable, columns: string[]): string;
|
| 5 |
+
export declare function unique(name?: string): UniqueOnConstraintBuilder;
|
| 6 |
+
export declare class UniqueConstraintBuilder {
|
| 7 |
+
private name?;
|
| 8 |
+
static readonly [entityKind]: string;
|
| 9 |
+
constructor(columns: SQLiteColumn[], name?: string | undefined);
|
| 10 |
+
}
|
| 11 |
+
export declare class UniqueOnConstraintBuilder {
|
| 12 |
+
static readonly [entityKind]: string;
|
| 13 |
+
constructor(name?: string);
|
| 14 |
+
on(...columns: [SQLiteColumn, ...SQLiteColumn[]]): UniqueConstraintBuilder;
|
| 15 |
+
}
|
| 16 |
+
export declare class UniqueConstraint {
|
| 17 |
+
readonly table: SQLiteTable;
|
| 18 |
+
static readonly [entityKind]: string;
|
| 19 |
+
readonly columns: SQLiteColumn[];
|
| 20 |
+
readonly name?: string;
|
| 21 |
+
constructor(table: SQLiteTable, columns: SQLiteColumn[], name?: string);
|
| 22 |
+
getName(): string | undefined;
|
| 23 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import { TableName } from "../table.utils.js";
|
| 3 |
+
function uniqueKeyName(table, columns) {
|
| 4 |
+
return `${table[TableName]}_${columns.join("_")}_unique`;
|
| 5 |
+
}
|
| 6 |
+
function unique(name) {
|
| 7 |
+
return new UniqueOnConstraintBuilder(name);
|
| 8 |
+
}
|
| 9 |
+
class UniqueConstraintBuilder {
|
| 10 |
+
constructor(columns, name) {
|
| 11 |
+
this.name = name;
|
| 12 |
+
this.columns = columns;
|
| 13 |
+
}
|
| 14 |
+
static [entityKind] = "SQLiteUniqueConstraintBuilder";
|
| 15 |
+
/** @internal */
|
| 16 |
+
columns;
|
| 17 |
+
/** @internal */
|
| 18 |
+
build(table) {
|
| 19 |
+
return new UniqueConstraint(table, this.columns, this.name);
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
class UniqueOnConstraintBuilder {
|
| 23 |
+
static [entityKind] = "SQLiteUniqueOnConstraintBuilder";
|
| 24 |
+
/** @internal */
|
| 25 |
+
name;
|
| 26 |
+
constructor(name) {
|
| 27 |
+
this.name = name;
|
| 28 |
+
}
|
| 29 |
+
on(...columns) {
|
| 30 |
+
return new UniqueConstraintBuilder(columns, this.name);
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
class UniqueConstraint {
|
| 34 |
+
constructor(table, columns, name) {
|
| 35 |
+
this.table = table;
|
| 36 |
+
this.columns = columns;
|
| 37 |
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
| 38 |
+
}
|
| 39 |
+
static [entityKind] = "SQLiteUniqueConstraint";
|
| 40 |
+
columns;
|
| 41 |
+
name;
|
| 42 |
+
getName() {
|
| 43 |
+
return this.name;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
export {
|
| 47 |
+
UniqueConstraint,
|
| 48 |
+
UniqueConstraintBuilder,
|
| 49 |
+
UniqueOnConstraintBuilder,
|
| 50 |
+
unique,
|
| 51 |
+
uniqueKeyName
|
| 52 |
+
};
|
| 53 |
+
//# sourceMappingURL=unique-constraint.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/unique-constraint.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/unique-constraint.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TableName } from '~/table.utils.ts';\nimport type { SQLiteColumn } from './columns/common.ts';\nimport type { SQLiteTable } from './table.ts';\n\nexport function uniqueKeyName(table: SQLiteTable, columns: string[]) {\n\treturn `${table[TableName]}_${columns.join('_')}_unique`;\n}\n\nexport function unique(name?: string): UniqueOnConstraintBuilder {\n\treturn new UniqueOnConstraintBuilder(name);\n}\n\nexport class UniqueConstraintBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueConstraintBuilder';\n\n\t/** @internal */\n\tcolumns: SQLiteColumn[];\n\n\tconstructor(\n\t\tcolumns: SQLiteColumn[],\n\t\tprivate name?: string,\n\t) {\n\t\tthis.columns = columns;\n\t}\n\n\t/** @internal */\n\tbuild(table: SQLiteTable): UniqueConstraint {\n\t\treturn new UniqueConstraint(table, this.columns, this.name);\n\t}\n}\n\nexport class UniqueOnConstraintBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueOnConstraintBuilder';\n\n\t/** @internal */\n\tname?: string;\n\n\tconstructor(\n\t\tname?: string,\n\t) {\n\t\tthis.name = name;\n\t}\n\n\ton(...columns: [SQLiteColumn, ...SQLiteColumn[]]) {\n\t\treturn new UniqueConstraintBuilder(columns, this.name);\n\t}\n}\n\nexport class UniqueConstraint {\n\tstatic readonly [entityKind]: string = 'SQLiteUniqueConstraint';\n\n\treadonly columns: SQLiteColumn[];\n\treadonly name?: string;\n\n\tconstructor(readonly table: SQLiteTable, columns: SQLiteColumn[], name?: string) {\n\t\tthis.columns = columns;\n\t\tthis.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));\n\t}\n\n\tgetName() {\n\t\treturn this.name;\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAInB,SAAS,cAAc,OAAoB,SAAmB;AACpE,SAAO,GAAG,MAAM,SAAS,CAAC,IAAI,QAAQ,KAAK,G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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var utils_exports = {};
|
| 20 |
+
__export(utils_exports, {
|
| 21 |
+
extractUsedTable: () => extractUsedTable,
|
| 22 |
+
getTableConfig: () => getTableConfig,
|
| 23 |
+
getViewConfig: () => getViewConfig
|
| 24 |
+
});
|
| 25 |
+
module.exports = __toCommonJS(utils_exports);
|
| 26 |
+
var import_entity = require("../entity.cjs");
|
| 27 |
+
var import_sql = require("../sql/sql.cjs");
|
| 28 |
+
var import_subquery = require("../subquery.cjs");
|
| 29 |
+
var import_table = require("../table.cjs");
|
| 30 |
+
var import_view_common = require("../view-common.cjs");
|
| 31 |
+
var import_checks = require("./checks.cjs");
|
| 32 |
+
var import_foreign_keys = require("./foreign-keys.cjs");
|
| 33 |
+
var import_indexes = require("./indexes.cjs");
|
| 34 |
+
var import_primary_keys = require("./primary-keys.cjs");
|
| 35 |
+
var import_table2 = require("./table.cjs");
|
| 36 |
+
var import_unique_constraint = require("./unique-constraint.cjs");
|
| 37 |
+
function getTableConfig(table) {
|
| 38 |
+
const columns = Object.values(table[import_table2.SQLiteTable.Symbol.Columns]);
|
| 39 |
+
const indexes = [];
|
| 40 |
+
const checks = [];
|
| 41 |
+
const primaryKeys = [];
|
| 42 |
+
const uniqueConstraints = [];
|
| 43 |
+
const foreignKeys = Object.values(table[import_table2.SQLiteTable.Symbol.InlineForeignKeys]);
|
| 44 |
+
const name = table[import_table.Table.Symbol.Name];
|
| 45 |
+
const extraConfigBuilder = table[import_table2.SQLiteTable.Symbol.ExtraConfigBuilder];
|
| 46 |
+
if (extraConfigBuilder !== void 0) {
|
| 47 |
+
const extraConfig = extraConfigBuilder(table[import_table2.SQLiteTable.Symbol.Columns]);
|
| 48 |
+
const extraValues = Array.isArray(extraConfig) ? extraConfig.flat(1) : Object.values(extraConfig);
|
| 49 |
+
for (const builder of Object.values(extraValues)) {
|
| 50 |
+
if ((0, import_entity.is)(builder, import_indexes.IndexBuilder)) {
|
| 51 |
+
indexes.push(builder.build(table));
|
| 52 |
+
} else if ((0, import_entity.is)(builder, import_checks.CheckBuilder)) {
|
| 53 |
+
checks.push(builder.build(table));
|
| 54 |
+
} else if ((0, import_entity.is)(builder, import_unique_constraint.UniqueConstraintBuilder)) {
|
| 55 |
+
uniqueConstraints.push(builder.build(table));
|
| 56 |
+
} else if ((0, import_entity.is)(builder, import_primary_keys.PrimaryKeyBuilder)) {
|
| 57 |
+
primaryKeys.push(builder.build(table));
|
| 58 |
+
} else if ((0, import_entity.is)(builder, import_foreign_keys.ForeignKeyBuilder)) {
|
| 59 |
+
foreignKeys.push(builder.build(table));
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
return {
|
| 64 |
+
columns,
|
| 65 |
+
indexes,
|
| 66 |
+
foreignKeys,
|
| 67 |
+
checks,
|
| 68 |
+
primaryKeys,
|
| 69 |
+
uniqueConstraints,
|
| 70 |
+
name
|
| 71 |
+
};
|
| 72 |
+
}
|
| 73 |
+
function extractUsedTable(table) {
|
| 74 |
+
if ((0, import_entity.is)(table, import_table2.SQLiteTable)) {
|
| 75 |
+
return [`${table[import_table.Table.Symbol.BaseName]}`];
|
| 76 |
+
}
|
| 77 |
+
if ((0, import_entity.is)(table, import_subquery.Subquery)) {
|
| 78 |
+
return table._.usedTables ?? [];
|
| 79 |
+
}
|
| 80 |
+
if ((0, import_entity.is)(table, import_sql.SQL)) {
|
| 81 |
+
return table.usedTables ?? [];
|
| 82 |
+
}
|
| 83 |
+
return [];
|
| 84 |
+
}
|
| 85 |
+
function getViewConfig(view) {
|
| 86 |
+
return {
|
| 87 |
+
...view[import_view_common.ViewBaseConfig]
|
| 88 |
+
// ...view[SQLiteViewConfig],
|
| 89 |
+
};
|
| 90 |
+
}
|
| 91 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 92 |
+
0 && (module.exports = {
|
| 93 |
+
extractUsedTable,
|
| 94 |
+
getTableConfig,
|
| 95 |
+
getViewConfig
|
| 96 |
+
});
|
| 97 |
+
//# sourceMappingURL=utils.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/utils.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/utils.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { Check } from './checks.ts';\nimport { CheckBuilder } from './checks.ts';\nimport type { ForeignKey } from './foreign-keys.ts';\nimport { ForeignKeyBuilder } from './foreign-keys.ts';\nimport type { Index } from './indexes.ts';\nimport { IndexBuilder } from './indexes.ts';\nimport type { PrimaryKey } from './primary-keys.ts';\nimport { PrimaryKeyBuilder } from './primary-keys.ts';\nimport { SQLiteTable } from './table.ts';\nimport { type UniqueConstraint, UniqueConstraintBuilder } from './unique-constraint.ts';\nimport type { SQLiteViewBase } from './view-base.ts';\nimport type { SQLiteView } from './view.ts';\n\nexport function getTableConfig<TTable extends SQLiteTable>(table: TTable) {\n\tconst columns = Object.values(table[SQLiteTable.Symbol.Columns]);\n\tconst indexes: Index[] = [];\n\tconst checks: Check[] = [];\n\tconst primaryKeys: PrimaryKey[] = [];\n\tconst uniqueConstraints: UniqueConstraint[] = [];\n\tconst foreignKeys: ForeignKey[] = Object.values(table[SQLiteTable.Symbol.InlineForeignKeys]);\n\tconst name = table[Table.Symbol.Name];\n\n\tconst extraConfigBuilder = table[SQLiteTable.Symbol.ExtraConfigBuilder];\n\n\tif (extraConfigBuilder !== undefined) {\n\t\tconst extraConfig = extraConfigBuilder(table[SQLiteTable.Symbol.Columns]);\n\t\tconst extraValues = Array.isArray(extraConfig) ? extraConfig.flat(1) as any[] : Object.values(extraConfig);\n\t\tfor (const builder of Object.values(extraValues)) {\n\t\t\tif (is(builder, IndexBuilder)) {\n\t\t\t\tindexes.push(builder.build(table));\n\t\t\t} else if (is(builder, CheckBuilder)) {\n\t\t\t\tchecks.push(builder.build(table));\n\t\t\t} else if (is(builder, UniqueConstraintBuilder)) {\n\t\t\t\tuniqueConstraints.push(builder.build(table));\n\t\t\t} else if (is(builder, PrimaryKeyBuilder)) {\n\t\t\t\tprimaryKeys.push(builder.build(table));\n\t\t\t} else if (is(builder, ForeignKeyBuilder)) {\n\t\t\t\tforeignKeys.push(builder.build(table));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcolumns,\n\t\tindexes,\n\t\tforeignKeys,\n\t\tchecks,\n\t\tprimaryKeys,\n\t\tuniqueConstraints,\n\t\tname,\n\t};\n}\n\nexport function extractUsedTable(table: SQLiteTable | Subquery | SQLiteViewBase | SQL): string[] {\n\tif (is(table, SQLiteTable)) {\n\t\treturn [`${table[Table.Symbol.BaseName]}`];\n\t}\n\tif (is(table, Subquery)) {\n\t\treturn table._.usedTables ?? [];\n\t}\n\tif (is(table, SQL)) {\n\t\treturn table.usedTables ?? [];\n\t}\n\treturn [];\n}\n\nexport type OnConflict = 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace';\n\nexport function getViewConfig<\n\tTName extends string = string,\n\tTExisting extends boolean = boolean,\n>(view: SQLiteView<TName, TExisting>) {\n\treturn {\n\t\t...view[ViewBaseConfig],\n\t\t// ...view[SQLiteViewConfig],\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,iBAAoB;AACpB,sBAAyB;AACzB,mBAAsB;AACtB,yBAA+B;AAE/B,oBAA6B;AAE7B,0BAAkC;AAElC,qBAA6B;AAE7B,0BAAkC;AAClC,IAAAA,gBAA4B;AAC5B,+BAA+D;AAIxD,SAAS,eAA2C,OAAe;AACzE,QAAM,UAAU,OAAO,OAAO,MAAM,0BAAY,OAAO,OAAO,CAAC;AAC/D,QAAM,UAAmB,CAAC;AAC1B,QAAM,SAAkB,CAAC;AACzB,QAAM,cAA4B,CAAC;AACnC,QAAM,oBAAwC,CAAC;AAC/C,QAAM,cAA4B,OAAO,OAAO,MAAM,0BAAY,OAAO,iBAAiB,CAAC;AAC3F,QAAM,OAAO,MAAM,mBAAM,OAAO,IAAI;AAEpC,QAAM,qBAAqB,MAAM,0BAAY,OAAO,kBAAkB;AAEtE,MAAI,uBAAuB,QAAW;AACrC,UAAM,cAAc,mBAAmB,MAAM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-0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { SQL } from "../sql/sql.cjs";
|
| 2 |
+
import { Subquery } from "../subquery.cjs";
|
| 3 |
+
import type { Check } from "./checks.cjs";
|
| 4 |
+
import type { ForeignKey } from "./foreign-keys.cjs";
|
| 5 |
+
import type { Index } from "./indexes.cjs";
|
| 6 |
+
import type { PrimaryKey } from "./primary-keys.cjs";
|
| 7 |
+
import { SQLiteTable } from "./table.cjs";
|
| 8 |
+
import { type UniqueConstraint } from "./unique-constraint.cjs";
|
| 9 |
+
import type { SQLiteViewBase } from "./view-base.cjs";
|
| 10 |
+
import type { SQLiteView } from "./view.cjs";
|
| 11 |
+
export declare function getTableConfig<TTable extends SQLiteTable>(table: TTable): {
|
| 12 |
+
columns: import("./index.ts").SQLiteColumn<any, {}, {}>[];
|
| 13 |
+
indexes: Index[];
|
| 14 |
+
foreignKeys: ForeignKey[];
|
| 15 |
+
checks: Check[];
|
| 16 |
+
primaryKeys: PrimaryKey[];
|
| 17 |
+
uniqueConstraints: UniqueConstraint[];
|
| 18 |
+
name: string;
|
| 19 |
+
};
|
| 20 |
+
export declare function extractUsedTable(table: SQLiteTable | Subquery | SQLiteViewBase | SQL): string[];
|
| 21 |
+
export type OnConflict = 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace';
|
| 22 |
+
export declare function getViewConfig<TName extends string = string, TExisting extends boolean = boolean>(view: SQLiteView<TName, TExisting>): {
|
| 23 |
+
name: TName;
|
| 24 |
+
originalName: TName;
|
| 25 |
+
schema: string | undefined;
|
| 26 |
+
selectedFields: import("../sql/sql.ts").ColumnsSelection;
|
| 27 |
+
isExisting: TExisting;
|
| 28 |
+
query: TExisting extends true ? undefined : SQL<unknown>;
|
| 29 |
+
isAlias: boolean;
|
| 30 |
+
};
|
e-commerce/node_modules/drizzle-orm/sqlite-core/utils.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { SQL } from "../sql/sql.js";
|
| 2 |
+
import { Subquery } from "../subquery.js";
|
| 3 |
+
import type { Check } from "./checks.js";
|
| 4 |
+
import type { ForeignKey } from "./foreign-keys.js";
|
| 5 |
+
import type { Index } from "./indexes.js";
|
| 6 |
+
import type { PrimaryKey } from "./primary-keys.js";
|
| 7 |
+
import { SQLiteTable } from "./table.js";
|
| 8 |
+
import { type UniqueConstraint } from "./unique-constraint.js";
|
| 9 |
+
import type { SQLiteViewBase } from "./view-base.js";
|
| 10 |
+
import type { SQLiteView } from "./view.js";
|
| 11 |
+
export declare function getTableConfig<TTable extends SQLiteTable>(table: TTable): {
|
| 12 |
+
columns: import("./index.js").SQLiteColumn<any, {}, {}>[];
|
| 13 |
+
indexes: Index[];
|
| 14 |
+
foreignKeys: ForeignKey[];
|
| 15 |
+
checks: Check[];
|
| 16 |
+
primaryKeys: PrimaryKey[];
|
| 17 |
+
uniqueConstraints: UniqueConstraint[];
|
| 18 |
+
name: string;
|
| 19 |
+
};
|
| 20 |
+
export declare function extractUsedTable(table: SQLiteTable | Subquery | SQLiteViewBase | SQL): string[];
|
| 21 |
+
export type OnConflict = 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace';
|
| 22 |
+
export declare function getViewConfig<TName extends string = string, TExisting extends boolean = boolean>(view: SQLiteView<TName, TExisting>): {
|
| 23 |
+
name: TName;
|
| 24 |
+
originalName: TName;
|
| 25 |
+
schema: string | undefined;
|
| 26 |
+
selectedFields: import("../sql/sql.js").ColumnsSelection;
|
| 27 |
+
isExisting: TExisting;
|
| 28 |
+
query: TExisting extends true ? undefined : SQL<unknown>;
|
| 29 |
+
isAlias: boolean;
|
| 30 |
+
};
|
e-commerce/node_modules/drizzle-orm/sqlite-core/utils.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { is } from "../entity.js";
|
| 2 |
+
import { SQL } from "../sql/sql.js";
|
| 3 |
+
import { Subquery } from "../subquery.js";
|
| 4 |
+
import { Table } from "../table.js";
|
| 5 |
+
import { ViewBaseConfig } from "../view-common.js";
|
| 6 |
+
import { CheckBuilder } from "./checks.js";
|
| 7 |
+
import { ForeignKeyBuilder } from "./foreign-keys.js";
|
| 8 |
+
import { IndexBuilder } from "./indexes.js";
|
| 9 |
+
import { PrimaryKeyBuilder } from "./primary-keys.js";
|
| 10 |
+
import { SQLiteTable } from "./table.js";
|
| 11 |
+
import { UniqueConstraintBuilder } from "./unique-constraint.js";
|
| 12 |
+
function getTableConfig(table) {
|
| 13 |
+
const columns = Object.values(table[SQLiteTable.Symbol.Columns]);
|
| 14 |
+
const indexes = [];
|
| 15 |
+
const checks = [];
|
| 16 |
+
const primaryKeys = [];
|
| 17 |
+
const uniqueConstraints = [];
|
| 18 |
+
const foreignKeys = Object.values(table[SQLiteTable.Symbol.InlineForeignKeys]);
|
| 19 |
+
const name = table[Table.Symbol.Name];
|
| 20 |
+
const extraConfigBuilder = table[SQLiteTable.Symbol.ExtraConfigBuilder];
|
| 21 |
+
if (extraConfigBuilder !== void 0) {
|
| 22 |
+
const extraConfig = extraConfigBuilder(table[SQLiteTable.Symbol.Columns]);
|
| 23 |
+
const extraValues = Array.isArray(extraConfig) ? extraConfig.flat(1) : Object.values(extraConfig);
|
| 24 |
+
for (const builder of Object.values(extraValues)) {
|
| 25 |
+
if (is(builder, IndexBuilder)) {
|
| 26 |
+
indexes.push(builder.build(table));
|
| 27 |
+
} else if (is(builder, CheckBuilder)) {
|
| 28 |
+
checks.push(builder.build(table));
|
| 29 |
+
} else if (is(builder, UniqueConstraintBuilder)) {
|
| 30 |
+
uniqueConstraints.push(builder.build(table));
|
| 31 |
+
} else if (is(builder, PrimaryKeyBuilder)) {
|
| 32 |
+
primaryKeys.push(builder.build(table));
|
| 33 |
+
} else if (is(builder, ForeignKeyBuilder)) {
|
| 34 |
+
foreignKeys.push(builder.build(table));
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
return {
|
| 39 |
+
columns,
|
| 40 |
+
indexes,
|
| 41 |
+
foreignKeys,
|
| 42 |
+
checks,
|
| 43 |
+
primaryKeys,
|
| 44 |
+
uniqueConstraints,
|
| 45 |
+
name
|
| 46 |
+
};
|
| 47 |
+
}
|
| 48 |
+
function extractUsedTable(table) {
|
| 49 |
+
if (is(table, SQLiteTable)) {
|
| 50 |
+
return [`${table[Table.Symbol.BaseName]}`];
|
| 51 |
+
}
|
| 52 |
+
if (is(table, Subquery)) {
|
| 53 |
+
return table._.usedTables ?? [];
|
| 54 |
+
}
|
| 55 |
+
if (is(table, SQL)) {
|
| 56 |
+
return table.usedTables ?? [];
|
| 57 |
+
}
|
| 58 |
+
return [];
|
| 59 |
+
}
|
| 60 |
+
function getViewConfig(view) {
|
| 61 |
+
return {
|
| 62 |
+
...view[ViewBaseConfig]
|
| 63 |
+
// ...view[SQLiteViewConfig],
|
| 64 |
+
};
|
| 65 |
+
}
|
| 66 |
+
export {
|
| 67 |
+
extractUsedTable,
|
| 68 |
+
getTableConfig,
|
| 69 |
+
getViewConfig
|
| 70 |
+
};
|
| 71 |
+
//# sourceMappingURL=utils.js.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/utils.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { Check } from './checks.ts';\nimport { CheckBuilder } from './checks.ts';\nimport type { ForeignKey } from './foreign-keys.ts';\nimport { ForeignKeyBuilder } from './foreign-keys.ts';\nimport type { Index } from './indexes.ts';\nimport { IndexBuilder } from './indexes.ts';\nimport type { PrimaryKey } from './primary-keys.ts';\nimport { PrimaryKeyBuilder } from './primary-keys.ts';\nimport { SQLiteTable } from './table.ts';\nimport { type UniqueConstraint, UniqueConstraintBuilder } from './unique-constraint.ts';\nimport type { SQLiteViewBase } from './view-base.ts';\nimport type { SQLiteView } from './view.ts';\n\nexport function getTableConfig<TTable extends SQLiteTable>(table: TTable) {\n\tconst columns = Object.values(table[SQLiteTable.Symbol.Columns]);\n\tconst indexes: Index[] = [];\n\tconst checks: Check[] = [];\n\tconst primaryKeys: PrimaryKey[] = [];\n\tconst uniqueConstraints: UniqueConstraint[] = [];\n\tconst foreignKeys: ForeignKey[] = Object.values(table[SQLiteTable.Symbol.InlineForeignKeys]);\n\tconst name = table[Table.Symbol.Name];\n\n\tconst extraConfigBuilder = table[SQLiteTable.Symbol.ExtraConfigBuilder];\n\n\tif (extraConfigBuilder !== undefined) {\n\t\tconst extraConfig = extraConfigBuilder(table[SQLiteTable.Symbol.Columns]);\n\t\tconst extraValues = Array.isArray(extraConfig) ? extraConfig.flat(1) as any[] : Object.values(extraConfig);\n\t\tfor (const builder of Object.values(extraValues)) {\n\t\t\tif (is(builder, IndexBuilder)) {\n\t\t\t\tindexes.push(builder.build(table));\n\t\t\t} else if (is(builder, CheckBuilder)) {\n\t\t\t\tchecks.push(builder.build(table));\n\t\t\t} else if (is(builder, UniqueConstraintBuilder)) {\n\t\t\t\tuniqueConstraints.push(builder.build(table));\n\t\t\t} else if (is(builder, PrimaryKeyBuilder)) {\n\t\t\t\tprimaryKeys.push(builder.build(table));\n\t\t\t} else if (is(builder, ForeignKeyBuilder)) {\n\t\t\t\tforeignKeys.push(builder.build(table));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcolumns,\n\t\tindexes,\n\t\tforeignKeys,\n\t\tchecks,\n\t\tprimaryKeys,\n\t\tuniqueConstraints,\n\t\tname,\n\t};\n}\n\nexport function extractUsedTable(table: SQLiteTable | Subquery | SQLiteViewBase | SQL): string[] {\n\tif (is(table, SQLiteTable)) {\n\t\treturn [`${table[Table.Symbol.BaseName]}`];\n\t}\n\tif (is(table, Subquery)) {\n\t\treturn table._.usedTables ?? [];\n\t}\n\tif (is(table, SQL)) {\n\t\treturn table.usedTables ?? [];\n\t}\n\treturn [];\n}\n\nexport type OnConflict = 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace';\n\nexport function getViewConfig<\n\tTName extends string = string,\n\tTExisting extends boolean = boolean,\n>(view: SQLiteView<TName, TExisting>) {\n\treturn {\n\t\t...view[ViewBaseConfig],\n\t\t// ...view[SQLiteViewConfig],\n\t};\n}\n"],"mappings":"AAAA,SAAS,UAAU;AACnB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS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A;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,iBAAiB,OAAgE;AAChG,MAAI,GAAG,OAAO,WAAW,GAAG;AAC3B,WAAO,CAAC,GAAG,MAAM,MAAM,OAAO,QAAQ,CAAC,EAAE;AAAA,EAC1C;AACA,MAAI,GAAG,OAAO,QAAQ,GAAG;AACxB,WAAO,MAAM,EAAE,cAAc,CAAC;AAAA,EAC/B;AACA,MAAI,GAAG,OAAO,GAAG,GAAG;AACnB,WAAO,MAAM,cAAc,CAAC;AAAA,EAC7B;AACA,SAAO,CAAC;AACT;AAIO,SAAS,cAGd,MAAoC;AACrC,SAAO;AAAA,IACN,GAAG,KAAK,cAAc;AAAA;AAAA,EAEvB;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var view_base_exports = {};
|
| 20 |
+
__export(view_base_exports, {
|
| 21 |
+
SQLiteViewBase: () => SQLiteViewBase
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(view_base_exports);
|
| 24 |
+
var import_entity = require("../entity.cjs");
|
| 25 |
+
var import_sql = require("../sql/sql.cjs");
|
| 26 |
+
class SQLiteViewBase extends import_sql.View {
|
| 27 |
+
static [import_entity.entityKind] = "SQLiteViewBase";
|
| 28 |
+
}
|
| 29 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 30 |
+
0 && (module.exports = {
|
| 31 |
+
SQLiteViewBase
|
| 32 |
+
});
|
| 33 |
+
//# sourceMappingURL=view-base.cjs.map
|
e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/sqlite-core/view-base.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { ColumnsSelection } from '~/sql/sql.ts';\nimport { View } from '~/sql/sql.ts';\n\nexport abstract class SQLiteViewBase<\n\tTName extends string = string,\n\tTExisting extends boolean = boolean,\n\tTSelection extends ColumnsSelection = ColumnsSelection,\n> extends View<TName, TExisting, TSelection> {\n\tstatic override readonly [entityKind]: string = 'SQLiteViewBase';\n\n\tdeclare _: View<TName, TExisting, TSelection>['_'] & {\n\t\tviewBrand: 'SQLiteView';\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAE3B,iBAAqB;AAEd,MAAe,uBAIZ,gBAAmC;AAAA,EAC5C,QAA0B,wBAAU,IAAY;AAKjD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.cjs";
|
| 2 |
+
import type { ColumnsSelection } from "../sql/sql.cjs";
|
| 3 |
+
import { View } from "../sql/sql.cjs";
|
| 4 |
+
export declare abstract class SQLiteViewBase<TName extends string = string, TExisting extends boolean = boolean, TSelection extends ColumnsSelection = ColumnsSelection> extends View<TName, TExisting, TSelection> {
|
| 5 |
+
static readonly [entityKind]: string;
|
| 6 |
+
_: View<TName, TExisting, TSelection>['_'] & {
|
| 7 |
+
viewBrand: 'SQLiteView';
|
| 8 |
+
};
|
| 9 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import type { ColumnsSelection } from "../sql/sql.js";
|
| 3 |
+
import { View } from "../sql/sql.js";
|
| 4 |
+
export declare abstract class SQLiteViewBase<TName extends string = string, TExisting extends boolean = boolean, TSelection extends ColumnsSelection = ColumnsSelection> extends View<TName, TExisting, TSelection> {
|
| 5 |
+
static readonly [entityKind]: string;
|
| 6 |
+
_: View<TName, TExisting, TSelection>['_'] & {
|
| 7 |
+
viewBrand: 'SQLiteView';
|
| 8 |
+
};
|
| 9 |
+
}
|
e-commerce/node_modules/drizzle-orm/sqlite-core/view-base.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import { View } from "../sql/sql.js";
|
| 3 |
+
class SQLiteViewBase extends View {
|
| 4 |
+
static [entityKind] = "SQLiteViewBase";
|
| 5 |
+
}
|
| 6 |
+
export {
|
| 7 |
+
SQLiteViewBase
|
| 8 |
+
};
|
| 9 |
+
//# sourceMappingURL=view-base.js.map
|