pgsql-template-tag 0.0.1 → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 - present, tai-kun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ export type Value = unknown;
2
+ export type RawValue = Value | Sql;
3
+ export declare class Sql {
4
+ get text(): string;
5
+ readonly values: readonly Value[];
6
+ private readonly _;
7
+ constructor(rawStrings: readonly string[], rawBindings: readonly RawValue[]);
8
+ toJSON(): {
9
+ text: string;
10
+ values: Value[];
11
+ };
12
+ toString(): string;
13
+ }
14
+ export declare function raw(value: string): Sql;
15
+ export declare const empty: Sql;
16
+ export declare function join(values: readonly RawValue[], separator?: string | undefined): Sql;
17
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,89 @@
1
+ export class Sql {
2
+ get text() {
3
+ if (!this._.t.c) {
4
+ let text = this._.s[0], placeholderIds = this._.t.v;
5
+ if (placeholderIds.length > 0) {
6
+ for (let i = 0, len = placeholderIds.length; i < len; i++) {
7
+ text += "$" + placeholderIds[i] + this._.s[i + 1];
8
+ }
9
+ }
10
+ this._.t = {
11
+ c: true,
12
+ v: text,
13
+ };
14
+ }
15
+ return this._.t.v;
16
+ }
17
+ constructor(rawStrings, rawBindings) {
18
+ if (rawStrings.length === 0) {
19
+ throw new TypeError("Expected at least 1 string");
20
+ }
21
+ if (rawStrings.length - 1 !== rawBindings.length) {
22
+ throw new TypeError(`Expected ${rawStrings.length} strings to have ${rawStrings.length - 1} values`);
23
+ }
24
+ const strings = [rawStrings[0]];
25
+ const bindings = [];
26
+ const placeholderIds = [];
27
+ if (rawStrings.length > 0) {
28
+ const valueToId = new Map();
29
+ for (let i = 0, len = rawBindings.length, child, rawString, placeholderId; i < len; i++) {
30
+ child = rawBindings[i];
31
+ rawString = rawStrings[i + 1];
32
+ if (child instanceof Sql) {
33
+ strings[strings.length - 1] += child._.s[0];
34
+ for (let j = 0, value; j < child.values.length; j++) {
35
+ value = child.values[j];
36
+ placeholderId = valueToId.get(value);
37
+ if (placeholderId === undefined) {
38
+ bindings.push(value);
39
+ placeholderId = bindings.length;
40
+ valueToId.set(value, placeholderId);
41
+ }
42
+ strings.push(child._.s[j + 1]);
43
+ placeholderIds.push(placeholderId);
44
+ }
45
+ strings[strings.length - 1] += rawString;
46
+ }
47
+ else {
48
+ placeholderId = valueToId.get(child);
49
+ if (placeholderId === undefined) {
50
+ bindings.push(child);
51
+ placeholderId = bindings.length;
52
+ valueToId.set(child, placeholderId);
53
+ }
54
+ strings.push(rawString);
55
+ placeholderIds.push(placeholderId);
56
+ }
57
+ }
58
+ }
59
+ this.values = bindings;
60
+ Object.defineProperty(this, "_", {
61
+ value: this._ = {
62
+ t: {
63
+ c: false,
64
+ v: placeholderIds,
65
+ },
66
+ s: strings,
67
+ },
68
+ });
69
+ }
70
+ toJSON() {
71
+ return {
72
+ text: this.text,
73
+ values: this.values.slice(),
74
+ };
75
+ }
76
+ toString() {
77
+ return this.text;
78
+ }
79
+ }
80
+ export function raw(value) {
81
+ return new Sql([value], []);
82
+ }
83
+ export const empty = raw("");
84
+ export function join(values, separator = ",") {
85
+ if (values.length === 0) {
86
+ return empty;
87
+ }
88
+ return new Sql(["", ...Array(values.length - 1).fill(separator), ""], values);
89
+ }
@@ -0,0 +1,3 @@
1
+ export { empty, join, raw, type RawValue, Sql, type Value } from "./core.js";
2
+ export { sql } from "./sql.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ export { empty, join, raw, Sql } from "./core.js";
2
+ export { sql } from "./sql.js";
@@ -0,0 +1,14 @@
1
+ import { join, raw, type RawValue, Sql } from "./core.js";
2
+ declare namespace sql {
3
+ type RawValue = import("./core.js").RawValue;
4
+ type Value = import("./core.js").Value;
5
+ type Sql = import("./core.js").Sql;
6
+ }
7
+ declare const sql: ((strings: TemplateStringsArray, ...bindings: readonly RawValue[]) => Sql) & {
8
+ readonly Sql: typeof Sql;
9
+ readonly raw: typeof raw;
10
+ readonly join: typeof join;
11
+ readonly empty: Sql;
12
+ };
13
+ export { sql };
14
+ //# sourceMappingURL=sql.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ import { empty, join, raw, Sql } from "./core.js";
2
+ const sql = /*#__PURE__*/ Object.assign(function sql(strings, ...bindings) {
3
+ return new Sql(strings, bindings);
4
+ }, {
5
+ Sql,
6
+ raw,
7
+ join,
8
+ empty,
9
+ });
10
+ export { sql };
package/package.json CHANGED
@@ -1,10 +1,42 @@
1
1
  {
2
2
  "name": "pgsql-template-tag",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for pgsql-template-tag",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "version": "0.0.2",
4
+ "description": "",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "tai-kun",
9
+ "files": [
10
+ "dist",
11
+ "src"
12
+ ],
13
+ "main": "./dist/src/index.js",
14
+ "module": "./dist/src/index.js",
15
+ "types": "./dist/src/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/src/index.d.ts",
19
+ "import": "./dist/src/index.js",
20
+ "require": "./dist/src/index.js"
21
+ }
22
+ },
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
+ "devDependencies": {
31
+ "@tsconfig/node22": "^22.0.5",
32
+ "@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",
38
+ "playwright": "^1.59.1",
39
+ "typescript": "^6.0.2",
40
+ "vitest": "^4.1.2"
41
+ }
10
42
  }
package/src/core.ts ADDED
@@ -0,0 +1,139 @@
1
+ export type Value = unknown;
2
+
3
+ export type RawValue = Value | Sql;
4
+
5
+ export class Sql {
6
+ public get text(): string {
7
+ if (!this._.t.c) {
8
+ let text = this._.s[0],
9
+ placeholderIds = this._.t.v;
10
+ if (placeholderIds.length > 0) {
11
+ for (let i = 0, len = placeholderIds.length; i < len; i++) {
12
+ text += "$" + placeholderIds[i] + this._.s[i + 1];
13
+ }
14
+ }
15
+
16
+ this._.t = {
17
+ c: true,
18
+ v: text,
19
+ };
20
+ }
21
+
22
+ return this._.t.v;
23
+ }
24
+
25
+ public readonly values: readonly Value[];
26
+
27
+ private readonly _: {
28
+ t: {
29
+ readonly c: false;
30
+ readonly v: readonly number[];
31
+ } | {
32
+ readonly c: true;
33
+ readonly v: string;
34
+ };
35
+ readonly s: readonly [string, ...string[]];
36
+ };
37
+
38
+ public constructor(rawStrings: readonly string[], rawBindings: readonly RawValue[]) {
39
+ if (rawStrings.length === 0) {
40
+ throw new TypeError("Expected at least 1 string");
41
+ }
42
+
43
+ if (rawStrings.length - 1 !== rawBindings.length) {
44
+ throw new TypeError(
45
+ `Expected ${rawStrings.length} strings to have ${rawStrings.length - 1} values`,
46
+ );
47
+ }
48
+
49
+ const strings: [string, ...string[]] = [rawStrings[0]!];
50
+ const bindings: Value[] = [];
51
+ const placeholderIds: number[] = [];
52
+
53
+ if (rawStrings.length > 0) {
54
+ const valueToId = new Map<Value, number>();
55
+
56
+ for (
57
+ let i = 0,
58
+ len = rawBindings.length,
59
+ child: unknown,
60
+ rawString: string,
61
+ placeholderId: number | undefined;
62
+ i < len;
63
+ i++
64
+ ) {
65
+ child = rawBindings[i];
66
+ rawString = rawStrings[i + 1]!;
67
+
68
+ if (child instanceof Sql) {
69
+ strings[strings.length - 1] += child._.s[0];
70
+
71
+ for (let j = 0, value: unknown; j < child.values.length; j++) {
72
+ value = child.values[j];
73
+ placeholderId = valueToId.get(value);
74
+ if (placeholderId === undefined) {
75
+ bindings.push(value);
76
+ placeholderId = bindings.length;
77
+ valueToId.set(value, placeholderId);
78
+ }
79
+
80
+ strings.push(child._.s[j + 1]!);
81
+ placeholderIds.push(placeholderId);
82
+ }
83
+
84
+ strings[strings.length - 1] += rawString;
85
+ } else {
86
+ placeholderId = valueToId.get(child);
87
+
88
+ if (placeholderId === undefined) {
89
+ bindings.push(child);
90
+ placeholderId = bindings.length;
91
+ valueToId.set(child, placeholderId);
92
+ }
93
+
94
+ strings.push(rawString);
95
+ placeholderIds.push(placeholderId);
96
+ }
97
+ }
98
+ }
99
+
100
+ this.values = bindings;
101
+ Object.defineProperty(this, "_", {
102
+ value: this._ = {
103
+ t: {
104
+ c: false,
105
+ v: placeholderIds,
106
+ },
107
+ s: strings,
108
+ },
109
+ });
110
+ }
111
+
112
+ public toJSON(): {
113
+ text: string;
114
+ values: Value[];
115
+ } {
116
+ return {
117
+ text: this.text,
118
+ values: this.values.slice(),
119
+ };
120
+ }
121
+
122
+ public toString(): string {
123
+ return this.text;
124
+ }
125
+ }
126
+
127
+ export function raw(value: string): Sql {
128
+ return new Sql([value], []);
129
+ }
130
+
131
+ export const empty: Sql = raw("");
132
+
133
+ export function join(values: readonly RawValue[], separator: string | undefined = ","): Sql {
134
+ if (values.length === 0) {
135
+ return empty;
136
+ }
137
+
138
+ return new Sql(["", ...Array(values.length - 1).fill(separator), ""], values);
139
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { empty, join, raw, type RawValue, Sql, type Value } from "./core.js";
2
+
3
+ export { sql } from "./sql.js";
package/src/sql.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { empty, join, raw, type RawValue, Sql } from "./core.js";
2
+
3
+ namespace sql {
4
+ export type RawValue = import("./core.js").RawValue;
5
+
6
+ export type Value = import("./core.js").Value;
7
+
8
+ export type Sql = import("./core.js").Sql;
9
+ }
10
+
11
+ const sql = /*#__PURE__*/ Object.assign(
12
+ function sql(strings: TemplateStringsArray, ...bindings: readonly RawValue[]): Sql {
13
+ return new Sql(strings, bindings);
14
+ },
15
+ {
16
+ Sql,
17
+ raw,
18
+ join,
19
+ empty,
20
+ } as const,
21
+ );
22
+
23
+ export { sql };
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # pgsql-template-tag
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `pgsql-template-tag`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**