sasat 0.21.7 → 0.21.9

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/cli/cli.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const cac = require('cac');
5
- const error = require('../shared/sasat.f544328b.cjs');
5
+ const error = require('../shared/sasat.19043592.cjs');
6
6
  require('pluralize');
7
7
  const fs = require('fs');
8
8
  const path = require('path');
@@ -1398,7 +1398,6 @@ const writeDiagram = async () => {
1398
1398
  const result = `erDiagram
1399
1399
  ${entities.join("\n")}
1400
1400
  `;
1401
- console.log();
1402
1401
  fs__default.writeFileSync(
1403
1402
  path__default.join(
1404
1403
  error.config().migration.out,
@@ -1431,7 +1430,7 @@ function processTable(store, table) {
1431
1430
  const rel2 = it;
1432
1431
  const ref = rel2.data.reference;
1433
1432
  const parent = store.table(ref.parentTable).column(ref.parentColumn);
1434
- return `${ref.parentTable} ${getRefType(parent, ref.relation)} ${table.tableName} : ${ref.relationName}`;
1433
+ return `${ref.parentTable} ${getRefType(parent, ref.relation)} ${table.tableName} : ${ref.relationName ?? rel2.data.reference.parentTable + "<->" + rel2.table.tableName}`;
1435
1434
  });
1436
1435
  return `${table.tableName} {
1437
1436
  ${table.columns.map((it) => ` ${it.columnName()} ${it.dataType()}`).join("\n")}
@@ -3565,6 +3564,8 @@ const makeJoinConditionThrowExpressions = (cv) => {
3565
3564
  const makeThrowExpressions = (condition) => {
3566
3565
  if (condition.kind === "custom")
3567
3566
  return [];
3567
+ if (condition.kind === "isNull")
3568
+ return [makeJoinConditionThrowExpressions(condition.value)];
3568
3569
  if (condition.operator === "BETWEEN") {
3569
3570
  return [
3570
3571
  makeJoinConditionThrowExpressions(condition.left),
@@ -3625,6 +3626,9 @@ const makeConditionExpr = (entity, condition) => {
3625
3626
  if (condition.kind === "custom") {
3626
3627
  return tsg.identifier(condition.conditionName).importFrom("../conditions").call(tsg.identifier("arg"));
3627
3628
  }
3629
+ if (condition.kind === "isNull") {
3630
+ return qExpr.property(condition.not ? "isNotNull" : "isNull").call(makeJoinConditionValueQExpr(entity, condition.value));
3631
+ }
3628
3632
  if (condition.operator === "BETWEEN") {
3629
3633
  return qExpr.property("between").call(
3630
3634
  makeJoinConditionValueQExpr(entity, condition.left),
@@ -3669,6 +3673,8 @@ const getChildConditionValue = (cv) => {
3669
3673
  const getConditionChildColumnNames = (getConditionValue) => (c) => {
3670
3674
  if (c.kind === "custom")
3671
3675
  return c.childRequiredFields || [];
3676
+ if (c.kind === "isNull")
3677
+ return [];
3672
3678
  const result = [getConditionValue(c.left)];
3673
3679
  if (c.operator === "IN") {
3674
3680
  result.push(getConditionValue(c.left));
@@ -4850,6 +4856,12 @@ const reverseConditionNode = (condition) => {
4850
4856
  parentRequiredFields: condition.childRequiredFields,
4851
4857
  childRequiredFields: condition.parentRequiredFields
4852
4858
  };
4859
+ if (condition.kind === "isNull") {
4860
+ if (condition.not) {
4861
+ return error.Conditions.rel.isNotNull(reverseConditionValue(condition.value));
4862
+ }
4863
+ return error.Conditions.rel.isNull(reverseConditionValue(condition.value));
4864
+ }
4853
4865
  if (condition.operator === "BETWEEN") {
4854
4866
  return error.Conditions.rel.between(
4855
4867
  reverseConditionValue(condition.left),
package/dist/cli/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { cac } from 'cac';
3
- import { S as SqlString, a as SasatError, c as config, r as readInitialSchema, g as getDbClient, m as mkDirIfNotExist, n as nonNullable, u as unique, C as Conditions, w as writeFileIfNotExist, b as writeCurrentSchema, d as writeYmlFile, e as defaultConf } from '../shared/sasat.01289068.mjs';
3
+ import { S as SqlString, a as SasatError, c as config, r as readInitialSchema, g as getDbClient, m as mkDirIfNotExist, n as nonNullable, u as unique, C as Conditions, w as writeFileIfNotExist, b as writeCurrentSchema, d as writeYmlFile, e as defaultConf } from '../shared/sasat.f15e60f6.mjs';
4
4
  import 'pluralize';
5
5
  import * as fs from 'fs';
6
6
  import fs__default from 'fs';
@@ -1373,7 +1373,6 @@ const writeDiagram = async () => {
1373
1373
  const result = `erDiagram
1374
1374
  ${entities.join("\n")}
1375
1375
  `;
1376
- console.log();
1377
1376
  fs__default.writeFileSync(
1378
1377
  path__default.join(
1379
1378
  config().migration.out,
@@ -1406,7 +1405,7 @@ function processTable(store, table) {
1406
1405
  const rel2 = it;
1407
1406
  const ref = rel2.data.reference;
1408
1407
  const parent = store.table(ref.parentTable).column(ref.parentColumn);
1409
- return `${ref.parentTable} ${getRefType(parent, ref.relation)} ${table.tableName} : ${ref.relationName}`;
1408
+ return `${ref.parentTable} ${getRefType(parent, ref.relation)} ${table.tableName} : ${ref.relationName ?? rel2.data.reference.parentTable + "<->" + rel2.table.tableName}`;
1410
1409
  });
1411
1410
  return `${table.tableName} {
1412
1411
  ${table.columns.map((it) => ` ${it.columnName()} ${it.dataType()}`).join("\n")}
@@ -3540,6 +3539,8 @@ const makeJoinConditionThrowExpressions = (cv) => {
3540
3539
  const makeThrowExpressions = (condition) => {
3541
3540
  if (condition.kind === "custom")
3542
3541
  return [];
3542
+ if (condition.kind === "isNull")
3543
+ return [makeJoinConditionThrowExpressions(condition.value)];
3543
3544
  if (condition.operator === "BETWEEN") {
3544
3545
  return [
3545
3546
  makeJoinConditionThrowExpressions(condition.left),
@@ -3600,6 +3601,9 @@ const makeConditionExpr = (entity, condition) => {
3600
3601
  if (condition.kind === "custom") {
3601
3602
  return tsg.identifier(condition.conditionName).importFrom("../conditions").call(tsg.identifier("arg"));
3602
3603
  }
3604
+ if (condition.kind === "isNull") {
3605
+ return qExpr.property(condition.not ? "isNotNull" : "isNull").call(makeJoinConditionValueQExpr(entity, condition.value));
3606
+ }
3603
3607
  if (condition.operator === "BETWEEN") {
3604
3608
  return qExpr.property("between").call(
3605
3609
  makeJoinConditionValueQExpr(entity, condition.left),
@@ -3644,6 +3648,8 @@ const getChildConditionValue = (cv) => {
3644
3648
  const getConditionChildColumnNames = (getConditionValue) => (c) => {
3645
3649
  if (c.kind === "custom")
3646
3650
  return c.childRequiredFields || [];
3651
+ if (c.kind === "isNull")
3652
+ return [];
3647
3653
  const result = [getConditionValue(c.left)];
3648
3654
  if (c.operator === "IN") {
3649
3655
  result.push(getConditionValue(c.left));
@@ -4825,6 +4831,12 @@ const reverseConditionNode = (condition) => {
4825
4831
  parentRequiredFields: condition.childRequiredFields,
4826
4832
  childRequiredFields: condition.parentRequiredFields
4827
4833
  };
4834
+ if (condition.kind === "isNull") {
4835
+ if (condition.not) {
4836
+ return Conditions.rel.isNotNull(reverseConditionValue(condition.value));
4837
+ }
4838
+ return Conditions.rel.isNull(reverseConditionValue(condition.value));
4839
+ }
4828
4840
  if (condition.operator === "BETWEEN") {
4829
4841
  return Conditions.rel.between(
4830
4842
  reverseConditionValue(condition.left),
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const error = require('./shared/sasat.f544328b.cjs');
3
+ const error = require('./shared/sasat.19043592.cjs');
4
4
  const SqlString = require('sqlstring');
5
5
  require('mysql2');
6
6
  require('util');
package/dist/index.d.cts CHANGED
@@ -514,6 +514,10 @@ type JoinConditionNode = {
514
514
  left: JoinConditionValue;
515
515
  operator: 'IN';
516
516
  right: JoinConditionValue[];
517
+ } | {
518
+ kind: 'isNull';
519
+ value: JoinConditionValue;
520
+ not: boolean;
517
521
  } | JoinCustomConditionNode;
518
522
  type JoinCustomConditionNode = {
519
523
  kind: 'custom';
@@ -717,6 +721,8 @@ declare const Conditions: {
717
721
  readonly between: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
718
722
  readonly comparison: (left: JoinConditionValue, operator: ComparisonOperators, right: JoinConditionValue) => JoinConditionNode;
719
723
  readonly in: (left: JoinConditionValue, right: JoinConditionValue[]) => JoinConditionNode;
724
+ readonly isNull: (value: JoinConditionValue) => JoinConditionNode;
725
+ readonly isNotNull: (value: JoinConditionValue) => JoinConditionNode;
720
726
  };
721
727
  readonly query: {
722
728
  readonly between: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
@@ -1086,4 +1092,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1086
1092
 
1087
1093
  type PagingOption = ListQueryOption;
1088
1094
 
1089
- export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
1095
+ export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLClient, type SQLExecutor, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
package/dist/index.d.mts CHANGED
@@ -514,6 +514,10 @@ type JoinConditionNode = {
514
514
  left: JoinConditionValue;
515
515
  operator: 'IN';
516
516
  right: JoinConditionValue[];
517
+ } | {
518
+ kind: 'isNull';
519
+ value: JoinConditionValue;
520
+ not: boolean;
517
521
  } | JoinCustomConditionNode;
518
522
  type JoinCustomConditionNode = {
519
523
  kind: 'custom';
@@ -717,6 +721,8 @@ declare const Conditions: {
717
721
  readonly between: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
718
722
  readonly comparison: (left: JoinConditionValue, operator: ComparisonOperators, right: JoinConditionValue) => JoinConditionNode;
719
723
  readonly in: (left: JoinConditionValue, right: JoinConditionValue[]) => JoinConditionNode;
724
+ readonly isNull: (value: JoinConditionValue) => JoinConditionNode;
725
+ readonly isNotNull: (value: JoinConditionValue) => JoinConditionNode;
720
726
  };
721
727
  readonly query: {
722
728
  readonly between: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
@@ -1086,4 +1092,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1086
1092
 
1087
1093
  type PagingOption = ListQueryOption;
1088
1094
 
1089
- export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
1095
+ export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLClient, type SQLExecutor, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
package/dist/index.d.ts CHANGED
@@ -514,6 +514,10 @@ type JoinConditionNode = {
514
514
  left: JoinConditionValue;
515
515
  operator: 'IN';
516
516
  right: JoinConditionValue[];
517
+ } | {
518
+ kind: 'isNull';
519
+ value: JoinConditionValue;
520
+ not: boolean;
517
521
  } | JoinCustomConditionNode;
518
522
  type JoinCustomConditionNode = {
519
523
  kind: 'custom';
@@ -717,6 +721,8 @@ declare const Conditions: {
717
721
  readonly between: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
718
722
  readonly comparison: (left: JoinConditionValue, operator: ComparisonOperators, right: JoinConditionValue) => JoinConditionNode;
719
723
  readonly in: (left: JoinConditionValue, right: JoinConditionValue[]) => JoinConditionNode;
724
+ readonly isNull: (value: JoinConditionValue) => JoinConditionNode;
725
+ readonly isNotNull: (value: JoinConditionValue) => JoinConditionNode;
720
726
  };
721
727
  readonly query: {
722
728
  readonly between: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
@@ -1086,4 +1092,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1086
1092
 
1087
1093
  type PagingOption = ListQueryOption;
1088
1094
 
1089
- export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
1095
+ export { type BooleanValueExpression, type CommandResponse, type ComparisonOperators, CompositeCondition, Conditions, type CustomCondition, type EntityResult, type EntityType, type Fields, type ListQueryOption, type LockMode, type MigrationStore, Mutations, type PagingOption, QExpr, Queries, type Query, type QueryOptions, type QueryResponse, type Relation, type RelationMap, type ResolverMiddleware, SQLClient, type SQLExecutor, SQLTransaction, SasatDBDatasource, type SasatMigration, Sql, SqlString, type TableInfo, type TypeFieldDefinition, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SqlString$1, n as nonNullable, u as unique, g as getDbClient, a as SasatError } from './shared/sasat.01289068.mjs';
2
- export { C as Conditions, p as pick } from './shared/sasat.01289068.mjs';
1
+ import { S as SqlString$1, n as nonNullable, u as unique, g as getDbClient, a as SasatError } from './shared/sasat.f15e60f6.mjs';
2
+ export { C as Conditions, p as pick } from './shared/sasat.f15e60f6.mjs';
3
3
  import * as SqlString from 'sqlstring';
4
4
  import 'mysql2';
5
5
  import 'util';
@@ -119,6 +119,16 @@ const inRel = (left, right) => ({
119
119
  right,
120
120
  operator: "IN"
121
121
  });
122
+ const isNullRel = (value) => ({
123
+ kind: "isNull",
124
+ value,
125
+ not: false
126
+ });
127
+ const isNotNullRel = (value) => ({
128
+ kind: "isNull",
129
+ value,
130
+ not: true
131
+ });
122
132
  const comparisonQuery = (left, operator, right) => ({
123
133
  kind: "comparison",
124
134
  left,
@@ -132,7 +142,9 @@ const Conditions = {
132
142
  rel: {
133
143
  between: betweenRel,
134
144
  comparison: comparisonRel,
135
- in: inRel
145
+ in: inRel,
146
+ isNull: isNullRel,
147
+ isNotNull: isNotNullRel
136
148
  },
137
149
  query: {
138
150
  between: betweenQuery,
@@ -97,6 +97,16 @@ const inRel = (left, right) => ({
97
97
  right,
98
98
  operator: "IN"
99
99
  });
100
+ const isNullRel = (value) => ({
101
+ kind: "isNull",
102
+ value,
103
+ not: false
104
+ });
105
+ const isNotNullRel = (value) => ({
106
+ kind: "isNull",
107
+ value,
108
+ not: true
109
+ });
100
110
  const comparisonQuery = (left, operator, right) => ({
101
111
  kind: "comparison",
102
112
  left,
@@ -110,7 +120,9 @@ const Conditions = {
110
120
  rel: {
111
121
  between: betweenRel,
112
122
  comparison: comparisonRel,
113
- in: inRel
123
+ in: inRel,
124
+ isNull: isNullRel,
125
+ isNotNull: isNotNullRel
114
126
  },
115
127
  query: {
116
128
  between: betweenQuery,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.21.7",
3
+ "version": "0.21.9",
4
4
  "repository": "https://github.com/nin138/sasat.git",
5
5
  "author": "nin138 <ninian138@gmail.com>",
6
6
  "license": "MIT",