rads-db 3.2.2 → 3.2.4
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.
- package/dist/config.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/{types-9a0ba02b.d.ts → types-17bcd41b.d.ts} +4 -1
- package/drivers/sql.cjs +13 -7
- package/drivers/sql.mjs +15 -7
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EntityDecoratorArgs, U as UiDecoratorArgs, a as UiFieldDecoratorArgs, V as ValidateEntityDecoratorArgs, b as ValidateFieldDecoratorArgs, F as FieldDecoratorArgs, C as ComputedDecoratorArgs, S as Schema, D as DriverConstructor, c as Driver, d as ComputedContext, R as RadsRequestContext, e as CreateRadsDbArgs, f as CreateRadsDbClientArgs } from './types-
|
|
2
|
-
export { O as Change, x as ComputedContextGlobal, k as CreateRadsArgsDrivers, m as CreateRadsDbArgsNormalized, ak as DeepKeys, af as DeepPartial, ad as DeepPartialWithNulls, ae as DeepPartialWithNullsItem, al as EntityMethods, w as EnumDefinition, v as FieldDefinition, J as FileSystemNode, u as FileUploadArgs, q as FileUploadDriver, p as FileUploadResult, H as GenerateClientNormalizedOptions, B as GenerateClientOptions, a9 as Get, $ as GetAggArgs, a0 as GetAggArgsAgg, a3 as GetAggArgsAny, a6 as GetAggResponse, _ as GetArgs, a2 as GetArgsAny, a5 as GetArgsInclude, Q as GetManyArgs, a1 as GetManyArgsAny, a7 as GetManyResponse, a8 as GetResponse, aa as GetResponseInclude, ab as GetResponseIncludeSelect, ac as GetResponseNoInclude, s as GetRestRoutesArgs, G as GetRestRoutesOptions, t as GetRestRoutesResponse, ah as InverseRelation, M as MinimalDriver, aj as Put, ai as PutArgs, P as PutEffect, g as RadsConfig, h as RadsConfigDataSource, r as RadsDbInstance, N as RadsFeature, y as RadsHookDoc, L as RadsUiSlotDefinition, K as RadsUiSlotName, I as RadsVitePluginOptions, ag as Relation, i as RequiredFields, l as RestDriverOptions, A as RestFileUploadDriverOptions, n as SchemaLoadResult, o as SchemaValidators, z as SqlDriverOptions, T as TypeDefinition, j as ValidateStringDecoratorArgs, X as VerifyManyArgs, a4 as VerifyManyArgsAny, Y as VerifyManyResponse, Z as Where, W as WhereJsonContains } from './types-
|
|
1
|
+
import { E as EntityDecoratorArgs, U as UiDecoratorArgs, a as UiFieldDecoratorArgs, V as ValidateEntityDecoratorArgs, b as ValidateFieldDecoratorArgs, F as FieldDecoratorArgs, C as ComputedDecoratorArgs, S as Schema, D as DriverConstructor, c as Driver, d as ComputedContext, R as RadsRequestContext, e as CreateRadsDbArgs, f as CreateRadsDbClientArgs } from './types-17bcd41b.js';
|
|
2
|
+
export { O as Change, x as ComputedContextGlobal, k as CreateRadsArgsDrivers, m as CreateRadsDbArgsNormalized, ak as DeepKeys, af as DeepPartial, ad as DeepPartialWithNulls, ae as DeepPartialWithNullsItem, al as EntityMethods, w as EnumDefinition, v as FieldDefinition, J as FileSystemNode, u as FileUploadArgs, q as FileUploadDriver, p as FileUploadResult, H as GenerateClientNormalizedOptions, B as GenerateClientOptions, a9 as Get, $ as GetAggArgs, a0 as GetAggArgsAgg, a3 as GetAggArgsAny, a6 as GetAggResponse, _ as GetArgs, a2 as GetArgsAny, a5 as GetArgsInclude, Q as GetManyArgs, a1 as GetManyArgsAny, a7 as GetManyResponse, a8 as GetResponse, aa as GetResponseInclude, ab as GetResponseIncludeSelect, ac as GetResponseNoInclude, s as GetRestRoutesArgs, G as GetRestRoutesOptions, t as GetRestRoutesResponse, ah as InverseRelation, M as MinimalDriver, aj as Put, ai as PutArgs, P as PutEffect, g as RadsConfig, h as RadsConfigDataSource, r as RadsDbInstance, N as RadsFeature, y as RadsHookDoc, L as RadsUiSlotDefinition, K as RadsUiSlotName, I as RadsVitePluginOptions, ag as Relation, i as RequiredFields, l as RestDriverOptions, A as RestFileUploadDriverOptions, n as SchemaLoadResult, o as SchemaValidators, z as SqlDriverOptions, T as TypeDefinition, j as ValidateStringDecoratorArgs, X as VerifyManyArgs, a4 as VerifyManyArgsAny, Y as VerifyManyResponse, Z as Where, W as WhereJsonContains } from './types-17bcd41b.js';
|
|
3
3
|
import { RadsDb } from '_rads-db';
|
|
4
4
|
export { RadsDb } from '_rads-db';
|
|
5
5
|
import 'mssql';
|
|
@@ -325,7 +325,10 @@ interface MinimalDriver {
|
|
|
325
325
|
deleteAll?: (args: GetManyArgsAny, ctx?: RadsRequestContext) => MaybePromise<Record<string, any>[]>;
|
|
326
326
|
put?: (data: Record<string, any>, ctx?: RadsRequestContext) => MaybePromise<void>;
|
|
327
327
|
verifyMany?: (args?: VerifyManyArgsAny, ctx?: RadsRequestContext) => MaybePromise<VerifyManyResponse>;
|
|
328
|
-
generateMigrationScript?: () => MaybePromise<
|
|
328
|
+
generateMigrationScript?: () => MaybePromise<{
|
|
329
|
+
createScript: string;
|
|
330
|
+
dropScript: string;
|
|
331
|
+
}>;
|
|
329
332
|
}
|
|
330
333
|
type Driver = Required<Omit<MinimalDriver, 'verifyMany' | 'client' | 'generateMigrationScript'>> & Pick<MinimalDriver, 'verifyMany' | 'client' | 'generateMigrationScript'>;
|
|
331
334
|
interface FieldDefinition {
|
package/drivers/sql.cjs
CHANGED
|
@@ -314,10 +314,10 @@ var _default = options => {
|
|
|
314
314
|
for (const p in parameters) {
|
|
315
315
|
req.input(p, parameters[p]);
|
|
316
316
|
}
|
|
317
|
-
|
|
317
|
+
ctx?.log?.(query);
|
|
318
318
|
const result2 = await req.query(query);
|
|
319
319
|
const nodes = result2.recordset || [];
|
|
320
|
-
|
|
320
|
+
ctx?.log?.(result2);
|
|
321
321
|
return nodes[0];
|
|
322
322
|
},
|
|
323
323
|
async putMany(items, ctx) {
|
|
@@ -366,6 +366,7 @@ var _default = options => {
|
|
|
366
366
|
console.error(`\u274C Failed insert into ${realTable} [${valuesChunk.length} rows]`);
|
|
367
367
|
console.error(`First 300 chars of query:
|
|
368
368
|
${insertQuery.slice(0, 300)}...`);
|
|
369
|
+
console.error(e);
|
|
369
370
|
throw e;
|
|
370
371
|
}
|
|
371
372
|
}
|
|
@@ -385,12 +386,17 @@ ${insertQuery.slice(0, 300)}...`);
|
|
|
385
386
|
const entity2 = schema2[entityName];
|
|
386
387
|
if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
|
|
387
388
|
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
388
|
-
tableNamePrefix: options.tablePrefix
|
|
389
|
+
tableNamePrefix: options.tablePrefix,
|
|
390
|
+
dropIfExists: true
|
|
389
391
|
});
|
|
390
392
|
const createTableRequest2 = getCreateTableRequestsFor(entityName, {
|
|
391
|
-
tableNamePrefix: options.stagingTablePrefix
|
|
393
|
+
tableNamePrefix: options.stagingTablePrefix,
|
|
394
|
+
dropIfExists: true
|
|
392
395
|
});
|
|
393
|
-
return
|
|
396
|
+
return {
|
|
397
|
+
dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
|
|
398
|
+
createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
|
|
399
|
+
};
|
|
394
400
|
}
|
|
395
401
|
function getCreateTableRequestsFor(entityName, options2) {
|
|
396
402
|
const {
|
|
@@ -657,10 +663,10 @@ END;
|
|
|
657
663
|
for (const p in parameters) {
|
|
658
664
|
req.input(p, parameters[p]);
|
|
659
665
|
}
|
|
660
|
-
|
|
666
|
+
ctx?.log?.(query);
|
|
661
667
|
const result2 = await req.query(query);
|
|
662
668
|
const nodes = result2.recordset || [];
|
|
663
|
-
|
|
669
|
+
ctx?.log?.(result2);
|
|
664
670
|
return {
|
|
665
671
|
nodes,
|
|
666
672
|
cursor: nodes.length === maxItemCount ? String((Number(args.cursor || "0") || 0) + nodes.length) : void 0
|
package/drivers/sql.mjs
CHANGED
|
@@ -183,10 +183,10 @@ export default (options) => {
|
|
|
183
183
|
for (const p in parameters) {
|
|
184
184
|
req.input(p, parameters[p]);
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
ctx?.log?.(query);
|
|
187
187
|
const result2 = await req.query(query);
|
|
188
188
|
const nodes = result2.recordset || [];
|
|
189
|
-
|
|
189
|
+
ctx?.log?.(result2);
|
|
190
190
|
return nodes[0];
|
|
191
191
|
},
|
|
192
192
|
async putMany(items, ctx) {
|
|
@@ -237,6 +237,7 @@ export default (options) => {
|
|
|
237
237
|
console.error(`\u274C Failed insert into ${realTable} [${valuesChunk.length} rows]`);
|
|
238
238
|
console.error(`First 300 chars of query:
|
|
239
239
|
${insertQuery.slice(0, 300)}...`);
|
|
240
|
+
console.error(e);
|
|
240
241
|
throw e;
|
|
241
242
|
}
|
|
242
243
|
}
|
|
@@ -255,11 +256,18 @@ ${insertQuery.slice(0, 300)}...`);
|
|
|
255
256
|
function buildMigrationScript(schema2, entityName) {
|
|
256
257
|
const entity2 = schema2[entityName];
|
|
257
258
|
if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
|
|
258
|
-
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
259
|
+
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
260
|
+
tableNamePrefix: options.tablePrefix,
|
|
261
|
+
dropIfExists: true
|
|
262
|
+
});
|
|
259
263
|
const createTableRequest2 = getCreateTableRequestsFor(entityName, {
|
|
260
|
-
tableNamePrefix: options.stagingTablePrefix
|
|
264
|
+
tableNamePrefix: options.stagingTablePrefix,
|
|
265
|
+
dropIfExists: true
|
|
261
266
|
});
|
|
262
|
-
return
|
|
267
|
+
return {
|
|
268
|
+
dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
|
|
269
|
+
createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
|
|
270
|
+
};
|
|
263
271
|
}
|
|
264
272
|
function getCreateTableRequestsFor(entityName, options2) {
|
|
265
273
|
const { tableNameSuffix, tableNamePrefix, dropIfExists, addPrimaryKey, addForeignKeys, foreignKeysTables } = options2 || {};
|
|
@@ -531,10 +539,10 @@ END;
|
|
|
531
539
|
for (const p in parameters) {
|
|
532
540
|
req.input(p, parameters[p]);
|
|
533
541
|
}
|
|
534
|
-
|
|
542
|
+
ctx?.log?.(query);
|
|
535
543
|
const result2 = await req.query(query);
|
|
536
544
|
const nodes = result2.recordset || [];
|
|
537
|
-
|
|
545
|
+
ctx?.log?.(result2);
|
|
538
546
|
return {
|
|
539
547
|
nodes,
|
|
540
548
|
cursor: nodes.length === maxItemCount ? String((Number(args.cursor || "0") || 0) + nodes.length) : void 0
|