sonamu 0.2.52 → 0.2.54
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/bin/cli-wrapper.mjs +1 -2
- package/dist/bin/cli-wrapper.mjs.map +1 -1
- package/dist/bin/cli.js +48 -48
- package/dist/bin/cli.mjs +2 -3
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/{chunk-4EET56IE.js → chunk-JOHF7PK4.js} +24 -11
- package/dist/chunk-JOHF7PK4.js.map +1 -0
- package/dist/{chunk-HEPO4HGK.mjs → chunk-L4KELCY7.mjs} +16 -4
- package/dist/chunk-L4KELCY7.mjs.map +1 -0
- package/dist/{chunk-JXJTFHF7.mjs → chunk-PTFDTOJU.mjs} +1 -2
- package/dist/{chunk-JXJTFHF7.mjs.map → chunk-PTFDTOJU.mjs.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/code-converters.ts +19 -0
- package/dist/chunk-4EET56IE.js.map +0 -1
- package/dist/chunk-HEPO4HGK.mjs.map +0 -1
|
@@ -356,6 +356,19 @@ function getZodTypeFromApiParamType(paramType, references) {
|
|
|
356
356
|
return reference;
|
|
357
357
|
case "union":
|
|
358
358
|
const unionType = paramType;
|
|
359
|
+
if (unionType.types.length === 2 && unionType.types.some((type) => type === "null")) {
|
|
360
|
+
if (unionType.types[0] === "null") {
|
|
361
|
+
return getZodTypeFromApiParamType(
|
|
362
|
+
unionType.types[1],
|
|
363
|
+
references
|
|
364
|
+
).nullable();
|
|
365
|
+
} else {
|
|
366
|
+
return getZodTypeFromApiParamType(
|
|
367
|
+
unionType.types[0],
|
|
368
|
+
references
|
|
369
|
+
).nullable();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
359
372
|
return _zod.z.union(
|
|
360
373
|
unionType.types.map(
|
|
361
374
|
(type) => getZodTypeFromApiParamType(type, references)
|
|
@@ -4163,7 +4176,7 @@ var DBClass = class {
|
|
|
4163
4176
|
);
|
|
4164
4177
|
try {
|
|
4165
4178
|
const knexfileModule = await Promise.resolve().then(() => _interopRequireWildcard(require(dbConfigPath)));
|
|
4166
|
-
return knexfileModule.default;
|
|
4179
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([knexfileModule, 'access', _81 => _81.default, 'optionalAccess', _82 => _82.default]), () => ( knexfileModule.default)), () => ( knexfileModule));
|
|
4167
4180
|
} catch (e17) {
|
|
4168
4181
|
}
|
|
4169
4182
|
throw new ServiceUnavailableException(
|
|
@@ -4304,7 +4317,7 @@ var UpsertBuilder = class {
|
|
|
4304
4317
|
this.tables.set(tableName, {
|
|
4305
4318
|
references: /* @__PURE__ */ new Set(),
|
|
4306
4319
|
rows: [],
|
|
4307
|
-
uniqueIndexes: _nullishCoalesce(_optionalChain([tableSpec, 'optionalAccess',
|
|
4320
|
+
uniqueIndexes: _nullishCoalesce(_optionalChain([tableSpec, 'optionalAccess', _83 => _83.uniqueIndexes]), () => ( [])),
|
|
4308
4321
|
uniquesMap: /* @__PURE__ */ new Map()
|
|
4309
4322
|
});
|
|
4310
4323
|
}
|
|
@@ -4719,7 +4732,7 @@ var BaseModelClass = class {
|
|
|
4719
4732
|
_chalk2.default.blue(countQuery.toQuery().toString())
|
|
4720
4733
|
);
|
|
4721
4734
|
}
|
|
4722
|
-
return _nullishCoalesce(_optionalChain([countRow, 'optionalAccess',
|
|
4735
|
+
return _nullishCoalesce(_optionalChain([countRow, 'optionalAccess', _84 => _84.total]), () => ( 0));
|
|
4723
4736
|
})();
|
|
4724
4737
|
const rows = await (async () => {
|
|
4725
4738
|
if (queryMode === "count") {
|
|
@@ -4895,7 +4908,7 @@ var SonamuClass = class {
|
|
|
4895
4908
|
}
|
|
4896
4909
|
async withFastify(server, config, options) {
|
|
4897
4910
|
if (this.isInitialized === false) {
|
|
4898
|
-
await this.init(_optionalChain([options, 'optionalAccess',
|
|
4911
|
+
await this.init(_optionalChain([options, 'optionalAccess', _85 => _85.doSilent]), _optionalChain([options, 'optionalAccess', _86 => _86.enableSync]));
|
|
4899
4912
|
}
|
|
4900
4913
|
server.get(
|
|
4901
4914
|
`${this.config.route.prefix}/routes`,
|
|
@@ -5313,7 +5326,7 @@ var Entity = class {
|
|
|
5313
5326
|
const relSubsetQuery = relEntity.resolveSubsetQuery("", relFields);
|
|
5314
5327
|
let manyJoin;
|
|
5315
5328
|
if (isHasManyRelationProp(relation)) {
|
|
5316
|
-
const fromCol = _nullishCoalesce(_optionalChain([relation, 'optionalAccess',
|
|
5329
|
+
const fromCol = _nullishCoalesce(_optionalChain([relation, 'optionalAccess', _87 => _87.fromColumn]), () => ( "id"));
|
|
5317
5330
|
manyJoin = {
|
|
5318
5331
|
fromTable: this.table,
|
|
5319
5332
|
fromCol,
|
|
@@ -6518,7 +6531,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
6518
6531
|
const [, keyName, from, referencesTable, referencesField, onClause] = matched2;
|
|
6519
6532
|
const [onUpdateFull, _onUpdate] = _nullishCoalesce((_nullishCoalesce(onClause, () => ( ""))).match(/ON UPDATE ([A-Z ]+)$/), () => ( []));
|
|
6520
6533
|
const onUpdate = _nullishCoalesce(_onUpdate, () => ( "NO ACTION"));
|
|
6521
|
-
const onDelete = _nullishCoalesce(_optionalChain([(_nullishCoalesce(onClause, () => ( ""))), 'access',
|
|
6534
|
+
const onDelete = _nullishCoalesce(_optionalChain([(_nullishCoalesce(onClause, () => ( ""))), 'access', _88 => _88.replace, 'call', _89 => _89(_nullishCoalesce(onUpdateFull, () => ( "")), ""), 'access', _90 => _90.match, 'call', _91 => _91(/ON DELETE ([A-Z ]+) /), 'optionalAccess', _92 => _92[1]]), () => ( "NO ACTION"));
|
|
6522
6535
|
return {
|
|
6523
6536
|
keyName,
|
|
6524
6537
|
from,
|
|
@@ -7393,7 +7406,7 @@ var FixtureManagerClass = class {
|
|
|
7393
7406
|
const targetDB = _knex2.default.call(void 0, Sonamu.dbConfig[targetDBName]);
|
|
7394
7407
|
const { entityId, field, value, searchType } = searchOptions;
|
|
7395
7408
|
const entity = EntityManager.get(entityId);
|
|
7396
|
-
const column = _optionalChain([entity, 'access',
|
|
7409
|
+
const column = _optionalChain([entity, 'access', _93 => _93.props, 'access', _94 => _94.find, 'call', _95 => _95((prop) => prop.name === field), 'optionalAccess', _96 => _96.type]) === "relation" ? `${field}_id` : field;
|
|
7397
7410
|
let query = sourceDB(entity.table);
|
|
7398
7411
|
if (searchType === "equals") {
|
|
7399
7412
|
query = query.where(column, value);
|
|
@@ -7465,7 +7478,7 @@ var FixtureManagerClass = class {
|
|
|
7465
7478
|
prop,
|
|
7466
7479
|
value: row[prop.name]
|
|
7467
7480
|
};
|
|
7468
|
-
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7481
|
+
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97._db]), () => ( BaseModel.getDB("w")));
|
|
7469
7482
|
if (isManyToManyRelationProp(prop)) {
|
|
7470
7483
|
const relatedEntity = EntityManager.get(prop.with);
|
|
7471
7484
|
const throughTable = prop.joinTable;
|
|
@@ -7484,7 +7497,7 @@ var FixtureManagerClass = class {
|
|
|
7484
7497
|
);
|
|
7485
7498
|
if (relatedProp) {
|
|
7486
7499
|
const relatedRow = await db(relatedEntity.table).where("id", row.id).first();
|
|
7487
|
-
record.columns[prop.name].value = _optionalChain([relatedRow, 'optionalAccess',
|
|
7500
|
+
record.columns[prop.name].value = _optionalChain([relatedRow, 'optionalAccess', _98 => _98.id]);
|
|
7488
7501
|
}
|
|
7489
7502
|
} else if (isRelationProp(prop)) {
|
|
7490
7503
|
const relatedId = row[`${prop.name}_id`];
|
|
@@ -7492,7 +7505,7 @@ var FixtureManagerClass = class {
|
|
|
7492
7505
|
if (relatedId) {
|
|
7493
7506
|
record.belongsRecords.push(`${prop.with}#${relatedId}`);
|
|
7494
7507
|
}
|
|
7495
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
7508
|
+
if (!_optionalChain([options, 'optionalAccess', _99 => _99.singleRecord]) && relatedId) {
|
|
7496
7509
|
const relatedEntity = EntityManager.get(prop.with);
|
|
7497
7510
|
const relatedRow = await db(relatedEntity.table).where("id", relatedId).first();
|
|
7498
7511
|
if (relatedRow) {
|
|
@@ -7832,4 +7845,4 @@ var FixtureManager = new FixtureManagerClass();
|
|
|
7832
7845
|
|
|
7833
7846
|
|
|
7834
7847
|
exports.SQLDateTimeString = SQLDateTimeString; exports.zArrayable = zArrayable; exports.isIntegerProp = isIntegerProp; exports.isBigIntegerProp = isBigIntegerProp; exports.isTextProp = isTextProp; exports.isStringProp = isStringProp; exports.isEnumProp = isEnumProp; exports.isFloatProp = isFloatProp; exports.isDoubleProp = isDoubleProp; exports.isDecimalProp = isDecimalProp; exports.isBooleanProp = isBooleanProp; exports.isDateProp = isDateProp; exports.isDateTimeProp = isDateTimeProp; exports.isTimeProp = isTimeProp; exports.isTimestampProp = isTimestampProp; exports.isJsonProp = isJsonProp; exports.isUuidProp = isUuidProp; exports.isVirtualProp = isVirtualProp; exports.isRelationProp = isRelationProp; exports.isOneToOneRelationProp = isOneToOneRelationProp; exports.isBelongsToOneRelationProp = isBelongsToOneRelationProp; exports.isHasManyRelationProp = isHasManyRelationProp; exports.isManyToManyRelationProp = isManyToManyRelationProp; exports.isCustomJoinClause = isCustomJoinClause; exports.SonamuQueryMode = SonamuQueryMode; exports.isKnexError = isKnexError; exports.ApiParamType = ApiParamType; exports.RenderingNode = RenderingNode; exports.TemplateOptions = TemplateOptions; exports.TemplateKey = TemplateKey; exports.GenerateOptions = GenerateOptions; exports.PathAndCode = PathAndCode; exports.getZodObjectFromApi = getZodObjectFromApi; exports.getZodObjectFromApiParams = getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = getZodTypeFromApiParamType; exports.propNodeToZodTypeDef = propNodeToZodTypeDef; exports.getTextTypeLength = getTextTypeLength; exports.propToZodTypeDef = propToZodTypeDef; exports.zodTypeToZodCode = zodTypeToZodCode; exports.apiParamToTsCode = apiParamToTsCode; exports.apiParamTypeToTsType = apiParamTypeToTsType; exports.unwrapPromiseOnce = unwrapPromiseOnce; exports.serializeZodType = serializeZodType; exports.zodTypeToTsTypeDef = zodTypeToTsTypeDef; exports.registeredApis = registeredApis; exports.api = api; exports.SoException = SoException; exports.isSoException = isSoException; exports.BadRequestException = BadRequestException; exports.UnauthorizedException = UnauthorizedException; exports.NotFoundException = NotFoundException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.InternalServerErrorException = InternalServerErrorException; exports.AlreadyProcessedException = AlreadyProcessedException; exports.DuplicateRowException = DuplicateRowException; exports.TargetNotFoundException = TargetNotFoundException; exports.globAsync = globAsync; exports.importMultiple = importMultiple; exports.findAppRootPath = findAppRootPath; exports.findApiRootPath = findApiRootPath; exports.nonNullable = nonNullable; exports.Entity = Entity; exports.EntityManager = EntityManager; exports.Syncer = Syncer; exports.isLocal = isLocal; exports.isRemote = isRemote; exports.isInDocker = isInDocker; exports.isDaemonServer = isDaemonServer; exports.isDevelopment = isDevelopment; exports.isStaging = isStaging; exports.isProduction = isProduction; exports.isTest = isTest; exports.DB = DB; exports.isRefField = isRefField; exports.UpsertBuilder = UpsertBuilder; exports.BaseModelClass = BaseModelClass; exports.BaseModel = BaseModel; exports.Sonamu = Sonamu; exports.Migrator = Migrator; exports.FixtureManagerClass = FixtureManagerClass; exports.FixtureManager = FixtureManager;
|
|
7835
|
-
//# sourceMappingURL=chunk-
|
|
7848
|
+
//# sourceMappingURL=chunk-JOHF7PK4.js.map
|