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 10)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- e-commerce/node_modules/drizzle-orm/gel-core/indexes.d.ts +79 -0
- e-commerce/node_modules/drizzle-orm/gel-core/indexes.js +121 -0
- e-commerce/node_modules/drizzle-orm/gel-core/indexes.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.cjs +58 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.d.cts +24 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.d.ts +24 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.js +33 -0
- e-commerce/node_modules/drizzle-orm/gel-core/policies.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.cjs +68 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.d.cts +30 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.d.ts +30 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.js +42 -0
- e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.cjs +73 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.d.cts +25 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.d.ts +25 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.js +49 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.cjs +109 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.d.cts +99 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.d.ts +99 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.js +85 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.cjs +35 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.d.cts +7 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.d.ts +7 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.js +8 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.cjs +222 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.d.cts +116 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.d.ts +116 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.js +197 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.cjs +114 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.d.cts +40 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.d.ts +40 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.js +90 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.js.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.cjs +139 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.cjs.map +1 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.d.cts +46 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.d.ts +46 -0
- e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.js +116 -0
e-commerce/node_modules/drizzle-orm/gel-core/indexes.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { SQL } from "../sql/sql.js";
|
| 2 |
+
import { entityKind } from "../entity.js";
|
| 3 |
+
import type { GelColumn, GelExtraConfigColumn } from "./columns/index.js";
|
| 4 |
+
import { IndexedColumn } from "./columns/index.js";
|
| 5 |
+
import type { GelTable } from "./table.js";
|
| 6 |
+
interface IndexConfig {
|
| 7 |
+
name?: string;
|
| 8 |
+
columns: Partial<IndexedColumn | SQL>[];
|
| 9 |
+
/**
|
| 10 |
+
* If true, the index will be created as `create unique index` instead of `create index`.
|
| 11 |
+
*/
|
| 12 |
+
unique: boolean;
|
| 13 |
+
/**
|
| 14 |
+
* If true, the index will be created as `create index concurrently` instead of `create index`.
|
| 15 |
+
*/
|
| 16 |
+
concurrently?: boolean;
|
| 17 |
+
/**
|
| 18 |
+
* If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.
|
| 19 |
+
*/
|
| 20 |
+
only: boolean;
|
| 21 |
+
/**
|
| 22 |
+
* Condition for partial index.
|
| 23 |
+
*/
|
| 24 |
+
where?: SQL;
|
| 25 |
+
/**
|
| 26 |
+
* The optional WITH clause specifies storage parameters for the index
|
| 27 |
+
*/
|
| 28 |
+
with?: Record<string, any>;
|
| 29 |
+
/**
|
| 30 |
+
* The optional WITH clause method for the index
|
| 31 |
+
*/
|
| 32 |
+
method?: 'btree' | string;
|
| 33 |
+
}
|
| 34 |
+
export type IndexColumn = GelColumn;
|
| 35 |
+
export type GelIndexMethod = 'btree' | 'hash' | 'gist' | 'sGelist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | (string & {});
|
| 36 |
+
export type GelIndexOpClass = 'abstime_ops' | 'access_method' | 'anyarray_eq' | 'anyarray_ge' | 'anyarray_gt' | 'anyarray_le' | 'anyarray_lt' | 'anyarray_ne' | 'bigint_ops' | 'bit_ops' | 'bool_ops' | 'box_ops' | 'bpchar_ops' | 'char_ops' | 'cidr_ops' | 'cstring_ops' | 'date_ops' | 'float_ops' | 'int2_ops' | 'int4_ops' | 'int8_ops' | 'interval_ops' | 'jsonb_ops' | 'macaddr_ops' | 'name_ops' | 'numeric_ops' | 'oid_ops' | 'oidint4_ops' | 'oidint8_ops' | 'oidname_ops' | 'oidvector_ops' | 'point_ops' | 'polygon_ops' | 'range_ops' | 'record_eq' | 'record_ge' | 'record_gt' | 'record_le' | 'record_lt' | 'record_ne' | 'text_ops' | 'time_ops' | 'timestamp_ops' | 'timestamptz_ops' | 'timetz_ops' | 'uuid_ops' | 'varbit_ops' | 'varchar_ops' | 'xml_ops' | 'vector_l2_ops' | 'vector_ip_ops' | 'vector_cosine_ops' | 'vector_l1_ops' | 'bit_hamming_ops' | 'bit_jaccard_ops' | 'halfvec_l2_ops' | 'sparsevec_l2_op' | (string & {});
|
| 37 |
+
export declare class IndexBuilderOn {
|
| 38 |
+
private unique;
|
| 39 |
+
private name?;
|
| 40 |
+
static readonly [entityKind]: string;
|
| 41 |
+
constructor(unique: boolean, name?: string | undefined);
|
| 42 |
+
on(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
| 43 |
+
onOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
| 44 |
+
/**
|
| 45 |
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
| 46 |
+
*
|
| 47 |
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
| 48 |
+
*
|
| 49 |
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
| 50 |
+
*
|
| 51 |
+
* @param method The name of the index method to be used
|
| 52 |
+
* @param columns
|
| 53 |
+
* @returns
|
| 54 |
+
*/
|
| 55 |
+
using(method: GelIndexMethod, ...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
| 56 |
+
}
|
| 57 |
+
export interface AnyIndexBuilder {
|
| 58 |
+
build(table: GelTable): Index;
|
| 59 |
+
}
|
| 60 |
+
export interface IndexBuilder extends AnyIndexBuilder {
|
| 61 |
+
}
|
| 62 |
+
export declare class IndexBuilder implements AnyIndexBuilder {
|
| 63 |
+
static readonly [entityKind]: string;
|
| 64 |
+
constructor(columns: Partial<IndexedColumn | SQL>[], unique: boolean, only: boolean, name?: string, method?: string);
|
| 65 |
+
concurrently(): this;
|
| 66 |
+
with(obj: Record<string, any>): this;
|
| 67 |
+
where(condition: SQL): this;
|
| 68 |
+
}
|
| 69 |
+
export declare class Index {
|
| 70 |
+
static readonly [entityKind]: string;
|
| 71 |
+
readonly config: IndexConfig & {
|
| 72 |
+
table: GelTable;
|
| 73 |
+
};
|
| 74 |
+
constructor(config: IndexConfig, table: GelTable);
|
| 75 |
+
}
|
| 76 |
+
export type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name'] : TColumns extends GelColumn[] ? TColumns[number]['_']['name'] : never;
|
| 77 |
+
export declare function index(name?: string): IndexBuilderOn;
|
| 78 |
+
export declare function uniqueIndex(name?: string): IndexBuilderOn;
|
| 79 |
+
export {};
|
e-commerce/node_modules/drizzle-orm/gel-core/indexes.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { SQL } from "../sql/sql.js";
|
| 2 |
+
import { entityKind, is } from "../entity.js";
|
| 3 |
+
import { IndexedColumn } from "./columns/index.js";
|
| 4 |
+
class IndexBuilderOn {
|
| 5 |
+
constructor(unique, name) {
|
| 6 |
+
this.unique = unique;
|
| 7 |
+
this.name = name;
|
| 8 |
+
}
|
| 9 |
+
static [entityKind] = "GelIndexBuilderOn";
|
| 10 |
+
on(...columns) {
|
| 11 |
+
return new IndexBuilder(
|
| 12 |
+
columns.map((it) => {
|
| 13 |
+
if (is(it, SQL)) {
|
| 14 |
+
return it;
|
| 15 |
+
}
|
| 16 |
+
it = it;
|
| 17 |
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
| 18 |
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
| 19 |
+
return clonedIndexedColumn;
|
| 20 |
+
}),
|
| 21 |
+
this.unique,
|
| 22 |
+
false,
|
| 23 |
+
this.name
|
| 24 |
+
);
|
| 25 |
+
}
|
| 26 |
+
onOnly(...columns) {
|
| 27 |
+
return new IndexBuilder(
|
| 28 |
+
columns.map((it) => {
|
| 29 |
+
if (is(it, SQL)) {
|
| 30 |
+
return it;
|
| 31 |
+
}
|
| 32 |
+
it = it;
|
| 33 |
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
| 34 |
+
it.indexConfig = it.defaultConfig;
|
| 35 |
+
return clonedIndexedColumn;
|
| 36 |
+
}),
|
| 37 |
+
this.unique,
|
| 38 |
+
true,
|
| 39 |
+
this.name
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
/**
|
| 43 |
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
| 44 |
+
*
|
| 45 |
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
| 46 |
+
*
|
| 47 |
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
| 48 |
+
*
|
| 49 |
+
* @param method The name of the index method to be used
|
| 50 |
+
* @param columns
|
| 51 |
+
* @returns
|
| 52 |
+
*/
|
| 53 |
+
using(method, ...columns) {
|
| 54 |
+
return new IndexBuilder(
|
| 55 |
+
columns.map((it) => {
|
| 56 |
+
if (is(it, SQL)) {
|
| 57 |
+
return it;
|
| 58 |
+
}
|
| 59 |
+
it = it;
|
| 60 |
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
| 61 |
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
| 62 |
+
return clonedIndexedColumn;
|
| 63 |
+
}),
|
| 64 |
+
this.unique,
|
| 65 |
+
true,
|
| 66 |
+
this.name,
|
| 67 |
+
method
|
| 68 |
+
);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
class IndexBuilder {
|
| 72 |
+
static [entityKind] = "GelIndexBuilder";
|
| 73 |
+
/** @internal */
|
| 74 |
+
config;
|
| 75 |
+
constructor(columns, unique, only, name, method = "btree") {
|
| 76 |
+
this.config = {
|
| 77 |
+
name,
|
| 78 |
+
columns,
|
| 79 |
+
unique,
|
| 80 |
+
only,
|
| 81 |
+
method
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
concurrently() {
|
| 85 |
+
this.config.concurrently = true;
|
| 86 |
+
return this;
|
| 87 |
+
}
|
| 88 |
+
with(obj) {
|
| 89 |
+
this.config.with = obj;
|
| 90 |
+
return this;
|
| 91 |
+
}
|
| 92 |
+
where(condition) {
|
| 93 |
+
this.config.where = condition;
|
| 94 |
+
return this;
|
| 95 |
+
}
|
| 96 |
+
/** @internal */
|
| 97 |
+
build(table) {
|
| 98 |
+
return new Index(this.config, table);
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
class Index {
|
| 102 |
+
static [entityKind] = "GelIndex";
|
| 103 |
+
config;
|
| 104 |
+
constructor(config, table) {
|
| 105 |
+
this.config = { ...config, table };
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
function index(name) {
|
| 109 |
+
return new IndexBuilderOn(false, name);
|
| 110 |
+
}
|
| 111 |
+
function uniqueIndex(name) {
|
| 112 |
+
return new IndexBuilderOn(true, name);
|
| 113 |
+
}
|
| 114 |
+
export {
|
| 115 |
+
Index,
|
| 116 |
+
IndexBuilder,
|
| 117 |
+
IndexBuilderOn,
|
| 118 |
+
index,
|
| 119 |
+
uniqueIndex
|
| 120 |
+
};
|
| 121 |
+
//# sourceMappingURL=indexes.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/indexes.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/gel-core/indexes.ts"],"sourcesContent":["import { SQL } from '~/sql/sql.ts';\n\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelColumn, GelExtraConfigColumn } from './columns/index.ts';\nimport { IndexedColumn } from './columns/index.ts';\nimport type { GelTable } from './table.ts';\n\ninterface IndexConfig {\n\tname?: string;\n\n\tcolumns: Partial<IndexedColumn | SQL>[];\n\n\t/**\n\t * If true, the index will be created as `create unique index` instead of `create index`.\n\t */\n\tunique: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index concurrently` instead of `create index`.\n\t */\n\tconcurrently?: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.\n\t */\n\tonly: boolean;\n\n\t/**\n\t * Condition for partial index.\n\t */\n\twhere?: SQL;\n\n\t/**\n\t * The optional WITH clause specifies storage parameters for the index\n\t */\n\twith?: Record<string, any>;\n\n\t/**\n\t * The optional WITH clause method for the index\n\t */\n\tmethod?: 'btree' | string;\n}\n\nexport type IndexColumn = GelColumn;\n\nexport type GelIndexMethod =\n\t| 'btree'\n\t| 'hash'\n\t| 'gist'\n\t| 'sGelist'\n\t| 'gin'\n\t| 'brin'\n\t| 'hnsw'\n\t| 'ivfflat'\n\t| (string & {});\n\nexport type GelIndexOpClass =\n\t| 'abstime_ops'\n\t| 'access_method'\n\t| 'anyarray_eq'\n\t| 'anyarray_ge'\n\t| 'anyarray_gt'\n\t| 'anyarray_le'\n\t| 'anyarray_lt'\n\t| 'anyarray_ne'\n\t| 'bigint_ops'\n\t| 'bit_ops'\n\t| 'bool_ops'\n\t| 'box_ops'\n\t| 'bpchar_ops'\n\t| 'char_ops'\n\t| 'cidr_ops'\n\t| 'cstring_ops'\n\t| 'date_ops'\n\t| 'float_ops'\n\t| 'int2_ops'\n\t| 'int4_ops'\n\t| 'int8_ops'\n\t| 'interval_ops'\n\t| 'jsonb_ops'\n\t| 'macaddr_ops'\n\t| 'name_ops'\n\t| 'numeric_ops'\n\t| 'oid_ops'\n\t| 'oidint4_ops'\n\t| 'oidint8_ops'\n\t| 'oidname_ops'\n\t| 'oidvector_ops'\n\t| 'point_ops'\n\t| 'polygon_ops'\n\t| 'range_ops'\n\t| 'record_eq'\n\t| 'record_ge'\n\t| 'record_gt'\n\t| 'record_le'\n\t| 'record_lt'\n\t| 'record_ne'\n\t| 'text_ops'\n\t| 'time_ops'\n\t| 'timestamp_ops'\n\t| 'timestamptz_ops'\n\t| 'timetz_ops'\n\t| 'uuid_ops'\n\t| 'varbit_ops'\n\t| 'varchar_ops'\n\t| 'xml_ops'\n\t| 'vector_l2_ops'\n\t| 'vector_ip_ops'\n\t| 'vector_cosine_ops'\n\t| 'vector_l1_ops'\n\t| 'bit_hamming_ops'\n\t| 'bit_jaccard_ops'\n\t| 'halfvec_l2_ops'\n\t| 'sparsevec_l2_op'\n\t| (string & {});\n\nexport class IndexBuilderOn {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilderOn';\n\n\tconstructor(private unique: boolean, private name?: string) {}\n\n\ton(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\tfalse,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\tonOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = it.defaultConfig;\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\t/**\n\t * Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.\n\t *\n\t * If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.\n\t *\n\t * **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**\n\t *\n\t * @param method The name of the index method to be used\n\t * @param columns\n\t * @returns\n\t */\n\tusing(\n\t\tmethod: GelIndexMethod,\n\t\t...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]\n\t): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t\tmethod,\n\t\t);\n\t}\n}\n\nexport interface AnyIndexBuilder {\n\tbuild(table: GelTable): Index;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IndexBuilder extends AnyIndexBuilder {}\n\nexport class IndexBuilder implements AnyIndexBuilder {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilder';\n\n\t/** @internal */\n\tconfig: IndexConfig;\n\n\tconstructor(\n\t\tcolumns: Partial<IndexedColumn | SQL>[],\n\t\tunique: boolean,\n\t\tonly: boolean,\n\t\tname?: string,\n\t\tmethod: string = 'btree',\n\t) {\n\t\tthis.config = {\n\t\t\tname,\n\t\t\tcolumns,\n\t\t\tunique,\n\t\t\tonly,\n\t\t\tmethod,\n\t\t};\n\t}\n\n\tconcurrently(): this {\n\t\tthis.config.concurrently = true;\n\t\treturn this;\n\t}\n\n\twith(obj: Record<string, any>): this {\n\t\tthis.config.with = obj;\n\t\treturn this;\n\t}\n\n\twhere(condition: SQL): this {\n\t\tthis.config.where = condition;\n\t\treturn this;\n\t}\n\n\t/** @internal */\n\tbuild(table: GelTable): Index {\n\t\treturn new Index(this.config, table);\n\t}\n}\n\nexport class Index {\n\tstatic readonly [entityKind]: string = 'GelIndex';\n\n\treadonly config: IndexConfig & { table: GelTable };\n\n\tconstructor(config: IndexConfig, table: GelTable) {\n\t\tthis.config = { ...config, table };\n\t}\n}\n\nexport type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name']\n\t: TColumns extends GelColumn[] ? TColumns[number]['_']['name']\n\t: never;\n\nexport function index(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(false, name);\n}\n\nexport function uniqueIndex(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(true, name);\n}\n"],"mappings":"AAAA,SAAS,WAAW;AAEpB,SAAS,YAAY,UAAU;AAE/B,SAAS,qBAAqB;AAgHvB,MAAM,eAAe;AAAA,EAG3B,YAAoB,QAAyB,MAAe;AAAxC;AAAyB;AAAA,EAAgB;AAAA,EAF7D,QAAiB,UAAU,IAAY;AAAA,EAIvC,MAAM,SAAwG;AAC7G,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAEA,UAAU,SAAwG;AACjH,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,GAAG;AACpB,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MACC,WACG,SACY;AACf,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACD;AASO,MAAM,aAAwC;AAAA,EACpD,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAAA,EAEA,YACC,SACA,QACA,MACA,MACA,SAAiB,SAChB;AACD,SAAK,SAAS;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,eAAqB;AACpB,SAAK,OAAO,eAAe;AAC3B,WAAO;AAAA,EACR;AAAA,EAEA,KAAK,KAAgC;AACpC,SAAK,OAAO,OAAO;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,WAAsB;AAC3B,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,OAAwB;AAC7B,WAAO,IAAI,MAAM,KAAK,QAAQ,KAAK;AAAA,EACpC;AACD;AAEO,MAAM,MAAM;AAAA,EAClB,QAAiB,UAAU,IAAY;AAAA,EAE9B;AAAA,EAET,YAAY,QAAqB,OAAiB;AACjD,SAAK,SAAS,EAAE,GAAG,QAAQ,MAAM;AAAA,EAClC;AACD;AAMO,SAAS,MAAM,MAA+B;AACpD,SAAO,IAAI,eAAe,OAAO,IAAI;AACtC;AAEO,SAAS,YAAY,MAA+B;AAC1D,SAAO,IAAI,eAAe,MAAM,IAAI;AACrC;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.cjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 policies_exports = {};
|
| 20 |
+
__export(policies_exports, {
|
| 21 |
+
GelPolicy: () => GelPolicy,
|
| 22 |
+
gelPolicy: () => gelPolicy
|
| 23 |
+
});
|
| 24 |
+
module.exports = __toCommonJS(policies_exports);
|
| 25 |
+
var import_entity = require("../entity.cjs");
|
| 26 |
+
class GelPolicy {
|
| 27 |
+
constructor(name, config) {
|
| 28 |
+
this.name = name;
|
| 29 |
+
if (config) {
|
| 30 |
+
this.as = config.as;
|
| 31 |
+
this.for = config.for;
|
| 32 |
+
this.to = config.to;
|
| 33 |
+
this.using = config.using;
|
| 34 |
+
this.withCheck = config.withCheck;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
static [import_entity.entityKind] = "GelPolicy";
|
| 38 |
+
as;
|
| 39 |
+
for;
|
| 40 |
+
to;
|
| 41 |
+
using;
|
| 42 |
+
withCheck;
|
| 43 |
+
/** @internal */
|
| 44 |
+
_linkedTable;
|
| 45 |
+
link(table) {
|
| 46 |
+
this._linkedTable = table;
|
| 47 |
+
return this;
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
function gelPolicy(name, config) {
|
| 51 |
+
return new GelPolicy(name, config);
|
| 52 |
+
}
|
| 53 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 54 |
+
0 && (module.exports = {
|
| 55 |
+
GelPolicy,
|
| 56 |
+
gelPolicy
|
| 57 |
+
});
|
| 58 |
+
//# sourceMappingURL=policies.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/gel-core/policies.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { GelRole } from './roles.ts';\nimport type { GelTable } from './table.ts';\n\nexport type GelPolicyToOption =\n\t| 'public'\n\t| 'current_role'\n\t| 'current_user'\n\t| 'session_user'\n\t| (string & {})\n\t| GelPolicyToOption[]\n\t| GelRole;\n\nexport interface GelPolicyConfig {\n\tas?: 'permissive' | 'restrictive';\n\tfor?: 'all' | 'select' | 'insert' | 'update' | 'delete';\n\tto?: GelPolicyToOption;\n\tusing?: SQL;\n\twithCheck?: SQL;\n}\n\nexport class GelPolicy implements GelPolicyConfig {\n\tstatic readonly [entityKind]: string = 'GelPolicy';\n\n\treadonly as: GelPolicyConfig['as'];\n\treadonly for: GelPolicyConfig['for'];\n\treadonly to: GelPolicyConfig['to'];\n\treadonly using: GelPolicyConfig['using'];\n\treadonly withCheck: GelPolicyConfig['withCheck'];\n\n\t/** @internal */\n\t_linkedTable?: GelTable;\n\n\tconstructor(\n\t\treadonly name: string,\n\t\tconfig?: GelPolicyConfig,\n\t) {\n\t\tif (config) {\n\t\t\tthis.as = config.as;\n\t\t\tthis.for = config.for;\n\t\t\tthis.to = config.to;\n\t\t\tthis.using = config.using;\n\t\t\tthis.withCheck = config.withCheck;\n\t\t}\n\t}\n\n\tlink(table: GelTable): this {\n\t\tthis._linkedTable = table;\n\t\treturn this;\n\t}\n}\n\nexport function gelPolicy(name: string, config?: GelPolicyConfig) {\n\treturn new GelPolicy(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAsBpB,MAAM,UAAqC;AAAA,EAYjD,YACU,MACT,QACC;AAFQ;AAGT,QAAI,QAAQ;AACX,WAAK,KAAK,OAAO;AACjB,WAAK,MAAM,OAAO;AAClB,WAAK,KAAK,OAAO;AACjB,WAAK,QAAQ,OAAO;AACpB,WAAK,YAAY,OAAO;AAAA,IACzB;AAAA,EACD;AAAA,EAtBA,QAAiB,wBAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGT;AAAA,EAeA,KAAK,OAAuB;AAC3B,SAAK,eAAe;AACpB,WAAO;AAAA,EACR;AACD;AAEO,SAAS,UAAU,MAAc,QAA0B;AACjE,SAAO,IAAI,UAAU,MAAM,MAAM;AAClC;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.d.cts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.cjs";
|
| 2 |
+
import type { SQL } from "../sql/sql.cjs";
|
| 3 |
+
import type { GelRole } from "./roles.cjs";
|
| 4 |
+
import type { GelTable } from "./table.cjs";
|
| 5 |
+
export type GelPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | GelPolicyToOption[] | GelRole;
|
| 6 |
+
export interface GelPolicyConfig {
|
| 7 |
+
as?: 'permissive' | 'restrictive';
|
| 8 |
+
for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
|
| 9 |
+
to?: GelPolicyToOption;
|
| 10 |
+
using?: SQL;
|
| 11 |
+
withCheck?: SQL;
|
| 12 |
+
}
|
| 13 |
+
export declare class GelPolicy implements GelPolicyConfig {
|
| 14 |
+
readonly name: string;
|
| 15 |
+
static readonly [entityKind]: string;
|
| 16 |
+
readonly as: GelPolicyConfig['as'];
|
| 17 |
+
readonly for: GelPolicyConfig['for'];
|
| 18 |
+
readonly to: GelPolicyConfig['to'];
|
| 19 |
+
readonly using: GelPolicyConfig['using'];
|
| 20 |
+
readonly withCheck: GelPolicyConfig['withCheck'];
|
| 21 |
+
constructor(name: string, config?: GelPolicyConfig);
|
| 22 |
+
link(table: GelTable): this;
|
| 23 |
+
}
|
| 24 |
+
export declare function gelPolicy(name: string, config?: GelPolicyConfig): GelPolicy;
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import type { SQL } from "../sql/sql.js";
|
| 3 |
+
import type { GelRole } from "./roles.js";
|
| 4 |
+
import type { GelTable } from "./table.js";
|
| 5 |
+
export type GelPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | GelPolicyToOption[] | GelRole;
|
| 6 |
+
export interface GelPolicyConfig {
|
| 7 |
+
as?: 'permissive' | 'restrictive';
|
| 8 |
+
for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
|
| 9 |
+
to?: GelPolicyToOption;
|
| 10 |
+
using?: SQL;
|
| 11 |
+
withCheck?: SQL;
|
| 12 |
+
}
|
| 13 |
+
export declare class GelPolicy implements GelPolicyConfig {
|
| 14 |
+
readonly name: string;
|
| 15 |
+
static readonly [entityKind]: string;
|
| 16 |
+
readonly as: GelPolicyConfig['as'];
|
| 17 |
+
readonly for: GelPolicyConfig['for'];
|
| 18 |
+
readonly to: GelPolicyConfig['to'];
|
| 19 |
+
readonly using: GelPolicyConfig['using'];
|
| 20 |
+
readonly withCheck: GelPolicyConfig['withCheck'];
|
| 21 |
+
constructor(name: string, config?: GelPolicyConfig);
|
| 22 |
+
link(table: GelTable): this;
|
| 23 |
+
}
|
| 24 |
+
export declare function gelPolicy(name: string, config?: GelPolicyConfig): GelPolicy;
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
class GelPolicy {
|
| 3 |
+
constructor(name, config) {
|
| 4 |
+
this.name = name;
|
| 5 |
+
if (config) {
|
| 6 |
+
this.as = config.as;
|
| 7 |
+
this.for = config.for;
|
| 8 |
+
this.to = config.to;
|
| 9 |
+
this.using = config.using;
|
| 10 |
+
this.withCheck = config.withCheck;
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
static [entityKind] = "GelPolicy";
|
| 14 |
+
as;
|
| 15 |
+
for;
|
| 16 |
+
to;
|
| 17 |
+
using;
|
| 18 |
+
withCheck;
|
| 19 |
+
/** @internal */
|
| 20 |
+
_linkedTable;
|
| 21 |
+
link(table) {
|
| 22 |
+
this._linkedTable = table;
|
| 23 |
+
return this;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
function gelPolicy(name, config) {
|
| 27 |
+
return new GelPolicy(name, config);
|
| 28 |
+
}
|
| 29 |
+
export {
|
| 30 |
+
GelPolicy,
|
| 31 |
+
gelPolicy
|
| 32 |
+
};
|
| 33 |
+
//# sourceMappingURL=policies.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/policies.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/gel-core/policies.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { GelRole } from './roles.ts';\nimport type { GelTable } from './table.ts';\n\nexport type GelPolicyToOption =\n\t| 'public'\n\t| 'current_role'\n\t| 'current_user'\n\t| 'session_user'\n\t| (string & {})\n\t| GelPolicyToOption[]\n\t| GelRole;\n\nexport interface GelPolicyConfig {\n\tas?: 'permissive' | 'restrictive';\n\tfor?: 'all' | 'select' | 'insert' | 'update' | 'delete';\n\tto?: GelPolicyToOption;\n\tusing?: SQL;\n\twithCheck?: SQL;\n}\n\nexport class GelPolicy implements GelPolicyConfig {\n\tstatic readonly [entityKind]: string = 'GelPolicy';\n\n\treadonly as: GelPolicyConfig['as'];\n\treadonly for: GelPolicyConfig['for'];\n\treadonly to: GelPolicyConfig['to'];\n\treadonly using: GelPolicyConfig['using'];\n\treadonly withCheck: GelPolicyConfig['withCheck'];\n\n\t/** @internal */\n\t_linkedTable?: GelTable;\n\n\tconstructor(\n\t\treadonly name: string,\n\t\tconfig?: GelPolicyConfig,\n\t) {\n\t\tif (config) {\n\t\t\tthis.as = config.as;\n\t\t\tthis.for = config.for;\n\t\t\tthis.to = config.to;\n\t\t\tthis.using = config.using;\n\t\t\tthis.withCheck = config.withCheck;\n\t\t}\n\t}\n\n\tlink(table: GelTable): this {\n\t\tthis._linkedTable = table;\n\t\treturn this;\n\t}\n}\n\nexport function gelPolicy(name: string, config?: GelPolicyConfig) {\n\treturn new GelPolicy(name, config);\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAsBpB,MAAM,UAAqC;AAAA,EAYjD,YACU,MACT,QACC;AAFQ;AAGT,QAAI,QAAQ;AACX,WAAK,KAAK,OAAO;AACjB,WAAK,MAAM,OAAO;AAClB,WAAK,KAAK,OAAO;AACjB,WAAK,QAAQ,OAAO;AACpB,WAAK,YAAY,OAAO;AAAA,IACzB;AAAA,EACD;AAAA,EAtBA,QAAiB,UAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGT;AAAA,EAeA,KAAK,OAAuB;AAC3B,SAAK,eAAe;AACpB,WAAO;AAAA,EACR;AACD;AAEO,SAAS,UAAU,MAAc,QAA0B;AACjE,SAAO,IAAI,UAAU,MAAM,MAAM;AAClC;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 primary_keys_exports = {};
|
| 20 |
+
__export(primary_keys_exports, {
|
| 21 |
+
PrimaryKey: () => PrimaryKey,
|
| 22 |
+
PrimaryKeyBuilder: () => PrimaryKeyBuilder,
|
| 23 |
+
primaryKey: () => primaryKey
|
| 24 |
+
});
|
| 25 |
+
module.exports = __toCommonJS(primary_keys_exports);
|
| 26 |
+
var import_entity = require("../entity.cjs");
|
| 27 |
+
var import_table = require("./table.cjs");
|
| 28 |
+
function primaryKey(...config) {
|
| 29 |
+
if (config[0].columns) {
|
| 30 |
+
return new PrimaryKeyBuilder(config[0].columns, config[0].name);
|
| 31 |
+
}
|
| 32 |
+
return new PrimaryKeyBuilder(config);
|
| 33 |
+
}
|
| 34 |
+
class PrimaryKeyBuilder {
|
| 35 |
+
static [import_entity.entityKind] = "GelPrimaryKeyBuilder";
|
| 36 |
+
/** @internal */
|
| 37 |
+
columns;
|
| 38 |
+
/** @internal */
|
| 39 |
+
name;
|
| 40 |
+
constructor(columns, name) {
|
| 41 |
+
this.columns = columns;
|
| 42 |
+
this.name = name;
|
| 43 |
+
}
|
| 44 |
+
/** @internal */
|
| 45 |
+
build(table) {
|
| 46 |
+
return new PrimaryKey(table, this.columns, this.name);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
class PrimaryKey {
|
| 50 |
+
constructor(table, columns, name) {
|
| 51 |
+
this.table = table;
|
| 52 |
+
this.columns = columns;
|
| 53 |
+
this.name = name;
|
| 54 |
+
}
|
| 55 |
+
static [import_entity.entityKind] = "GelPrimaryKey";
|
| 56 |
+
columns;
|
| 57 |
+
name;
|
| 58 |
+
getName() {
|
| 59 |
+
return this.name ?? `${this.table[import_table.GelTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 63 |
+
0 && (module.exports = {
|
| 64 |
+
PrimaryKey,
|
| 65 |
+
PrimaryKeyBuilder,
|
| 66 |
+
primaryKey
|
| 67 |
+
});
|
| 68 |
+
//# sourceMappingURL=primary-keys.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/gel-core/primary-keys.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { AnyGelColumn, GelColumn } from './columns/index.ts';\nimport { GelTable } from './table.ts';\n\nexport function primaryKey<\n\tTTableName extends string,\n\tTColumn extends AnyGelColumn<{ tableName: TTableName }>,\n\tTColumns extends AnyGelColumn<{ tableName: TTableName }>[],\n>(config: { name?: string; columns: [TColumn, ...TColumns] }): PrimaryKeyBuilder;\n/**\n * @deprecated: Please use primaryKey({ columns: [] }) instead of this function\n * @param columns\n */\nexport function primaryKey<\n\tTTableName extends string,\n\tTColumns extends AnyGelColumn<{ tableName: TTableName }>[],\n>(...columns: TColumns): PrimaryKeyBuilder;\nexport function primaryKey(...config: any) {\n\tif (config[0].columns) {\n\t\treturn new PrimaryKeyBuilder(config[0].columns, config[0].name);\n\t}\n\treturn new PrimaryKeyBuilder(config);\n}\n\nexport class PrimaryKeyBuilder {\n\tstatic readonly [entityKind]: string = 'GelPrimaryKeyBuilder';\n\n\t/** @internal */\n\tcolumns: GelColumn[];\n\n\t/** @internal */\n\tname?: string;\n\n\tconstructor(\n\t\tcolumns: GelColumn[],\n\t\tname?: string,\n\t) {\n\t\tthis.columns = columns;\n\t\tthis.name = name;\n\t}\n\n\t/** @internal */\n\tbuild(table: GelTable): PrimaryKey {\n\t\treturn new PrimaryKey(table, this.columns, this.name);\n\t}\n}\n\nexport class PrimaryKey {\n\tstatic readonly [entityKind]: string = 'GelPrimaryKey';\n\n\treadonly columns: AnyGelColumn<{}>[];\n\treadonly name?: string;\n\n\tconstructor(readonly table: GelTable, columns: AnyGelColumn<{}>[], name?: string) {\n\t\tthis.columns = columns;\n\t\tthis.name = name;\n\t}\n\n\tgetName(): string {\n\t\treturn this.name ?? `${this.table[GelTable.Symbol.Name]}_${this.columns.map((column) => column.name).join('_')}_pk`;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAE3B,mBAAyB;AAelB,SAAS,cAAc,QAAa;AAC1C,MAAI,OAAO,CAAC,EAAE,SAAS;AACtB,WAAO,IAAI,kBAAkB,OAAO,CAAC,EAAE,SAAS,OAAO,CAAC,EAAE,IAAI;AAAA,EAC/D;AACA,SAAO,IAAI,kBAAkB,MAAM;AACpC;AAEO,MAAM,kBAAkB;AAAA,EAC9B,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAGvC;AAAA;AAAA,EAGA;AAAA,EAEA,YACC,SACA,MACC;AACD,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AAAA;AAAA,EAGA,MAAM,OAA6B;AAClC,WAAO,IAAI,WAAW,OAAO,KAAK,SAAS,KAAK,IAAI;AAAA,EACrD;AACD;AAEO,MAAM,WAAW;AAAA,EAMvB,YAAqB,OAAiB,SAA6B,MAAe;AAA7D;AACpB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AAAA,EARA,QAAiB,wBAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAAA,EAOT,UAAkB;AACjB,WAAO,KAAK,QAAQ,GAAG,KAAK,MAAM,sBAAS,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,WAAW,OAAO,IAAI,EAAE,KAAK,GAAG,CAAC;AAAA,EAC/G;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.d.cts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.cjs";
|
| 2 |
+
import type { AnyGelColumn, GelColumn } from "./columns/index.cjs";
|
| 3 |
+
import { GelTable } from "./table.cjs";
|
| 4 |
+
export declare function primaryKey<TTableName extends string, TColumn extends AnyGelColumn<{
|
| 5 |
+
tableName: TTableName;
|
| 6 |
+
}>, TColumns extends AnyGelColumn<{
|
| 7 |
+
tableName: TTableName;
|
| 8 |
+
}>[]>(config: {
|
| 9 |
+
name?: string;
|
| 10 |
+
columns: [TColumn, ...TColumns];
|
| 11 |
+
}): PrimaryKeyBuilder;
|
| 12 |
+
/**
|
| 13 |
+
* @deprecated: Please use primaryKey({ columns: [] }) instead of this function
|
| 14 |
+
* @param columns
|
| 15 |
+
*/
|
| 16 |
+
export declare function primaryKey<TTableName extends string, TColumns extends AnyGelColumn<{
|
| 17 |
+
tableName: TTableName;
|
| 18 |
+
}>[]>(...columns: TColumns): PrimaryKeyBuilder;
|
| 19 |
+
export declare class PrimaryKeyBuilder {
|
| 20 |
+
static readonly [entityKind]: string;
|
| 21 |
+
constructor(columns: GelColumn[], name?: string);
|
| 22 |
+
}
|
| 23 |
+
export declare class PrimaryKey {
|
| 24 |
+
readonly table: GelTable;
|
| 25 |
+
static readonly [entityKind]: string;
|
| 26 |
+
readonly columns: AnyGelColumn<{}>[];
|
| 27 |
+
readonly name?: string;
|
| 28 |
+
constructor(table: GelTable, columns: AnyGelColumn<{}>[], name?: string);
|
| 29 |
+
getName(): string;
|
| 30 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import type { AnyGelColumn, GelColumn } from "./columns/index.js";
|
| 3 |
+
import { GelTable } from "./table.js";
|
| 4 |
+
export declare function primaryKey<TTableName extends string, TColumn extends AnyGelColumn<{
|
| 5 |
+
tableName: TTableName;
|
| 6 |
+
}>, TColumns extends AnyGelColumn<{
|
| 7 |
+
tableName: TTableName;
|
| 8 |
+
}>[]>(config: {
|
| 9 |
+
name?: string;
|
| 10 |
+
columns: [TColumn, ...TColumns];
|
| 11 |
+
}): PrimaryKeyBuilder;
|
| 12 |
+
/**
|
| 13 |
+
* @deprecated: Please use primaryKey({ columns: [] }) instead of this function
|
| 14 |
+
* @param columns
|
| 15 |
+
*/
|
| 16 |
+
export declare function primaryKey<TTableName extends string, TColumns extends AnyGelColumn<{
|
| 17 |
+
tableName: TTableName;
|
| 18 |
+
}>[]>(...columns: TColumns): PrimaryKeyBuilder;
|
| 19 |
+
export declare class PrimaryKeyBuilder {
|
| 20 |
+
static readonly [entityKind]: string;
|
| 21 |
+
constructor(columns: GelColumn[], name?: string);
|
| 22 |
+
}
|
| 23 |
+
export declare class PrimaryKey {
|
| 24 |
+
readonly table: GelTable;
|
| 25 |
+
static readonly [entityKind]: string;
|
| 26 |
+
readonly columns: AnyGelColumn<{}>[];
|
| 27 |
+
readonly name?: string;
|
| 28 |
+
constructor(table: GelTable, columns: AnyGelColumn<{}>[], name?: string);
|
| 29 |
+
getName(): string;
|
| 30 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../entity.js";
|
| 2 |
+
import { GelTable } from "./table.js";
|
| 3 |
+
function primaryKey(...config) {
|
| 4 |
+
if (config[0].columns) {
|
| 5 |
+
return new PrimaryKeyBuilder(config[0].columns, config[0].name);
|
| 6 |
+
}
|
| 7 |
+
return new PrimaryKeyBuilder(config);
|
| 8 |
+
}
|
| 9 |
+
class PrimaryKeyBuilder {
|
| 10 |
+
static [entityKind] = "GelPrimaryKeyBuilder";
|
| 11 |
+
/** @internal */
|
| 12 |
+
columns;
|
| 13 |
+
/** @internal */
|
| 14 |
+
name;
|
| 15 |
+
constructor(columns, name) {
|
| 16 |
+
this.columns = columns;
|
| 17 |
+
this.name = name;
|
| 18 |
+
}
|
| 19 |
+
/** @internal */
|
| 20 |
+
build(table) {
|
| 21 |
+
return new PrimaryKey(table, this.columns, this.name);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
class PrimaryKey {
|
| 25 |
+
constructor(table, columns, name) {
|
| 26 |
+
this.table = table;
|
| 27 |
+
this.columns = columns;
|
| 28 |
+
this.name = name;
|
| 29 |
+
}
|
| 30 |
+
static [entityKind] = "GelPrimaryKey";
|
| 31 |
+
columns;
|
| 32 |
+
name;
|
| 33 |
+
getName() {
|
| 34 |
+
return this.name ?? `${this.table[GelTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
export {
|
| 38 |
+
PrimaryKey,
|
| 39 |
+
PrimaryKeyBuilder,
|
| 40 |
+
primaryKey
|
| 41 |
+
};
|
| 42 |
+
//# sourceMappingURL=primary-keys.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/primary-keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/gel-core/primary-keys.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { AnyGelColumn, GelColumn } from './columns/index.ts';\nimport { GelTable } from './table.ts';\n\nexport function primaryKey<\n\tTTableName extends string,\n\tTColumn extends AnyGelColumn<{ tableName: TTableName }>,\n\tTColumns extends AnyGelColumn<{ tableName: TTableName }>[],\n>(config: { name?: string; columns: [TColumn, ...TColumns] }): PrimaryKeyBuilder;\n/**\n * @deprecated: Please use primaryKey({ columns: [] }) instead of this function\n * @param columns\n */\nexport function primaryKey<\n\tTTableName extends string,\n\tTColumns extends AnyGelColumn<{ tableName: TTableName }>[],\n>(...columns: TColumns): PrimaryKeyBuilder;\nexport function primaryKey(...config: any) {\n\tif (config[0].columns) {\n\t\treturn new PrimaryKeyBuilder(config[0].columns, config[0].name);\n\t}\n\treturn new PrimaryKeyBuilder(config);\n}\n\nexport class PrimaryKeyBuilder {\n\tstatic readonly [entityKind]: string = 'GelPrimaryKeyBuilder';\n\n\t/** @internal */\n\tcolumns: GelColumn[];\n\n\t/** @internal */\n\tname?: string;\n\n\tconstructor(\n\t\tcolumns: GelColumn[],\n\t\tname?: string,\n\t) {\n\t\tthis.columns = columns;\n\t\tthis.name = name;\n\t}\n\n\t/** @internal */\n\tbuild(table: GelTable): PrimaryKey {\n\t\treturn new PrimaryKey(table, this.columns, this.name);\n\t}\n}\n\nexport class PrimaryKey {\n\tstatic readonly [entityKind]: string = 'GelPrimaryKey';\n\n\treadonly columns: AnyGelColumn<{}>[];\n\treadonly name?: string;\n\n\tconstructor(readonly table: GelTable, columns: AnyGelColumn<{}>[], name?: string) {\n\t\tthis.columns = columns;\n\t\tthis.name = name;\n\t}\n\n\tgetName(): string {\n\t\treturn this.name ?? `${this.table[GelTable.Symbol.Name]}_${this.columns.map((column) => column.name).join('_')}_pk`;\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AAelB,SAAS,cAAc,QAAa;AAC1C,MAAI,OAAO,CAAC,EAAE,SAAS;AACtB,WAAO,IAAI,kBAAkB,OAAO,CAAC,EAAE,SAAS,OAAO,CAAC,EAAE,IAAI;AAAA,EAC/D;AACA,SAAO,IAAI,kBAAkB,MAAM;AACpC;AAEO,MAAM,kBAAkB;AAAA,EAC9B,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAAA;AAAA,EAGA;AAAA,EAEA,YACC,SACA,MACC;AACD,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AAAA;AAAA,EAGA,MAAM,OAA6B;AAClC,WAAO,IAAI,WAAW,OAAO,KAAK,SAAS,KAAK,IAAI;AAAA,EACrD;AACD;AAEO,MAAM,WAAW;AAAA,EAMvB,YAAqB,OAAiB,SAA6B,MAAe;AAA7D;AACpB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AAAA,EARA,QAAiB,UAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAAA,EAOT,UAAkB;AACjB,WAAO,KAAK,QAAQ,GAAG,KAAK,MAAM,SAAS,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,WAAW,OAAO,IAAI,EAAE,KAAK,GAAG,CAAC;AAAA,EAC/G;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.cjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 count_exports = {};
|
| 20 |
+
__export(count_exports, {
|
| 21 |
+
GelCountBuilder: () => GelCountBuilder
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(count_exports);
|
| 24 |
+
var import_entity = require("../../entity.cjs");
|
| 25 |
+
var import_sql = require("../../sql/sql.cjs");
|
| 26 |
+
class GelCountBuilder extends import_sql.SQL {
|
| 27 |
+
constructor(params) {
|
| 28 |
+
super(GelCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
| 29 |
+
this.params = params;
|
| 30 |
+
this.mapWith(Number);
|
| 31 |
+
this.session = params.session;
|
| 32 |
+
this.sql = GelCountBuilder.buildCount(
|
| 33 |
+
params.source,
|
| 34 |
+
params.filters
|
| 35 |
+
);
|
| 36 |
+
}
|
| 37 |
+
sql;
|
| 38 |
+
static [import_entity.entityKind] = "GelCountBuilder";
|
| 39 |
+
[Symbol.toStringTag] = "GelCountBuilder";
|
| 40 |
+
session;
|
| 41 |
+
static buildEmbeddedCount(source, filters) {
|
| 42 |
+
return import_sql.sql`(select count(*) from ${source}${import_sql.sql.raw(" where ").if(filters)}${filters})`;
|
| 43 |
+
}
|
| 44 |
+
static buildCount(source, filters) {
|
| 45 |
+
return import_sql.sql`select count(*) as count from ${source}${import_sql.sql.raw(" where ").if(filters)}${filters};`;
|
| 46 |
+
}
|
| 47 |
+
then(onfulfilled, onrejected) {
|
| 48 |
+
return Promise.resolve(this.session.count(this.sql)).then(
|
| 49 |
+
onfulfilled,
|
| 50 |
+
onrejected
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
catch(onRejected) {
|
| 54 |
+
return this.then(void 0, onRejected);
|
| 55 |
+
}
|
| 56 |
+
finally(onFinally) {
|
| 57 |
+
return this.then(
|
| 58 |
+
(value) => {
|
| 59 |
+
onFinally?.();
|
| 60 |
+
return value;
|
| 61 |
+
},
|
| 62 |
+
(reason) => {
|
| 63 |
+
onFinally?.();
|
| 64 |
+
throw reason;
|
| 65 |
+
}
|
| 66 |
+
);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 70 |
+
0 && (module.exports = {
|
| 71 |
+
GelCountBuilder
|
| 72 |
+
});
|
| 73 |
+
//# sourceMappingURL=count.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { GelSession } from '../session.ts';\nimport type { GelTable } from '../table.ts';\n\nexport class GelCountBuilder<\n\tTSession extends GelSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'GelCountBuilder';\n\t[Symbol.toStringTag] = 'GelCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: GelTable | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: GelTable | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters};`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: GelTable | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(GelCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = GelCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => any) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,iBAA0C;AAInC,MAAM,wBAEH,eAAmD;AAAA,EAsB5D,YACU,QAKR;AACD,UAAM,gBAAgB,mBAAmB,OAAO,QAAQ,OAAO,OAAO,EAAE,WAAW;AAN1E;AAQT,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,OAAO;AAEtB,SAAK,MAAM,gBAAgB;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAtCQ;AAAA,EAER,QAA0B,wBAAU,IAAI;AAAA,EACxC,CAAC,OAAO,WAAW,IAAI;AAAA,EAEf;AAAA,EAER,OAAe,mBACd,QACA,SACc;AACd,WAAO,uCAAoC,MAAM,GAAG,eAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EAC7F;AAAA,EAEA,OAAe,WACd,QACA,SACc;AACd,WAAO,+CAA4C,MAAM,GAAG,eAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EACrG;AAAA,EAqBA,KACC,aACA,YAC+B;AAC/B,WAAO,QAAQ,QAAQ,KAAK,QAAQ,MAAM,KAAK,GAAG,CAAC,EACjD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACF;AAAA,EAEA,MACC,YACkB;AAClB,WAAO,KAAK,KAAK,QAAW,UAAU;AAAA,EACvC;AAAA,EAEA,QAAQ,WAA8D;AACrE,WAAO,KAAK;AAAA,MACX,CAAC,UAAU;AACV,oBAAY;AACZ,eAAO;AAAA,MACR;AAAA,MACA,CAAC,WAAW;AACX,oBAAY;AACZ,cAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.d.cts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.cjs";
|
| 2 |
+
import { SQL, type SQLWrapper } from "../../sql/sql.cjs";
|
| 3 |
+
import type { GelSession } from "../session.cjs";
|
| 4 |
+
import type { GelTable } from "../table.cjs";
|
| 5 |
+
export declare class GelCountBuilder<TSession extends GelSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper {
|
| 6 |
+
readonly params: {
|
| 7 |
+
source: GelTable | SQL | SQLWrapper;
|
| 8 |
+
filters?: SQL<unknown>;
|
| 9 |
+
session: TSession;
|
| 10 |
+
};
|
| 11 |
+
private sql;
|
| 12 |
+
static readonly [entityKind] = "GelCountBuilder";
|
| 13 |
+
[Symbol.toStringTag]: string;
|
| 14 |
+
private session;
|
| 15 |
+
private static buildEmbeddedCount;
|
| 16 |
+
private static buildCount;
|
| 17 |
+
constructor(params: {
|
| 18 |
+
source: GelTable | SQL | SQLWrapper;
|
| 19 |
+
filters?: SQL<unknown>;
|
| 20 |
+
session: TSession;
|
| 21 |
+
});
|
| 22 |
+
then<TResult1 = number, TResult2 = never>(onfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
| 23 |
+
catch(onRejected?: ((reason: any) => any) | null | undefined): Promise<number>;
|
| 24 |
+
finally(onFinally?: (() => void) | null | undefined): Promise<number>;
|
| 25 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import { SQL, type SQLWrapper } from "../../sql/sql.js";
|
| 3 |
+
import type { GelSession } from "../session.js";
|
| 4 |
+
import type { GelTable } from "../table.js";
|
| 5 |
+
export declare class GelCountBuilder<TSession extends GelSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper {
|
| 6 |
+
readonly params: {
|
| 7 |
+
source: GelTable | SQL | SQLWrapper;
|
| 8 |
+
filters?: SQL<unknown>;
|
| 9 |
+
session: TSession;
|
| 10 |
+
};
|
| 11 |
+
private sql;
|
| 12 |
+
static readonly [entityKind] = "GelCountBuilder";
|
| 13 |
+
[Symbol.toStringTag]: string;
|
| 14 |
+
private session;
|
| 15 |
+
private static buildEmbeddedCount;
|
| 16 |
+
private static buildCount;
|
| 17 |
+
constructor(params: {
|
| 18 |
+
source: GelTable | SQL | SQLWrapper;
|
| 19 |
+
filters?: SQL<unknown>;
|
| 20 |
+
session: TSession;
|
| 21 |
+
});
|
| 22 |
+
then<TResult1 = number, TResult2 = never>(onfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
| 23 |
+
catch(onRejected?: ((reason: any) => any) | null | undefined): Promise<number>;
|
| 24 |
+
finally(onFinally?: (() => void) | null | undefined): Promise<number>;
|
| 25 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import { SQL, sql } from "../../sql/sql.js";
|
| 3 |
+
class GelCountBuilder extends SQL {
|
| 4 |
+
constructor(params) {
|
| 5 |
+
super(GelCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
| 6 |
+
this.params = params;
|
| 7 |
+
this.mapWith(Number);
|
| 8 |
+
this.session = params.session;
|
| 9 |
+
this.sql = GelCountBuilder.buildCount(
|
| 10 |
+
params.source,
|
| 11 |
+
params.filters
|
| 12 |
+
);
|
| 13 |
+
}
|
| 14 |
+
sql;
|
| 15 |
+
static [entityKind] = "GelCountBuilder";
|
| 16 |
+
[Symbol.toStringTag] = "GelCountBuilder";
|
| 17 |
+
session;
|
| 18 |
+
static buildEmbeddedCount(source, filters) {
|
| 19 |
+
return sql`(select count(*) from ${source}${sql.raw(" where ").if(filters)}${filters})`;
|
| 20 |
+
}
|
| 21 |
+
static buildCount(source, filters) {
|
| 22 |
+
return sql`select count(*) as count from ${source}${sql.raw(" where ").if(filters)}${filters};`;
|
| 23 |
+
}
|
| 24 |
+
then(onfulfilled, onrejected) {
|
| 25 |
+
return Promise.resolve(this.session.count(this.sql)).then(
|
| 26 |
+
onfulfilled,
|
| 27 |
+
onrejected
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
catch(onRejected) {
|
| 31 |
+
return this.then(void 0, onRejected);
|
| 32 |
+
}
|
| 33 |
+
finally(onFinally) {
|
| 34 |
+
return this.then(
|
| 35 |
+
(value) => {
|
| 36 |
+
onFinally?.();
|
| 37 |
+
return value;
|
| 38 |
+
},
|
| 39 |
+
(reason) => {
|
| 40 |
+
onFinally?.();
|
| 41 |
+
throw reason;
|
| 42 |
+
}
|
| 43 |
+
);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
export {
|
| 47 |
+
GelCountBuilder
|
| 48 |
+
};
|
| 49 |
+
//# sourceMappingURL=count.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/count.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { GelSession } from '../session.ts';\nimport type { GelTable } from '../table.ts';\n\nexport class GelCountBuilder<\n\tTSession extends GelSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'GelCountBuilder';\n\t[Symbol.toStringTag] = 'GelCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: GelTable | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: GelTable | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters};`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: GelTable | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(GelCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = GelCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => any) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,WAA4B;AAInC,MAAM,wBAEH,IAAmD;AAAA,EAsB5D,YACU,QAKR;AACD,UAAM,gBAAgB,mBAAmB,OAAO,QAAQ,OAAO,OAAO,EAAE,WAAW;AAN1E;AAQT,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,OAAO;AAEtB,SAAK,MAAM,gBAAgB;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAtCQ;AAAA,EAER,QAA0B,UAAU,IAAI;AAAA,EACxC,CAAC,OAAO,WAAW,IAAI;AAAA,EAEf;AAAA,EAER,OAAe,mBACd,QACA,SACc;AACd,WAAO,4BAAoC,MAAM,GAAG,IAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EAC7F;AAAA,EAEA,OAAe,WACd,QACA,SACc;AACd,WAAO,oCAA4C,MAAM,GAAG,IAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EACrG;AAAA,EAqBA,KACC,aACA,YAC+B;AAC/B,WAAO,QAAQ,QAAQ,KAAK,QAAQ,MAAM,KAAK,GAAG,CAAC,EACjD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACF;AAAA,EAEA,MACC,YACkB;AAClB,WAAO,KAAK,KAAK,QAAW,UAAU;AAAA,EACvC;AAAA,EAEA,QAAQ,WAA8D;AACrE,WAAO,KAAK;AAAA,MACX,CAAC,UAAU;AACV,oBAAY;AACZ,eAAO;AAAA,MACR;AAAA,MACA,CAAC,WAAW;AACX,oBAAY;AACZ,cAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.cjs
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 delete_exports = {};
|
| 20 |
+
__export(delete_exports, {
|
| 21 |
+
GelDeleteBase: () => GelDeleteBase
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(delete_exports);
|
| 24 |
+
var import_entity = require("../../entity.cjs");
|
| 25 |
+
var import_query_promise = require("../../query-promise.cjs");
|
| 26 |
+
var import_table = require("../../table.cjs");
|
| 27 |
+
var import_tracing = require("../../tracing.cjs");
|
| 28 |
+
var import_utils = require("../../utils.cjs");
|
| 29 |
+
var import_utils2 = require("../utils.cjs");
|
| 30 |
+
class GelDeleteBase extends import_query_promise.QueryPromise {
|
| 31 |
+
constructor(table, session, dialect, withList) {
|
| 32 |
+
super();
|
| 33 |
+
this.session = session;
|
| 34 |
+
this.dialect = dialect;
|
| 35 |
+
this.config = { table, withList };
|
| 36 |
+
}
|
| 37 |
+
static [import_entity.entityKind] = "GelDelete";
|
| 38 |
+
config;
|
| 39 |
+
/**
|
| 40 |
+
* Adds a `where` clause to the query.
|
| 41 |
+
*
|
| 42 |
+
* Calling this method will delete only those rows that fulfill a specified condition.
|
| 43 |
+
*
|
| 44 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
| 45 |
+
*
|
| 46 |
+
* @param where the `where` clause.
|
| 47 |
+
*
|
| 48 |
+
* @example
|
| 49 |
+
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
| 50 |
+
*
|
| 51 |
+
* ```ts
|
| 52 |
+
* // Delete all cars with green color
|
| 53 |
+
* await db.delete(cars).where(eq(cars.color, 'green'));
|
| 54 |
+
* // or
|
| 55 |
+
* await db.delete(cars).where(sql`${cars.color} = 'green'`)
|
| 56 |
+
* ```
|
| 57 |
+
*
|
| 58 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 59 |
+
*
|
| 60 |
+
* ```ts
|
| 61 |
+
* // Delete all BMW cars with a green color
|
| 62 |
+
* await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 63 |
+
*
|
| 64 |
+
* // Delete all cars with the green or blue color
|
| 65 |
+
* await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 66 |
+
* ```
|
| 67 |
+
*/
|
| 68 |
+
where(where) {
|
| 69 |
+
this.config.where = where;
|
| 70 |
+
return this;
|
| 71 |
+
}
|
| 72 |
+
returning(fields = this.config.table[import_table.Table.Symbol.Columns]) {
|
| 73 |
+
this.config.returning = (0, import_utils.orderSelectedFields)(fields);
|
| 74 |
+
return this;
|
| 75 |
+
}
|
| 76 |
+
/** @internal */
|
| 77 |
+
getSQL() {
|
| 78 |
+
return this.dialect.buildDeleteQuery(this.config);
|
| 79 |
+
}
|
| 80 |
+
toSQL() {
|
| 81 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 82 |
+
return rest;
|
| 83 |
+
}
|
| 84 |
+
/** @internal */
|
| 85 |
+
_prepare(name) {
|
| 86 |
+
return import_tracing.tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 87 |
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
| 88 |
+
type: "delete",
|
| 89 |
+
tables: (0, import_utils2.extractUsedTable)(this.config.table)
|
| 90 |
+
});
|
| 91 |
+
});
|
| 92 |
+
}
|
| 93 |
+
prepare(name) {
|
| 94 |
+
return this._prepare(name);
|
| 95 |
+
}
|
| 96 |
+
execute = (placeholderValues) => {
|
| 97 |
+
return import_tracing.tracer.startActiveSpan("drizzle.operation", () => {
|
| 98 |
+
return this._prepare().execute(placeholderValues);
|
| 99 |
+
});
|
| 100 |
+
};
|
| 101 |
+
$dynamic() {
|
| 102 |
+
return this;
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 106 |
+
0 && (module.exports = {
|
| 107 |
+
GelDeleteBase
|
| 108 |
+
});
|
| 109 |
+
//# sourceMappingURL=delete.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/delete.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport type { GelTable } from '~/gel-core/table.ts';\nimport type { SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport { orderSelectedFields } from '~/utils.ts';\nimport type { GelColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts';\n\nexport type GelDeleteWithout<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T\n\t: Omit<\n\t\tGelDeleteBase<\n\t\t\tT['_']['table'],\n\t\t\tT['_']['queryResult'],\n\t\t\tT['_']['returning'],\n\t\t\tTDynamic,\n\t\t\tT['_']['excludedMethods'] | K\n\t\t>,\n\t\tT['_']['excludedMethods'] | K\n\t>;\n\nexport type GelDelete<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = GelDeleteBase<TTable, TQueryResult, TReturning, true, never>;\n\nexport interface GelDeleteConfig {\n\twhere?: SQL | undefined;\n\ttable: GelTable;\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type GelDeleteReturningAll<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n> = GelDeleteWithout<\n\tGelDeleteBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['table']['$inferSelect'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelDeleteReturning<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFieldsFlat,\n> = GelDeleteWithout<\n\tGelDeleteBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tSelectResultFields<TSelectedFields>,\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelDeletePrepare<T extends AnyGelDeleteBase> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelDeleteDynamic<T extends AnyGelDeleteBase> = GelDelete<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['returning']\n>;\n\nexport type AnyGelDeleteBase = GelDeleteBase<any, any, any, any, any>;\n\nexport interface GelDeleteBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\tdialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelDeleteBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\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 ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelDelete';\n\n\tprivate config: GelDeleteConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { table, withList };\n\t}\n\n\t/**\n\t * Adds a `where` clause to the query.\n\t *\n\t * Calling this method will delete only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete}\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 deleted.\n\t *\n\t * ```ts\n\t * // Delete all cars with green color\n\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.delete(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 * // Delete all BMW cars with a green color\n\t * await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Delete all cars with the green or blue color\n\t * await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): GelDeleteWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\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 deleted rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete#delete-with-return}\n\t *\n\t * @example\n\t * ```ts\n\t * // Delete all cars with the green color and return all fields\n\t * const deletedCars: Car[] = await db.delete(cars)\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Delete all cars with the green color and return only their id and brand fields\n\t * const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): GelDeleteReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFieldsFlat>(\n\t\tfields: TSelectedFields,\n\t): GelDeleteReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields: SelectedFieldsFlat = this.config.table[Table.Symbol.Columns],\n\t): GelDeleteReturning<this, TDynamic, any> {\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildDeleteQuery(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(name?: string): GelDeletePrepare<this> {\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\treturn this.session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & {\n\t\t\t\t\texecute: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t\t\t\t}\n\t\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {\n\t\t\t\ttype: 'delete',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t});\n\t\t});\n\t}\n\n\tprepare(name: string): GelDeletePrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n\n\t$dynamic(): GelDeleteDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAW3B,2BAA6B;AAI7B,mBAAsB;AACtB,qBAAuB;AACvB,mBAAoC;AAEpC,IAAAA,gBAAiC;AAoG1B,MAAM,sBAOH,kCAIV;AAAA,EAKC,YACC,OACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,OAAO,SAAS;AAAA,EACjC;AAAA,EAZA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyCR,MAAM,OAAmE;AACxE,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA,EA0BA,UACC,SAA6B,KAAK,OAAO,MAAM,mBAAM,OAAO,OAAO,GACzB;AAC1C,SAAK,OAAO,gBAAY,kCAA+B,MAAM;AAC7D,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAS,MAAuC;AAC/C,WAAO,sBAAO,gBAAgB,wBAAwB,MAAM;AAC3D,aAAO,KAAK,QAAQ,aAIlB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,GAAG,KAAK,OAAO,WAAW,MAAM,MAAM,QAAW;AAAA,QACvF,MAAM;AAAA,QACN,YAAQ,gCAAiB,KAAK,OAAO,KAAK;AAAA,MAC3C,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA,EAEA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,sBAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,IACjD,CAAC;AAAA,EACF;AAAA,EAEA,WAAmC;AAClC,WAAO;AAAA,EACR;AACD;","names":["import_utils"]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.d.cts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.cjs";
|
| 2 |
+
import type { GelDialect } from "../dialect.cjs";
|
| 3 |
+
import type { GelPreparedQuery, GelQueryResultHKT, GelQueryResultKind, GelSession, PreparedQueryConfig } from "../session.cjs";
|
| 4 |
+
import type { GelTable } from "../table.cjs";
|
| 5 |
+
import type { SelectResultFields } from "../../query-builders/select.types.cjs";
|
| 6 |
+
import { QueryPromise } from "../../query-promise.cjs";
|
| 7 |
+
import type { RunnableQuery } from "../../runnable-query.cjs";
|
| 8 |
+
import type { Query, SQL, SQLWrapper } from "../../sql/sql.cjs";
|
| 9 |
+
import type { Subquery } from "../../subquery.cjs";
|
| 10 |
+
import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.cjs";
|
| 11 |
+
export type GelDeleteWithout<T extends AnyGelDeleteBase, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<GelDeleteBase<T['_']['table'], T['_']['queryResult'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 12 |
+
export type GelDelete<TTable extends GelTable = GelTable, TQueryResult extends GelQueryResultHKT = GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = GelDeleteBase<TTable, TQueryResult, TReturning, true, never>;
|
| 13 |
+
export interface GelDeleteConfig {
|
| 14 |
+
where?: SQL | undefined;
|
| 15 |
+
table: GelTable;
|
| 16 |
+
returning?: SelectedFieldsOrdered;
|
| 17 |
+
withList?: Subquery[];
|
| 18 |
+
}
|
| 19 |
+
export type GelDeleteReturningAll<T extends AnyGelDeleteBase, TDynamic extends boolean> = GelDeleteWithout<GelDeleteBase<T['_']['table'], T['_']['queryResult'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 20 |
+
export type GelDeleteReturning<T extends AnyGelDeleteBase, TDynamic extends boolean, TSelectedFields extends SelectedFieldsFlat> = GelDeleteWithout<GelDeleteBase<T['_']['table'], T['_']['queryResult'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 21 |
+
export type GelDeletePrepare<T extends AnyGelDeleteBase> = GelPreparedQuery<PreparedQueryConfig & {
|
| 22 |
+
execute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never> : T['_']['returning'][];
|
| 23 |
+
}>;
|
| 24 |
+
export type GelDeleteDynamic<T extends AnyGelDeleteBase> = GelDelete<T['_']['table'], T['_']['queryResult'], T['_']['returning']>;
|
| 25 |
+
export type AnyGelDeleteBase = GelDeleteBase<any, any, any, any, any>;
|
| 26 |
+
export interface GelDeleteBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>, RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 27 |
+
readonly _: {
|
| 28 |
+
dialect: 'gel';
|
| 29 |
+
readonly table: TTable;
|
| 30 |
+
readonly queryResult: TQueryResult;
|
| 31 |
+
readonly returning: TReturning;
|
| 32 |
+
readonly dynamic: TDynamic;
|
| 33 |
+
readonly excludedMethods: TExcludedMethods;
|
| 34 |
+
readonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];
|
| 35 |
+
};
|
| 36 |
+
}
|
| 37 |
+
export declare class GelDeleteBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]> implements RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 38 |
+
private session;
|
| 39 |
+
private dialect;
|
| 40 |
+
static readonly [entityKind]: string;
|
| 41 |
+
private config;
|
| 42 |
+
constructor(table: TTable, session: GelSession, dialect: GelDialect, withList?: Subquery[]);
|
| 43 |
+
/**
|
| 44 |
+
* Adds a `where` clause to the query.
|
| 45 |
+
*
|
| 46 |
+
* Calling this method will delete only those rows that fulfill a specified condition.
|
| 47 |
+
*
|
| 48 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
| 49 |
+
*
|
| 50 |
+
* @param where the `where` clause.
|
| 51 |
+
*
|
| 52 |
+
* @example
|
| 53 |
+
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
| 54 |
+
*
|
| 55 |
+
* ```ts
|
| 56 |
+
* // Delete all cars with green color
|
| 57 |
+
* await db.delete(cars).where(eq(cars.color, 'green'));
|
| 58 |
+
* // or
|
| 59 |
+
* await db.delete(cars).where(sql`${cars.color} = 'green'`)
|
| 60 |
+
* ```
|
| 61 |
+
*
|
| 62 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 63 |
+
*
|
| 64 |
+
* ```ts
|
| 65 |
+
* // Delete all BMW cars with a green color
|
| 66 |
+
* await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 67 |
+
*
|
| 68 |
+
* // Delete all cars with the green or blue color
|
| 69 |
+
* await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 70 |
+
* ```
|
| 71 |
+
*/
|
| 72 |
+
where(where: SQL | undefined): GelDeleteWithout<this, TDynamic, 'where'>;
|
| 73 |
+
/**
|
| 74 |
+
* Adds a `returning` clause to the query.
|
| 75 |
+
*
|
| 76 |
+
* Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.
|
| 77 |
+
*
|
| 78 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete#delete-with-return}
|
| 79 |
+
*
|
| 80 |
+
* @example
|
| 81 |
+
* ```ts
|
| 82 |
+
* // Delete all cars with the green color and return all fields
|
| 83 |
+
* const deletedCars: Car[] = await db.delete(cars)
|
| 84 |
+
* .where(eq(cars.color, 'green'))
|
| 85 |
+
* .returning();
|
| 86 |
+
*
|
| 87 |
+
* // Delete all cars with the green color and return only their id and brand fields
|
| 88 |
+
* const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
|
| 89 |
+
* .where(eq(cars.color, 'green'))
|
| 90 |
+
* .returning({ id: cars.id, brand: cars.brand });
|
| 91 |
+
* ```
|
| 92 |
+
*/
|
| 93 |
+
returning(): GelDeleteReturningAll<this, TDynamic>;
|
| 94 |
+
returning<TSelectedFields extends SelectedFieldsFlat>(fields: TSelectedFields): GelDeleteReturning<this, TDynamic, TSelectedFields>;
|
| 95 |
+
toSQL(): Query;
|
| 96 |
+
prepare(name: string): GelDeletePrepare<this>;
|
| 97 |
+
execute: ReturnType<this['prepare']>['execute'];
|
| 98 |
+
$dynamic(): GelDeleteDynamic<this>;
|
| 99 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import type { GelDialect } from "../dialect.js";
|
| 3 |
+
import type { GelPreparedQuery, GelQueryResultHKT, GelQueryResultKind, GelSession, PreparedQueryConfig } from "../session.js";
|
| 4 |
+
import type { GelTable } from "../table.js";
|
| 5 |
+
import type { SelectResultFields } from "../../query-builders/select.types.js";
|
| 6 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 7 |
+
import type { RunnableQuery } from "../../runnable-query.js";
|
| 8 |
+
import type { Query, SQL, SQLWrapper } from "../../sql/sql.js";
|
| 9 |
+
import type { Subquery } from "../../subquery.js";
|
| 10 |
+
import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.js";
|
| 11 |
+
export type GelDeleteWithout<T extends AnyGelDeleteBase, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<GelDeleteBase<T['_']['table'], T['_']['queryResult'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 12 |
+
export type GelDelete<TTable extends GelTable = GelTable, TQueryResult extends GelQueryResultHKT = GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = GelDeleteBase<TTable, TQueryResult, TReturning, true, never>;
|
| 13 |
+
export interface GelDeleteConfig {
|
| 14 |
+
where?: SQL | undefined;
|
| 15 |
+
table: GelTable;
|
| 16 |
+
returning?: SelectedFieldsOrdered;
|
| 17 |
+
withList?: Subquery[];
|
| 18 |
+
}
|
| 19 |
+
export type GelDeleteReturningAll<T extends AnyGelDeleteBase, TDynamic extends boolean> = GelDeleteWithout<GelDeleteBase<T['_']['table'], T['_']['queryResult'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 20 |
+
export type GelDeleteReturning<T extends AnyGelDeleteBase, TDynamic extends boolean, TSelectedFields extends SelectedFieldsFlat> = GelDeleteWithout<GelDeleteBase<T['_']['table'], T['_']['queryResult'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
|
| 21 |
+
export type GelDeletePrepare<T extends AnyGelDeleteBase> = GelPreparedQuery<PreparedQueryConfig & {
|
| 22 |
+
execute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never> : T['_']['returning'][];
|
| 23 |
+
}>;
|
| 24 |
+
export type GelDeleteDynamic<T extends AnyGelDeleteBase> = GelDelete<T['_']['table'], T['_']['queryResult'], T['_']['returning']>;
|
| 25 |
+
export type AnyGelDeleteBase = GelDeleteBase<any, any, any, any, any>;
|
| 26 |
+
export interface GelDeleteBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>, RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 27 |
+
readonly _: {
|
| 28 |
+
dialect: 'gel';
|
| 29 |
+
readonly table: TTable;
|
| 30 |
+
readonly queryResult: TQueryResult;
|
| 31 |
+
readonly returning: TReturning;
|
| 32 |
+
readonly dynamic: TDynamic;
|
| 33 |
+
readonly excludedMethods: TExcludedMethods;
|
| 34 |
+
readonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];
|
| 35 |
+
};
|
| 36 |
+
}
|
| 37 |
+
export declare class GelDeleteBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]> implements RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 38 |
+
private session;
|
| 39 |
+
private dialect;
|
| 40 |
+
static readonly [entityKind]: string;
|
| 41 |
+
private config;
|
| 42 |
+
constructor(table: TTable, session: GelSession, dialect: GelDialect, withList?: Subquery[]);
|
| 43 |
+
/**
|
| 44 |
+
* Adds a `where` clause to the query.
|
| 45 |
+
*
|
| 46 |
+
* Calling this method will delete only those rows that fulfill a specified condition.
|
| 47 |
+
*
|
| 48 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
| 49 |
+
*
|
| 50 |
+
* @param where the `where` clause.
|
| 51 |
+
*
|
| 52 |
+
* @example
|
| 53 |
+
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
| 54 |
+
*
|
| 55 |
+
* ```ts
|
| 56 |
+
* // Delete all cars with green color
|
| 57 |
+
* await db.delete(cars).where(eq(cars.color, 'green'));
|
| 58 |
+
* // or
|
| 59 |
+
* await db.delete(cars).where(sql`${cars.color} = 'green'`)
|
| 60 |
+
* ```
|
| 61 |
+
*
|
| 62 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 63 |
+
*
|
| 64 |
+
* ```ts
|
| 65 |
+
* // Delete all BMW cars with a green color
|
| 66 |
+
* await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 67 |
+
*
|
| 68 |
+
* // Delete all cars with the green or blue color
|
| 69 |
+
* await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 70 |
+
* ```
|
| 71 |
+
*/
|
| 72 |
+
where(where: SQL | undefined): GelDeleteWithout<this, TDynamic, 'where'>;
|
| 73 |
+
/**
|
| 74 |
+
* Adds a `returning` clause to the query.
|
| 75 |
+
*
|
| 76 |
+
* Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.
|
| 77 |
+
*
|
| 78 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete#delete-with-return}
|
| 79 |
+
*
|
| 80 |
+
* @example
|
| 81 |
+
* ```ts
|
| 82 |
+
* // Delete all cars with the green color and return all fields
|
| 83 |
+
* const deletedCars: Car[] = await db.delete(cars)
|
| 84 |
+
* .where(eq(cars.color, 'green'))
|
| 85 |
+
* .returning();
|
| 86 |
+
*
|
| 87 |
+
* // Delete all cars with the green color and return only their id and brand fields
|
| 88 |
+
* const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
|
| 89 |
+
* .where(eq(cars.color, 'green'))
|
| 90 |
+
* .returning({ id: cars.id, brand: cars.brand });
|
| 91 |
+
* ```
|
| 92 |
+
*/
|
| 93 |
+
returning(): GelDeleteReturningAll<this, TDynamic>;
|
| 94 |
+
returning<TSelectedFields extends SelectedFieldsFlat>(fields: TSelectedFields): GelDeleteReturning<this, TDynamic, TSelectedFields>;
|
| 95 |
+
toSQL(): Query;
|
| 96 |
+
prepare(name: string): GelDeletePrepare<this>;
|
| 97 |
+
execute: ReturnType<this['prepare']>['execute'];
|
| 98 |
+
$dynamic(): GelDeleteDynamic<this>;
|
| 99 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 3 |
+
import { Table } from "../../table.js";
|
| 4 |
+
import { tracer } from "../../tracing.js";
|
| 5 |
+
import { orderSelectedFields } from "../../utils.js";
|
| 6 |
+
import { extractUsedTable } from "../utils.js";
|
| 7 |
+
class GelDeleteBase extends QueryPromise {
|
| 8 |
+
constructor(table, session, dialect, withList) {
|
| 9 |
+
super();
|
| 10 |
+
this.session = session;
|
| 11 |
+
this.dialect = dialect;
|
| 12 |
+
this.config = { table, withList };
|
| 13 |
+
}
|
| 14 |
+
static [entityKind] = "GelDelete";
|
| 15 |
+
config;
|
| 16 |
+
/**
|
| 17 |
+
* Adds a `where` clause to the query.
|
| 18 |
+
*
|
| 19 |
+
* Calling this method will delete only those rows that fulfill a specified condition.
|
| 20 |
+
*
|
| 21 |
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
| 22 |
+
*
|
| 23 |
+
* @param where the `where` clause.
|
| 24 |
+
*
|
| 25 |
+
* @example
|
| 26 |
+
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
| 27 |
+
*
|
| 28 |
+
* ```ts
|
| 29 |
+
* // Delete all cars with green color
|
| 30 |
+
* await db.delete(cars).where(eq(cars.color, 'green'));
|
| 31 |
+
* // or
|
| 32 |
+
* await db.delete(cars).where(sql`${cars.color} = 'green'`)
|
| 33 |
+
* ```
|
| 34 |
+
*
|
| 35 |
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
| 36 |
+
*
|
| 37 |
+
* ```ts
|
| 38 |
+
* // Delete all BMW cars with a green color
|
| 39 |
+
* await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
| 40 |
+
*
|
| 41 |
+
* // Delete all cars with the green or blue color
|
| 42 |
+
* await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
| 43 |
+
* ```
|
| 44 |
+
*/
|
| 45 |
+
where(where) {
|
| 46 |
+
this.config.where = where;
|
| 47 |
+
return this;
|
| 48 |
+
}
|
| 49 |
+
returning(fields = this.config.table[Table.Symbol.Columns]) {
|
| 50 |
+
this.config.returning = orderSelectedFields(fields);
|
| 51 |
+
return this;
|
| 52 |
+
}
|
| 53 |
+
/** @internal */
|
| 54 |
+
getSQL() {
|
| 55 |
+
return this.dialect.buildDeleteQuery(this.config);
|
| 56 |
+
}
|
| 57 |
+
toSQL() {
|
| 58 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 59 |
+
return rest;
|
| 60 |
+
}
|
| 61 |
+
/** @internal */
|
| 62 |
+
_prepare(name) {
|
| 63 |
+
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 64 |
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
| 65 |
+
type: "delete",
|
| 66 |
+
tables: extractUsedTable(this.config.table)
|
| 67 |
+
});
|
| 68 |
+
});
|
| 69 |
+
}
|
| 70 |
+
prepare(name) {
|
| 71 |
+
return this._prepare(name);
|
| 72 |
+
}
|
| 73 |
+
execute = (placeholderValues) => {
|
| 74 |
+
return tracer.startActiveSpan("drizzle.operation", () => {
|
| 75 |
+
return this._prepare().execute(placeholderValues);
|
| 76 |
+
});
|
| 77 |
+
};
|
| 78 |
+
$dynamic() {
|
| 79 |
+
return this;
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
export {
|
| 83 |
+
GelDeleteBase
|
| 84 |
+
};
|
| 85 |
+
//# sourceMappingURL=delete.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/delete.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/delete.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport type { GelTable } from '~/gel-core/table.ts';\nimport type { SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport { orderSelectedFields } from '~/utils.ts';\nimport type { GelColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts';\n\nexport type GelDeleteWithout<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T\n\t: Omit<\n\t\tGelDeleteBase<\n\t\t\tT['_']['table'],\n\t\t\tT['_']['queryResult'],\n\t\t\tT['_']['returning'],\n\t\t\tTDynamic,\n\t\t\tT['_']['excludedMethods'] | K\n\t\t>,\n\t\tT['_']['excludedMethods'] | K\n\t>;\n\nexport type GelDelete<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = GelDeleteBase<TTable, TQueryResult, TReturning, true, never>;\n\nexport interface GelDeleteConfig {\n\twhere?: SQL | undefined;\n\ttable: GelTable;\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type GelDeleteReturningAll<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n> = GelDeleteWithout<\n\tGelDeleteBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['table']['$inferSelect'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelDeleteReturning<\n\tT extends AnyGelDeleteBase,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFieldsFlat,\n> = GelDeleteWithout<\n\tGelDeleteBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tSelectResultFields<TSelectedFields>,\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelDeletePrepare<T extends AnyGelDeleteBase> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelDeleteDynamic<T extends AnyGelDeleteBase> = GelDelete<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['returning']\n>;\n\nexport type AnyGelDeleteBase = GelDeleteBase<any, any, any, any, any>;\n\nexport interface GelDeleteBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\tdialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelDeleteBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\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 ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelDelete';\n\n\tprivate config: GelDeleteConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { table, withList };\n\t}\n\n\t/**\n\t * Adds a `where` clause to the query.\n\t *\n\t * Calling this method will delete only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete}\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 deleted.\n\t *\n\t * ```ts\n\t * // Delete all cars with green color\n\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.delete(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 * // Delete all BMW cars with a green color\n\t * await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Delete all cars with the green or blue color\n\t * await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): GelDeleteWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\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 deleted rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete#delete-with-return}\n\t *\n\t * @example\n\t * ```ts\n\t * // Delete all cars with the green color and return all fields\n\t * const deletedCars: Car[] = await db.delete(cars)\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Delete all cars with the green color and return only their id and brand fields\n\t * const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): GelDeleteReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFieldsFlat>(\n\t\tfields: TSelectedFields,\n\t): GelDeleteReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields: SelectedFieldsFlat = this.config.table[Table.Symbol.Columns],\n\t): GelDeleteReturning<this, TDynamic, any> {\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildDeleteQuery(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(name?: string): GelDeletePrepare<this> {\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\treturn this.session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & {\n\t\t\t\t\texecute: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t\t\t\t}\n\t\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {\n\t\t\t\ttype: 'delete',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t});\n\t\t});\n\t}\n\n\tprepare(name: string): GelDeletePrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n\n\t$dynamic(): GelDeleteDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAW3B,SAAS,oBAAoB;AAI7B,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAAS,wBAAwB;AAoG1B,MAAM,sBAOH,aAIV;AAAA,EAKC,YACC,OACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,OAAO,SAAS;AAAA,EACjC;AAAA,EAZA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyCR,MAAM,OAAmE;AACxE,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA,EA0BA,UACC,SAA6B,KAAK,OAAO,MAAM,MAAM,OAAO,OAAO,GACzB;AAC1C,SAAK,OAAO,YAAY,oBAA+B,MAAM;AAC7D,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAS,MAAuC;AAC/C,WAAO,OAAO,gBAAgB,wBAAwB,MAAM;AAC3D,aAAO,KAAK,QAAQ,aAIlB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,GAAG,KAAK,OAAO,WAAW,MAAM,MAAM,QAAW;AAAA,QACvF,MAAM;AAAA,QACN,QAAQ,iBAAiB,KAAK,OAAO,KAAK;AAAA,MAC3C,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA,EAEA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,OAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,IACjD,CAAC;AAAA,EACF;AAAA,EAEA,WAAmC;AAClC,WAAO;AAAA,EACR;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
| 15 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 16 |
+
var query_builders_exports = {};
|
| 17 |
+
module.exports = __toCommonJS(query_builders_exports);
|
| 18 |
+
__reExport(query_builders_exports, require("./delete.cjs"), module.exports);
|
| 19 |
+
__reExport(query_builders_exports, require("./insert.cjs"), module.exports);
|
| 20 |
+
__reExport(query_builders_exports, require("./query-builder.cjs"), module.exports);
|
| 21 |
+
__reExport(query_builders_exports, require("./refresh-materialized-view.cjs"), module.exports);
|
| 22 |
+
__reExport(query_builders_exports, require("./select.cjs"), module.exports);
|
| 23 |
+
__reExport(query_builders_exports, require("./select.types.cjs"), module.exports);
|
| 24 |
+
__reExport(query_builders_exports, require("./update.cjs"), module.exports);
|
| 25 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 26 |
+
0 && (module.exports = {
|
| 27 |
+
...require("./delete.cjs"),
|
| 28 |
+
...require("./insert.cjs"),
|
| 29 |
+
...require("./query-builder.cjs"),
|
| 30 |
+
...require("./refresh-materialized-view.cjs"),
|
| 31 |
+
...require("./select.cjs"),
|
| 32 |
+
...require("./select.types.cjs"),
|
| 33 |
+
...require("./update.cjs")
|
| 34 |
+
});
|
| 35 |
+
//# sourceMappingURL=index.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/index.ts"],"sourcesContent":["export * from './delete.ts';\nexport * from './insert.ts';\nexport * from './query-builder.ts';\nexport * from './refresh-materialized-view.ts';\nexport * from './select.ts';\nexport * from './select.types.ts';\nexport * from './update.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mCAAc,wBAAd;AACA,mCAAc,wBADd;AAEA,mCAAc,+BAFd;AAGA,mCAAc,2CAHd;AAIA,mCAAc,wBAJd;AAKA,mCAAc,8BALd;AAMA,mCAAc,wBANd;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "./delete.cjs";
|
| 2 |
+
export * from "./insert.cjs";
|
| 3 |
+
export * from "./query-builder.cjs";
|
| 4 |
+
export * from "./refresh-materialized-view.cjs";
|
| 5 |
+
export * from "./select.cjs";
|
| 6 |
+
export * from "./select.types.cjs";
|
| 7 |
+
export * from "./update.cjs";
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "./delete.js";
|
| 2 |
+
export * from "./insert.js";
|
| 3 |
+
export * from "./query-builder.js";
|
| 4 |
+
export * from "./refresh-materialized-view.js";
|
| 5 |
+
export * from "./select.js";
|
| 6 |
+
export * from "./select.types.js";
|
| 7 |
+
export * from "./update.js";
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "./delete.js";
|
| 2 |
+
export * from "./insert.js";
|
| 3 |
+
export * from "./query-builder.js";
|
| 4 |
+
export * from "./refresh-materialized-view.js";
|
| 5 |
+
export * from "./select.js";
|
| 6 |
+
export * from "./select.types.js";
|
| 7 |
+
export * from "./update.js";
|
| 8 |
+
//# sourceMappingURL=index.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/index.ts"],"sourcesContent":["export * from './delete.ts';\nexport * from './insert.ts';\nexport * from './query-builder.ts';\nexport * from './refresh-materialized-view.ts';\nexport * from './select.ts';\nexport * from './select.types.ts';\nexport * from './update.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.cjs
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 insert_exports = {};
|
| 20 |
+
__export(insert_exports, {
|
| 21 |
+
GelInsertBase: () => GelInsertBase,
|
| 22 |
+
GelInsertBuilder: () => GelInsertBuilder
|
| 23 |
+
});
|
| 24 |
+
module.exports = __toCommonJS(insert_exports);
|
| 25 |
+
var import_entity = require("../../entity.cjs");
|
| 26 |
+
var import_query_promise = require("../../query-promise.cjs");
|
| 27 |
+
var import_sql = require("../../sql/sql.cjs");
|
| 28 |
+
var import_table = require("../../table.cjs");
|
| 29 |
+
var import_tracing = require("../../tracing.cjs");
|
| 30 |
+
var import_utils = require("../../utils.cjs");
|
| 31 |
+
var import_utils2 = require("../utils.cjs");
|
| 32 |
+
var import_query_builder = require("./query-builder.cjs");
|
| 33 |
+
class GelInsertBuilder {
|
| 34 |
+
constructor(table, session, dialect, withList, overridingSystemValue_) {
|
| 35 |
+
this.table = table;
|
| 36 |
+
this.session = session;
|
| 37 |
+
this.dialect = dialect;
|
| 38 |
+
this.withList = withList;
|
| 39 |
+
this.overridingSystemValue_ = overridingSystemValue_;
|
| 40 |
+
}
|
| 41 |
+
static [import_entity.entityKind] = "GelInsertBuilder";
|
| 42 |
+
authToken;
|
| 43 |
+
/** @internal */
|
| 44 |
+
setToken(token) {
|
| 45 |
+
this.authToken = token;
|
| 46 |
+
return this;
|
| 47 |
+
}
|
| 48 |
+
overridingSystemValue() {
|
| 49 |
+
this.overridingSystemValue_ = true;
|
| 50 |
+
return this;
|
| 51 |
+
}
|
| 52 |
+
values(values) {
|
| 53 |
+
values = Array.isArray(values) ? values : [values];
|
| 54 |
+
if (values.length === 0) {
|
| 55 |
+
throw new Error("values() must be called with at least one value");
|
| 56 |
+
}
|
| 57 |
+
const mappedValues = values.map((entry) => {
|
| 58 |
+
const result = {};
|
| 59 |
+
const cols = this.table[import_table.Table.Symbol.Columns];
|
| 60 |
+
for (const colKey of Object.keys(entry)) {
|
| 61 |
+
const colValue = entry[colKey];
|
| 62 |
+
result[colKey] = (0, import_entity.is)(colValue, import_sql.SQL) ? colValue : new import_sql.Param(colValue, cols[colKey]);
|
| 63 |
+
}
|
| 64 |
+
return result;
|
| 65 |
+
});
|
| 66 |
+
return new GelInsertBase(
|
| 67 |
+
this.table,
|
| 68 |
+
mappedValues,
|
| 69 |
+
this.session,
|
| 70 |
+
this.dialect,
|
| 71 |
+
this.withList,
|
| 72 |
+
false,
|
| 73 |
+
this.overridingSystemValue_
|
| 74 |
+
);
|
| 75 |
+
}
|
| 76 |
+
select(selectQuery) {
|
| 77 |
+
const select = typeof selectQuery === "function" ? selectQuery(new import_query_builder.QueryBuilder()) : selectQuery;
|
| 78 |
+
if (!(0, import_entity.is)(select, import_sql.SQL) && !(0, import_utils.haveSameKeys)(this.table[import_table.Columns], select._.selectedFields)) {
|
| 79 |
+
throw new Error(
|
| 80 |
+
"Insert select error: selected fields are not the same or are in a different order compared to the table definition"
|
| 81 |
+
);
|
| 82 |
+
}
|
| 83 |
+
return new GelInsertBase(this.table, select, this.session, this.dialect, this.withList, true);
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
class GelInsertBase extends import_query_promise.QueryPromise {
|
| 87 |
+
constructor(table, values, session, dialect, withList, select, overridingSystemValue_) {
|
| 88 |
+
super();
|
| 89 |
+
this.session = session;
|
| 90 |
+
this.dialect = dialect;
|
| 91 |
+
this.config = { table, values, withList, select, overridingSystemValue_ };
|
| 92 |
+
}
|
| 93 |
+
static [import_entity.entityKind] = "GelInsert";
|
| 94 |
+
config;
|
| 95 |
+
returning(fields = this.config.table[import_table.Table.Symbol.Columns]) {
|
| 96 |
+
this.config.returning = (0, import_utils.orderSelectedFields)(fields);
|
| 97 |
+
return this;
|
| 98 |
+
}
|
| 99 |
+
/**
|
| 100 |
+
* Adds an `on conflict do nothing` clause to the query.
|
| 101 |
+
*
|
| 102 |
+
* Calling this method simply avoids inserting a row as its alternative action.
|
| 103 |
+
*
|
| 104 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}
|
| 105 |
+
*
|
| 106 |
+
* @param config The `target` and `where` clauses.
|
| 107 |
+
*
|
| 108 |
+
* @example
|
| 109 |
+
* ```ts
|
| 110 |
+
* // Insert one row and cancel the insert if there's a conflict
|
| 111 |
+
* await db.insert(cars)
|
| 112 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 113 |
+
* .onConflictDoNothing();
|
| 114 |
+
*
|
| 115 |
+
* // Explicitly specify conflict target
|
| 116 |
+
* await db.insert(cars)
|
| 117 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 118 |
+
* .onConflictDoNothing({ target: cars.id });
|
| 119 |
+
* ```
|
| 120 |
+
*/
|
| 121 |
+
// TODO not supported
|
| 122 |
+
// onConflictDoNothing(
|
| 123 |
+
// config: { target?: IndexColumn | IndexColumn[]; where?: SQL } = {},
|
| 124 |
+
// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {
|
| 125 |
+
// if (config.target === undefined) {
|
| 126 |
+
// this.config.onConflict = sql`do nothing`;
|
| 127 |
+
// } else {
|
| 128 |
+
// let targetColumn = '';
|
| 129 |
+
// targetColumn = Array.isArray(config.target)
|
| 130 |
+
// ? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')
|
| 131 |
+
// : this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));
|
| 132 |
+
// const whereSql = config.where ? sql` where ${config.where}` : undefined;
|
| 133 |
+
// this.config.onConflict = sql`(${sql.raw(targetColumn)})${whereSql} do nothing`;
|
| 134 |
+
// }
|
| 135 |
+
// return this as any;
|
| 136 |
+
// }
|
| 137 |
+
/**
|
| 138 |
+
* Adds an `on conflict do update` clause to the query.
|
| 139 |
+
*
|
| 140 |
+
* Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.
|
| 141 |
+
*
|
| 142 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts}
|
| 143 |
+
*
|
| 144 |
+
* @param config The `target`, `set` and `where` clauses.
|
| 145 |
+
*
|
| 146 |
+
* @example
|
| 147 |
+
* ```ts
|
| 148 |
+
* // Update the row if there's a conflict
|
| 149 |
+
* await db.insert(cars)
|
| 150 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 151 |
+
* .onConflictDoUpdate({
|
| 152 |
+
* target: cars.id,
|
| 153 |
+
* set: { brand: 'Porsche' }
|
| 154 |
+
* });
|
| 155 |
+
*
|
| 156 |
+
* // Upsert with 'where' clause
|
| 157 |
+
* await db.insert(cars)
|
| 158 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 159 |
+
* .onConflictDoUpdate({
|
| 160 |
+
* target: cars.id,
|
| 161 |
+
* set: { brand: 'newBMW' },
|
| 162 |
+
* targetWhere: sql`${cars.createdAt} > '2023-01-01'::date`,
|
| 163 |
+
* });
|
| 164 |
+
* ```
|
| 165 |
+
*/
|
| 166 |
+
// TODO not supported
|
| 167 |
+
// onConflictDoUpdate(
|
| 168 |
+
// config: GelInsertOnConflictDoUpdateConfig<this>,
|
| 169 |
+
// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {
|
| 170 |
+
// if (config.where && (config.targetWhere || config.setWhere)) {
|
| 171 |
+
// throw new Error(
|
| 172 |
+
// 'You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.',
|
| 173 |
+
// );
|
| 174 |
+
// }
|
| 175 |
+
// const whereSql = config.where ? sql` where ${config.where}` : undefined;
|
| 176 |
+
// const targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : undefined;
|
| 177 |
+
// const setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : undefined;
|
| 178 |
+
// const setSql = this.dialect.buildUpdateSet(this.config.table, mapUpdateSet(this.config.table, config.set));
|
| 179 |
+
// let targetColumn = '';
|
| 180 |
+
// targetColumn = Array.isArray(config.target)
|
| 181 |
+
// ? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')
|
| 182 |
+
// : this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));
|
| 183 |
+
// this.config.onConflict = sql`(${
|
| 184 |
+
// sql.raw(targetColumn)
|
| 185 |
+
// })${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;
|
| 186 |
+
// return this as any;
|
| 187 |
+
// }
|
| 188 |
+
/** @internal */
|
| 189 |
+
getSQL() {
|
| 190 |
+
return this.dialect.buildInsertQuery(this.config);
|
| 191 |
+
}
|
| 192 |
+
toSQL() {
|
| 193 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 194 |
+
return rest;
|
| 195 |
+
}
|
| 196 |
+
/** @internal */
|
| 197 |
+
_prepare(name) {
|
| 198 |
+
return import_tracing.tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 199 |
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
| 200 |
+
type: "insert",
|
| 201 |
+
tables: (0, import_utils2.extractUsedTable)(this.config.table)
|
| 202 |
+
});
|
| 203 |
+
});
|
| 204 |
+
}
|
| 205 |
+
prepare(name) {
|
| 206 |
+
return this._prepare(name);
|
| 207 |
+
}
|
| 208 |
+
execute = (placeholderValues) => {
|
| 209 |
+
return import_tracing.tracer.startActiveSpan("drizzle.operation", () => {
|
| 210 |
+
return this._prepare().execute(placeholderValues);
|
| 211 |
+
});
|
| 212 |
+
};
|
| 213 |
+
$dynamic() {
|
| 214 |
+
return this;
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 218 |
+
0 && (module.exports = {
|
| 219 |
+
GelInsertBase,
|
| 220 |
+
GelInsertBuilder
|
| 221 |
+
});
|
| 222 |
+
//# sourceMappingURL=insert.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/insert.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { IndexColumn } from '~/gel-core/indexes.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport type { GelTable, TableConfig } from '~/gel-core/table.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { Placeholder, Query, SQLWrapper } from '~/sql/sql.ts';\nimport { Param, SQL } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport type { InferInsertModel } from '~/table.ts';\nimport { Columns, Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport { haveSameKeys, type NeonAuthToken, orderSelectedFields } from '~/utils.ts';\nimport type { AnyGelColumn, GelColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport { QueryBuilder } from './query-builder.ts';\nimport type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts';\nimport type { GelUpdateSetSource } from './update.ts';\n\nexport interface GelInsertConfig<TTable extends GelTable = GelTable> {\n\ttable: TTable;\n\tvalues: Record<string, Param | SQL>[] | GelInsertSelectQueryBuilder<TTable> | SQL;\n\twithList?: Subquery[];\n\tonConflict?: SQL;\n\treturning?: SelectedFieldsOrdered;\n\tselect?: boolean;\n\toverridingSystemValue_?: boolean;\n}\n\nexport type GelInsertValue<TTable extends GelTable<TableConfig>, OverrideT extends boolean = false> =\n\t& {\n\t\t[Key in keyof InferInsertModel<TTable, { dbColumnNames: false; override: OverrideT }>]:\n\t\t\t| InferInsertModel<TTable, { dbColumnNames: false; override: OverrideT }>[Key]\n\t\t\t| SQL\n\t\t\t| Placeholder;\n\t}\n\t& {};\n\nexport type GelInsertSelectQueryBuilder<TTable extends GelTable> = TypedQueryBuilder<\n\t{ [K in keyof TTable['$inferInsert']]: AnyGelColumn | SQL | SQL.Aliased | TTable['$inferInsert'][K] }\n>;\n\nexport class GelInsertBuilder<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tOverrideT extends boolean = false,\n> {\n\tstatic readonly [entityKind]: string = 'GelInsertBuilder';\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\tprivate withList?: Subquery[],\n\t\tprivate overridingSystemValue_?: boolean,\n\t) {}\n\n\tprivate authToken?: NeonAuthToken;\n\t/** @internal */\n\tsetToken(token?: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\toverridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'> {\n\t\tthis.overridingSystemValue_ = true;\n\t\treturn this as any;\n\t}\n\n\tvalues(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;\n\tvalues(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;\n\tvalues(\n\t\tvalues: GelInsertValue<TTable, OverrideT> | GelInsertValue<TTable, OverrideT>[],\n\t): GelInsertBase<TTable, TQueryResult> {\n\t\tvalues = Array.isArray(values) ? values : [values];\n\t\tif (values.length === 0) {\n\t\t\tthrow new Error('values() must be called with at least one value');\n\t\t}\n\t\tconst mappedValues = values.map((entry) => {\n\t\t\tconst result: Record<string, Param | SQL> = {};\n\t\t\tconst cols = this.table[Table.Symbol.Columns];\n\t\t\tfor (const colKey of Object.keys(entry)) {\n\t\t\t\tconst colValue = entry[colKey as keyof typeof entry];\n\t\t\t\tresult[colKey] = is(colValue, SQL) ? colValue : new Param(colValue, cols[colKey]);\n\t\t\t}\n\t\t\treturn result;\n\t\t});\n\n\t\treturn new GelInsertBase(\n\t\t\tthis.table,\n\t\t\tmappedValues,\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t\tfalse,\n\t\t\tthis.overridingSystemValue_,\n\t\t);\n\t}\n\n\tselect(selectQuery: (qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: (qb: QueryBuilder) => SQL): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: SQL): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;\n\tselect(\n\t\tselectQuery:\n\t\t\t| SQL\n\t\t\t| GelInsertSelectQueryBuilder<TTable>\n\t\t\t| ((qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable> | SQL),\n\t): GelInsertBase<TTable, TQueryResult> {\n\t\tconst select = typeof selectQuery === 'function' ? selectQuery(new QueryBuilder()) : selectQuery;\n\n\t\tif (\n\t\t\t!is(select, SQL)\n\t\t\t&& !haveSameKeys(this.table[Columns], select._.selectedFields)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Insert select error: selected fields are not the same or are in a different order compared to the table definition',\n\t\t\t);\n\t\t}\n\n\t\treturn new GelInsertBase(this.table, select, this.session, this.dialect, this.withList, true);\n\t}\n}\n\nexport type GelInsertWithout<T extends AnyGelInsert, TDynamic extends boolean, K extends keyof T & string> =\n\tTDynamic extends true ? T\n\t\t: Omit<\n\t\t\tGelInsertBase<\n\t\t\t\tT['_']['table'],\n\t\t\t\tT['_']['queryResult'],\n\t\t\t\tT['_']['returning'],\n\t\t\t\tTDynamic,\n\t\t\t\tT['_']['excludedMethods'] | K\n\t\t\t>,\n\t\t\tT['_']['excludedMethods'] | K\n\t\t>;\n\nexport type GelInsertReturning<\n\tT extends AnyGelInsert,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFieldsFlat,\n> = GelInsertBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tSelectResultFields<TSelectedFields>,\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\nexport type GelInsertReturningAll<T extends AnyGelInsert, TDynamic extends boolean> = GelInsertBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['table']['$inferSelect'],\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\nexport interface GelInsertOnConflictDoUpdateConfig<T extends AnyGelInsert> {\n\ttarget: IndexColumn | IndexColumn[];\n\t/** @deprecated use either `targetWhere` or `setWhere` */\n\twhere?: SQL;\n\t// TODO: add tests for targetWhere and setWhere\n\ttargetWhere?: SQL;\n\tsetWhere?: SQL;\n\tset: GelUpdateSetSource<T['_']['table']>;\n}\n\nexport type GelInsertPrepare<T extends AnyGelInsert> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelInsertDynamic<T extends AnyGelInsert> = GelInsert<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['returning']\n>;\n\nexport type AnyGelInsert = GelInsertBase<any, any, any, any, any>;\n\nexport type GelInsert<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = GelInsertBase<TTable, TQueryResult, TReturning, true, never>;\n\nexport interface GelInsertBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelInsertBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = 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 ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelInsert';\n\n\tprivate config: GelInsertConfig<TTable>;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tvalues: GelInsertConfig['values'],\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t\tselect?: boolean,\n\t\toverridingSystemValue_?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.config = { table, values: values as any, withList, select, overridingSystemValue_ };\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 inserted rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Insert one row and return all fields\n\t * const insertedCar: Car[] = await db.insert(cars)\n\t * .values({ brand: 'BMW' })\n\t * .returning();\n\t *\n\t * // Insert one row and return only the id\n\t * const insertedCarId: { id: number }[] = await db.insert(cars)\n\t * .values({ brand: 'BMW' })\n\t * .returning({ id: cars.id });\n\t * ```\n\t */\n\treturning(): GelInsertWithout<GelInsertReturningAll<this, TDynamic>, TDynamic, 'returning'>;\n\treturning<TSelectedFields extends SelectedFieldsFlat>(\n\t\tfields: TSelectedFields,\n\t): GelInsertWithout<GelInsertReturning<this, TDynamic, TSelectedFields>, TDynamic, 'returning'>;\n\treturning(\n\t\tfields: SelectedFieldsFlat = this.config.table[Table.Symbol.Columns],\n\t): GelInsertWithout<AnyGelInsert, TDynamic, 'returning'> {\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `on conflict do nothing` clause to the query.\n\t *\n\t * Calling this method simply avoids inserting a row as its alternative action.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}\n\t *\n\t * @param config The `target` and `where` clauses.\n\t *\n\t * @example\n\t * ```ts\n\t * // Insert one row and cancel the insert if there's a conflict\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoNothing();\n\t *\n\t * // Explicitly specify conflict target\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoNothing({ target: cars.id });\n\t * ```\n\t */\n\t// TODO not supported\n\t// onConflictDoNothing(\n\t// \tconfig: { target?: IndexColumn | IndexColumn[]; where?: SQL } = {},\n\t// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {\n\t// \tif (config.target === undefined) {\n\t// \t\tthis.config.onConflict = sql`do nothing`;\n\t// \t} else {\n\t// \t\tlet targetColumn = '';\n\t// \t\ttargetColumn = Array.isArray(config.target)\n\t// \t\t\t? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')\n\t// \t\t\t: this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));\n\n\t// \t\tconst whereSql = config.where ? sql` where ${config.where}` : undefined;\n\t// \t\tthis.config.onConflict = sql`(${sql.raw(targetColumn)})${whereSql} do nothing`;\n\t// \t}\n\t// \treturn this as any;\n\t// }\n\n\t/**\n\t * Adds an `on conflict do update` clause to the query.\n\t *\n\t * Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts}\n\t *\n\t * @param config The `target`, `set` and `where` clauses.\n\t *\n\t * @example\n\t * ```ts\n\t * // Update the row if there's a conflict\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoUpdate({\n\t * target: cars.id,\n\t * set: { brand: 'Porsche' }\n\t * });\n\t *\n\t * // Upsert with 'where' clause\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoUpdate({\n\t * target: cars.id,\n\t * set: { brand: 'newBMW' },\n\t * targetWhere: sql`${cars.createdAt} > '2023-01-01'::date`,\n\t * });\n\t * ```\n\t */\n\t// TODO not supported\n\t// onConflictDoUpdate(\n\t// \tconfig: GelInsertOnConflictDoUpdateConfig<this>,\n\t// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {\n\t// \tif (config.where && (config.targetWhere || config.setWhere)) {\n\t// \t\tthrow new Error(\n\t// \t\t\t'You cannot use both \"where\" and \"targetWhere\"/\"setWhere\" at the same time - \"where\" is deprecated, use \"targetWhere\" or \"setWhere\" instead.',\n\t// \t\t);\n\t// \t}\n\t// \tconst whereSql = config.where ? sql` where ${config.where}` : undefined;\n\t// \tconst targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : undefined;\n\t// \tconst setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : undefined;\n\t// \tconst setSql = this.dialect.buildUpdateSet(this.config.table, mapUpdateSet(this.config.table, config.set));\n\t// \tlet targetColumn = '';\n\t// \ttargetColumn = Array.isArray(config.target)\n\t// \t\t? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')\n\t// \t\t: this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));\n\t// \tthis.config.onConflict = sql`(${\n\t// \t\tsql.raw(targetColumn)\n\t// \t})${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;\n\t// \treturn this as any;\n\t// }\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildInsertQuery(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(name?: string): GelInsertPrepare<this> {\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\treturn this.session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & {\n\t\t\t\t\texecute: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t\t\t\t}\n\t\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {\n\t\t\t\ttype: 'insert',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t});\n\t\t});\n\t}\n\n\tprepare(name: string): GelInsertPrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n\n\t$dynamic(): GelInsertDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAa/B,2BAA6B;AAG7B,iBAA2B;AAG3B,mBAA+B;AAC/B,qBAAuB;AACvB,mBAAsE;AAEtE,IAAAA,gBAAiC;AACjC,2BAA6B;AA2BtB,MAAM,iBAIX;AAAA,EAGD,YACS,OACA,SACA,SACA,UACA,wBACP;AALO;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EARH,QAAiB,wBAAU,IAAY;AAAA,EAU/B;AAAA;AAAA,EAER,SAAS,OAAuB;AAC/B,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AAAA,EAEA,wBAAqG;AACpG,SAAK,yBAAyB;AAC9B,WAAO;AAAA,EACR;AAAA,EAIA,OACC,QACsC;AACtC,aAAS,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD,QAAI,OAAO,WAAW,GAAG;AACxB,YAAM,IAAI,MAAM,iDAAiD;AAAA,IAClE;AACA,UAAM,eAAe,OAAO,IAAI,CAAC,UAAU;AAC1C,YAAM,SAAsC,CAAC;AAC7C,YAAM,OAAO,KAAK,MAAM,mBAAM,OAAO,OAAO;AAC5C,iBAAW,UAAU,OAAO,KAAK,KAAK,GAAG;AACxC,cAAM,WAAW,MAAM,MAA4B;AACnD,eAAO,MAAM,QAAI,kBAAG,UAAU,cAAG,IAAI,WAAW,IAAI,iBAAM,UAAU,KAAK,MAAM,CAAC;AAAA,MACjF;AACA,aAAO;AAAA,IACR,CAAC;AAED,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAMA,OACC,aAIsC;AACtC,UAAM,SAAS,OAAO,gBAAgB,aAAa,YAAY,IAAI,kCAAa,CAAC,IAAI;AAErF,QACC,KAAC,kBAAG,QAAQ,cAAG,KACZ,KAAC,2BAAa,KAAK,MAAM,oBAAO,GAAG,OAAO,EAAE,cAAc,GAC5D;AACD,YAAM,IAAI;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAEA,WAAO,IAAI,cAAc,KAAK,OAAO,QAAQ,KAAK,SAAS,KAAK,SAAS,KAAK,UAAU,IAAI;AAAA,EAC7F;AACD;AAwFO,MAAM,sBAQH,kCAIV;AAAA,EAKC,YACC,OACA,QACQ,SACA,SACR,UACA,QACA,wBACC;AACD,UAAM;AANE;AACA;AAMR,SAAK,SAAS,EAAE,OAAO,QAAuB,UAAU,QAAQ,uBAAuB;AAAA,EACxF;AAAA,EAfA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA,EAuCR,UACC,SAA6B,KAAK,OAAO,MAAM,mBAAM,OAAO,OAAO,GACX;AACxD,SAAK,OAAO,gBAAY,kCAA+B,MAAM;AAC7D,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+FA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAS,MAAuC;AAC/C,WAAO,sBAAO,gBAAgB,wBAAwB,MAAM;AAC3D,aAAO,KAAK,QAAQ,aAIlB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,GAAG,KAAK,OAAO,WAAW,MAAM,MAAM,QAAW;AAAA,QACvF,MAAM;AAAA,QACN,YAAQ,gCAAiB,KAAK,OAAO,KAAK;AAAA,MAC3C,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA,EAEA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,sBAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,IACjD,CAAC;AAAA,EACF;AAAA,EAEA,WAAmC;AAClC,WAAO;AAAA,EACR;AACD;","names":["import_utils"]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.d.cts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.cjs";
|
| 2 |
+
import type { GelDialect } from "../dialect.cjs";
|
| 3 |
+
import type { IndexColumn } from "../indexes.cjs";
|
| 4 |
+
import type { GelPreparedQuery, GelQueryResultHKT, GelQueryResultKind, GelSession, PreparedQueryConfig } from "../session.cjs";
|
| 5 |
+
import type { GelTable, TableConfig } from "../table.cjs";
|
| 6 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.cjs";
|
| 7 |
+
import type { SelectResultFields } from "../../query-builders/select.types.cjs";
|
| 8 |
+
import { QueryPromise } from "../../query-promise.cjs";
|
| 9 |
+
import type { RunnableQuery } from "../../runnable-query.cjs";
|
| 10 |
+
import type { Placeholder, Query, SQLWrapper } from "../../sql/sql.cjs";
|
| 11 |
+
import { Param, SQL } from "../../sql/sql.cjs";
|
| 12 |
+
import type { Subquery } from "../../subquery.cjs";
|
| 13 |
+
import type { InferInsertModel } from "../../table.cjs";
|
| 14 |
+
import type { AnyGelColumn } from "../columns/common.cjs";
|
| 15 |
+
import { QueryBuilder } from "./query-builder.cjs";
|
| 16 |
+
import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.cjs";
|
| 17 |
+
import type { GelUpdateSetSource } from "./update.cjs";
|
| 18 |
+
export interface GelInsertConfig<TTable extends GelTable = GelTable> {
|
| 19 |
+
table: TTable;
|
| 20 |
+
values: Record<string, Param | SQL>[] | GelInsertSelectQueryBuilder<TTable> | SQL;
|
| 21 |
+
withList?: Subquery[];
|
| 22 |
+
onConflict?: SQL;
|
| 23 |
+
returning?: SelectedFieldsOrdered;
|
| 24 |
+
select?: boolean;
|
| 25 |
+
overridingSystemValue_?: boolean;
|
| 26 |
+
}
|
| 27 |
+
export type GelInsertValue<TTable extends GelTable<TableConfig>, OverrideT extends boolean = false> = {
|
| 28 |
+
[Key in keyof InferInsertModel<TTable, {
|
| 29 |
+
dbColumnNames: false;
|
| 30 |
+
override: OverrideT;
|
| 31 |
+
}>]: InferInsertModel<TTable, {
|
| 32 |
+
dbColumnNames: false;
|
| 33 |
+
override: OverrideT;
|
| 34 |
+
}>[Key] | SQL | Placeholder;
|
| 35 |
+
} & {};
|
| 36 |
+
export type GelInsertSelectQueryBuilder<TTable extends GelTable> = TypedQueryBuilder<{
|
| 37 |
+
[K in keyof TTable['$inferInsert']]: AnyGelColumn | SQL | SQL.Aliased | TTable['$inferInsert'][K];
|
| 38 |
+
}>;
|
| 39 |
+
export declare class GelInsertBuilder<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, OverrideT extends boolean = false> {
|
| 40 |
+
private table;
|
| 41 |
+
private session;
|
| 42 |
+
private dialect;
|
| 43 |
+
private withList?;
|
| 44 |
+
private overridingSystemValue_?;
|
| 45 |
+
static readonly [entityKind]: string;
|
| 46 |
+
constructor(table: TTable, session: GelSession, dialect: GelDialect, withList?: Subquery[] | undefined, overridingSystemValue_?: boolean | undefined);
|
| 47 |
+
private authToken?;
|
| 48 |
+
overridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'>;
|
| 49 |
+
values(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;
|
| 50 |
+
values(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;
|
| 51 |
+
select(selectQuery: (qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;
|
| 52 |
+
select(selectQuery: (qb: QueryBuilder) => SQL): GelInsertBase<TTable, TQueryResult>;
|
| 53 |
+
select(selectQuery: SQL): GelInsertBase<TTable, TQueryResult>;
|
| 54 |
+
select(selectQuery: GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;
|
| 55 |
+
}
|
| 56 |
+
export type GelInsertWithout<T extends AnyGelInsert, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<GelInsertBase<T['_']['table'], T['_']['queryResult'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 57 |
+
export type GelInsertReturning<T extends AnyGelInsert, TDynamic extends boolean, TSelectedFields extends SelectedFieldsFlat> = GelInsertBase<T['_']['table'], T['_']['queryResult'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>;
|
| 58 |
+
export type GelInsertReturningAll<T extends AnyGelInsert, TDynamic extends boolean> = GelInsertBase<T['_']['table'], T['_']['queryResult'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>;
|
| 59 |
+
export interface GelInsertOnConflictDoUpdateConfig<T extends AnyGelInsert> {
|
| 60 |
+
target: IndexColumn | IndexColumn[];
|
| 61 |
+
/** @deprecated use either `targetWhere` or `setWhere` */
|
| 62 |
+
where?: SQL;
|
| 63 |
+
targetWhere?: SQL;
|
| 64 |
+
setWhere?: SQL;
|
| 65 |
+
set: GelUpdateSetSource<T['_']['table']>;
|
| 66 |
+
}
|
| 67 |
+
export type GelInsertPrepare<T extends AnyGelInsert> = GelPreparedQuery<PreparedQueryConfig & {
|
| 68 |
+
execute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never> : T['_']['returning'][];
|
| 69 |
+
}>;
|
| 70 |
+
export type GelInsertDynamic<T extends AnyGelInsert> = GelInsert<T['_']['table'], T['_']['queryResult'], T['_']['returning']>;
|
| 71 |
+
export type AnyGelInsert = GelInsertBase<any, any, any, any, any>;
|
| 72 |
+
export type GelInsert<TTable extends GelTable = GelTable, TQueryResult extends GelQueryResultHKT = GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = GelInsertBase<TTable, TQueryResult, TReturning, true, never>;
|
| 73 |
+
export interface GelInsertBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>, RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 74 |
+
readonly _: {
|
| 75 |
+
readonly dialect: 'gel';
|
| 76 |
+
readonly table: TTable;
|
| 77 |
+
readonly queryResult: TQueryResult;
|
| 78 |
+
readonly returning: TReturning;
|
| 79 |
+
readonly dynamic: TDynamic;
|
| 80 |
+
readonly excludedMethods: TExcludedMethods;
|
| 81 |
+
readonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
export declare class GelInsertBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]> implements RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 85 |
+
private session;
|
| 86 |
+
private dialect;
|
| 87 |
+
static readonly [entityKind]: string;
|
| 88 |
+
private config;
|
| 89 |
+
constructor(table: TTable, values: GelInsertConfig['values'], session: GelSession, dialect: GelDialect, withList?: Subquery[], select?: boolean, overridingSystemValue_?: boolean);
|
| 90 |
+
/**
|
| 91 |
+
* Adds a `returning` clause to the query.
|
| 92 |
+
*
|
| 93 |
+
* Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned.
|
| 94 |
+
*
|
| 95 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning}
|
| 96 |
+
*
|
| 97 |
+
* @example
|
| 98 |
+
* ```ts
|
| 99 |
+
* // Insert one row and return all fields
|
| 100 |
+
* const insertedCar: Car[] = await db.insert(cars)
|
| 101 |
+
* .values({ brand: 'BMW' })
|
| 102 |
+
* .returning();
|
| 103 |
+
*
|
| 104 |
+
* // Insert one row and return only the id
|
| 105 |
+
* const insertedCarId: { id: number }[] = await db.insert(cars)
|
| 106 |
+
* .values({ brand: 'BMW' })
|
| 107 |
+
* .returning({ id: cars.id });
|
| 108 |
+
* ```
|
| 109 |
+
*/
|
| 110 |
+
returning(): GelInsertWithout<GelInsertReturningAll<this, TDynamic>, TDynamic, 'returning'>;
|
| 111 |
+
returning<TSelectedFields extends SelectedFieldsFlat>(fields: TSelectedFields): GelInsertWithout<GelInsertReturning<this, TDynamic, TSelectedFields>, TDynamic, 'returning'>;
|
| 112 |
+
toSQL(): Query;
|
| 113 |
+
prepare(name: string): GelInsertPrepare<this>;
|
| 114 |
+
execute: ReturnType<this['prepare']>['execute'];
|
| 115 |
+
$dynamic(): GelInsertDynamic<this>;
|
| 116 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import type { GelDialect } from "../dialect.js";
|
| 3 |
+
import type { IndexColumn } from "../indexes.js";
|
| 4 |
+
import type { GelPreparedQuery, GelQueryResultHKT, GelQueryResultKind, GelSession, PreparedQueryConfig } from "../session.js";
|
| 5 |
+
import type { GelTable, TableConfig } from "../table.js";
|
| 6 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.js";
|
| 7 |
+
import type { SelectResultFields } from "../../query-builders/select.types.js";
|
| 8 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 9 |
+
import type { RunnableQuery } from "../../runnable-query.js";
|
| 10 |
+
import type { Placeholder, Query, SQLWrapper } from "../../sql/sql.js";
|
| 11 |
+
import { Param, SQL } from "../../sql/sql.js";
|
| 12 |
+
import type { Subquery } from "../../subquery.js";
|
| 13 |
+
import type { InferInsertModel } from "../../table.js";
|
| 14 |
+
import type { AnyGelColumn } from "../columns/common.js";
|
| 15 |
+
import { QueryBuilder } from "./query-builder.js";
|
| 16 |
+
import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.js";
|
| 17 |
+
import type { GelUpdateSetSource } from "./update.js";
|
| 18 |
+
export interface GelInsertConfig<TTable extends GelTable = GelTable> {
|
| 19 |
+
table: TTable;
|
| 20 |
+
values: Record<string, Param | SQL>[] | GelInsertSelectQueryBuilder<TTable> | SQL;
|
| 21 |
+
withList?: Subquery[];
|
| 22 |
+
onConflict?: SQL;
|
| 23 |
+
returning?: SelectedFieldsOrdered;
|
| 24 |
+
select?: boolean;
|
| 25 |
+
overridingSystemValue_?: boolean;
|
| 26 |
+
}
|
| 27 |
+
export type GelInsertValue<TTable extends GelTable<TableConfig>, OverrideT extends boolean = false> = {
|
| 28 |
+
[Key in keyof InferInsertModel<TTable, {
|
| 29 |
+
dbColumnNames: false;
|
| 30 |
+
override: OverrideT;
|
| 31 |
+
}>]: InferInsertModel<TTable, {
|
| 32 |
+
dbColumnNames: false;
|
| 33 |
+
override: OverrideT;
|
| 34 |
+
}>[Key] | SQL | Placeholder;
|
| 35 |
+
} & {};
|
| 36 |
+
export type GelInsertSelectQueryBuilder<TTable extends GelTable> = TypedQueryBuilder<{
|
| 37 |
+
[K in keyof TTable['$inferInsert']]: AnyGelColumn | SQL | SQL.Aliased | TTable['$inferInsert'][K];
|
| 38 |
+
}>;
|
| 39 |
+
export declare class GelInsertBuilder<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, OverrideT extends boolean = false> {
|
| 40 |
+
private table;
|
| 41 |
+
private session;
|
| 42 |
+
private dialect;
|
| 43 |
+
private withList?;
|
| 44 |
+
private overridingSystemValue_?;
|
| 45 |
+
static readonly [entityKind]: string;
|
| 46 |
+
constructor(table: TTable, session: GelSession, dialect: GelDialect, withList?: Subquery[] | undefined, overridingSystemValue_?: boolean | undefined);
|
| 47 |
+
private authToken?;
|
| 48 |
+
overridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'>;
|
| 49 |
+
values(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;
|
| 50 |
+
values(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;
|
| 51 |
+
select(selectQuery: (qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;
|
| 52 |
+
select(selectQuery: (qb: QueryBuilder) => SQL): GelInsertBase<TTable, TQueryResult>;
|
| 53 |
+
select(selectQuery: SQL): GelInsertBase<TTable, TQueryResult>;
|
| 54 |
+
select(selectQuery: GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;
|
| 55 |
+
}
|
| 56 |
+
export type GelInsertWithout<T extends AnyGelInsert, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<GelInsertBase<T['_']['table'], T['_']['queryResult'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
| 57 |
+
export type GelInsertReturning<T extends AnyGelInsert, TDynamic extends boolean, TSelectedFields extends SelectedFieldsFlat> = GelInsertBase<T['_']['table'], T['_']['queryResult'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>;
|
| 58 |
+
export type GelInsertReturningAll<T extends AnyGelInsert, TDynamic extends boolean> = GelInsertBase<T['_']['table'], T['_']['queryResult'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>;
|
| 59 |
+
export interface GelInsertOnConflictDoUpdateConfig<T extends AnyGelInsert> {
|
| 60 |
+
target: IndexColumn | IndexColumn[];
|
| 61 |
+
/** @deprecated use either `targetWhere` or `setWhere` */
|
| 62 |
+
where?: SQL;
|
| 63 |
+
targetWhere?: SQL;
|
| 64 |
+
setWhere?: SQL;
|
| 65 |
+
set: GelUpdateSetSource<T['_']['table']>;
|
| 66 |
+
}
|
| 67 |
+
export type GelInsertPrepare<T extends AnyGelInsert> = GelPreparedQuery<PreparedQueryConfig & {
|
| 68 |
+
execute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never> : T['_']['returning'][];
|
| 69 |
+
}>;
|
| 70 |
+
export type GelInsertDynamic<T extends AnyGelInsert> = GelInsert<T['_']['table'], T['_']['queryResult'], T['_']['returning']>;
|
| 71 |
+
export type AnyGelInsert = GelInsertBase<any, any, any, any, any>;
|
| 72 |
+
export type GelInsert<TTable extends GelTable = GelTable, TQueryResult extends GelQueryResultHKT = GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = GelInsertBase<TTable, TQueryResult, TReturning, true, never>;
|
| 73 |
+
export interface GelInsertBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>, RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 74 |
+
readonly _: {
|
| 75 |
+
readonly dialect: 'gel';
|
| 76 |
+
readonly table: TTable;
|
| 77 |
+
readonly queryResult: TQueryResult;
|
| 78 |
+
readonly returning: TReturning;
|
| 79 |
+
readonly dynamic: TDynamic;
|
| 80 |
+
readonly excludedMethods: TExcludedMethods;
|
| 81 |
+
readonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
export declare class GelInsertBase<TTable extends GelTable, TQueryResult extends GelQueryResultHKT, TReturning extends Record<string, unknown> | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]> implements RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>, SQLWrapper {
|
| 85 |
+
private session;
|
| 86 |
+
private dialect;
|
| 87 |
+
static readonly [entityKind]: string;
|
| 88 |
+
private config;
|
| 89 |
+
constructor(table: TTable, values: GelInsertConfig['values'], session: GelSession, dialect: GelDialect, withList?: Subquery[], select?: boolean, overridingSystemValue_?: boolean);
|
| 90 |
+
/**
|
| 91 |
+
* Adds a `returning` clause to the query.
|
| 92 |
+
*
|
| 93 |
+
* Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned.
|
| 94 |
+
*
|
| 95 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning}
|
| 96 |
+
*
|
| 97 |
+
* @example
|
| 98 |
+
* ```ts
|
| 99 |
+
* // Insert one row and return all fields
|
| 100 |
+
* const insertedCar: Car[] = await db.insert(cars)
|
| 101 |
+
* .values({ brand: 'BMW' })
|
| 102 |
+
* .returning();
|
| 103 |
+
*
|
| 104 |
+
* // Insert one row and return only the id
|
| 105 |
+
* const insertedCarId: { id: number }[] = await db.insert(cars)
|
| 106 |
+
* .values({ brand: 'BMW' })
|
| 107 |
+
* .returning({ id: cars.id });
|
| 108 |
+
* ```
|
| 109 |
+
*/
|
| 110 |
+
returning(): GelInsertWithout<GelInsertReturningAll<this, TDynamic>, TDynamic, 'returning'>;
|
| 111 |
+
returning<TSelectedFields extends SelectedFieldsFlat>(fields: TSelectedFields): GelInsertWithout<GelInsertReturning<this, TDynamic, TSelectedFields>, TDynamic, 'returning'>;
|
| 112 |
+
toSQL(): Query;
|
| 113 |
+
prepare(name: string): GelInsertPrepare<this>;
|
| 114 |
+
execute: ReturnType<this['prepare']>['execute'];
|
| 115 |
+
$dynamic(): GelInsertDynamic<this>;
|
| 116 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind, is } from "../../entity.js";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 3 |
+
import { Param, SQL } from "../../sql/sql.js";
|
| 4 |
+
import { Columns, Table } from "../../table.js";
|
| 5 |
+
import { tracer } from "../../tracing.js";
|
| 6 |
+
import { haveSameKeys, orderSelectedFields } from "../../utils.js";
|
| 7 |
+
import { extractUsedTable } from "../utils.js";
|
| 8 |
+
import { QueryBuilder } from "./query-builder.js";
|
| 9 |
+
class GelInsertBuilder {
|
| 10 |
+
constructor(table, session, dialect, withList, overridingSystemValue_) {
|
| 11 |
+
this.table = table;
|
| 12 |
+
this.session = session;
|
| 13 |
+
this.dialect = dialect;
|
| 14 |
+
this.withList = withList;
|
| 15 |
+
this.overridingSystemValue_ = overridingSystemValue_;
|
| 16 |
+
}
|
| 17 |
+
static [entityKind] = "GelInsertBuilder";
|
| 18 |
+
authToken;
|
| 19 |
+
/** @internal */
|
| 20 |
+
setToken(token) {
|
| 21 |
+
this.authToken = token;
|
| 22 |
+
return this;
|
| 23 |
+
}
|
| 24 |
+
overridingSystemValue() {
|
| 25 |
+
this.overridingSystemValue_ = true;
|
| 26 |
+
return this;
|
| 27 |
+
}
|
| 28 |
+
values(values) {
|
| 29 |
+
values = Array.isArray(values) ? values : [values];
|
| 30 |
+
if (values.length === 0) {
|
| 31 |
+
throw new Error("values() must be called with at least one value");
|
| 32 |
+
}
|
| 33 |
+
const mappedValues = values.map((entry) => {
|
| 34 |
+
const result = {};
|
| 35 |
+
const cols = this.table[Table.Symbol.Columns];
|
| 36 |
+
for (const colKey of Object.keys(entry)) {
|
| 37 |
+
const colValue = entry[colKey];
|
| 38 |
+
result[colKey] = is(colValue, SQL) ? colValue : new Param(colValue, cols[colKey]);
|
| 39 |
+
}
|
| 40 |
+
return result;
|
| 41 |
+
});
|
| 42 |
+
return new GelInsertBase(
|
| 43 |
+
this.table,
|
| 44 |
+
mappedValues,
|
| 45 |
+
this.session,
|
| 46 |
+
this.dialect,
|
| 47 |
+
this.withList,
|
| 48 |
+
false,
|
| 49 |
+
this.overridingSystemValue_
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
select(selectQuery) {
|
| 53 |
+
const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder()) : selectQuery;
|
| 54 |
+
if (!is(select, SQL) && !haveSameKeys(this.table[Columns], select._.selectedFields)) {
|
| 55 |
+
throw new Error(
|
| 56 |
+
"Insert select error: selected fields are not the same or are in a different order compared to the table definition"
|
| 57 |
+
);
|
| 58 |
+
}
|
| 59 |
+
return new GelInsertBase(this.table, select, this.session, this.dialect, this.withList, true);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
class GelInsertBase extends QueryPromise {
|
| 63 |
+
constructor(table, values, session, dialect, withList, select, overridingSystemValue_) {
|
| 64 |
+
super();
|
| 65 |
+
this.session = session;
|
| 66 |
+
this.dialect = dialect;
|
| 67 |
+
this.config = { table, values, withList, select, overridingSystemValue_ };
|
| 68 |
+
}
|
| 69 |
+
static [entityKind] = "GelInsert";
|
| 70 |
+
config;
|
| 71 |
+
returning(fields = this.config.table[Table.Symbol.Columns]) {
|
| 72 |
+
this.config.returning = orderSelectedFields(fields);
|
| 73 |
+
return this;
|
| 74 |
+
}
|
| 75 |
+
/**
|
| 76 |
+
* Adds an `on conflict do nothing` clause to the query.
|
| 77 |
+
*
|
| 78 |
+
* Calling this method simply avoids inserting a row as its alternative action.
|
| 79 |
+
*
|
| 80 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}
|
| 81 |
+
*
|
| 82 |
+
* @param config The `target` and `where` clauses.
|
| 83 |
+
*
|
| 84 |
+
* @example
|
| 85 |
+
* ```ts
|
| 86 |
+
* // Insert one row and cancel the insert if there's a conflict
|
| 87 |
+
* await db.insert(cars)
|
| 88 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 89 |
+
* .onConflictDoNothing();
|
| 90 |
+
*
|
| 91 |
+
* // Explicitly specify conflict target
|
| 92 |
+
* await db.insert(cars)
|
| 93 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 94 |
+
* .onConflictDoNothing({ target: cars.id });
|
| 95 |
+
* ```
|
| 96 |
+
*/
|
| 97 |
+
// TODO not supported
|
| 98 |
+
// onConflictDoNothing(
|
| 99 |
+
// config: { target?: IndexColumn | IndexColumn[]; where?: SQL } = {},
|
| 100 |
+
// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {
|
| 101 |
+
// if (config.target === undefined) {
|
| 102 |
+
// this.config.onConflict = sql`do nothing`;
|
| 103 |
+
// } else {
|
| 104 |
+
// let targetColumn = '';
|
| 105 |
+
// targetColumn = Array.isArray(config.target)
|
| 106 |
+
// ? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')
|
| 107 |
+
// : this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));
|
| 108 |
+
// const whereSql = config.where ? sql` where ${config.where}` : undefined;
|
| 109 |
+
// this.config.onConflict = sql`(${sql.raw(targetColumn)})${whereSql} do nothing`;
|
| 110 |
+
// }
|
| 111 |
+
// return this as any;
|
| 112 |
+
// }
|
| 113 |
+
/**
|
| 114 |
+
* Adds an `on conflict do update` clause to the query.
|
| 115 |
+
*
|
| 116 |
+
* Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.
|
| 117 |
+
*
|
| 118 |
+
* See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts}
|
| 119 |
+
*
|
| 120 |
+
* @param config The `target`, `set` and `where` clauses.
|
| 121 |
+
*
|
| 122 |
+
* @example
|
| 123 |
+
* ```ts
|
| 124 |
+
* // Update the row if there's a conflict
|
| 125 |
+
* await db.insert(cars)
|
| 126 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 127 |
+
* .onConflictDoUpdate({
|
| 128 |
+
* target: cars.id,
|
| 129 |
+
* set: { brand: 'Porsche' }
|
| 130 |
+
* });
|
| 131 |
+
*
|
| 132 |
+
* // Upsert with 'where' clause
|
| 133 |
+
* await db.insert(cars)
|
| 134 |
+
* .values({ id: 1, brand: 'BMW' })
|
| 135 |
+
* .onConflictDoUpdate({
|
| 136 |
+
* target: cars.id,
|
| 137 |
+
* set: { brand: 'newBMW' },
|
| 138 |
+
* targetWhere: sql`${cars.createdAt} > '2023-01-01'::date`,
|
| 139 |
+
* });
|
| 140 |
+
* ```
|
| 141 |
+
*/
|
| 142 |
+
// TODO not supported
|
| 143 |
+
// onConflictDoUpdate(
|
| 144 |
+
// config: GelInsertOnConflictDoUpdateConfig<this>,
|
| 145 |
+
// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {
|
| 146 |
+
// if (config.where && (config.targetWhere || config.setWhere)) {
|
| 147 |
+
// throw new Error(
|
| 148 |
+
// 'You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.',
|
| 149 |
+
// );
|
| 150 |
+
// }
|
| 151 |
+
// const whereSql = config.where ? sql` where ${config.where}` : undefined;
|
| 152 |
+
// const targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : undefined;
|
| 153 |
+
// const setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : undefined;
|
| 154 |
+
// const setSql = this.dialect.buildUpdateSet(this.config.table, mapUpdateSet(this.config.table, config.set));
|
| 155 |
+
// let targetColumn = '';
|
| 156 |
+
// targetColumn = Array.isArray(config.target)
|
| 157 |
+
// ? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')
|
| 158 |
+
// : this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));
|
| 159 |
+
// this.config.onConflict = sql`(${
|
| 160 |
+
// sql.raw(targetColumn)
|
| 161 |
+
// })${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;
|
| 162 |
+
// return this as any;
|
| 163 |
+
// }
|
| 164 |
+
/** @internal */
|
| 165 |
+
getSQL() {
|
| 166 |
+
return this.dialect.buildInsertQuery(this.config);
|
| 167 |
+
}
|
| 168 |
+
toSQL() {
|
| 169 |
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
| 170 |
+
return rest;
|
| 171 |
+
}
|
| 172 |
+
/** @internal */
|
| 173 |
+
_prepare(name) {
|
| 174 |
+
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 175 |
+
return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
| 176 |
+
type: "insert",
|
| 177 |
+
tables: extractUsedTable(this.config.table)
|
| 178 |
+
});
|
| 179 |
+
});
|
| 180 |
+
}
|
| 181 |
+
prepare(name) {
|
| 182 |
+
return this._prepare(name);
|
| 183 |
+
}
|
| 184 |
+
execute = (placeholderValues) => {
|
| 185 |
+
return tracer.startActiveSpan("drizzle.operation", () => {
|
| 186 |
+
return this._prepare().execute(placeholderValues);
|
| 187 |
+
});
|
| 188 |
+
};
|
| 189 |
+
$dynamic() {
|
| 190 |
+
return this;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
export {
|
| 194 |
+
GelInsertBase,
|
| 195 |
+
GelInsertBuilder
|
| 196 |
+
};
|
| 197 |
+
//# sourceMappingURL=insert.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/insert.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/insert.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { IndexColumn } from '~/gel-core/indexes.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport type { GelTable, TableConfig } from '~/gel-core/table.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { SelectResultFields } from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { Placeholder, Query, SQLWrapper } from '~/sql/sql.ts';\nimport { Param, SQL } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport type { InferInsertModel } from '~/table.ts';\nimport { Columns, Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport { haveSameKeys, type NeonAuthToken, orderSelectedFields } from '~/utils.ts';\nimport type { AnyGelColumn, GelColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport { QueryBuilder } from './query-builder.ts';\nimport type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts';\nimport type { GelUpdateSetSource } from './update.ts';\n\nexport interface GelInsertConfig<TTable extends GelTable = GelTable> {\n\ttable: TTable;\n\tvalues: Record<string, Param | SQL>[] | GelInsertSelectQueryBuilder<TTable> | SQL;\n\twithList?: Subquery[];\n\tonConflict?: SQL;\n\treturning?: SelectedFieldsOrdered;\n\tselect?: boolean;\n\toverridingSystemValue_?: boolean;\n}\n\nexport type GelInsertValue<TTable extends GelTable<TableConfig>, OverrideT extends boolean = false> =\n\t& {\n\t\t[Key in keyof InferInsertModel<TTable, { dbColumnNames: false; override: OverrideT }>]:\n\t\t\t| InferInsertModel<TTable, { dbColumnNames: false; override: OverrideT }>[Key]\n\t\t\t| SQL\n\t\t\t| Placeholder;\n\t}\n\t& {};\n\nexport type GelInsertSelectQueryBuilder<TTable extends GelTable> = TypedQueryBuilder<\n\t{ [K in keyof TTable['$inferInsert']]: AnyGelColumn | SQL | SQL.Aliased | TTable['$inferInsert'][K] }\n>;\n\nexport class GelInsertBuilder<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tOverrideT extends boolean = false,\n> {\n\tstatic readonly [entityKind]: string = 'GelInsertBuilder';\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\tprivate withList?: Subquery[],\n\t\tprivate overridingSystemValue_?: boolean,\n\t) {}\n\n\tprivate authToken?: NeonAuthToken;\n\t/** @internal */\n\tsetToken(token?: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\toverridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'> {\n\t\tthis.overridingSystemValue_ = true;\n\t\treturn this as any;\n\t}\n\n\tvalues(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;\n\tvalues(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;\n\tvalues(\n\t\tvalues: GelInsertValue<TTable, OverrideT> | GelInsertValue<TTable, OverrideT>[],\n\t): GelInsertBase<TTable, TQueryResult> {\n\t\tvalues = Array.isArray(values) ? values : [values];\n\t\tif (values.length === 0) {\n\t\t\tthrow new Error('values() must be called with at least one value');\n\t\t}\n\t\tconst mappedValues = values.map((entry) => {\n\t\t\tconst result: Record<string, Param | SQL> = {};\n\t\t\tconst cols = this.table[Table.Symbol.Columns];\n\t\t\tfor (const colKey of Object.keys(entry)) {\n\t\t\t\tconst colValue = entry[colKey as keyof typeof entry];\n\t\t\t\tresult[colKey] = is(colValue, SQL) ? colValue : new Param(colValue, cols[colKey]);\n\t\t\t}\n\t\t\treturn result;\n\t\t});\n\n\t\treturn new GelInsertBase(\n\t\t\tthis.table,\n\t\t\tmappedValues,\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t\tfalse,\n\t\t\tthis.overridingSystemValue_,\n\t\t);\n\t}\n\n\tselect(selectQuery: (qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: (qb: QueryBuilder) => SQL): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: SQL): GelInsertBase<TTable, TQueryResult>;\n\tselect(selectQuery: GelInsertSelectQueryBuilder<TTable>): GelInsertBase<TTable, TQueryResult>;\n\tselect(\n\t\tselectQuery:\n\t\t\t| SQL\n\t\t\t| GelInsertSelectQueryBuilder<TTable>\n\t\t\t| ((qb: QueryBuilder) => GelInsertSelectQueryBuilder<TTable> | SQL),\n\t): GelInsertBase<TTable, TQueryResult> {\n\t\tconst select = typeof selectQuery === 'function' ? selectQuery(new QueryBuilder()) : selectQuery;\n\n\t\tif (\n\t\t\t!is(select, SQL)\n\t\t\t&& !haveSameKeys(this.table[Columns], select._.selectedFields)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Insert select error: selected fields are not the same or are in a different order compared to the table definition',\n\t\t\t);\n\t\t}\n\n\t\treturn new GelInsertBase(this.table, select, this.session, this.dialect, this.withList, true);\n\t}\n}\n\nexport type GelInsertWithout<T extends AnyGelInsert, TDynamic extends boolean, K extends keyof T & string> =\n\tTDynamic extends true ? T\n\t\t: Omit<\n\t\t\tGelInsertBase<\n\t\t\t\tT['_']['table'],\n\t\t\t\tT['_']['queryResult'],\n\t\t\t\tT['_']['returning'],\n\t\t\t\tTDynamic,\n\t\t\t\tT['_']['excludedMethods'] | K\n\t\t\t>,\n\t\t\tT['_']['excludedMethods'] | K\n\t\t>;\n\nexport type GelInsertReturning<\n\tT extends AnyGelInsert,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFieldsFlat,\n> = GelInsertBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tSelectResultFields<TSelectedFields>,\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\nexport type GelInsertReturningAll<T extends AnyGelInsert, TDynamic extends boolean> = GelInsertBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['table']['$inferSelect'],\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\nexport interface GelInsertOnConflictDoUpdateConfig<T extends AnyGelInsert> {\n\ttarget: IndexColumn | IndexColumn[];\n\t/** @deprecated use either `targetWhere` or `setWhere` */\n\twhere?: SQL;\n\t// TODO: add tests for targetWhere and setWhere\n\ttargetWhere?: SQL;\n\tsetWhere?: SQL;\n\tset: GelUpdateSetSource<T['_']['table']>;\n}\n\nexport type GelInsertPrepare<T extends AnyGelInsert> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelInsertDynamic<T extends AnyGelInsert> = GelInsert<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['returning']\n>;\n\nexport type AnyGelInsert = GelInsertBase<any, any, any, any, any>;\n\nexport type GelInsert<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n> = GelInsertBase<TTable, TQueryResult, TReturning, true, never>;\n\nexport interface GelInsertBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelInsertBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTReturning extends Record<string, unknown> | undefined = 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 ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelInsert';\n\n\tprivate config: GelInsertConfig<TTable>;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tvalues: GelInsertConfig['values'],\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t\tselect?: boolean,\n\t\toverridingSystemValue_?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.config = { table, values: values as any, withList, select, overridingSystemValue_ };\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 inserted rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Insert one row and return all fields\n\t * const insertedCar: Car[] = await db.insert(cars)\n\t * .values({ brand: 'BMW' })\n\t * .returning();\n\t *\n\t * // Insert one row and return only the id\n\t * const insertedCarId: { id: number }[] = await db.insert(cars)\n\t * .values({ brand: 'BMW' })\n\t * .returning({ id: cars.id });\n\t * ```\n\t */\n\treturning(): GelInsertWithout<GelInsertReturningAll<this, TDynamic>, TDynamic, 'returning'>;\n\treturning<TSelectedFields extends SelectedFieldsFlat>(\n\t\tfields: TSelectedFields,\n\t): GelInsertWithout<GelInsertReturning<this, TDynamic, TSelectedFields>, TDynamic, 'returning'>;\n\treturning(\n\t\tfields: SelectedFieldsFlat = this.config.table[Table.Symbol.Columns],\n\t): GelInsertWithout<AnyGelInsert, TDynamic, 'returning'> {\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `on conflict do nothing` clause to the query.\n\t *\n\t * Calling this method simply avoids inserting a row as its alternative action.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}\n\t *\n\t * @param config The `target` and `where` clauses.\n\t *\n\t * @example\n\t * ```ts\n\t * // Insert one row and cancel the insert if there's a conflict\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoNothing();\n\t *\n\t * // Explicitly specify conflict target\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoNothing({ target: cars.id });\n\t * ```\n\t */\n\t// TODO not supported\n\t// onConflictDoNothing(\n\t// \tconfig: { target?: IndexColumn | IndexColumn[]; where?: SQL } = {},\n\t// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {\n\t// \tif (config.target === undefined) {\n\t// \t\tthis.config.onConflict = sql`do nothing`;\n\t// \t} else {\n\t// \t\tlet targetColumn = '';\n\t// \t\ttargetColumn = Array.isArray(config.target)\n\t// \t\t\t? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')\n\t// \t\t\t: this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));\n\n\t// \t\tconst whereSql = config.where ? sql` where ${config.where}` : undefined;\n\t// \t\tthis.config.onConflict = sql`(${sql.raw(targetColumn)})${whereSql} do nothing`;\n\t// \t}\n\t// \treturn this as any;\n\t// }\n\n\t/**\n\t * Adds an `on conflict do update` clause to the query.\n\t *\n\t * Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts}\n\t *\n\t * @param config The `target`, `set` and `where` clauses.\n\t *\n\t * @example\n\t * ```ts\n\t * // Update the row if there's a conflict\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoUpdate({\n\t * target: cars.id,\n\t * set: { brand: 'Porsche' }\n\t * });\n\t *\n\t * // Upsert with 'where' clause\n\t * await db.insert(cars)\n\t * .values({ id: 1, brand: 'BMW' })\n\t * .onConflictDoUpdate({\n\t * target: cars.id,\n\t * set: { brand: 'newBMW' },\n\t * targetWhere: sql`${cars.createdAt} > '2023-01-01'::date`,\n\t * });\n\t * ```\n\t */\n\t// TODO not supported\n\t// onConflictDoUpdate(\n\t// \tconfig: GelInsertOnConflictDoUpdateConfig<this>,\n\t// ): GelInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {\n\t// \tif (config.where && (config.targetWhere || config.setWhere)) {\n\t// \t\tthrow new Error(\n\t// \t\t\t'You cannot use both \"where\" and \"targetWhere\"/\"setWhere\" at the same time - \"where\" is deprecated, use \"targetWhere\" or \"setWhere\" instead.',\n\t// \t\t);\n\t// \t}\n\t// \tconst whereSql = config.where ? sql` where ${config.where}` : undefined;\n\t// \tconst targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : undefined;\n\t// \tconst setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : undefined;\n\t// \tconst setSql = this.dialect.buildUpdateSet(this.config.table, mapUpdateSet(this.config.table, config.set));\n\t// \tlet targetColumn = '';\n\t// \ttargetColumn = Array.isArray(config.target)\n\t// \t\t? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')\n\t// \t\t: this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));\n\t// \tthis.config.onConflict = sql`(${\n\t// \t\tsql.raw(targetColumn)\n\t// \t})${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;\n\t// \treturn this as any;\n\t// }\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildInsertQuery(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(name?: string): GelInsertPrepare<this> {\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\treturn this.session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & {\n\t\t\t\t\texecute: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t\t\t\t}\n\t\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {\n\t\t\t\ttype: 'insert',\n\t\t\t\ttables: extractUsedTable(this.config.table),\n\t\t\t});\n\t\t});\n\t}\n\n\tprepare(name: string): GelInsertPrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n\n\t$dynamic(): GelInsertDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAa/B,SAAS,oBAAoB;AAG7B,SAAS,OAAO,WAAW;AAG3B,SAAS,SAAS,aAAa;AAC/B,SAAS,cAAc;AACvB,SAAS,cAAkC,2BAA2B;AAEtE,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AA2BtB,MAAM,iBAIX;AAAA,EAGD,YACS,OACA,SACA,SACA,UACA,wBACP;AALO;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EARH,QAAiB,UAAU,IAAY;AAAA,EAU/B;AAAA;AAAA,EAER,SAAS,OAAuB;AAC/B,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AAAA,EAEA,wBAAqG;AACpG,SAAK,yBAAyB;AAC9B,WAAO;AAAA,EACR;AAAA,EAIA,OACC,QACsC;AACtC,aAAS,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD,QAAI,OAAO,WAAW,GAAG;AACxB,YAAM,IAAI,MAAM,iDAAiD;AAAA,IAClE;AACA,UAAM,eAAe,OAAO,IAAI,CAAC,UAAU;AAC1C,YAAM,SAAsC,CAAC;AAC7C,YAAM,OAAO,KAAK,MAAM,MAAM,OAAO,OAAO;AAC5C,iBAAW,UAAU,OAAO,KAAK,KAAK,GAAG;AACxC,cAAM,WAAW,MAAM,MAA4B;AACnD,eAAO,MAAM,IAAI,GAAG,UAAU,GAAG,IAAI,WAAW,IAAI,MAAM,UAAU,KAAK,MAAM,CAAC;AAAA,MACjF;AACA,aAAO;AAAA,IACR,CAAC;AAED,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAMA,OACC,aAIsC;AACtC,UAAM,SAAS,OAAO,gBAAgB,aAAa,YAAY,IAAI,aAAa,CAAC,IAAI;AAErF,QACC,CAAC,GAAG,QAAQ,GAAG,KACZ,CAAC,aAAa,KAAK,MAAM,OAAO,GAAG,OAAO,EAAE,cAAc,GAC5D;AACD,YAAM,IAAI;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAEA,WAAO,IAAI,cAAc,KAAK,OAAO,QAAQ,KAAK,SAAS,KAAK,SAAS,KAAK,UAAU,IAAI;AAAA,EAC7F;AACD;AAwFO,MAAM,sBAQH,aAIV;AAAA,EAKC,YACC,OACA,QACQ,SACA,SACR,UACA,QACA,wBACC;AACD,UAAM;AANE;AACA;AAMR,SAAK,SAAS,EAAE,OAAO,QAAuB,UAAU,QAAQ,uBAAuB;AAAA,EACxF;AAAA,EAfA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA,EAuCR,UACC,SAA6B,KAAK,OAAO,MAAM,MAAM,OAAO,OAAO,GACX;AACxD,SAAK,OAAO,YAAY,oBAA+B,MAAM;AAC7D,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+FA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAS,MAAuC;AAC/C,WAAO,OAAO,gBAAgB,wBAAwB,MAAM;AAC3D,aAAO,KAAK,QAAQ,aAIlB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,GAAG,KAAK,OAAO,WAAW,MAAM,MAAM,QAAW;AAAA,QACvF,MAAM;AAAA,QACN,QAAQ,iBAAiB,KAAK,OAAO,KAAK;AAAA,MAC3C,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA,EAEA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,OAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,IACjD,CAAC;AAAA,EACF;AAAA,EAEA,WAAmC;AAClC,WAAO;AAAA,EACR;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.cjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 query_builder_exports = {};
|
| 20 |
+
__export(query_builder_exports, {
|
| 21 |
+
QueryBuilder: () => QueryBuilder
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(query_builder_exports);
|
| 24 |
+
var import_entity = require("../../entity.cjs");
|
| 25 |
+
var import_dialect = require("../dialect.cjs");
|
| 26 |
+
var import_selection_proxy = require("../../selection-proxy.cjs");
|
| 27 |
+
var import_subquery = require("../../subquery.cjs");
|
| 28 |
+
var import_select = require("./select.cjs");
|
| 29 |
+
class QueryBuilder {
|
| 30 |
+
static [import_entity.entityKind] = "GelQueryBuilder";
|
| 31 |
+
dialect;
|
| 32 |
+
dialectConfig;
|
| 33 |
+
constructor(dialect) {
|
| 34 |
+
this.dialect = (0, import_entity.is)(dialect, import_dialect.GelDialect) ? dialect : void 0;
|
| 35 |
+
this.dialectConfig = (0, import_entity.is)(dialect, import_dialect.GelDialect) ? void 0 : dialect;
|
| 36 |
+
}
|
| 37 |
+
$with(alias) {
|
| 38 |
+
const queryBuilder = this;
|
| 39 |
+
return {
|
| 40 |
+
as(qb) {
|
| 41 |
+
if (typeof qb === "function") {
|
| 42 |
+
qb = qb(queryBuilder);
|
| 43 |
+
}
|
| 44 |
+
return new Proxy(
|
| 45 |
+
new import_subquery.WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true),
|
| 46 |
+
new import_selection_proxy.SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
| 47 |
+
);
|
| 48 |
+
}
|
| 49 |
+
};
|
| 50 |
+
}
|
| 51 |
+
with(...queries) {
|
| 52 |
+
const self = this;
|
| 53 |
+
function select(fields) {
|
| 54 |
+
return new import_select.GelSelectBuilder({
|
| 55 |
+
fields: fields ?? void 0,
|
| 56 |
+
session: void 0,
|
| 57 |
+
dialect: self.getDialect(),
|
| 58 |
+
withList: queries
|
| 59 |
+
});
|
| 60 |
+
}
|
| 61 |
+
function selectDistinct(fields) {
|
| 62 |
+
return new import_select.GelSelectBuilder({
|
| 63 |
+
fields: fields ?? void 0,
|
| 64 |
+
session: void 0,
|
| 65 |
+
dialect: self.getDialect(),
|
| 66 |
+
distinct: true
|
| 67 |
+
});
|
| 68 |
+
}
|
| 69 |
+
function selectDistinctOn(on, fields) {
|
| 70 |
+
return new import_select.GelSelectBuilder({
|
| 71 |
+
fields: fields ?? void 0,
|
| 72 |
+
session: void 0,
|
| 73 |
+
dialect: self.getDialect(),
|
| 74 |
+
distinct: { on }
|
| 75 |
+
});
|
| 76 |
+
}
|
| 77 |
+
return { select, selectDistinct, selectDistinctOn };
|
| 78 |
+
}
|
| 79 |
+
select(fields) {
|
| 80 |
+
return new import_select.GelSelectBuilder({
|
| 81 |
+
fields: fields ?? void 0,
|
| 82 |
+
session: void 0,
|
| 83 |
+
dialect: this.getDialect()
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
selectDistinct(fields) {
|
| 87 |
+
return new import_select.GelSelectBuilder({
|
| 88 |
+
fields: fields ?? void 0,
|
| 89 |
+
session: void 0,
|
| 90 |
+
dialect: this.getDialect(),
|
| 91 |
+
distinct: true
|
| 92 |
+
});
|
| 93 |
+
}
|
| 94 |
+
selectDistinctOn(on, fields) {
|
| 95 |
+
return new import_select.GelSelectBuilder({
|
| 96 |
+
fields: fields ?? void 0,
|
| 97 |
+
session: void 0,
|
| 98 |
+
dialect: this.getDialect(),
|
| 99 |
+
distinct: { on }
|
| 100 |
+
});
|
| 101 |
+
}
|
| 102 |
+
// Lazy load dialect to avoid circular dependency
|
| 103 |
+
getDialect() {
|
| 104 |
+
if (!this.dialect) {
|
| 105 |
+
this.dialect = new import_dialect.GelDialect(this.dialectConfig);
|
| 106 |
+
}
|
| 107 |
+
return this.dialect;
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 111 |
+
0 && (module.exports = {
|
| 112 |
+
QueryBuilder
|
| 113 |
+
});
|
| 114 |
+
//# sourceMappingURL=query-builder.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/query-builder.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport type { GelDialectConfig } from '~/gel-core/dialect.ts';\nimport { GelDialect } from '~/gel-core/dialect.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { ColumnsSelection, SQLWrapper } from '~/sql/sql.ts';\nimport { WithSubquery } from '~/subquery.ts';\nimport type { GelColumn } from '../columns/index.ts';\nimport type { WithSubqueryWithSelection } from '../subquery.ts';\nimport { GelSelectBuilder } from './select.ts';\nimport type { SelectedFields } from './select.types.ts';\n\nexport class QueryBuilder {\n\tstatic readonly [entityKind]: string = 'GelQueryBuilder';\n\n\tprivate dialect: GelDialect | undefined;\n\tprivate dialectConfig: GelDialectConfig | undefined;\n\n\tconstructor(dialect?: GelDialect | GelDialectConfig) {\n\t\tthis.dialect = is(dialect, GelDialect) ? dialect : undefined;\n\t\tthis.dialectConfig = is(dialect, GelDialect) ? undefined : dialect;\n\t}\n\n\t$with<TAlias extends string>(alias: TAlias) {\n\t\tconst queryBuilder = this;\n\n\t\treturn {\n\t\t\tas<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\tif (typeof qb === 'function') {\n\t\t\t\t\tqb = qb(queryBuilder);\n\t\t\t\t}\n\n\t\t\t\treturn new Proxy(\n\t\t\t\t\tnew WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),\n\t\t\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t\t\t) as WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t},\n\t\t};\n\t}\n\n\twith(...queries: WithSubquery[]) {\n\t\tconst self = this;\n\n\t\tfunction select(): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction select<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction select<TSelection extends SelectedFields>(\n\t\t\tfields?: TSelection,\n\t\t): GelSelectBuilder<TSelection | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\twithList: queries,\n\t\t\t});\n\t\t}\n\n\t\tfunction selectDistinct(): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction selectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction selectDistinct(fields?: SelectedFields): GelSelectBuilder<SelectedFields | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\tdistinct: true,\n\t\t\t});\n\t\t}\n\n\t\tfunction selectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction selectDistinctOn<TSelection extends SelectedFields>(\n\t\t\ton: (GelColumn | SQLWrapper)[],\n\t\t\tfields: TSelection,\n\t\t): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction selectDistinctOn(\n\t\t\ton: (GelColumn | SQLWrapper)[],\n\t\t\tfields?: SelectedFields,\n\t\t): GelSelectBuilder<SelectedFields | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\tdistinct: { on },\n\t\t\t});\n\t\t}\n\n\t\treturn { select, selectDistinct, selectDistinctOn };\n\t}\n\n\tselect(): GelSelectBuilder<undefined, 'qb'>;\n\tselect<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\tselect<TSelection extends SelectedFields>(fields?: TSelection): GelSelectBuilder<TSelection | undefined, 'qb'> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t});\n\t}\n\n\tselectDistinct(): GelSelectBuilder<undefined>;\n\tselectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection>;\n\tselectDistinct(fields?: SelectedFields): GelSelectBuilder<SelectedFields | undefined> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t\tdistinct: true,\n\t\t});\n\t}\n\n\tselectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined>;\n\tselectDistinctOn<TSelection extends SelectedFields>(\n\t\ton: (GelColumn | SQLWrapper)[],\n\t\tfields: TSelection,\n\t): GelSelectBuilder<TSelection>;\n\tselectDistinctOn(\n\t\ton: (GelColumn | SQLWrapper)[],\n\t\tfields?: SelectedFields,\n\t): GelSelectBuilder<SelectedFields | undefined> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t\tdistinct: { on },\n\t\t});\n\t}\n\n\t// Lazy load dialect to avoid circular dependency\n\tprivate getDialect() {\n\t\tif (!this.dialect) {\n\t\t\tthis.dialect = new GelDialect(this.dialectConfig);\n\t\t}\n\n\t\treturn this.dialect;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAE/B,qBAA2B;AAE3B,6BAAsC;AAEtC,sBAA6B;AAG7B,oBAAiC;AAG1B,MAAM,aAAa;AAAA,EACzB,QAAiB,wBAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EAER,YAAY,SAAyC;AACpD,SAAK,cAAU,kBAAG,SAAS,yBAAU,IAAI,UAAU;AACnD,SAAK,oBAAgB,kBAAG,SAAS,yBAAU,IAAI,SAAY;AAAA,EAC5D;AAAA,EAEA,MAA6B,OAAe;AAC3C,UAAM,eAAe;AAErB,WAAO;AAAA,MACN,GACC,IACgD;AAChD,YAAI,OAAO,OAAO,YAAY;AAC7B,eAAK,GAAG,YAAY;AAAA,QACrB;AAEA,eAAO,IAAI;AAAA,UACV,IAAI,6BAAa,GAAG,OAAO,GAAG,GAAG,kBAAkB,GAAqB,OAAO,IAAI;AAAA,UACnF,IAAI,6CAAsB,EAAE,OAAO,oBAAoB,SAAS,aAAa,QAAQ,CAAC;AAAA,QACvF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,QAAQ,SAAyB;AAChC,UAAM,OAAO;AAIb,aAAS,OACR,QACiD;AACjD,aAAO,IAAI,+BAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU;AAAA,MACX,CAAC;AAAA,IACF;AAIA,aAAS,eAAe,QAA6E;AACpG,aAAO,IAAI,+BAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU;AAAA,MACX,CAAC;AAAA,IACF;AAOA,aAAS,iBACR,IACA,QACqD;AACrD,aAAO,IAAI,+BAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU,EAAE,GAAG;AAAA,MAChB,CAAC;AAAA,IACF;AAEA,WAAO,EAAE,QAAQ,gBAAgB,iBAAiB;AAAA,EACnD;AAAA,EAIA,OAA0C,QAAqE;AAC9G,WAAO,IAAI,+BAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,IAC1B,CAAC;AAAA,EACF;AAAA,EAIA,eAAe,QAAuE;AACrF,WAAO,IAAI,+BAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,MACzB,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EAOA,iBACC,IACA,QAC+C;AAC/C,WAAO,IAAI,+BAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,MACzB,UAAU,EAAE,GAAG;AAAA,IAChB,CAAC;AAAA,EACF;AAAA;AAAA,EAGQ,aAAa;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,WAAK,UAAU,IAAI,0BAAW,KAAK,aAAa;AAAA,IACjD;AAEA,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.d.cts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.cjs";
|
| 2 |
+
import type { GelDialectConfig } from "../dialect.cjs";
|
| 3 |
+
import { GelDialect } from "../dialect.cjs";
|
| 4 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.cjs";
|
| 5 |
+
import type { ColumnsSelection, SQLWrapper } from "../../sql/sql.cjs";
|
| 6 |
+
import { WithSubquery } from "../../subquery.cjs";
|
| 7 |
+
import type { GelColumn } from "../columns/index.cjs";
|
| 8 |
+
import type { WithSubqueryWithSelection } from "../subquery.cjs";
|
| 9 |
+
import { GelSelectBuilder } from "./select.cjs";
|
| 10 |
+
import type { SelectedFields } from "./select.types.cjs";
|
| 11 |
+
export declare class QueryBuilder {
|
| 12 |
+
static readonly [entityKind]: string;
|
| 13 |
+
private dialect;
|
| 14 |
+
private dialectConfig;
|
| 15 |
+
constructor(dialect?: GelDialect | GelDialectConfig);
|
| 16 |
+
$with<TAlias extends string>(alias: TAlias): {
|
| 17 |
+
as<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
|
| 18 |
+
};
|
| 19 |
+
with(...queries: WithSubquery[]): {
|
| 20 |
+
select: {
|
| 21 |
+
(): GelSelectBuilder<undefined, "qb">;
|
| 22 |
+
<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 23 |
+
};
|
| 24 |
+
selectDistinct: {
|
| 25 |
+
(): GelSelectBuilder<undefined, "qb">;
|
| 26 |
+
<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 27 |
+
};
|
| 28 |
+
selectDistinctOn: {
|
| 29 |
+
(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined, "qb">;
|
| 30 |
+
<TSelection extends SelectedFields>(on: (GelColumn | SQLWrapper)[], fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 31 |
+
};
|
| 32 |
+
};
|
| 33 |
+
select(): GelSelectBuilder<undefined, 'qb'>;
|
| 34 |
+
select<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;
|
| 35 |
+
selectDistinct(): GelSelectBuilder<undefined>;
|
| 36 |
+
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection>;
|
| 37 |
+
selectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined>;
|
| 38 |
+
selectDistinctOn<TSelection extends SelectedFields>(on: (GelColumn | SQLWrapper)[], fields: TSelection): GelSelectBuilder<TSelection>;
|
| 39 |
+
private getDialect;
|
| 40 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import type { GelDialectConfig } from "../dialect.js";
|
| 3 |
+
import { GelDialect } from "../dialect.js";
|
| 4 |
+
import type { TypedQueryBuilder } from "../../query-builders/query-builder.js";
|
| 5 |
+
import type { ColumnsSelection, SQLWrapper } from "../../sql/sql.js";
|
| 6 |
+
import { WithSubquery } from "../../subquery.js";
|
| 7 |
+
import type { GelColumn } from "../columns/index.js";
|
| 8 |
+
import type { WithSubqueryWithSelection } from "../subquery.js";
|
| 9 |
+
import { GelSelectBuilder } from "./select.js";
|
| 10 |
+
import type { SelectedFields } from "./select.types.js";
|
| 11 |
+
export declare class QueryBuilder {
|
| 12 |
+
static readonly [entityKind]: string;
|
| 13 |
+
private dialect;
|
| 14 |
+
private dialectConfig;
|
| 15 |
+
constructor(dialect?: GelDialect | GelDialectConfig);
|
| 16 |
+
$with<TAlias extends string>(alias: TAlias): {
|
| 17 |
+
as<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
|
| 18 |
+
};
|
| 19 |
+
with(...queries: WithSubquery[]): {
|
| 20 |
+
select: {
|
| 21 |
+
(): GelSelectBuilder<undefined, "qb">;
|
| 22 |
+
<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 23 |
+
};
|
| 24 |
+
selectDistinct: {
|
| 25 |
+
(): GelSelectBuilder<undefined, "qb">;
|
| 26 |
+
<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 27 |
+
};
|
| 28 |
+
selectDistinctOn: {
|
| 29 |
+
(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined, "qb">;
|
| 30 |
+
<TSelection extends SelectedFields>(on: (GelColumn | SQLWrapper)[], fields: TSelection): GelSelectBuilder<TSelection, "qb">;
|
| 31 |
+
};
|
| 32 |
+
};
|
| 33 |
+
select(): GelSelectBuilder<undefined, 'qb'>;
|
| 34 |
+
select<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;
|
| 35 |
+
selectDistinct(): GelSelectBuilder<undefined>;
|
| 36 |
+
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection>;
|
| 37 |
+
selectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined>;
|
| 38 |
+
selectDistinctOn<TSelection extends SelectedFields>(on: (GelColumn | SQLWrapper)[], fields: TSelection): GelSelectBuilder<TSelection>;
|
| 39 |
+
private getDialect;
|
| 40 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind, is } from "../../entity.js";
|
| 2 |
+
import { GelDialect } from "../dialect.js";
|
| 3 |
+
import { SelectionProxyHandler } from "../../selection-proxy.js";
|
| 4 |
+
import { WithSubquery } from "../../subquery.js";
|
| 5 |
+
import { GelSelectBuilder } from "./select.js";
|
| 6 |
+
class QueryBuilder {
|
| 7 |
+
static [entityKind] = "GelQueryBuilder";
|
| 8 |
+
dialect;
|
| 9 |
+
dialectConfig;
|
| 10 |
+
constructor(dialect) {
|
| 11 |
+
this.dialect = is(dialect, GelDialect) ? dialect : void 0;
|
| 12 |
+
this.dialectConfig = is(dialect, GelDialect) ? void 0 : dialect;
|
| 13 |
+
}
|
| 14 |
+
$with(alias) {
|
| 15 |
+
const queryBuilder = this;
|
| 16 |
+
return {
|
| 17 |
+
as(qb) {
|
| 18 |
+
if (typeof qb === "function") {
|
| 19 |
+
qb = qb(queryBuilder);
|
| 20 |
+
}
|
| 21 |
+
return new Proxy(
|
| 22 |
+
new WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true),
|
| 23 |
+
new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
| 24 |
+
);
|
| 25 |
+
}
|
| 26 |
+
};
|
| 27 |
+
}
|
| 28 |
+
with(...queries) {
|
| 29 |
+
const self = this;
|
| 30 |
+
function select(fields) {
|
| 31 |
+
return new GelSelectBuilder({
|
| 32 |
+
fields: fields ?? void 0,
|
| 33 |
+
session: void 0,
|
| 34 |
+
dialect: self.getDialect(),
|
| 35 |
+
withList: queries
|
| 36 |
+
});
|
| 37 |
+
}
|
| 38 |
+
function selectDistinct(fields) {
|
| 39 |
+
return new GelSelectBuilder({
|
| 40 |
+
fields: fields ?? void 0,
|
| 41 |
+
session: void 0,
|
| 42 |
+
dialect: self.getDialect(),
|
| 43 |
+
distinct: true
|
| 44 |
+
});
|
| 45 |
+
}
|
| 46 |
+
function selectDistinctOn(on, fields) {
|
| 47 |
+
return new GelSelectBuilder({
|
| 48 |
+
fields: fields ?? void 0,
|
| 49 |
+
session: void 0,
|
| 50 |
+
dialect: self.getDialect(),
|
| 51 |
+
distinct: { on }
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
return { select, selectDistinct, selectDistinctOn };
|
| 55 |
+
}
|
| 56 |
+
select(fields) {
|
| 57 |
+
return new GelSelectBuilder({
|
| 58 |
+
fields: fields ?? void 0,
|
| 59 |
+
session: void 0,
|
| 60 |
+
dialect: this.getDialect()
|
| 61 |
+
});
|
| 62 |
+
}
|
| 63 |
+
selectDistinct(fields) {
|
| 64 |
+
return new GelSelectBuilder({
|
| 65 |
+
fields: fields ?? void 0,
|
| 66 |
+
session: void 0,
|
| 67 |
+
dialect: this.getDialect(),
|
| 68 |
+
distinct: true
|
| 69 |
+
});
|
| 70 |
+
}
|
| 71 |
+
selectDistinctOn(on, fields) {
|
| 72 |
+
return new GelSelectBuilder({
|
| 73 |
+
fields: fields ?? void 0,
|
| 74 |
+
session: void 0,
|
| 75 |
+
dialect: this.getDialect(),
|
| 76 |
+
distinct: { on }
|
| 77 |
+
});
|
| 78 |
+
}
|
| 79 |
+
// Lazy load dialect to avoid circular dependency
|
| 80 |
+
getDialect() {
|
| 81 |
+
if (!this.dialect) {
|
| 82 |
+
this.dialect = new GelDialect(this.dialectConfig);
|
| 83 |
+
}
|
| 84 |
+
return this.dialect;
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
export {
|
| 88 |
+
QueryBuilder
|
| 89 |
+
};
|
| 90 |
+
//# sourceMappingURL=query-builder.js.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query-builder.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/query-builder.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport type { GelDialectConfig } from '~/gel-core/dialect.ts';\nimport { GelDialect } from '~/gel-core/dialect.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { ColumnsSelection, SQLWrapper } from '~/sql/sql.ts';\nimport { WithSubquery } from '~/subquery.ts';\nimport type { GelColumn } from '../columns/index.ts';\nimport type { WithSubqueryWithSelection } from '../subquery.ts';\nimport { GelSelectBuilder } from './select.ts';\nimport type { SelectedFields } from './select.types.ts';\n\nexport class QueryBuilder {\n\tstatic readonly [entityKind]: string = 'GelQueryBuilder';\n\n\tprivate dialect: GelDialect | undefined;\n\tprivate dialectConfig: GelDialectConfig | undefined;\n\n\tconstructor(dialect?: GelDialect | GelDialectConfig) {\n\t\tthis.dialect = is(dialect, GelDialect) ? dialect : undefined;\n\t\tthis.dialectConfig = is(dialect, GelDialect) ? undefined : dialect;\n\t}\n\n\t$with<TAlias extends string>(alias: TAlias) {\n\t\tconst queryBuilder = this;\n\n\t\treturn {\n\t\t\tas<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\tif (typeof qb === 'function') {\n\t\t\t\t\tqb = qb(queryBuilder);\n\t\t\t\t}\n\n\t\t\t\treturn new Proxy(\n\t\t\t\t\tnew WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),\n\t\t\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t\t\t) as WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t},\n\t\t};\n\t}\n\n\twith(...queries: WithSubquery[]) {\n\t\tconst self = this;\n\n\t\tfunction select(): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction select<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction select<TSelection extends SelectedFields>(\n\t\t\tfields?: TSelection,\n\t\t): GelSelectBuilder<TSelection | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\twithList: queries,\n\t\t\t});\n\t\t}\n\n\t\tfunction selectDistinct(): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction selectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction selectDistinct(fields?: SelectedFields): GelSelectBuilder<SelectedFields | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\tdistinct: true,\n\t\t\t});\n\t\t}\n\n\t\tfunction selectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined, 'qb'>;\n\t\tfunction selectDistinctOn<TSelection extends SelectedFields>(\n\t\t\ton: (GelColumn | SQLWrapper)[],\n\t\t\tfields: TSelection,\n\t\t): GelSelectBuilder<TSelection, 'qb'>;\n\t\tfunction selectDistinctOn(\n\t\t\ton: (GelColumn | SQLWrapper)[],\n\t\t\tfields?: SelectedFields,\n\t\t): GelSelectBuilder<SelectedFields | undefined, 'qb'> {\n\t\t\treturn new GelSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: undefined,\n\t\t\t\tdialect: self.getDialect(),\n\t\t\t\tdistinct: { on },\n\t\t\t});\n\t\t}\n\n\t\treturn { select, selectDistinct, selectDistinctOn };\n\t}\n\n\tselect(): GelSelectBuilder<undefined, 'qb'>;\n\tselect<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection, 'qb'>;\n\tselect<TSelection extends SelectedFields>(fields?: TSelection): GelSelectBuilder<TSelection | undefined, 'qb'> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t});\n\t}\n\n\tselectDistinct(): GelSelectBuilder<undefined>;\n\tselectDistinct<TSelection extends SelectedFields>(fields: TSelection): GelSelectBuilder<TSelection>;\n\tselectDistinct(fields?: SelectedFields): GelSelectBuilder<SelectedFields | undefined> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t\tdistinct: true,\n\t\t});\n\t}\n\n\tselectDistinctOn(on: (GelColumn | SQLWrapper)[]): GelSelectBuilder<undefined>;\n\tselectDistinctOn<TSelection extends SelectedFields>(\n\t\ton: (GelColumn | SQLWrapper)[],\n\t\tfields: TSelection,\n\t): GelSelectBuilder<TSelection>;\n\tselectDistinctOn(\n\t\ton: (GelColumn | SQLWrapper)[],\n\t\tfields?: SelectedFields,\n\t): GelSelectBuilder<SelectedFields | undefined> {\n\t\treturn new GelSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: undefined,\n\t\t\tdialect: this.getDialect(),\n\t\t\tdistinct: { on },\n\t\t});\n\t}\n\n\t// Lazy load dialect to avoid circular dependency\n\tprivate getDialect() {\n\t\tif (!this.dialect) {\n\t\t\tthis.dialect = new GelDialect(this.dialectConfig);\n\t\t}\n\n\t\treturn this.dialect;\n\t}\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAE/B,SAAS,kBAAkB;AAE3B,SAAS,6BAA6B;AAEtC,SAAS,oBAAoB;AAG7B,SAAS,wBAAwB;AAG1B,MAAM,aAAa;AAAA,EACzB,QAAiB,UAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EAER,YAAY,SAAyC;AACpD,SAAK,UAAU,GAAG,SAAS,UAAU,IAAI,UAAU;AACnD,SAAK,gBAAgB,GAAG,SAAS,UAAU,IAAI,SAAY;AAAA,EAC5D;AAAA,EAEA,MAA6B,OAAe;AAC3C,UAAM,eAAe;AAErB,WAAO;AAAA,MACN,GACC,IACgD;AAChD,YAAI,OAAO,OAAO,YAAY;AAC7B,eAAK,GAAG,YAAY;AAAA,QACrB;AAEA,eAAO,IAAI;AAAA,UACV,IAAI,aAAa,GAAG,OAAO,GAAG,GAAG,kBAAkB,GAAqB,OAAO,IAAI;AAAA,UACnF,IAAI,sBAAsB,EAAE,OAAO,oBAAoB,SAAS,aAAa,QAAQ,CAAC;AAAA,QACvF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,QAAQ,SAAyB;AAChC,UAAM,OAAO;AAIb,aAAS,OACR,QACiD;AACjD,aAAO,IAAI,iBAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU;AAAA,MACX,CAAC;AAAA,IACF;AAIA,aAAS,eAAe,QAA6E;AACpG,aAAO,IAAI,iBAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU;AAAA,MACX,CAAC;AAAA,IACF;AAOA,aAAS,iBACR,IACA,QACqD;AACrD,aAAO,IAAI,iBAAiB;AAAA,QAC3B,QAAQ,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,SAAS,KAAK,WAAW;AAAA,QACzB,UAAU,EAAE,GAAG;AAAA,MAChB,CAAC;AAAA,IACF;AAEA,WAAO,EAAE,QAAQ,gBAAgB,iBAAiB;AAAA,EACnD;AAAA,EAIA,OAA0C,QAAqE;AAC9G,WAAO,IAAI,iBAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,IAC1B,CAAC;AAAA,EACF;AAAA,EAIA,eAAe,QAAuE;AACrF,WAAO,IAAI,iBAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,MACzB,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EAOA,iBACC,IACA,QAC+C;AAC/C,WAAO,IAAI,iBAAiB;AAAA,MAC3B,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,SAAS,KAAK,WAAW;AAAA,MACzB,UAAU,EAAE,GAAG;AAAA,IAChB,CAAC;AAAA,EACF;AAAA;AAAA,EAGQ,aAAa;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,WAAK,UAAU,IAAI,WAAW,KAAK,aAAa;AAAA,IACjD;AAEA,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.cjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 query_exports = {};
|
| 20 |
+
__export(query_exports, {
|
| 21 |
+
GelRelationalQuery: () => GelRelationalQuery,
|
| 22 |
+
RelationalQueryBuilder: () => RelationalQueryBuilder
|
| 23 |
+
});
|
| 24 |
+
module.exports = __toCommonJS(query_exports);
|
| 25 |
+
var import_entity = require("../../entity.cjs");
|
| 26 |
+
var import_query_promise = require("../../query-promise.cjs");
|
| 27 |
+
var import_relations = require("../../relations.cjs");
|
| 28 |
+
var import_tracing = require("../../tracing.cjs");
|
| 29 |
+
class RelationalQueryBuilder {
|
| 30 |
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
| 31 |
+
this.fullSchema = fullSchema;
|
| 32 |
+
this.schema = schema;
|
| 33 |
+
this.tableNamesMap = tableNamesMap;
|
| 34 |
+
this.table = table;
|
| 35 |
+
this.tableConfig = tableConfig;
|
| 36 |
+
this.dialect = dialect;
|
| 37 |
+
this.session = session;
|
| 38 |
+
}
|
| 39 |
+
static [import_entity.entityKind] = "GelRelationalQueryBuilder";
|
| 40 |
+
findMany(config) {
|
| 41 |
+
return new GelRelationalQuery(
|
| 42 |
+
this.fullSchema,
|
| 43 |
+
this.schema,
|
| 44 |
+
this.tableNamesMap,
|
| 45 |
+
this.table,
|
| 46 |
+
this.tableConfig,
|
| 47 |
+
this.dialect,
|
| 48 |
+
this.session,
|
| 49 |
+
config ? config : {},
|
| 50 |
+
"many"
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
findFirst(config) {
|
| 54 |
+
return new GelRelationalQuery(
|
| 55 |
+
this.fullSchema,
|
| 56 |
+
this.schema,
|
| 57 |
+
this.tableNamesMap,
|
| 58 |
+
this.table,
|
| 59 |
+
this.tableConfig,
|
| 60 |
+
this.dialect,
|
| 61 |
+
this.session,
|
| 62 |
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
| 63 |
+
"first"
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
class GelRelationalQuery extends import_query_promise.QueryPromise {
|
| 68 |
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
| 69 |
+
super();
|
| 70 |
+
this.fullSchema = fullSchema;
|
| 71 |
+
this.schema = schema;
|
| 72 |
+
this.tableNamesMap = tableNamesMap;
|
| 73 |
+
this.table = table;
|
| 74 |
+
this.tableConfig = tableConfig;
|
| 75 |
+
this.dialect = dialect;
|
| 76 |
+
this.session = session;
|
| 77 |
+
this.config = config;
|
| 78 |
+
this.mode = mode;
|
| 79 |
+
}
|
| 80 |
+
static [import_entity.entityKind] = "GelRelationalQuery";
|
| 81 |
+
/** @internal */
|
| 82 |
+
_prepare(name) {
|
| 83 |
+
return import_tracing.tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 84 |
+
const { query, builtQuery } = this._toSQL();
|
| 85 |
+
return this.session.prepareQuery(
|
| 86 |
+
builtQuery,
|
| 87 |
+
void 0,
|
| 88 |
+
name,
|
| 89 |
+
true,
|
| 90 |
+
(rawRows, mapColumnValue) => {
|
| 91 |
+
const rows = rawRows.map(
|
| 92 |
+
(row) => (0, import_relations.mapRelationalRow)(this.schema, this.tableConfig, row, query.selection, mapColumnValue)
|
| 93 |
+
);
|
| 94 |
+
if (this.mode === "first") {
|
| 95 |
+
return rows[0];
|
| 96 |
+
}
|
| 97 |
+
return rows;
|
| 98 |
+
}
|
| 99 |
+
);
|
| 100 |
+
});
|
| 101 |
+
}
|
| 102 |
+
prepare(name) {
|
| 103 |
+
return this._prepare(name);
|
| 104 |
+
}
|
| 105 |
+
_getQuery() {
|
| 106 |
+
return this.dialect.buildRelationalQueryWithoutPK({
|
| 107 |
+
fullSchema: this.fullSchema,
|
| 108 |
+
schema: this.schema,
|
| 109 |
+
tableNamesMap: this.tableNamesMap,
|
| 110 |
+
table: this.table,
|
| 111 |
+
tableConfig: this.tableConfig,
|
| 112 |
+
queryConfig: this.config,
|
| 113 |
+
tableAlias: this.tableConfig.tsName
|
| 114 |
+
});
|
| 115 |
+
}
|
| 116 |
+
/** @internal */
|
| 117 |
+
getSQL() {
|
| 118 |
+
return this._getQuery().sql;
|
| 119 |
+
}
|
| 120 |
+
_toSQL() {
|
| 121 |
+
const query = this._getQuery();
|
| 122 |
+
const builtQuery = this.dialect.sqlToQuery(query.sql);
|
| 123 |
+
return { query, builtQuery };
|
| 124 |
+
}
|
| 125 |
+
toSQL() {
|
| 126 |
+
return this._toSQL().builtQuery;
|
| 127 |
+
}
|
| 128 |
+
execute() {
|
| 129 |
+
return import_tracing.tracer.startActiveSpan("drizzle.operation", () => {
|
| 130 |
+
return this._prepare().execute(void 0);
|
| 131 |
+
});
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 135 |
+
0 && (module.exports = {
|
| 136 |
+
GelRelationalQuery,
|
| 137 |
+
RelationalQueryBuilder
|
| 138 |
+
});
|
| 139 |
+
//# sourceMappingURL=query.cjs.map
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/gel-core/query-builders/query.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport {\n\ttype BuildQueryResult,\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tmapRelationalRow,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { Query, QueryWithTypings, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport { tracer } from '~/tracing.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { GelDialect } from '../dialect.ts';\nimport type { GelPreparedQuery, GelSession, PreparedQueryConfig } from '../session.ts';\nimport type { GelTable } from '../table.ts';\n\nexport class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {\n\tstatic readonly [entityKind]: string = 'GelRelationalQueryBuilder';\n\n\tconstructor(\n\t\tprivate fullSchema: Record<string, unknown>,\n\t\tprivate schema: TSchema,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: GelTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: GelDialect,\n\t\tprivate session: GelSession,\n\t) {}\n\n\tfindMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>,\n\t): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TConfig>[]> {\n\t\treturn new GelRelationalQuery(\n\t\t\tthis.fullSchema,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig ? (config as DBQueryConfig<'many', true>) : {},\n\t\t\t'many',\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(\n\t\tconfig?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>,\n\t): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TSelection> | undefined> {\n\t\treturn new GelRelationalQuery(\n\t\t\tthis.fullSchema,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig ? { ...(config as DBQueryConfig<'many', true> | undefined), limit: 1 } : { limit: 1 },\n\t\t\t'first',\n\t\t);\n\t}\n}\n\nexport class GelRelationalQuery<TResult> extends QueryPromise<TResult>\n\timplements RunnableQuery<TResult, 'gel'>, SQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelRelationalQuery';\n\n\tdeclare readonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly result: TResult;\n\t};\n\n\tconstructor(\n\t\tprivate fullSchema: Record<string, unknown>,\n\t\tprivate schema: TablesRelationalConfig,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: GelTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: GelDialect,\n\t\tprivate session: GelSession,\n\t\tprivate config: DBQueryConfig<'many', true> | true,\n\t\tprivate mode: 'many' | 'first',\n\t) {\n\t\tsuper();\n\t}\n\n\t/** @internal */\n\t_prepare(name?: string): GelPreparedQuery<PreparedQueryConfig & { execute: TResult }> {\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\tconst { query, builtQuery } = this._toSQL();\n\n\t\t\treturn this.session.prepareQuery<PreparedQueryConfig & { execute: TResult }>(\n\t\t\t\tbuiltQuery,\n\t\t\t\tundefined,\n\t\t\t\tname,\n\t\t\t\ttrue,\n\t\t\t\t(rawRows, mapColumnValue) => {\n\t\t\t\t\tconst rows = rawRows.map((row) =>\n\t\t\t\t\t\tmapRelationalRow(this.schema, this.tableConfig, row, query.selection, mapColumnValue)\n\t\t\t\t\t);\n\t\t\t\t\tif (this.mode === 'first') {\n\t\t\t\t\t\treturn rows[0] as TResult;\n\t\t\t\t\t}\n\t\t\t\t\treturn rows as TResult;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tprepare(name: string): GelPreparedQuery<PreparedQueryConfig & { execute: TResult }> {\n\t\treturn this._prepare(name);\n\t}\n\n\tprivate _getQuery() {\n\t\treturn this.dialect.buildRelationalQueryWithoutPK({\n\t\t\tfullSchema: this.fullSchema,\n\t\t\tschema: this.schema,\n\t\t\ttableNamesMap: this.tableNamesMap,\n\t\t\ttable: this.table,\n\t\t\ttableConfig: this.tableConfig,\n\t\t\tqueryConfig: this.config,\n\t\t\ttableAlias: this.tableConfig.tsName,\n\t\t});\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this._getQuery().sql as SQL;\n\t}\n\n\tprivate _toSQL(): { query: BuildRelationalQueryResult; builtQuery: QueryWithTypings } {\n\t\tconst query = this._getQuery();\n\n\t\tconst builtQuery = this.dialect.sqlToQuery(query.sql as SQL);\n\n\t\treturn { query, builtQuery };\n\t}\n\n\ttoSQL(): Query {\n\t\treturn this._toSQL().builtQuery;\n\t}\n\n\toverride execute(): Promise<TResult> {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(undefined);\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,2BAA6B;AAC7B,uBAOO;AAGP,qBAAuB;AAMhB,MAAM,uBAAsG;AAAA,EAGlH,YACS,YACA,QACA,eACA,OACA,aACA,SACA,SACP;AAPO;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAVH,QAAiB,wBAAU,IAAY;AAAA,EAYvC,SACC,QACoE;AACpE,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,SAAU,SAAyC,CAAC;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,UACC,QACiF;AACjF,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,SAAS,EAAE,GAAI,QAAoD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;AAAA,MAC3F;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,2BAAoC,kCAEjD;AAAA,EAQC,YACS,YACA,QACA,eACA,OACA,aACA,SACA,SACA,QACA,MACP;AACD,UAAM;AAVE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAGT;AAAA,EAnBA,QAA0B,wBAAU,IAAY;AAAA;AAAA,EAsBhD,SAAS,MAA6E;AACrF,WAAO,sBAAO,gBAAgB,wBAAwB,MAAM;AAC3D,YAAM,EAAE,OAAO,WAAW,IAAI,KAAK,OAAO;AAE1C,aAAO,KAAK,QAAQ;AAAA,QACnB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,CAAC,SAAS,mBAAmB;AAC5B,gBAAM,OAAO,QAAQ;AAAA,YAAI,CAAC,YACzB,mCAAiB,KAAK,QAAQ,KAAK,aAAa,KAAK,MAAM,WAAW,cAAc;AAAA,UACrF;AACA,cAAI,KAAK,SAAS,SAAS;AAC1B,mBAAO,KAAK,CAAC;AAAA,UACd;AACA,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EAEA,QAAQ,MAA4E;AACnF,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAEQ,YAAY;AACnB,WAAO,KAAK,QAAQ,8BAA8B;AAAA,MACjD,YAAY,KAAK;AAAA,MACjB,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK,YAAY;AAAA,IAC9B,CAAC;AAAA,EACF;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,UAAU,EAAE;AAAA,EACzB;AAAA,EAEQ,SAA8E;AACrF,UAAM,QAAQ,KAAK,UAAU;AAE7B,UAAM,aAAa,KAAK,QAAQ,WAAW,MAAM,GAAU;AAE3D,WAAO,EAAE,OAAO,WAAW;AAAA,EAC5B;AAAA,EAEA,QAAe;AACd,WAAO,KAAK,OAAO,EAAE;AAAA,EACtB;AAAA,EAES,UAA4B;AACpC,WAAO,sBAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,MAAS;AAAA,IACzC,CAAC;AAAA,EACF;AACD;","names":[]}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.d.cts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.cjs";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.cjs";
|
| 3 |
+
import { type BuildQueryResult, type DBQueryConfig, type TableRelationalConfig, type TablesRelationalConfig } from "../../relations.cjs";
|
| 4 |
+
import type { RunnableQuery } from "../../runnable-query.cjs";
|
| 5 |
+
import type { Query, SQLWrapper } from "../../sql/sql.cjs";
|
| 6 |
+
import type { KnownKeysOnly } from "../../utils.cjs";
|
| 7 |
+
import type { GelDialect } from "../dialect.cjs";
|
| 8 |
+
import type { GelPreparedQuery, GelSession, PreparedQueryConfig } from "../session.cjs";
|
| 9 |
+
import type { GelTable } from "../table.cjs";
|
| 10 |
+
export declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
|
| 11 |
+
private fullSchema;
|
| 12 |
+
private schema;
|
| 13 |
+
private tableNamesMap;
|
| 14 |
+
private table;
|
| 15 |
+
private tableConfig;
|
| 16 |
+
private dialect;
|
| 17 |
+
private session;
|
| 18 |
+
static readonly [entityKind]: string;
|
| 19 |
+
constructor(fullSchema: Record<string, unknown>, schema: TSchema, tableNamesMap: Record<string, string>, table: GelTable, tableConfig: TableRelationalConfig, dialect: GelDialect, session: GelSession);
|
| 20 |
+
findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
| 21 |
+
findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
| 22 |
+
}
|
| 23 |
+
export declare class GelRelationalQuery<TResult> extends QueryPromise<TResult> implements RunnableQuery<TResult, 'gel'>, SQLWrapper {
|
| 24 |
+
private fullSchema;
|
| 25 |
+
private schema;
|
| 26 |
+
private tableNamesMap;
|
| 27 |
+
private table;
|
| 28 |
+
private tableConfig;
|
| 29 |
+
private dialect;
|
| 30 |
+
private session;
|
| 31 |
+
private config;
|
| 32 |
+
private mode;
|
| 33 |
+
static readonly [entityKind]: string;
|
| 34 |
+
readonly _: {
|
| 35 |
+
readonly dialect: 'gel';
|
| 36 |
+
readonly result: TResult;
|
| 37 |
+
};
|
| 38 |
+
constructor(fullSchema: Record<string, unknown>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: GelTable, tableConfig: TableRelationalConfig, dialect: GelDialect, session: GelSession, config: DBQueryConfig<'many', true> | true, mode: 'many' | 'first');
|
| 39 |
+
prepare(name: string): GelPreparedQuery<PreparedQueryConfig & {
|
| 40 |
+
execute: TResult;
|
| 41 |
+
}>;
|
| 42 |
+
private _getQuery;
|
| 43 |
+
private _toSQL;
|
| 44 |
+
toSQL(): Query;
|
| 45 |
+
execute(): Promise<TResult>;
|
| 46 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 3 |
+
import { type BuildQueryResult, type DBQueryConfig, type TableRelationalConfig, type TablesRelationalConfig } from "../../relations.js";
|
| 4 |
+
import type { RunnableQuery } from "../../runnable-query.js";
|
| 5 |
+
import type { Query, SQLWrapper } from "../../sql/sql.js";
|
| 6 |
+
import type { KnownKeysOnly } from "../../utils.js";
|
| 7 |
+
import type { GelDialect } from "../dialect.js";
|
| 8 |
+
import type { GelPreparedQuery, GelSession, PreparedQueryConfig } from "../session.js";
|
| 9 |
+
import type { GelTable } from "../table.js";
|
| 10 |
+
export declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
|
| 11 |
+
private fullSchema;
|
| 12 |
+
private schema;
|
| 13 |
+
private tableNamesMap;
|
| 14 |
+
private table;
|
| 15 |
+
private tableConfig;
|
| 16 |
+
private dialect;
|
| 17 |
+
private session;
|
| 18 |
+
static readonly [entityKind]: string;
|
| 19 |
+
constructor(fullSchema: Record<string, unknown>, schema: TSchema, tableNamesMap: Record<string, string>, table: GelTable, tableConfig: TableRelationalConfig, dialect: GelDialect, session: GelSession);
|
| 20 |
+
findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
| 21 |
+
findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>): GelRelationalQuery<BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
| 22 |
+
}
|
| 23 |
+
export declare class GelRelationalQuery<TResult> extends QueryPromise<TResult> implements RunnableQuery<TResult, 'gel'>, SQLWrapper {
|
| 24 |
+
private fullSchema;
|
| 25 |
+
private schema;
|
| 26 |
+
private tableNamesMap;
|
| 27 |
+
private table;
|
| 28 |
+
private tableConfig;
|
| 29 |
+
private dialect;
|
| 30 |
+
private session;
|
| 31 |
+
private config;
|
| 32 |
+
private mode;
|
| 33 |
+
static readonly [entityKind]: string;
|
| 34 |
+
readonly _: {
|
| 35 |
+
readonly dialect: 'gel';
|
| 36 |
+
readonly result: TResult;
|
| 37 |
+
};
|
| 38 |
+
constructor(fullSchema: Record<string, unknown>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: GelTable, tableConfig: TableRelationalConfig, dialect: GelDialect, session: GelSession, config: DBQueryConfig<'many', true> | true, mode: 'many' | 'first');
|
| 39 |
+
prepare(name: string): GelPreparedQuery<PreparedQueryConfig & {
|
| 40 |
+
execute: TResult;
|
| 41 |
+
}>;
|
| 42 |
+
private _getQuery;
|
| 43 |
+
private _toSQL;
|
| 44 |
+
toSQL(): Query;
|
| 45 |
+
execute(): Promise<TResult>;
|
| 46 |
+
}
|
e-commerce/node_modules/drizzle-orm/gel-core/query-builders/query.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { entityKind } from "../../entity.js";
|
| 2 |
+
import { QueryPromise } from "../../query-promise.js";
|
| 3 |
+
import {
|
| 4 |
+
mapRelationalRow
|
| 5 |
+
} from "../../relations.js";
|
| 6 |
+
import { tracer } from "../../tracing.js";
|
| 7 |
+
class RelationalQueryBuilder {
|
| 8 |
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
| 9 |
+
this.fullSchema = fullSchema;
|
| 10 |
+
this.schema = schema;
|
| 11 |
+
this.tableNamesMap = tableNamesMap;
|
| 12 |
+
this.table = table;
|
| 13 |
+
this.tableConfig = tableConfig;
|
| 14 |
+
this.dialect = dialect;
|
| 15 |
+
this.session = session;
|
| 16 |
+
}
|
| 17 |
+
static [entityKind] = "GelRelationalQueryBuilder";
|
| 18 |
+
findMany(config) {
|
| 19 |
+
return new GelRelationalQuery(
|
| 20 |
+
this.fullSchema,
|
| 21 |
+
this.schema,
|
| 22 |
+
this.tableNamesMap,
|
| 23 |
+
this.table,
|
| 24 |
+
this.tableConfig,
|
| 25 |
+
this.dialect,
|
| 26 |
+
this.session,
|
| 27 |
+
config ? config : {},
|
| 28 |
+
"many"
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
findFirst(config) {
|
| 32 |
+
return new GelRelationalQuery(
|
| 33 |
+
this.fullSchema,
|
| 34 |
+
this.schema,
|
| 35 |
+
this.tableNamesMap,
|
| 36 |
+
this.table,
|
| 37 |
+
this.tableConfig,
|
| 38 |
+
this.dialect,
|
| 39 |
+
this.session,
|
| 40 |
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
| 41 |
+
"first"
|
| 42 |
+
);
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
class GelRelationalQuery extends QueryPromise {
|
| 46 |
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
| 47 |
+
super();
|
| 48 |
+
this.fullSchema = fullSchema;
|
| 49 |
+
this.schema = schema;
|
| 50 |
+
this.tableNamesMap = tableNamesMap;
|
| 51 |
+
this.table = table;
|
| 52 |
+
this.tableConfig = tableConfig;
|
| 53 |
+
this.dialect = dialect;
|
| 54 |
+
this.session = session;
|
| 55 |
+
this.config = config;
|
| 56 |
+
this.mode = mode;
|
| 57 |
+
}
|
| 58 |
+
static [entityKind] = "GelRelationalQuery";
|
| 59 |
+
/** @internal */
|
| 60 |
+
_prepare(name) {
|
| 61 |
+
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
| 62 |
+
const { query, builtQuery } = this._toSQL();
|
| 63 |
+
return this.session.prepareQuery(
|
| 64 |
+
builtQuery,
|
| 65 |
+
void 0,
|
| 66 |
+
name,
|
| 67 |
+
true,
|
| 68 |
+
(rawRows, mapColumnValue) => {
|
| 69 |
+
const rows = rawRows.map(
|
| 70 |
+
(row) => mapRelationalRow(this.schema, this.tableConfig, row, query.selection, mapColumnValue)
|
| 71 |
+
);
|
| 72 |
+
if (this.mode === "first") {
|
| 73 |
+
return rows[0];
|
| 74 |
+
}
|
| 75 |
+
return rows;
|
| 76 |
+
}
|
| 77 |
+
);
|
| 78 |
+
});
|
| 79 |
+
}
|
| 80 |
+
prepare(name) {
|
| 81 |
+
return this._prepare(name);
|
| 82 |
+
}
|
| 83 |
+
_getQuery() {
|
| 84 |
+
return this.dialect.buildRelationalQueryWithoutPK({
|
| 85 |
+
fullSchema: this.fullSchema,
|
| 86 |
+
schema: this.schema,
|
| 87 |
+
tableNamesMap: this.tableNamesMap,
|
| 88 |
+
table: this.table,
|
| 89 |
+
tableConfig: this.tableConfig,
|
| 90 |
+
queryConfig: this.config,
|
| 91 |
+
tableAlias: this.tableConfig.tsName
|
| 92 |
+
});
|
| 93 |
+
}
|
| 94 |
+
/** @internal */
|
| 95 |
+
getSQL() {
|
| 96 |
+
return this._getQuery().sql;
|
| 97 |
+
}
|
| 98 |
+
_toSQL() {
|
| 99 |
+
const query = this._getQuery();
|
| 100 |
+
const builtQuery = this.dialect.sqlToQuery(query.sql);
|
| 101 |
+
return { query, builtQuery };
|
| 102 |
+
}
|
| 103 |
+
toSQL() {
|
| 104 |
+
return this._toSQL().builtQuery;
|
| 105 |
+
}
|
| 106 |
+
execute() {
|
| 107 |
+
return tracer.startActiveSpan("drizzle.operation", () => {
|
| 108 |
+
return this._prepare().execute(void 0);
|
| 109 |
+
});
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
export {
|
| 113 |
+
GelRelationalQuery,
|
| 114 |
+
RelationalQueryBuilder
|
| 115 |
+
};
|
| 116 |
+
//# sourceMappingURL=query.js.map
|