sasat 0.21.6 → 0.21.7

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/index.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const queryToSql_js = require('runtime/dsl/query/sql/queryToSql.js');
4
3
  const error = require('./shared/sasat.f544328b.cjs');
5
4
  const SqlString = require('sqlstring');
6
5
  require('mysql2');
@@ -44,30 +43,6 @@ var QueryNodeKind = /* @__PURE__ */ ((QueryNodeKind2) => {
44
43
  return QueryNodeKind2;
45
44
  })(QueryNodeKind || {});
46
45
 
47
- const getJoin = (from) => {
48
- return from.joins.flatMap((join) => [join, ...getJoin(join.table)]);
49
- };
50
- const getLock = (lock) => {
51
- if (!lock)
52
- return "";
53
- if (lock === "FOR UPDATE")
54
- return " FOR UPDATE";
55
- return " FOR SHARE";
56
- };
57
- const queryToSql = (query) => {
58
- const select = query.select.map(Sql.select).join(", ");
59
- const join = getJoin(query.from).map(Sql.join).join(" ");
60
- const where = query.where ? " WHERE " + Sql.booleanValue(query.where) : "";
61
- const groupBy = query.groupBy ? " GROUP BY" + query.groupBy.cols.map(Sql.value).join(",") : "";
62
- const having = query.having ? "HAVING " + Sql.booleanValue(query.having) : "";
63
- const sort = query.sort && query.sort.length !== 0 ? " ORDER BY " + Sql.sorts(query.sort) : "";
64
- const limit = query.limit ? " LIMIT " + query.limit : "";
65
- const offset = query.offset ? " OFFSET " + query.offset : "";
66
- if (offset && !limit)
67
- throw new Error("LIMIT is required to use OFFSET.");
68
- return `SELECT ${select} FROM ${Sql.table(query.from)}` + join + where + groupBy + having + sort + limit + offset + getLock(query.lock);
69
- };
70
-
71
46
  const SELECT_ALIAS_SEPARATOR = "__";
72
47
  const Sql = {
73
48
  select: (expr) => {
@@ -184,6 +159,30 @@ const Sql = {
184
159
  }
185
160
  };
186
161
 
162
+ const getJoin = (from) => {
163
+ return from.joins.flatMap((join) => [join, ...getJoin(join.table)]);
164
+ };
165
+ const getLock = (lock) => {
166
+ if (!lock)
167
+ return "";
168
+ if (lock === "FOR UPDATE")
169
+ return " FOR UPDATE";
170
+ return " FOR SHARE";
171
+ };
172
+ const queryToSql = (query) => {
173
+ const select = query.select.map(Sql.select).join(", ");
174
+ const join = getJoin(query.from).map(Sql.join).join(" ");
175
+ const where = query.where ? " WHERE " + Sql.booleanValue(query.where) : "";
176
+ const groupBy = query.groupBy ? " GROUP BY" + query.groupBy.cols.map(Sql.value).join(",") : "";
177
+ const having = query.having ? "HAVING " + Sql.booleanValue(query.having) : "";
178
+ const sort = query.sort && query.sort.length !== 0 ? " ORDER BY " + Sql.sorts(query.sort) : "";
179
+ const limit = query.limit ? " LIMIT " + query.limit : "";
180
+ const offset = query.offset ? " OFFSET " + query.offset : "";
181
+ if (offset && !limit)
182
+ throw new Error("LIMIT is required to use OFFSET.");
183
+ return `SELECT ${select} FROM ${Sql.table(query.from)}` + join + where + groupBy + having + sort + limit + offset + getLock(query.lock);
184
+ };
185
+
187
186
  const makeParamsMiddleware = (update) => {
188
187
  return (args) => {
189
188
  args[1] = update(args[1]);
@@ -1042,7 +1041,6 @@ const pagingOption = (option) => {
1042
1041
  return { numberOfItem: option.numberOfItem, offset: option.offset, sort };
1043
1042
  };
1044
1043
 
1045
- exports.queryToSql = queryToSql_js.queryToSql;
1046
1044
  exports.Conditions = error.Conditions;
1047
1045
  exports.SqlString = error.SqlString;
1048
1046
  exports.getDbClient = error.getDbClient;
@@ -1069,3 +1067,4 @@ exports.makeParamsMiddleware = makeParamsMiddleware;
1069
1067
  exports.makeResolver = makeResolver;
1070
1068
  exports.pagingOption = pagingOption;
1071
1069
  exports.qe = QExpr;
1070
+ exports.queryToSql = queryToSql;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- export { queryToSql } from 'runtime/dsl/query/sql/queryToSql.js';
2
1
  import pkg from 'sqlstring';
3
2
  import { GraphQLResolveInfo } from 'graphql/type';
4
3
  import Hashids from 'hashids';
@@ -149,6 +148,8 @@ type Sort = {
149
148
  direction?: SortDirection;
150
149
  };
151
150
 
151
+ declare const queryToSql: (query: Query) => string;
152
+
152
153
  type QueryResponse = Array<{
153
154
  [key: string]: SqlValueType;
154
155
  }>;
@@ -1085,4 +1086,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1085
1086
 
1086
1087
  type PagingOption = ListQueryOption;
1087
1088
 
1088
- 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 };
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 };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- export { queryToSql } from 'runtime/dsl/query/sql/queryToSql.js';
2
1
  import pkg from 'sqlstring';
3
2
  import { GraphQLResolveInfo } from 'graphql/type';
4
3
  import Hashids from 'hashids';
@@ -149,6 +148,8 @@ type Sort = {
149
148
  direction?: SortDirection;
150
149
  };
151
150
 
151
+ declare const queryToSql: (query: Query) => string;
152
+
152
153
  type QueryResponse = Array<{
153
154
  [key: string]: SqlValueType;
154
155
  }>;
@@ -1085,4 +1086,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1085
1086
 
1086
1087
  type PagingOption = ListQueryOption;
1087
1088
 
1088
- 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { queryToSql } from 'runtime/dsl/query/sql/queryToSql.js';
2
1
  import pkg from 'sqlstring';
3
2
  import { GraphQLResolveInfo } from 'graphql/type';
4
3
  import Hashids from 'hashids';
@@ -149,6 +148,8 @@ type Sort = {
149
148
  direction?: SortDirection;
150
149
  };
151
150
 
151
+ declare const queryToSql: (query: Query) => string;
152
+
152
153
  type QueryResponse = Array<{
153
154
  [key: string]: SqlValueType;
154
155
  }>;
@@ -1085,4 +1086,4 @@ declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
1085
1086
 
1086
1087
  type PagingOption = ListQueryOption;
1087
1088
 
1088
- 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 };
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 };
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- export { queryToSql } from 'runtime/dsl/query/sql/queryToSql.js';
2
1
  import { S as SqlString$1, n as nonNullable, u as unique, g as getDbClient, a as SasatError } from './shared/sasat.01289068.mjs';
3
2
  export { C as Conditions, p as pick } from './shared/sasat.01289068.mjs';
4
3
  import * as SqlString from 'sqlstring';
@@ -29,30 +28,6 @@ var QueryNodeKind = /* @__PURE__ */ ((QueryNodeKind2) => {
29
28
  return QueryNodeKind2;
30
29
  })(QueryNodeKind || {});
31
30
 
32
- const getJoin = (from) => {
33
- return from.joins.flatMap((join) => [join, ...getJoin(join.table)]);
34
- };
35
- const getLock = (lock) => {
36
- if (!lock)
37
- return "";
38
- if (lock === "FOR UPDATE")
39
- return " FOR UPDATE";
40
- return " FOR SHARE";
41
- };
42
- const queryToSql = (query) => {
43
- const select = query.select.map(Sql.select).join(", ");
44
- const join = getJoin(query.from).map(Sql.join).join(" ");
45
- const where = query.where ? " WHERE " + Sql.booleanValue(query.where) : "";
46
- const groupBy = query.groupBy ? " GROUP BY" + query.groupBy.cols.map(Sql.value).join(",") : "";
47
- const having = query.having ? "HAVING " + Sql.booleanValue(query.having) : "";
48
- const sort = query.sort && query.sort.length !== 0 ? " ORDER BY " + Sql.sorts(query.sort) : "";
49
- const limit = query.limit ? " LIMIT " + query.limit : "";
50
- const offset = query.offset ? " OFFSET " + query.offset : "";
51
- if (offset && !limit)
52
- throw new Error("LIMIT is required to use OFFSET.");
53
- return `SELECT ${select} FROM ${Sql.table(query.from)}` + join + where + groupBy + having + sort + limit + offset + getLock(query.lock);
54
- };
55
-
56
31
  const SELECT_ALIAS_SEPARATOR = "__";
57
32
  const Sql = {
58
33
  select: (expr) => {
@@ -169,6 +144,30 @@ const Sql = {
169
144
  }
170
145
  };
171
146
 
147
+ const getJoin = (from) => {
148
+ return from.joins.flatMap((join) => [join, ...getJoin(join.table)]);
149
+ };
150
+ const getLock = (lock) => {
151
+ if (!lock)
152
+ return "";
153
+ if (lock === "FOR UPDATE")
154
+ return " FOR UPDATE";
155
+ return " FOR SHARE";
156
+ };
157
+ const queryToSql = (query) => {
158
+ const select = query.select.map(Sql.select).join(", ");
159
+ const join = getJoin(query.from).map(Sql.join).join(" ");
160
+ const where = query.where ? " WHERE " + Sql.booleanValue(query.where) : "";
161
+ const groupBy = query.groupBy ? " GROUP BY" + query.groupBy.cols.map(Sql.value).join(",") : "";
162
+ const having = query.having ? "HAVING " + Sql.booleanValue(query.having) : "";
163
+ const sort = query.sort && query.sort.length !== 0 ? " ORDER BY " + Sql.sorts(query.sort) : "";
164
+ const limit = query.limit ? " LIMIT " + query.limit : "";
165
+ const offset = query.offset ? " OFFSET " + query.offset : "";
166
+ if (offset && !limit)
167
+ throw new Error("LIMIT is required to use OFFSET.");
168
+ return `SELECT ${select} FROM ${Sql.table(query.from)}` + join + where + groupBy + having + sort + limit + offset + getLock(query.lock);
169
+ };
170
+
172
171
  const makeParamsMiddleware = (update) => {
173
172
  return (args) => {
174
173
  args[1] = update(args[1]);
@@ -1027,4 +1026,4 @@ const pagingOption = (option) => {
1027
1026
  return { numberOfItem: option.numberOfItem, offset: option.offset, sort };
1028
1027
  };
1029
1028
 
1030
- export { CompositeCondition, Mutations, QExpr, Queries, SasatDBDatasource, Sql, SqlString$1 as SqlString, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, QExpr as qe };
1029
+ export { CompositeCondition, Mutations, QExpr, Queries, SasatDBDatasource, Sql, SqlString$1 as SqlString, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, QExpr as qe, queryToSql };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.21.6",
3
+ "version": "0.21.7",
4
4
  "repository": "https://github.com/nin138/sasat.git",
5
5
  "author": "nin138 <ninian138@gmail.com>",
6
6
  "license": "MIT",