pgsql-template-tag 0.0.2 → 0.0.3

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # pgsql-template-tag
@@ -14,4 +14,5 @@ export declare class Sql {
14
14
  export declare function raw(value: string): Sql;
15
15
  export declare const empty: Sql;
16
16
  export declare function join(values: readonly RawValue[], separator?: string | undefined): Sql;
17
+ export declare function ident(value: string): string;
17
18
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC;AAE5B,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC;AAEnC,qBAAa,GAAG;IACd,IAAW,IAAI,IAAI,MAAM,CAiBxB;IAED,SAAgB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAEzC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAShB;gBAEiB,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,SAAS,QAAQ,EAAE;IA0E3E,MAAM,IAAI;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,KAAK,EAAE,CAAC;KACjB;IAOM,QAAQ,IAAI,MAAM;CAG1B;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAEtC;AAED,eAAO,MAAM,KAAK,EAAE,GAAa,CAAC;AAElC,wBAAgB,IAAI,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,SAAS,GAAE,MAAM,GAAG,SAAe,GAAG,GAAG,CAM1F"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC;AAG5B,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC;AAEnC,qBAAa,GAAG;IACd,IAAW,IAAI,IAAI,MAAM,CAiBxB;IAED,SAAgB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAEzC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAWhB;gBAEiB,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,SAAS,QAAQ,EAAE;IA0E3E,MAAM,IAAI;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,KAAK,EAAE,CAAC;KACjB;IAOM,QAAQ,IAAI,MAAM;CAG1B;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAEtC;AAED,eAAO,MAAM,KAAK,EAAE,GAAa,CAAC;AAElC,wBAAgB,IAAI,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,SAAS,GAAE,MAAM,GAAG,SAAe,GAAG,GAAG,CAM1F;AAID,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C"}
package/dist/src/core.js CHANGED
@@ -58,13 +58,13 @@ export class Sql {
58
58
  }
59
59
  this.values = bindings;
60
60
  Object.defineProperty(this, "_", {
61
- value: this._ = {
61
+ value: (this._ = {
62
62
  t: {
63
63
  c: false,
64
64
  v: placeholderIds,
65
65
  },
66
66
  s: strings,
67
- },
67
+ }),
68
68
  });
69
69
  }
70
70
  toJSON() {
@@ -87,3 +87,7 @@ export function join(values, separator = ",") {
87
87
  }
88
88
  return new Sql(["", ...Array(values.length - 1).fill(separator), ""], values);
89
89
  }
90
+ const DOUBLE_QUOTE_REGEX = /"/g;
91
+ export function ident(value) {
92
+ return '"' + value.replace(DOUBLE_QUOTE_REGEX, '""') + '"';
93
+ }
@@ -1,3 +1,3 @@
1
- export { empty, join, raw, type RawValue, Sql, type Value } from "./core.js";
1
+ export { empty, join, raw, ident, type RawValue, Sql, type Value } from "./core.js";
2
2
  export { sql } from "./sql.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,GAAG,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,GAAG,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEpF,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { empty, join, raw, Sql } from "./core.js";
1
+ export { empty, join, raw, ident, Sql } from "./core.js";
2
2
  export { sql } from "./sql.js";
package/dist/src/sql.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { join, raw, type RawValue, Sql } from "./core.js";
1
+ import { join, raw, Sql, ident } from "./core.js";
2
2
  declare namespace sql {
3
3
  type RawValue = import("./core.js").RawValue;
4
4
  type Value = import("./core.js").Value;
5
5
  type Sql = import("./core.js").Sql;
6
6
  }
7
- declare const sql: ((strings: TemplateStringsArray, ...bindings: readonly RawValue[]) => Sql) & {
7
+ declare const sql: ((strings: TemplateStringsArray, ...bindings: readonly sql.RawValue[]) => sql.Sql) & {
8
8
  readonly Sql: typeof Sql;
9
9
  readonly raw: typeof raw;
10
10
  readonly join: typeof join;
11
11
  readonly empty: Sql;
12
+ readonly ident: typeof ident;
12
13
  };
13
14
  export { sql };
14
15
  //# sourceMappingURL=sql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEjE,kBAAU,GAAG,CAAC;IACZ,KAAY,QAAQ,GAAG,OAAO,WAAW,EAAE,QAAQ,CAAC;IAEpD,KAAY,KAAK,GAAG,OAAO,WAAW,EAAE,KAAK,CAAC;IAE9C,KAAY,GAAG,GAAG,OAAO,WAAW,EAAE,GAAG,CAAC;CAC3C;AAED,QAAA,MAAM,GAAG,aACe,oBAAoB,eAAe,SAAS,QAAQ,EAAE,KAAG,GAAG;;;;;CASnF,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzD,kBAAU,GAAG,CAAC;IACZ,KAAY,QAAQ,GAAG,OAAO,WAAW,EAAE,QAAQ,CAAC;IAEpD,KAAY,KAAK,GAAG,OAAO,WAAW,EAAE,KAAK,CAAC;IAE9C,KAAY,GAAG,GAAG,OAAO,WAAW,EAAE,GAAG,CAAC;CAC3C;AAED,QAAA,MAAM,GAAG,aACe,oBAAoB,eAAe,SAAS,GAAG,CAAC,QAAQ,EAAE,KAAG,GAAG,CAAC,GAAG;;;;;;CAU3F,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/src/sql.js CHANGED
@@ -1,4 +1,4 @@
1
- import { empty, join, raw, Sql } from "./core.js";
1
+ import { empty, join, raw, Sql, ident } from "./core.js";
2
2
  const sql = /*#__PURE__*/ Object.assign(function sql(strings, ...bindings) {
3
3
  return new Sql(strings, bindings);
4
4
  }, {
@@ -6,5 +6,6 @@ const sql = /*#__PURE__*/ Object.assign(function sql(strings, ...bindings) {
6
6
  raw,
7
7
  join,
8
8
  empty,
9
+ ident,
9
10
  });
10
11
  export { sql };
package/package.json CHANGED
@@ -1,42 +1,48 @@
1
1
  {
2
2
  "name": "pgsql-template-tag",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
- "type": "module",
6
- "sideEffects": false,
5
+ "homepage": "https://github.com/tai-kun/pgsql-template-tag",
7
6
  "license": "MIT",
8
7
  "author": "tai-kun",
8
+ "repository": {
9
+ "url": "https://github.com/tai-kun/pgsql-template-tag"
10
+ },
9
11
  "files": [
10
12
  "dist",
11
- "src"
13
+ "src",
14
+ "package.json",
15
+ "LICENSE",
16
+ "README.md"
12
17
  ],
18
+ "type": "module",
19
+ "sideEffects": false,
13
20
  "main": "./dist/src/index.js",
14
- "module": "./dist/src/index.js",
15
21
  "types": "./dist/src/index.d.ts",
16
22
  "exports": {
17
23
  ".": {
18
24
  "types": "./dist/src/index.d.ts",
19
- "import": "./dist/src/index.js",
20
- "require": "./dist/src/index.js"
25
+ "default": "./dist/src/index.js"
21
26
  }
22
27
  },
23
- "homepage": "https://tai-kun.github.io/pgsql-template-tag",
24
- "repository": {
25
- "url": "https://github.com/tai-kun/pgsql-template-tag"
26
- },
27
- "scripts": {
28
- "build": "tsc --project ./.config/tsconfig.build.json"
29
- },
30
28
  "devDependencies": {
31
- "@tsconfig/node22": "^22.0.5",
29
+ "@tsconfig/node24": "^24.0.4",
32
30
  "@tsconfig/strictest": "^2.0.8",
33
- "@types/node": "^22.19.17",
34
- "@vitest/browser": "^4.1.2",
35
- "@vitest/browser-playwright": "^4.1.2",
36
- "dprint": "^0.53.2",
37
- "npm-check-updates": "^20.0.0",
31
+ "@types/node": "^24.12.2",
32
+ "@valibot/i18n": "^1.1.0",
33
+ "@vitest/browser": "^4.1.5",
34
+ "@vitest/browser-playwright": "^4.1.5",
35
+ "npm-check-updates": "^20.0.2",
36
+ "oxfmt": "^0.46.0",
37
+ "oxlint": "^1.61.0",
38
+ "oxlint-tsgolint": "^0.22.0",
38
39
  "playwright": "^1.59.1",
39
- "typescript": "^6.0.2",
40
- "vitest": "^4.1.2"
40
+ "typescript": "^6.0.3",
41
+ "vite": "^8.0.10",
42
+ "vitest": "^4.1.5"
43
+ },
44
+ "readme": "README.md",
45
+ "scripts": {
46
+ "build": "tsc --project ./.config/tsconfig.build.json"
41
47
  }
42
- }
48
+ }
package/src/core.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type Value = unknown;
2
2
 
3
+ // oxlint-disable-next-line typescript/no-redundant-type-constituents
3
4
  export type RawValue = Value | Sql;
4
5
 
5
6
  export class Sql {
@@ -25,13 +26,15 @@ export class Sql {
25
26
  public readonly values: readonly Value[];
26
27
 
27
28
  private readonly _: {
28
- t: {
29
- readonly c: false;
30
- readonly v: readonly number[];
31
- } | {
32
- readonly c: true;
33
- readonly v: string;
34
- };
29
+ t:
30
+ | {
31
+ readonly c: false;
32
+ readonly v: readonly number[];
33
+ }
34
+ | {
35
+ readonly c: true;
36
+ readonly v: string;
37
+ };
35
38
  readonly s: readonly [string, ...string[]];
36
39
  };
37
40
 
@@ -99,13 +102,13 @@ export class Sql {
99
102
 
100
103
  this.values = bindings;
101
104
  Object.defineProperty(this, "_", {
102
- value: this._ = {
105
+ value: (this._ = {
103
106
  t: {
104
107
  c: false,
105
108
  v: placeholderIds,
106
109
  },
107
110
  s: strings,
108
- },
111
+ }),
109
112
  });
110
113
  }
111
114
 
@@ -137,3 +140,9 @@ export function join(values: readonly RawValue[], separator: string | undefined
137
140
 
138
141
  return new Sql(["", ...Array(values.length - 1).fill(separator), ""], values);
139
142
  }
143
+
144
+ const DOUBLE_QUOTE_REGEX = /"/g;
145
+
146
+ export function ident(value: string): string {
147
+ return '"' + value.replace(DOUBLE_QUOTE_REGEX, '""') + '"';
148
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { empty, join, raw, type RawValue, Sql, type Value } from "./core.js";
1
+ export { empty, join, raw, ident, type RawValue, Sql, type Value } from "./core.js";
2
2
 
3
3
  export { sql } from "./sql.js";
package/src/sql.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { empty, join, raw, type RawValue, Sql } from "./core.js";
1
+ import { empty, join, raw, Sql, ident } from "./core.js";
2
2
 
3
3
  namespace sql {
4
4
  export type RawValue = import("./core.js").RawValue;
@@ -9,7 +9,7 @@ namespace sql {
9
9
  }
10
10
 
11
11
  const sql = /*#__PURE__*/ Object.assign(
12
- function sql(strings: TemplateStringsArray, ...bindings: readonly RawValue[]): Sql {
12
+ function sql(strings: TemplateStringsArray, ...bindings: readonly sql.RawValue[]): sql.Sql {
13
13
  return new Sql(strings, bindings);
14
14
  },
15
15
  {
@@ -17,6 +17,7 @@ const sql = /*#__PURE__*/ Object.assign(
17
17
  raw,
18
18
  join,
19
19
  empty,
20
+ ident,
20
21
  } as const,
21
22
  );
22
23