azure-mock 2.20.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +201 -201
  2. package/dist/better-sqlite3-CtLaF97z-DWR9uC3b.js +129 -0
  3. package/dist/chunk-2X2C5D2I-dJHtPFe9-DxsO-1YF.js +4026 -0
  4. package/dist/d1-pK2J-_yx-BoQTXsTa.js +185 -0
  5. package/dist/dialect-pBb6Cg_F-xgpUtfmk.js +570 -0
  6. package/dist/dist-C481edUb-CHbOkeXH.js +10131 -0
  7. package/dist/dist-DUzzleZr-DxHmeYjp.js +2 -0
  8. package/dist/index.d.ts +21 -21
  9. package/dist/index.js +20396 -18921
  10. package/dist/libsql-Nq-S0r5x-d2dAzhgO.js +240 -0
  11. package/dist/logger-TIsK7375-CLNNa25D.js +652 -0
  12. package/dist/migrator-B9kYwLqO-4g9JX3_v.js +8 -0
  13. package/dist/migrator-BfTfJctM-DrNlb1BS.js +8 -0
  14. package/dist/migrator-BjoW0_3j-CD-XdZ5a.js +8 -0
  15. package/dist/migrator-CWWlo_Jk-C4Hw4PPN.js +8 -0
  16. package/dist/migrator-CpiXRkls-COYfhljd.js +24 -0
  17. package/dist/migrator-CtqJkLVI-D1lU6ZV0.js +8 -0
  18. package/dist/migrator-CxcBjmET-Dcd21VIf.js +8 -0
  19. package/dist/migrator-Cyhbhxo_-Bh7sF0R3.js +21 -0
  20. package/dist/migrator-DG1mWUoR-DVfkqn_v.js +31 -0
  21. package/dist/migrator-DrWmHwY2-YjAfotd7.js +8 -0
  22. package/dist/migrator-WAPonQxA-CRvJJhKG.js +8 -0
  23. package/dist/migrator-Zdh8WMMx-gsmNXspd.js +8 -0
  24. package/dist/migrator-xRJ6NOTS-SsAuB-Gi.js +24 -0
  25. package/dist/migrator-xbWwvFYF-BjyVdQS8.js +8 -0
  26. package/dist/mysql2-DkoPEsRu-BMwVSCmY.js +251 -0
  27. package/dist/neon-serverless-BEVFA7yv-DGSPAG1z.js +205 -0
  28. package/dist/node-postgres-DQA7bEhW-CkM_cVLD.js +216 -0
  29. package/dist/nodefs-Bc8b83o_-DetP9qUa.js +24 -0
  30. package/dist/opfs-ahp-DbstDvx--CHskKtzG.js +365 -0
  31. package/dist/pg-ylxXyvKj-Hm8vcZoi.js +279 -0
  32. package/dist/pglite-CPs4w-D9-DHOg0D8W.js +179 -0
  33. package/dist/pglite-DMWgTUE6-BOIRUWUT.js +2 -0
  34. package/dist/planetscale-serverless-DUMheN-f-Dyc_W6V_.js +172 -0
  35. package/dist/query-builder-CLJAKedv-DTZiP7B6.js +1715 -0
  36. package/dist/query-builder-CT3_liD0-hhg5kRTk.js +1347 -0
  37. package/dist/session-BOEirggu-DTmpyU_x.js +2485 -0
  38. package/dist/session-CAUQtT0A-BoVK2x7A.js +745 -0
  39. package/dist/session-Cjeygn2Z-BO0mi6pq.js +989 -0
  40. package/dist/singlestore-Cdlo23hW-BuFJ4Zqb.js +1647 -0
  41. package/dist/sql-CNZp2yLp-Bwugq384.js +611 -0
  42. package/dist/sqlite-proxy-BgUfVEbZ-CsSkc-_K.js +190 -0
  43. package/dist/src-LcyXhCXE-C_vKJiLK.js +1920 -0
  44. package/dist/vercel-postgres-BYmFKsTS-CpV2usun.js +203 -0
  45. package/package.json +7 -8
@@ -0,0 +1,190 @@
1
+ import { C as sql, _ as fillPlaceholders, g as entityKind } from "./sql-CNZp2yLp-Bwugq384.js";
2
+ import { M as mapResultRow, n as DefaultLogger, o as NoopCache, s as NoopLogger, x as extractTablesRelationalConfig, y as createTableRelationsHelpers } from "./logger-TIsK7375-CLNNa25D.js";
3
+ import { n as SQLiteAsyncDialect } from "./query-builder-CT3_liD0-hhg5kRTk.js";
4
+ import { i as SQLiteTransaction, n as SQLitePreparedQuery, r as SQLiteSession, t as BaseSQLiteDatabase } from "./session-Cjeygn2Z-BO0mi6pq.js";
5
+ //#region ../db/dist/sqlite-proxy-BgUfVEbZ.js
6
+ var SQLiteRemoteSession = class extends SQLiteSession {
7
+ constructor(client, dialect, schema, batchCLient, options = {}) {
8
+ super(dialect);
9
+ this.client = client;
10
+ this.schema = schema;
11
+ this.batchCLient = batchCLient;
12
+ this.logger = options.logger ?? new NoopLogger();
13
+ this.cache = options.cache ?? new NoopCache();
14
+ }
15
+ static [entityKind] = "SQLiteRemoteSession";
16
+ logger;
17
+ cache;
18
+ prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
19
+ return new RemotePreparedQuery(this.client, query, this.logger, this.cache, queryMetadata, cacheConfig, fields, executeMethod, isResponseInArrayMode, customResultMapper);
20
+ }
21
+ async batch(queries) {
22
+ const preparedQueries = [];
23
+ const builtQueries = [];
24
+ for (const query of queries) {
25
+ const preparedQuery = query._prepare();
26
+ const builtQuery = preparedQuery.getQuery();
27
+ preparedQueries.push(preparedQuery);
28
+ builtQueries.push({
29
+ sql: builtQuery.sql,
30
+ params: builtQuery.params,
31
+ method: builtQuery.method
32
+ });
33
+ }
34
+ return (await this.batchCLient(builtQueries)).map((result, i) => preparedQueries[i].mapResult(result, true));
35
+ }
36
+ async transaction(transaction, config) {
37
+ const tx = new SQLiteProxyTransaction("async", this.dialect, this, this.schema);
38
+ await this.run(sql.raw(`begin${config?.behavior ? " " + config.behavior : ""}`));
39
+ try {
40
+ const result = await transaction(tx);
41
+ await this.run(sql`commit`);
42
+ return result;
43
+ } catch (err) {
44
+ await this.run(sql`rollback`);
45
+ throw err;
46
+ }
47
+ }
48
+ extractRawAllValueFromBatchResult(result) {
49
+ return result.rows;
50
+ }
51
+ extractRawGetValueFromBatchResult(result) {
52
+ return result.rows[0];
53
+ }
54
+ extractRawValuesValueFromBatchResult(result) {
55
+ return result.rows;
56
+ }
57
+ };
58
+ var SQLiteProxyTransaction = class SQLiteProxyTransaction extends SQLiteTransaction {
59
+ static [entityKind] = "SQLiteProxyTransaction";
60
+ async transaction(transaction) {
61
+ const savepointName = `sp${this.nestedIndex}`;
62
+ const tx = new SQLiteProxyTransaction("async", this.dialect, this.session, this.schema, this.nestedIndex + 1);
63
+ await this.session.run(sql.raw(`savepoint ${savepointName}`));
64
+ try {
65
+ const result = await transaction(tx);
66
+ await this.session.run(sql.raw(`release savepoint ${savepointName}`));
67
+ return result;
68
+ } catch (err) {
69
+ await this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
70
+ throw err;
71
+ }
72
+ }
73
+ };
74
+ var RemotePreparedQuery = class extends SQLitePreparedQuery {
75
+ constructor(client, query, logger, cache, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
76
+ super("async", executeMethod, query, cache, queryMetadata, cacheConfig);
77
+ this.client = client;
78
+ this.logger = logger;
79
+ this.fields = fields;
80
+ this._isResponseInArrayMode = _isResponseInArrayMode;
81
+ this.customResultMapper = customResultMapper;
82
+ this.customResultMapper = customResultMapper;
83
+ this.method = executeMethod;
84
+ }
85
+ static [entityKind] = "SQLiteProxyPreparedQuery";
86
+ method;
87
+ getQuery() {
88
+ return {
89
+ ...this.query,
90
+ method: this.method
91
+ };
92
+ }
93
+ async run(placeholderValues) {
94
+ const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
95
+ this.logger.logQuery(this.query.sql, params);
96
+ return await this.queryWithCache(this.query.sql, params, async () => {
97
+ return await this.client(this.query.sql, params, "run");
98
+ });
99
+ }
100
+ mapAllResult(rows, isFromBatch) {
101
+ if (isFromBatch) rows = rows.rows;
102
+ if (!this.fields && !this.customResultMapper) return rows;
103
+ if (this.customResultMapper) return this.customResultMapper(rows);
104
+ return rows.map((row) => {
105
+ return mapResultRow(this.fields, row, this.joinsNotNullableMap);
106
+ });
107
+ }
108
+ async all(placeholderValues) {
109
+ const { query, logger, client } = this;
110
+ const params = fillPlaceholders(query.params, placeholderValues ?? {});
111
+ logger.logQuery(query.sql, params);
112
+ const { rows } = await this.queryWithCache(query.sql, params, async () => {
113
+ return await client(query.sql, params, "all");
114
+ });
115
+ return this.mapAllResult(rows);
116
+ }
117
+ async get(placeholderValues) {
118
+ const { query, logger, client } = this;
119
+ const params = fillPlaceholders(query.params, placeholderValues ?? {});
120
+ logger.logQuery(query.sql, params);
121
+ const clientResult = await this.queryWithCache(query.sql, params, async () => {
122
+ return await client(query.sql, params, "get");
123
+ });
124
+ return this.mapGetResult(clientResult.rows);
125
+ }
126
+ mapGetResult(rows, isFromBatch) {
127
+ if (isFromBatch) rows = rows.rows;
128
+ const row = rows;
129
+ if (!this.fields && !this.customResultMapper) return row;
130
+ if (!row) return;
131
+ if (this.customResultMapper) return this.customResultMapper([rows]);
132
+ return mapResultRow(this.fields, row, this.joinsNotNullableMap);
133
+ }
134
+ async values(placeholderValues) {
135
+ const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
136
+ this.logger.logQuery(this.query.sql, params);
137
+ return (await this.queryWithCache(this.query.sql, params, async () => {
138
+ return await this.client(this.query.sql, params, "values");
139
+ })).rows;
140
+ }
141
+ /** @internal */
142
+ isResponseInArrayMode() {
143
+ return this._isResponseInArrayMode;
144
+ }
145
+ };
146
+ var SqliteRemoteDatabase = class extends BaseSQLiteDatabase {
147
+ static [entityKind] = "SqliteRemoteDatabase";
148
+ async batch(batch) {
149
+ return this.session.batch(batch);
150
+ }
151
+ };
152
+ function drizzle(callback, batchCallback, config) {
153
+ const dialect = new SQLiteAsyncDialect({ casing: config?.casing });
154
+ let logger;
155
+ let cache;
156
+ let _batchCallback;
157
+ let _config = {};
158
+ if (batchCallback) {
159
+ if (typeof batchCallback === "function") {
160
+ _batchCallback = batchCallback;
161
+ _config = config ?? {};
162
+ } else {
163
+ _batchCallback = void 0;
164
+ _config = batchCallback;
165
+ }
166
+ if (_config.logger === true) logger = new DefaultLogger();
167
+ else if (_config.logger !== false) {
168
+ logger = _config.logger;
169
+ cache = _config.cache;
170
+ }
171
+ }
172
+ let schema;
173
+ if (_config.schema) {
174
+ const tablesConfig = extractTablesRelationalConfig(_config.schema, createTableRelationsHelpers);
175
+ schema = {
176
+ fullSchema: _config.schema,
177
+ schema: tablesConfig.tables,
178
+ tableNamesMap: tablesConfig.tableNamesMap
179
+ };
180
+ }
181
+ const db = new SqliteRemoteDatabase("async", dialect, new SQLiteRemoteSession(callback, dialect, schema, _batchCallback, {
182
+ logger,
183
+ cache
184
+ }), schema);
185
+ db.$cache = cache;
186
+ if (db.$cache) db.$cache["invalidate"] = cache?.onMutate;
187
+ return db;
188
+ }
189
+ //#endregion
190
+ export { drizzle };