drizzle-orm 0.35.3-d39c24e → 0.36.0-19f042a
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/mysql-core/columns/decimal.cjs +12 -7
- package/mysql-core/columns/decimal.cjs.map +1 -1
- package/mysql-core/columns/decimal.d.cts +3 -1
- package/mysql-core/columns/decimal.d.ts +3 -1
- package/mysql-core/columns/decimal.js +12 -7
- package/mysql-core/columns/decimal.js.map +1 -1
- package/mysql-core/columns/double.cjs +7 -3
- package/mysql-core/columns/double.cjs.map +1 -1
- package/mysql-core/columns/double.d.cts +4 -2
- package/mysql-core/columns/double.d.ts +4 -2
- package/mysql-core/columns/double.js +7 -3
- package/mysql-core/columns/double.js.map +1 -1
- package/mysql-core/columns/float.cjs +20 -4
- package/mysql-core/columns/float.cjs.map +1 -1
- package/mysql-core/columns/float.d.cts +13 -4
- package/mysql-core/columns/float.d.ts +13 -4
- package/mysql-core/columns/float.js +20 -4
- package/mysql-core/columns/float.js.map +1 -1
- package/neon/rls.cjs +31 -11
- package/neon/rls.cjs.map +1 -1
- package/neon/rls.d.cts +12 -3
- package/neon/rls.d.ts +12 -3
- package/neon/rls.js +31 -11
- package/neon/rls.js.map +1 -1
- package/package.json +49 -49
- package/supabase/rls.cjs +10 -3
- package/supabase/rls.cjs.map +1 -1
- package/supabase/rls.d.cts +112 -0
- package/supabase/rls.d.ts +112 -0
- package/supabase/rls.js +11 -4
- package/supabase/rls.js.map +1 -1
- package/utils.cjs +1 -1
- package/utils.cjs.map +1 -1
- package/utils.js +1 -1
- package/utils.js.map +1 -1
- package/version.cjs +2 -2
- package/version.cjs.map +1 -1
- package/version.d.cts +2 -2
- package/version.d.ts +2 -2
- package/version.js +2 -2
- package/version.js.map +1 -1
|
@@ -28,10 +28,11 @@ var import_utils = require("../../utils.cjs");
|
|
|
28
28
|
var import_common = require("./common.cjs");
|
|
29
29
|
class MySqlDecimalBuilder extends import_common.MySqlColumnBuilderWithAutoIncrement {
|
|
30
30
|
static [import_entity.entityKind] = "MySqlDecimalBuilder";
|
|
31
|
-
constructor(name,
|
|
31
|
+
constructor(name, config) {
|
|
32
32
|
super(name, "string", "MySqlDecimal");
|
|
33
|
-
this.config.precision = precision;
|
|
34
|
-
this.config.scale = scale;
|
|
33
|
+
this.config.precision = config?.precision;
|
|
34
|
+
this.config.scale = config?.scale;
|
|
35
|
+
this.config.unsigned = config?.unsigned;
|
|
35
36
|
}
|
|
36
37
|
/** @internal */
|
|
37
38
|
build(table) {
|
|
@@ -45,19 +46,23 @@ class MySqlDecimal extends import_common.MySqlColumnWithAutoIncrement {
|
|
|
45
46
|
static [import_entity.entityKind] = "MySqlDecimal";
|
|
46
47
|
precision = this.config.precision;
|
|
47
48
|
scale = this.config.scale;
|
|
49
|
+
unsigned = this.config.unsigned;
|
|
48
50
|
getSQLType() {
|
|
51
|
+
let type = "";
|
|
49
52
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
50
|
-
|
|
53
|
+
type += `decimal(${this.precision},${this.scale})`;
|
|
51
54
|
} else if (this.precision === void 0) {
|
|
52
|
-
|
|
55
|
+
type += "decimal";
|
|
53
56
|
} else {
|
|
54
|
-
|
|
57
|
+
type += `decimal(${this.precision})`;
|
|
55
58
|
}
|
|
59
|
+
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
60
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
function decimal(a, b = {}) {
|
|
59
64
|
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
|
|
60
|
-
return new MySqlDecimalBuilder(name, config
|
|
65
|
+
return new MySqlDecimalBuilder(name, config);
|
|
61
66
|
}
|
|
62
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
68
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'],
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal(\n\tconfig: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\treturn new MySqlDecimalBuilder(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,mBAAuC;AACvC,oBAAkF;AAY3E,MAAM,4BAEH,kDAA2D;AAAA,EACpE,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAwC;AACpE,UAAM,MAAM,UAAU,cAAc;AACpC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OACgD;AAChD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,qBACJ,2CACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,WAAW,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAChD,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,WAAW,KAAK,SAAS;AAAA,IAClC;AACA,WAAO,SAAS,mBAAmB,SAAS,gBAAgB,YAAY;AACxE,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,QAAQ,GAAiC,IAAwB,CAAC,GAAG;AACpF,QAAM,EAAE,MAAM,OAAO,QAAI,qCAA2C,GAAG,CAAC;AACxE,SAAO,IAAI,oBAAoB,MAAM,MAAM;AAC5C;","names":[]}
|
|
@@ -13,17 +13,19 @@ export type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuild
|
|
|
13
13
|
}>;
|
|
14
14
|
export declare class MySqlDecimalBuilder<T extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
15
15
|
static readonly [entityKind]: string;
|
|
16
|
-
constructor(name: T['name'],
|
|
16
|
+
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
17
17
|
}
|
|
18
18
|
export declare class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
20
|
readonly precision: number | undefined;
|
|
21
21
|
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
22
23
|
getSQLType(): string;
|
|
23
24
|
}
|
|
24
25
|
export interface MySqlDecimalConfig {
|
|
25
26
|
precision?: number;
|
|
26
27
|
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export declare function decimal(): MySqlDecimalBuilderInitial<''>;
|
|
29
31
|
export declare function decimal(config: MySqlDecimalConfig): MySqlDecimalBuilderInitial<''>;
|
|
@@ -13,17 +13,19 @@ export type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuild
|
|
|
13
13
|
}>;
|
|
14
14
|
export declare class MySqlDecimalBuilder<T extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
15
15
|
static readonly [entityKind]: string;
|
|
16
|
-
constructor(name: T['name'],
|
|
16
|
+
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
17
17
|
}
|
|
18
18
|
export declare class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
20
|
readonly precision: number | undefined;
|
|
21
21
|
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
22
23
|
getSQLType(): string;
|
|
23
24
|
}
|
|
24
25
|
export interface MySqlDecimalConfig {
|
|
25
26
|
precision?: number;
|
|
26
27
|
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export declare function decimal(): MySqlDecimalBuilderInitial<''>;
|
|
29
31
|
export declare function decimal(config: MySqlDecimalConfig): MySqlDecimalBuilderInitial<''>;
|
|
@@ -3,10 +3,11 @@ import { getColumnNameAndConfig } from "../../utils.js";
|
|
|
3
3
|
import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from "./common.js";
|
|
4
4
|
class MySqlDecimalBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
5
5
|
static [entityKind] = "MySqlDecimalBuilder";
|
|
6
|
-
constructor(name,
|
|
6
|
+
constructor(name, config) {
|
|
7
7
|
super(name, "string", "MySqlDecimal");
|
|
8
|
-
this.config.precision = precision;
|
|
9
|
-
this.config.scale = scale;
|
|
8
|
+
this.config.precision = config?.precision;
|
|
9
|
+
this.config.scale = config?.scale;
|
|
10
|
+
this.config.unsigned = config?.unsigned;
|
|
10
11
|
}
|
|
11
12
|
/** @internal */
|
|
12
13
|
build(table) {
|
|
@@ -20,19 +21,23 @@ class MySqlDecimal extends MySqlColumnWithAutoIncrement {
|
|
|
20
21
|
static [entityKind] = "MySqlDecimal";
|
|
21
22
|
precision = this.config.precision;
|
|
22
23
|
scale = this.config.scale;
|
|
24
|
+
unsigned = this.config.unsigned;
|
|
23
25
|
getSQLType() {
|
|
26
|
+
let type = "";
|
|
24
27
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
25
|
-
|
|
28
|
+
type += `decimal(${this.precision},${this.scale})`;
|
|
26
29
|
} else if (this.precision === void 0) {
|
|
27
|
-
|
|
30
|
+
type += "decimal";
|
|
28
31
|
} else {
|
|
29
|
-
|
|
32
|
+
type += `decimal(${this.precision})`;
|
|
30
33
|
}
|
|
34
|
+
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
35
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
function decimal(a, b = {}) {
|
|
34
39
|
const { name, config } = getColumnNameAndConfig(a, b);
|
|
35
|
-
return new MySqlDecimalBuilder(name, config
|
|
40
|
+
return new MySqlDecimalBuilder(name, config);
|
|
36
41
|
}
|
|
37
42
|
export {
|
|
38
43
|
MySqlDecimal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'],
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal(\n\tconfig: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\treturn new MySqlDecimalBuilder(name, config);\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAS,qCAAqC,oCAAoC;AAY3E,MAAM,4BAEH,oCAA2D;AAAA,EACpE,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAwC;AACpE,UAAM,MAAM,UAAU,cAAc;AACpC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OACgD;AAChD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,qBACJ,6BACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,WAAW,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAChD,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,WAAW,KAAK,SAAS;AAAA,IAClC;AACA,WAAO,SAAS,mBAAmB,SAAS,gBAAgB,YAAY;AACxE,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,QAAQ,GAAiC,IAAwB,CAAC,GAAG;AACpF,QAAM,EAAE,MAAM,OAAO,IAAI,uBAA2C,GAAG,CAAC;AACxE,SAAO,IAAI,oBAAoB,MAAM,MAAM;AAC5C;","names":[]}
|
|
@@ -32,6 +32,7 @@ class MySqlDoubleBuilder extends import_common.MySqlColumnBuilderWithAutoIncreme
|
|
|
32
32
|
super(name, "number", "MySqlDouble");
|
|
33
33
|
this.config.precision = config?.precision;
|
|
34
34
|
this.config.scale = config?.scale;
|
|
35
|
+
this.config.unsigned = config?.unsigned;
|
|
35
36
|
}
|
|
36
37
|
/** @internal */
|
|
37
38
|
build(table) {
|
|
@@ -42,14 +43,17 @@ class MySqlDouble extends import_common.MySqlColumnWithAutoIncrement {
|
|
|
42
43
|
static [import_entity.entityKind] = "MySqlDouble";
|
|
43
44
|
precision = this.config.precision;
|
|
44
45
|
scale = this.config.scale;
|
|
46
|
+
unsigned = this.config.unsigned;
|
|
45
47
|
getSQLType() {
|
|
48
|
+
let type = "";
|
|
46
49
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
47
|
-
|
|
50
|
+
type += `double(${this.precision},${this.scale})`;
|
|
48
51
|
} else if (this.precision === void 0) {
|
|
49
|
-
|
|
52
|
+
type += "double";
|
|
50
53
|
} else {
|
|
51
|
-
|
|
54
|
+
type += `double(${this.precision})`;
|
|
52
55
|
}
|
|
56
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
function double(a, b) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/double.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDoubleBuilderInitial<TName extends string> = MySqlDoubleBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDouble';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDoubleBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDoubleConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDouble');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDouble<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDouble<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDouble';\n\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/double.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDoubleBuilderInitial<TName extends string> = MySqlDoubleBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDouble';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDoubleBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDoubleConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDouble');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDouble<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDouble<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDouble';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `double(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'double';\n\t\t} else {\n\t\t\ttype += `double(${this.precision})`;\n\t\t}\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDoubleConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function double(): MySqlDoubleBuilderInitial<''>;\nexport function double(\n\tconfig?: MySqlDoubleConfig,\n): MySqlDoubleBuilderInitial<''>;\nexport function double<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDoubleConfig,\n): MySqlDoubleBuilderInitial<TName>;\nexport function double(a?: string | MySqlDoubleConfig, b?: MySqlDoubleConfig) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDoubleConfig>(a, b);\n\treturn new MySqlDoubleBuilder(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,mBAAuC;AACvC,oBAAkF;AAY3E,MAAM,2BACJ,kDACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAuC;AACnE,UAAM,MAAM,UAAU,aAAa;AACnC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OAC+C;AAC/C,WAAO,IAAI,YAA6C,OAAO,KAAK,MAA8C;AAAA,EACnH;AACD;AAEO,MAAM,oBACJ,2CACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,UAAU,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAC/C,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,UAAU,KAAK,SAAS;AAAA,IACjC;AACA,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,OAAO,GAAgC,GAAuB;AAC7E,QAAM,EAAE,MAAM,OAAO,QAAI,qCAA0C,GAAG,CAAC;AACvE,SAAO,IAAI,mBAAmB,MAAM,MAAM;AAC3C;","names":[]}
|
|
@@ -17,13 +17,15 @@ export declare class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'numbe
|
|
|
17
17
|
}
|
|
18
18
|
export declare class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>> extends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
|
-
precision: number | undefined;
|
|
21
|
-
scale: number | undefined;
|
|
20
|
+
readonly precision: number | undefined;
|
|
21
|
+
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
22
23
|
getSQLType(): string;
|
|
23
24
|
}
|
|
24
25
|
export interface MySqlDoubleConfig {
|
|
25
26
|
precision?: number;
|
|
26
27
|
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export declare function double(): MySqlDoubleBuilderInitial<''>;
|
|
29
31
|
export declare function double(config?: MySqlDoubleConfig): MySqlDoubleBuilderInitial<''>;
|
|
@@ -17,13 +17,15 @@ export declare class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'numbe
|
|
|
17
17
|
}
|
|
18
18
|
export declare class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>> extends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
|
-
precision: number | undefined;
|
|
21
|
-
scale: number | undefined;
|
|
20
|
+
readonly precision: number | undefined;
|
|
21
|
+
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
22
23
|
getSQLType(): string;
|
|
23
24
|
}
|
|
24
25
|
export interface MySqlDoubleConfig {
|
|
25
26
|
precision?: number;
|
|
26
27
|
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export declare function double(): MySqlDoubleBuilderInitial<''>;
|
|
29
31
|
export declare function double(config?: MySqlDoubleConfig): MySqlDoubleBuilderInitial<''>;
|
|
@@ -7,6 +7,7 @@ class MySqlDoubleBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
|
7
7
|
super(name, "number", "MySqlDouble");
|
|
8
8
|
this.config.precision = config?.precision;
|
|
9
9
|
this.config.scale = config?.scale;
|
|
10
|
+
this.config.unsigned = config?.unsigned;
|
|
10
11
|
}
|
|
11
12
|
/** @internal */
|
|
12
13
|
build(table) {
|
|
@@ -17,14 +18,17 @@ class MySqlDouble extends MySqlColumnWithAutoIncrement {
|
|
|
17
18
|
static [entityKind] = "MySqlDouble";
|
|
18
19
|
precision = this.config.precision;
|
|
19
20
|
scale = this.config.scale;
|
|
21
|
+
unsigned = this.config.unsigned;
|
|
20
22
|
getSQLType() {
|
|
23
|
+
let type = "";
|
|
21
24
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
22
|
-
|
|
25
|
+
type += `double(${this.precision},${this.scale})`;
|
|
23
26
|
} else if (this.precision === void 0) {
|
|
24
|
-
|
|
27
|
+
type += "double";
|
|
25
28
|
} else {
|
|
26
|
-
|
|
29
|
+
type += `double(${this.precision})`;
|
|
27
30
|
}
|
|
31
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
function double(a, b) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/double.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDoubleBuilderInitial<TName extends string> = MySqlDoubleBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDouble';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDoubleBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDoubleConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDouble');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDouble<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDouble<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDouble';\n\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/double.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDoubleBuilderInitial<TName extends string> = MySqlDoubleBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDouble';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlDoubleBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDoubleBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDoubleConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDouble');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDouble<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDouble<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlDouble<T extends ColumnBaseConfig<'number', 'MySqlDouble'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDoubleConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDouble';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `double(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'double';\n\t\t} else {\n\t\t\ttype += `double(${this.precision})`;\n\t\t}\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDoubleConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function double(): MySqlDoubleBuilderInitial<''>;\nexport function double(\n\tconfig?: MySqlDoubleConfig,\n): MySqlDoubleBuilderInitial<''>;\nexport function double<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDoubleConfig,\n): MySqlDoubleBuilderInitial<TName>;\nexport function double(a?: string | MySqlDoubleConfig, b?: MySqlDoubleConfig) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDoubleConfig>(a, b);\n\treturn new MySqlDoubleBuilder(name, config);\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAS,qCAAqC,oCAAoC;AAY3E,MAAM,2BACJ,oCACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAuC;AACnE,UAAM,MAAM,UAAU,aAAa;AACnC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OAC+C;AAC/C,WAAO,IAAI,YAA6C,OAAO,KAAK,MAA8C;AAAA,EACnH;AACD;AAEO,MAAM,oBACJ,6BACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,UAAU,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAC/C,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,UAAU,KAAK,SAAS;AAAA,IACjC;AACA,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,OAAO,GAAgC,GAAuB;AAC7E,QAAM,EAAE,MAAM,OAAO,IAAI,uBAA0C,GAAG,CAAC;AACvE,SAAO,IAAI,mBAAmB,MAAM,MAAM;AAC3C;","names":[]}
|
|
@@ -24,11 +24,15 @@ __export(float_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(float_exports);
|
|
26
26
|
var import_entity = require("../../entity.cjs");
|
|
27
|
+
var import_utils = require("../../utils.cjs");
|
|
27
28
|
var import_common = require("./common.cjs");
|
|
28
29
|
class MySqlFloatBuilder extends import_common.MySqlColumnBuilderWithAutoIncrement {
|
|
29
30
|
static [import_entity.entityKind] = "MySqlFloatBuilder";
|
|
30
|
-
constructor(name) {
|
|
31
|
+
constructor(name, config) {
|
|
31
32
|
super(name, "number", "MySqlFloat");
|
|
33
|
+
this.config.precision = config?.precision;
|
|
34
|
+
this.config.scale = config?.scale;
|
|
35
|
+
this.config.unsigned = config?.unsigned;
|
|
32
36
|
}
|
|
33
37
|
/** @internal */
|
|
34
38
|
build(table) {
|
|
@@ -37,12 +41,24 @@ class MySqlFloatBuilder extends import_common.MySqlColumnBuilderWithAutoIncremen
|
|
|
37
41
|
}
|
|
38
42
|
class MySqlFloat extends import_common.MySqlColumnWithAutoIncrement {
|
|
39
43
|
static [import_entity.entityKind] = "MySqlFloat";
|
|
44
|
+
precision = this.config.precision;
|
|
45
|
+
scale = this.config.scale;
|
|
46
|
+
unsigned = this.config.unsigned;
|
|
40
47
|
getSQLType() {
|
|
41
|
-
|
|
48
|
+
let type = "";
|
|
49
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
50
|
+
type += `float(${this.precision},${this.scale})`;
|
|
51
|
+
} else if (this.precision === void 0) {
|
|
52
|
+
type += "float";
|
|
53
|
+
} else {
|
|
54
|
+
type += `float(${this.precision})`;
|
|
55
|
+
}
|
|
56
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
|
-
function float(
|
|
45
|
-
|
|
59
|
+
function float(a, b) {
|
|
60
|
+
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
|
|
61
|
+
return new MySqlFloatBuilder(name, config);
|
|
46
62
|
}
|
|
47
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
64
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/float.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlFloat';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloatBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'MySqlFloat');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlFloat<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlFloat<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/float.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlFloat';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlFloatConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloatBuilder';\n\n\tconstructor(name: T['name'], config: MySqlFloatConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlFloat');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlFloat<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlFloat<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlFloatConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloat';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `float(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'float';\n\t\t} else {\n\t\t\ttype += `float(${this.precision})`;\n\t\t}\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlFloatConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function float(): MySqlFloatBuilderInitial<''>;\nexport function float(\n\tconfig?: MySqlFloatConfig,\n): MySqlFloatBuilderInitial<''>;\nexport function float<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlFloatConfig,\n): MySqlFloatBuilderInitial<TName>;\nexport function float(a?: string | MySqlFloatConfig, b?: MySqlFloatConfig) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlFloatConfig>(a, b);\n\treturn new MySqlFloatBuilder(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,mBAAuC;AACvC,oBAAkF;AAY3E,MAAM,0BACJ,kDACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAsC;AAClE,UAAM,MAAM,UAAU,YAAY;AAClC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OAC8C;AAC9C,WAAO,IAAI,WAA4C,OAAO,KAAK,MAA8C;AAAA,EAClH;AACD;AAEO,MAAM,mBACJ,2CACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,SAAS,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAC9C,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,SAAS,KAAK,SAAS;AAAA,IAChC;AACA,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,MAAM,GAA+B,GAAsB;AAC1E,QAAM,EAAE,MAAM,OAAO,QAAI,qCAAyC,GAAG,CAAC;AACtE,SAAO,IAAI,kBAAkB,MAAM,MAAM;AAC1C;","names":[]}
|
|
@@ -11,13 +11,22 @@ export type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{
|
|
|
11
11
|
enumValues: undefined;
|
|
12
12
|
generated: undefined;
|
|
13
13
|
}>;
|
|
14
|
-
export declare class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnBuilderWithAutoIncrement<T> {
|
|
14
|
+
export declare class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlFloatConfig> {
|
|
15
15
|
static readonly [entityKind]: string;
|
|
16
|
-
constructor(name: T['name']);
|
|
16
|
+
constructor(name: T['name'], config: MySqlFloatConfig | undefined);
|
|
17
17
|
}
|
|
18
|
-
export declare class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnWithAutoIncrement<T> {
|
|
18
|
+
export declare class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnWithAutoIncrement<T, MySqlFloatConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
|
+
readonly precision: number | undefined;
|
|
21
|
+
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
20
23
|
getSQLType(): string;
|
|
21
24
|
}
|
|
25
|
+
export interface MySqlFloatConfig {
|
|
26
|
+
precision?: number;
|
|
27
|
+
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
29
|
+
}
|
|
22
30
|
export declare function float(): MySqlFloatBuilderInitial<''>;
|
|
23
|
-
export declare function float
|
|
31
|
+
export declare function float(config?: MySqlFloatConfig): MySqlFloatBuilderInitial<''>;
|
|
32
|
+
export declare function float<TName extends string>(name: TName, config?: MySqlFloatConfig): MySqlFloatBuilderInitial<TName>;
|
|
@@ -11,13 +11,22 @@ export type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{
|
|
|
11
11
|
enumValues: undefined;
|
|
12
12
|
generated: undefined;
|
|
13
13
|
}>;
|
|
14
|
-
export declare class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnBuilderWithAutoIncrement<T> {
|
|
14
|
+
export declare class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlFloatConfig> {
|
|
15
15
|
static readonly [entityKind]: string;
|
|
16
|
-
constructor(name: T['name']);
|
|
16
|
+
constructor(name: T['name'], config: MySqlFloatConfig | undefined);
|
|
17
17
|
}
|
|
18
|
-
export declare class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnWithAutoIncrement<T> {
|
|
18
|
+
export declare class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>> extends MySqlColumnWithAutoIncrement<T, MySqlFloatConfig> {
|
|
19
19
|
static readonly [entityKind]: string;
|
|
20
|
+
readonly precision: number | undefined;
|
|
21
|
+
readonly scale: number | undefined;
|
|
22
|
+
readonly unsigned: boolean | undefined;
|
|
20
23
|
getSQLType(): string;
|
|
21
24
|
}
|
|
25
|
+
export interface MySqlFloatConfig {
|
|
26
|
+
precision?: number;
|
|
27
|
+
scale?: number;
|
|
28
|
+
unsigned?: boolean;
|
|
29
|
+
}
|
|
22
30
|
export declare function float(): MySqlFloatBuilderInitial<''>;
|
|
23
|
-
export declare function float
|
|
31
|
+
export declare function float(config?: MySqlFloatConfig): MySqlFloatBuilderInitial<''>;
|
|
32
|
+
export declare function float<TName extends string>(name: TName, config?: MySqlFloatConfig): MySqlFloatBuilderInitial<TName>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { entityKind } from "../../entity.js";
|
|
2
|
+
import { getColumnNameAndConfig } from "../../utils.js";
|
|
2
3
|
import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from "./common.js";
|
|
3
4
|
class MySqlFloatBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
4
5
|
static [entityKind] = "MySqlFloatBuilder";
|
|
5
|
-
constructor(name) {
|
|
6
|
+
constructor(name, config) {
|
|
6
7
|
super(name, "number", "MySqlFloat");
|
|
8
|
+
this.config.precision = config?.precision;
|
|
9
|
+
this.config.scale = config?.scale;
|
|
10
|
+
this.config.unsigned = config?.unsigned;
|
|
7
11
|
}
|
|
8
12
|
/** @internal */
|
|
9
13
|
build(table) {
|
|
@@ -12,12 +16,24 @@ class MySqlFloatBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
|
12
16
|
}
|
|
13
17
|
class MySqlFloat extends MySqlColumnWithAutoIncrement {
|
|
14
18
|
static [entityKind] = "MySqlFloat";
|
|
19
|
+
precision = this.config.precision;
|
|
20
|
+
scale = this.config.scale;
|
|
21
|
+
unsigned = this.config.unsigned;
|
|
15
22
|
getSQLType() {
|
|
16
|
-
|
|
23
|
+
let type = "";
|
|
24
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
25
|
+
type += `float(${this.precision},${this.scale})`;
|
|
26
|
+
} else if (this.precision === void 0) {
|
|
27
|
+
type += "float";
|
|
28
|
+
} else {
|
|
29
|
+
type += `float(${this.precision})`;
|
|
30
|
+
}
|
|
31
|
+
return this.unsigned ? `${type} unsigned` : type;
|
|
17
32
|
}
|
|
18
33
|
}
|
|
19
|
-
function float(
|
|
20
|
-
|
|
34
|
+
function float(a, b) {
|
|
35
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
36
|
+
return new MySqlFloatBuilder(name, config);
|
|
21
37
|
}
|
|
22
38
|
export {
|
|
23
39
|
MySqlFloat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/float.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlFloat';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloatBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'MySqlFloat');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlFloat<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlFloat<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/float.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlFloatBuilderInitial<TName extends string> = MySqlFloatBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlFloat';\n\tdata: number;\n\tdriverParam: number | string;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class MySqlFloatBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T, MySqlFloatConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloatBuilder';\n\n\tconstructor(name: T['name'], config: MySqlFloatConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlFloat');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlFloat<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlFloat<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlFloat<T extends ColumnBaseConfig<'number', 'MySqlFloat'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlFloatConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlFloat';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `float(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'float';\n\t\t} else {\n\t\t\ttype += `float(${this.precision})`;\n\t\t}\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlFloatConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function float(): MySqlFloatBuilderInitial<''>;\nexport function float(\n\tconfig?: MySqlFloatConfig,\n): MySqlFloatBuilderInitial<''>;\nexport function float<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlFloatConfig,\n): MySqlFloatBuilderInitial<TName>;\nexport function float(a?: string | MySqlFloatConfig, b?: MySqlFloatConfig) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlFloatConfig>(a, b);\n\treturn new MySqlFloatBuilder(name, config);\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAS,qCAAqC,oCAAoC;AAY3E,MAAM,0BACJ,oCACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAsC;AAClE,UAAM,MAAM,UAAU,YAAY;AAClC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OAC8C;AAC9C,WAAO,IAAI,WAA4C,OAAO,KAAK,MAA8C;AAAA,EAClH;AACD;AAEO,MAAM,mBACJ,6BACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAErD,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,SAAS,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAC9C,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,SAAS,KAAK,SAAS;AAAA,IAChC;AACA,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,MAAM,GAA+B,GAAsB;AAC1E,QAAM,EAAE,MAAM,OAAO,IAAI,uBAAyC,GAAG,CAAC;AACtE,SAAO,IAAI,kBAAkB,MAAM,MAAM;AAC1C;","names":[]}
|
package/neon/rls.cjs
CHANGED
|
@@ -29,8 +29,28 @@ var import_pg_core = require("../pg-core/index.cjs");
|
|
|
29
29
|
var import_roles = require("../pg-core/roles.cjs");
|
|
30
30
|
var import_sql = require("../sql/sql.cjs");
|
|
31
31
|
const crudPolicy = (options) => {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (options.read === void 0) {
|
|
33
|
+
throw new Error("crudPolicy requires a read policy");
|
|
34
|
+
}
|
|
35
|
+
if (options.modify === void 0) {
|
|
36
|
+
throw new Error("crudPolicy requires a modify policy");
|
|
37
|
+
}
|
|
38
|
+
let read;
|
|
39
|
+
if (options.read === true) {
|
|
40
|
+
read = import_sql.sql`true`;
|
|
41
|
+
} else if (options.read === false) {
|
|
42
|
+
read = import_sql.sql`false`;
|
|
43
|
+
} else if (options.read !== null) {
|
|
44
|
+
read = options.read;
|
|
45
|
+
}
|
|
46
|
+
let modify;
|
|
47
|
+
if (options.modify === true) {
|
|
48
|
+
modify = import_sql.sql`true`;
|
|
49
|
+
} else if (options.modify === false) {
|
|
50
|
+
modify = import_sql.sql`false`;
|
|
51
|
+
} else if (options.modify !== null) {
|
|
52
|
+
modify = options.modify;
|
|
53
|
+
}
|
|
34
54
|
let rolesName = "";
|
|
35
55
|
if (Array.isArray(options.role)) {
|
|
36
56
|
rolesName = options.role.map((it) => {
|
|
@@ -40,28 +60,28 @@ const crudPolicy = (options) => {
|
|
|
40
60
|
rolesName = (0, import_entity.is)(options.role, import_roles.PgRole) ? options.role.name : options.role;
|
|
41
61
|
}
|
|
42
62
|
return [
|
|
43
|
-
(0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-
|
|
63
|
+
read && (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-select`, {
|
|
64
|
+
for: "select",
|
|
65
|
+
to: options.role,
|
|
66
|
+
using: read
|
|
67
|
+
}),
|
|
68
|
+
modify && (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-insert`, {
|
|
44
69
|
for: "insert",
|
|
45
70
|
to: options.role,
|
|
46
71
|
withCheck: modify
|
|
47
72
|
}),
|
|
48
|
-
(0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-update`, {
|
|
73
|
+
modify && (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-update`, {
|
|
49
74
|
for: "update",
|
|
50
75
|
to: options.role,
|
|
51
76
|
using: modify,
|
|
52
77
|
withCheck: modify
|
|
53
78
|
}),
|
|
54
|
-
(0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-delete`, {
|
|
79
|
+
modify && (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-delete`, {
|
|
55
80
|
for: "delete",
|
|
56
81
|
to: options.role,
|
|
57
82
|
using: modify
|
|
58
|
-
}),
|
|
59
|
-
(0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-select`, {
|
|
60
|
-
for: "select",
|
|
61
|
-
to: options.role,
|
|
62
|
-
using: read
|
|
63
83
|
})
|
|
64
|
-
];
|
|
84
|
+
].filter(Boolean);
|
|
65
85
|
};
|
|
66
86
|
const authenticatedRole = (0, import_roles.pgRole)("authenticated").existing();
|
|
67
87
|
const anonymousRole = (0, import_roles.pgRole)("anonymous").existing();
|
package/neon/rls.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { type AnyPgColumn, pgPolicy, type PgPolicyToOption } from '~/pg-core/index.ts';\nimport { PgRole, pgRole } from '~/pg-core/roles.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (options: {\n\trole: PgPolicyToOption;\n\tread
|
|
1
|
+
{"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { type AnyPgColumn, pgPolicy, type PgPolicyToOption } from '~/pg-core/index.ts';\nimport { PgRole, pgRole } from '~/pg-core/roles.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\n/**\n * Generates a set of PostgreSQL row-level security (RLS) policies for CRUD operations based on the provided options.\n *\n * @param options - An object containing the policy configuration.\n * @param options.role - The PostgreSQL role(s) to apply the policy to. Can be a single `PgRole` instance or an array of `PgRole` instances or role names.\n * @param options.read - The SQL expression or boolean value that defines the read policy. Set to `true` to allow all reads, `false` to deny all reads, or provide a custom SQL expression. Set to `null` to prevent the policy from being generated.\n * @param options.modify - The SQL expression or boolean value that defines the modify (insert, update, delete) policies. Set to `true` to allow all modifications, `false` to deny all modifications, or provide a custom SQL expression. Set to `null` to prevent policies from being generated.\n * @returns An array of PostgreSQL policy definitions, one for each CRUD operation.\n */\nexport const crudPolicy = (options: {\n\trole: PgPolicyToOption;\n\tread: SQL | boolean | null;\n\tmodify: SQL | boolean | null;\n}) => {\n\tif (options.read === undefined) {\n\t\tthrow new Error('crudPolicy requires a read policy');\n\t}\n\n\tif (options.modify === undefined) {\n\t\tthrow new Error('crudPolicy requires a modify policy');\n\t}\n\n\tlet read: SQL | undefined;\n\tif (options.read === true) {\n\t\tread = sql`true`;\n\t} else if (options.read === false) {\n\t\tread = sql`false`;\n\t} else if (options.read !== null) {\n\t\tread = options.read;\n\t}\n\n\tlet modify: SQL | undefined;\n\tif (options.modify === true) {\n\t\tmodify = sql`true`;\n\t} else if (options.modify === false) {\n\t\tmodify = sql`false`;\n\t} else if (options.modify !== null) {\n\t\tmodify = options.modify;\n\t}\n\n\tlet rolesName = '';\n\tif (Array.isArray(options.role)) {\n\t\trolesName = options.role\n\t\t\t.map((it) => {\n\t\t\t\treturn is(it, PgRole) ? it.name : (it as string);\n\t\t\t})\n\t\t\t.join('-');\n\t} else {\n\t\trolesName = is(options.role, PgRole)\n\t\t\t? options.role.name\n\t\t\t: (options.role as string);\n\t}\n\n\treturn [\n\t\tread\n\t\t&& pgPolicy(`crud-${rolesName}-policy-select`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\n\t\tmodify\n\t\t&& pgPolicy(`crud-${rolesName}-policy-insert`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\tmodify\n\t\t&& pgPolicy(`crud-${rolesName}-policy-update`, {\n\t\t\tfor: 'update',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\tmodify\n\t\t&& pgPolicy(`crud-${rolesName}-policy-delete`, {\n\t\t\tfor: 'delete',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t}),\n\t].filter(Boolean);\n};\n\n// These are default roles that Neon will set up.\nexport const authenticatedRole = pgRole('authenticated').existing();\nexport const anonymousRole = pgRole('anonymous').existing();\n\nexport const authUid = (userIdColumn: AnyPgColumn) => sql`(select auth.user_id() = ${userIdColumn})`;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,qBAAkE;AAClE,mBAA+B;AAC/B,iBAA8B;AAWvB,MAAM,aAAa,CAAC,YAIrB;AACL,MAAI,QAAQ,SAAS,QAAW;AAC/B,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACpD;AAEA,MAAI,QAAQ,WAAW,QAAW;AACjC,UAAM,IAAI,MAAM,qCAAqC;AAAA,EACtD;AAEA,MAAI;AACJ,MAAI,QAAQ,SAAS,MAAM;AAC1B,WAAO;AAAA,EACR,WAAW,QAAQ,SAAS,OAAO;AAClC,WAAO;AAAA,EACR,WAAW,QAAQ,SAAS,MAAM;AACjC,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI;AACJ,MAAI,QAAQ,WAAW,MAAM;AAC5B,aAAS;AAAA,EACV,WAAW,QAAQ,WAAW,OAAO;AACpC,aAAS;AAAA,EACV,WAAW,QAAQ,WAAW,MAAM;AACnC,aAAS,QAAQ;AAAA,EAClB;AAEA,MAAI,YAAY;AAChB,MAAI,MAAM,QAAQ,QAAQ,IAAI,GAAG;AAChC,gBAAY,QAAQ,KAClB,IAAI,CAAC,OAAO;AACZ,iBAAO,kBAAG,IAAI,mBAAM,IAAI,GAAG,OAAQ;AAAA,IACpC,CAAC,EACA,KAAK,GAAG;AAAA,EACX,OAAO;AACN,oBAAY,kBAAG,QAAQ,MAAM,mBAAM,IAChC,QAAQ,KAAK,OACZ,QAAQ;AAAA,EACb;AAEA,SAAO;AAAA,IACN,YACG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAC9C,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,IAED,cACG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAC9C,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,cACG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAC9C,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,cACG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAC9C,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF,EAAE,OAAO,OAAO;AACjB;AAGO,MAAM,wBAAoB,qBAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,oBAAgB,qBAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,0CAA+B,YAAY;","names":[]}
|
package/neon/rls.d.cts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { type AnyPgColumn, type PgPolicyToOption } from "../pg-core/index.cjs";
|
|
2
2
|
import { PgRole } from "../pg-core/roles.cjs";
|
|
3
3
|
import { type SQL } from "../sql/sql.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Generates a set of PostgreSQL row-level security (RLS) policies for CRUD operations based on the provided options.
|
|
6
|
+
*
|
|
7
|
+
* @param options - An object containing the policy configuration.
|
|
8
|
+
* @param options.role - The PostgreSQL role(s) to apply the policy to. Can be a single `PgRole` instance or an array of `PgRole` instances or role names.
|
|
9
|
+
* @param options.read - The SQL expression or boolean value that defines the read policy. Set to `true` to allow all reads, `false` to deny all reads, or provide a custom SQL expression. Set to `null` to prevent the policy from being generated.
|
|
10
|
+
* @param options.modify - The SQL expression or boolean value that defines the modify (insert, update, delete) policies. Set to `true` to allow all modifications, `false` to deny all modifications, or provide a custom SQL expression. Set to `null` to prevent policies from being generated.
|
|
11
|
+
* @returns An array of PostgreSQL policy definitions, one for each CRUD operation.
|
|
12
|
+
*/
|
|
4
13
|
export declare const crudPolicy: (options: {
|
|
5
14
|
role: PgPolicyToOption;
|
|
6
|
-
read
|
|
7
|
-
modify
|
|
8
|
-
}) => import("../pg-core/index.ts").PgPolicy[];
|
|
15
|
+
read: SQL | boolean | null;
|
|
16
|
+
modify: SQL | boolean | null;
|
|
17
|
+
}) => (import("../pg-core/index.ts").PgPolicy | undefined)[];
|
|
9
18
|
export declare const authenticatedRole: PgRole;
|
|
10
19
|
export declare const anonymousRole: PgRole;
|
|
11
20
|
export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
|