rads-db 3.2.3 → 3.2.5
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.cjs +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -0
- package/dist/{types-9a0ba02b.d.ts → types-17bcd41b.d.ts} +4 -1
- package/drivers/sql.cjs +8 -3
- package/drivers/sql.mjs +10 -3
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -644,6 +644,8 @@ function verifyRelationsSetup(schema, effects) {
|
|
|
644
644
|
const id_in = ___default.keys(changedDocsById);
|
|
645
645
|
if (!id_in.length)
|
|
646
646
|
return;
|
|
647
|
+
if (!drivers[entityName])
|
|
648
|
+
return;
|
|
647
649
|
const affectedDocs = await drivers[entityName].getAll(
|
|
648
650
|
{
|
|
649
651
|
where: { [fName]: { id_in } },
|
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';
|
package/dist/index.mjs
CHANGED
|
@@ -637,6 +637,8 @@ function verifyRelationsSetup(schema, effects) {
|
|
|
637
637
|
const id_in = _.keys(changedDocsById);
|
|
638
638
|
if (!id_in.length)
|
|
639
639
|
return;
|
|
640
|
+
if (!drivers[entityName])
|
|
641
|
+
return;
|
|
640
642
|
const affectedDocs = await drivers[entityName].getAll(
|
|
641
643
|
{
|
|
642
644
|
where: { [fName]: { id_in } },
|
|
@@ -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
|
@@ -386,12 +386,17 @@ ${insertQuery.slice(0, 300)}...`);
|
|
|
386
386
|
const entity2 = schema2[entityName];
|
|
387
387
|
if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
|
|
388
388
|
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
389
|
-
tableNamePrefix: options.tablePrefix
|
|
389
|
+
tableNamePrefix: options.tablePrefix,
|
|
390
|
+
dropIfExists: true
|
|
390
391
|
});
|
|
391
392
|
const createTableRequest2 = getCreateTableRequestsFor(entityName, {
|
|
392
|
-
tableNamePrefix: options.stagingTablePrefix
|
|
393
|
+
tableNamePrefix: options.stagingTablePrefix,
|
|
394
|
+
dropIfExists: true
|
|
393
395
|
});
|
|
394
|
-
return
|
|
396
|
+
return {
|
|
397
|
+
dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
|
|
398
|
+
createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
|
|
399
|
+
};
|
|
395
400
|
}
|
|
396
401
|
function getCreateTableRequestsFor(entityName, options2) {
|
|
397
402
|
const {
|
package/drivers/sql.mjs
CHANGED
|
@@ -256,11 +256,18 @@ ${insertQuery.slice(0, 300)}...`);
|
|
|
256
256
|
function buildMigrationScript(schema2, entityName) {
|
|
257
257
|
const entity2 = schema2[entityName];
|
|
258
258
|
if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
|
|
259
|
-
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
259
|
+
const createTableRequest1 = getCreateTableRequestsFor(entityName, {
|
|
260
|
+
tableNamePrefix: options.tablePrefix,
|
|
261
|
+
dropIfExists: true
|
|
262
|
+
});
|
|
260
263
|
const createTableRequest2 = getCreateTableRequestsFor(entityName, {
|
|
261
|
-
tableNamePrefix: options.stagingTablePrefix
|
|
264
|
+
tableNamePrefix: options.stagingTablePrefix,
|
|
265
|
+
dropIfExists: true
|
|
262
266
|
});
|
|
263
|
-
return
|
|
267
|
+
return {
|
|
268
|
+
dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
|
|
269
|
+
createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
|
|
270
|
+
};
|
|
264
271
|
}
|
|
265
272
|
function getCreateTableRequestsFor(entityName, options2) {
|
|
266
273
|
const { tableNameSuffix, tableNamePrefix, dropIfExists, addPrimaryKey, addForeignKeys, foreignKeysTables } = options2 || {};
|