@danceroutine/tango-core 1.11.0 → 1.11.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/dist/{TangoError-DdQVQNZU.js → TangoError-Cvgnm026.js} +8 -4
- package/dist/TangoError-Cvgnm026.js.map +1 -0
- package/dist/TangoError-ptR2iApz.d.ts +45 -0
- package/dist/chunk-D7D4PA-g.js +13 -0
- package/dist/errors/index.d.ts +3 -15
- package/dist/errors/index.js +3 -5
- package/dist/{errors-VacGsSaj.js → errors-DpI5Dxmr.js} +45 -36
- package/dist/errors-DpI5Dxmr.js.map +1 -0
- package/dist/http/index.d.ts +2 -10
- package/dist/http/index.js +2 -5
- package/dist/{http-63cMANMG.js → http-6e0y_vd6.js} +95 -79
- package/dist/{http-63cMANMG.js.map → http-6e0y_vd6.js.map} +1 -1
- package/dist/index-B5PoK4LH.d.ts +86 -0
- package/dist/index-D8o4DOOG.d.ts +824 -0
- package/dist/index-DFWodYLS.d.ts +161 -0
- package/dist/index-DPABSINz.d.ts +114 -0
- package/dist/index-MZzjIxgD.d.ts +59 -0
- package/dist/index.d.ts +7 -20
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +2 -3
- package/dist/logging/index.js +2 -3
- package/dist/logging-UC5uXHET.js +68 -0
- package/dist/logging-UC5uXHET.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -14
- package/dist/runtime/index.js +2 -3
- package/dist/{runtime-B8KkgD3R.js → runtime-BAG_EKuM.js} +44 -35
- package/dist/runtime-BAG_EKuM.js.map +1 -0
- package/dist/sql/index.d.ts +2 -13
- package/dist/sql/index.js +2 -3
- package/dist/{sql-BI3ptL9-.js → sql-CIPnuTYO.js} +21 -16
- package/dist/{sql-BI3ptL9-.js.map → sql-CIPnuTYO.js.map} +1 -1
- package/package.json +3 -3
- package/dist/TangoError-DdQVQNZU.js.map +0 -1
- package/dist/chunk-BkvOhyD0.js +0 -12
- package/dist/errors/AuthenticationError.d.ts +0 -15
- package/dist/errors/ConflictError.d.ts +0 -15
- package/dist/errors/HttpError.d.ts +0 -7
- package/dist/errors/MultipleObjectsReturned.d.ts +0 -11
- package/dist/errors/NotFoundError.d.ts +0 -15
- package/dist/errors/PermissionDenied.d.ts +0 -15
- package/dist/errors/TangoError.d.ts +0 -33
- package/dist/errors/ValidationError.d.ts +0 -14
- package/dist/errors/factories/HttpErrorFactory.d.ts +0 -59
- package/dist/errors/factories/index.d.ts +0 -4
- package/dist/errors-VacGsSaj.js.map +0 -1
- package/dist/http/TangoBody.d.ts +0 -110
- package/dist/http/TangoHeaders.d.ts +0 -191
- package/dist/http/TangoQueryParams.d.ts +0 -81
- package/dist/http/TangoRequest.d.ts +0 -130
- package/dist/http/TangoResponse.d.ts +0 -305
- package/dist/logging/ConsoleLogger.d.ts +0 -15
- package/dist/logging/Logger.d.ts +0 -13
- package/dist/logging/getLogger.d.ts +0 -23
- package/dist/logging-BWeD4HOO.js +0 -48
- package/dist/logging-BWeD4HOO.js.map +0 -1
- package/dist/runtime/binary/index.d.ts +0 -6
- package/dist/runtime/binary/isArrayBuffer.d.ts +0 -4
- package/dist/runtime/binary/isBlob.d.ts +0 -4
- package/dist/runtime/binary/isUint8Array.d.ts +0 -4
- package/dist/runtime/date/index.d.ts +0 -4
- package/dist/runtime/date/isDate.d.ts +0 -4
- package/dist/runtime/error/index.d.ts +0 -4
- package/dist/runtime/error/isError.d.ts +0 -4
- package/dist/runtime/internal/hasTag.d.ts +0 -1
- package/dist/runtime/object/index.d.ts +0 -5
- package/dist/runtime/object/isNil.d.ts +0 -4
- package/dist/runtime/object/isObject.d.ts +0 -4
- package/dist/runtime/web/index.d.ts +0 -7
- package/dist/runtime/web/isFile.d.ts +0 -4
- package/dist/runtime/web/isFormData.d.ts +0 -4
- package/dist/runtime/web/isReadableStream.d.ts +0 -4
- package/dist/runtime/web/isURLSearchParams.d.ts +0 -4
- package/dist/runtime-B8KkgD3R.js.map +0 -1
- package/dist/sql/SqlDialect.d.ts +0 -5
- package/dist/sql/SqlIdentifierRole.d.ts +0 -13
- package/dist/sql/SqlSafetyEngine.d.ts +0 -50
- package/dist/sql/TrustedSqlFragment.d.ts +0 -5
- package/dist/sql/ValidatedSqlIdentifier.d.ts +0 -7
- package/dist/sql/isTrustedSqlFragment.d.ts +0 -5
- package/dist/sql/quoteSqlIdentifier.d.ts +0 -6
- package/dist/sql/trustedSql.d.ts +0 -5
- package/dist/sql/validateSqlIdentifier.d.ts +0 -6
|
@@ -1,117 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as __exportAll } from "./chunk-D7D4PA-g.js";
|
|
3
2
|
//#region src/runtime/object/isNil.ts
|
|
3
|
+
/**
|
|
4
|
+
* Return true when a value is `null` or `undefined`.
|
|
5
|
+
*/
|
|
4
6
|
function isNil(value) {
|
|
5
|
-
return value === null || value ===
|
|
7
|
+
return value === null || value === void 0;
|
|
6
8
|
}
|
|
7
|
-
|
|
8
9
|
//#endregion
|
|
9
10
|
//#region src/runtime/internal/hasTag.ts
|
|
10
11
|
function hasTag(value, tag) {
|
|
11
12
|
return !isNil(value) && Object.prototype.toString.call(value) === `[object ${tag}]`;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/runtime/binary/isArrayBuffer.ts
|
|
16
|
+
/**
|
|
17
|
+
* Return true when a value is an `ArrayBuffer`.
|
|
18
|
+
*/
|
|
16
19
|
function isArrayBuffer(value) {
|
|
17
20
|
return hasTag(value, "ArrayBuffer");
|
|
18
21
|
}
|
|
19
|
-
|
|
20
22
|
//#endregion
|
|
21
23
|
//#region src/runtime/binary/isUint8Array.ts
|
|
24
|
+
/**
|
|
25
|
+
* Return true when a value is a `Uint8Array`.
|
|
26
|
+
*/
|
|
22
27
|
function isUint8Array(value) {
|
|
23
28
|
return hasTag(value, "Uint8Array");
|
|
24
29
|
}
|
|
25
|
-
|
|
26
30
|
//#endregion
|
|
27
31
|
//#region src/runtime/binary/isBlob.ts
|
|
32
|
+
/**
|
|
33
|
+
* Return true when a value is a `Blob`.
|
|
34
|
+
*/
|
|
28
35
|
function isBlob(value) {
|
|
29
36
|
return hasTag(value, "Blob");
|
|
30
37
|
}
|
|
31
|
-
|
|
32
38
|
//#endregion
|
|
33
39
|
//#region src/runtime/binary/index.ts
|
|
34
|
-
var binary_exports = {
|
|
35
|
-
__export(binary_exports, {
|
|
40
|
+
var binary_exports = /* @__PURE__ */ __exportAll({
|
|
36
41
|
isArrayBuffer: () => isArrayBuffer,
|
|
37
42
|
isBlob: () => isBlob,
|
|
38
43
|
isUint8Array: () => isUint8Array
|
|
39
44
|
});
|
|
40
|
-
|
|
41
45
|
//#endregion
|
|
42
46
|
//#region src/runtime/web/isFormData.ts
|
|
47
|
+
/**
|
|
48
|
+
* Return true when a value is `FormData`.
|
|
49
|
+
*/
|
|
43
50
|
function isFormData(value) {
|
|
44
51
|
return hasTag(value, "FormData");
|
|
45
52
|
}
|
|
46
|
-
|
|
47
53
|
//#endregion
|
|
48
54
|
//#region src/runtime/web/isURLSearchParams.ts
|
|
55
|
+
/**
|
|
56
|
+
* Return true when a value is `URLSearchParams`.
|
|
57
|
+
*/
|
|
49
58
|
function isURLSearchParams(value) {
|
|
50
59
|
return hasTag(value, "URLSearchParams");
|
|
51
60
|
}
|
|
52
|
-
|
|
53
61
|
//#endregion
|
|
54
62
|
//#region src/runtime/web/isReadableStream.ts
|
|
63
|
+
/**
|
|
64
|
+
* Return true when a value is a readable web stream.
|
|
65
|
+
*/
|
|
55
66
|
function isReadableStream(value) {
|
|
56
67
|
return hasTag(value, "ReadableStream");
|
|
57
68
|
}
|
|
58
|
-
|
|
59
69
|
//#endregion
|
|
60
70
|
//#region src/runtime/web/isFile.ts
|
|
71
|
+
/**
|
|
72
|
+
* Return true when a value is a web `File`.
|
|
73
|
+
*/
|
|
61
74
|
function isFile(value) {
|
|
62
75
|
return hasTag(value, "File");
|
|
63
76
|
}
|
|
64
|
-
|
|
65
77
|
//#endregion
|
|
66
78
|
//#region src/runtime/web/index.ts
|
|
67
|
-
var web_exports = {
|
|
68
|
-
__export(web_exports, {
|
|
79
|
+
var web_exports = /* @__PURE__ */ __exportAll({
|
|
69
80
|
isFile: () => isFile,
|
|
70
81
|
isFormData: () => isFormData,
|
|
71
82
|
isReadableStream: () => isReadableStream,
|
|
72
83
|
isURLSearchParams: () => isURLSearchParams
|
|
73
84
|
});
|
|
74
|
-
|
|
75
85
|
//#endregion
|
|
76
86
|
//#region src/runtime/object/isObject.ts
|
|
87
|
+
/**
|
|
88
|
+
* Return true when a value is a non-null object.
|
|
89
|
+
*/
|
|
77
90
|
function isObject(value) {
|
|
78
91
|
return typeof value === "object" && value !== null;
|
|
79
92
|
}
|
|
80
|
-
|
|
81
93
|
//#endregion
|
|
82
94
|
//#region src/runtime/object/index.ts
|
|
83
|
-
var object_exports = {
|
|
84
|
-
__export(object_exports, {
|
|
95
|
+
var object_exports = /* @__PURE__ */ __exportAll({
|
|
85
96
|
isNil: () => isNil,
|
|
86
97
|
isObject: () => isObject
|
|
87
98
|
});
|
|
88
|
-
|
|
89
99
|
//#endregion
|
|
90
100
|
//#region src/runtime/error/isError.ts
|
|
101
|
+
/**
|
|
102
|
+
* Return true when a value looks like an `Error`.
|
|
103
|
+
*/
|
|
91
104
|
function isError(value) {
|
|
92
105
|
return isObject(value) && typeof value.name === "string" && typeof value.message === "string";
|
|
93
106
|
}
|
|
94
|
-
|
|
95
107
|
//#endregion
|
|
96
108
|
//#region src/runtime/error/index.ts
|
|
97
|
-
var error_exports = {};
|
|
98
|
-
__export(error_exports, { isError: () => isError });
|
|
99
|
-
|
|
109
|
+
var error_exports = /* @__PURE__ */ __exportAll({ isError: () => isError });
|
|
100
110
|
//#endregion
|
|
101
111
|
//#region src/runtime/date/isDate.ts
|
|
112
|
+
/**
|
|
113
|
+
* Return true when a value is a `Date`.
|
|
114
|
+
*/
|
|
102
115
|
function isDate(value) {
|
|
103
116
|
return hasTag(value, "Date");
|
|
104
117
|
}
|
|
105
|
-
|
|
106
118
|
//#endregion
|
|
107
119
|
//#region src/runtime/date/index.ts
|
|
108
|
-
var date_exports = {};
|
|
109
|
-
__export(date_exports, { isDate: () => isDate });
|
|
110
|
-
|
|
120
|
+
var date_exports = /* @__PURE__ */ __exportAll({ isDate: () => isDate });
|
|
111
121
|
//#endregion
|
|
112
122
|
//#region src/runtime/index.ts
|
|
113
|
-
var runtime_exports = {
|
|
114
|
-
__export(runtime_exports, {
|
|
123
|
+
var runtime_exports = /* @__PURE__ */ __exportAll({
|
|
115
124
|
binary: () => binary_exports,
|
|
116
125
|
date: () => date_exports,
|
|
117
126
|
error: () => error_exports,
|
|
@@ -129,7 +138,7 @@ __export(runtime_exports, {
|
|
|
129
138
|
object: () => object_exports,
|
|
130
139
|
web: () => web_exports
|
|
131
140
|
});
|
|
132
|
-
|
|
133
141
|
//#endregion
|
|
134
|
-
export {
|
|
135
|
-
|
|
142
|
+
export { isNil as _, isError as a, web_exports as c, isURLSearchParams as d, isFormData as f, isArrayBuffer as g, isUint8Array as h, error_exports as i, isFile as l, isBlob as m, date_exports as n, object_exports as o, binary_exports as p, isDate as r, isObject as s, runtime_exports as t, isReadableStream as u };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=runtime-BAG_EKuM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-BAG_EKuM.js","names":[],"sources":["../src/runtime/object/isNil.ts","../src/runtime/internal/hasTag.ts","../src/runtime/binary/isArrayBuffer.ts","../src/runtime/binary/isUint8Array.ts","../src/runtime/binary/isBlob.ts","../src/runtime/binary/index.ts","../src/runtime/web/isFormData.ts","../src/runtime/web/isURLSearchParams.ts","../src/runtime/web/isReadableStream.ts","../src/runtime/web/isFile.ts","../src/runtime/web/index.ts","../src/runtime/object/isObject.ts","../src/runtime/object/index.ts","../src/runtime/error/isError.ts","../src/runtime/error/index.ts","../src/runtime/date/isDate.ts","../src/runtime/date/index.ts","../src/runtime/index.ts"],"sourcesContent":["/**\n * Return true when a value is `null` or `undefined`.\n */\nexport function isNil(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n","import { isNil } from '../object/isNil';\n\nexport function hasTag(value: unknown, tag: string): boolean {\n return !isNil(value) && Object.prototype.toString.call(value) === `[object ${tag}]`;\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is an `ArrayBuffer`.\n */\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n return hasTag(value, 'ArrayBuffer');\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is a `Uint8Array`.\n */\nexport function isUint8Array(value: unknown): value is Uint8Array<ArrayBuffer> {\n return hasTag(value, 'Uint8Array');\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is a `Blob`.\n */\nexport function isBlob(value: unknown): value is Blob {\n return hasTag(value, 'Blob');\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { isArrayBuffer } from './isArrayBuffer';\nexport { isUint8Array } from './isUint8Array';\nexport { isBlob } from './isBlob';\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is `FormData`.\n */\nexport function isFormData(value: unknown): value is FormData {\n return hasTag(value, 'FormData');\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is `URLSearchParams`.\n */\nexport function isURLSearchParams(value: unknown): value is URLSearchParams {\n return hasTag(value, 'URLSearchParams');\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is a readable web stream.\n */\nexport function isReadableStream(value: unknown): value is ReadableStream<Uint8Array<ArrayBuffer>> {\n return hasTag(value, 'ReadableStream');\n}\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is a web `File`.\n */\nexport function isFile(value: unknown): value is File {\n return hasTag(value, 'File');\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { isFormData } from './isFormData';\nexport { isURLSearchParams } from './isURLSearchParams';\nexport { isReadableStream } from './isReadableStream';\nexport { isFile } from './isFile';\n","/**\n * Return true when a value is a non-null object.\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { isObject } from './isObject';\nexport { isNil } from './isNil';\n","import { isObject } from '../object/isObject';\n\n/**\n * Return true when a value looks like an `Error`.\n */\nexport function isError(value: unknown): value is Error {\n return (\n isObject(value) &&\n typeof (value as { name?: unknown }).name === 'string' &&\n typeof (value as { message?: unknown }).message === 'string'\n );\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { isError } from './isError';\n","import { hasTag } from '../internal/hasTag';\n\n/**\n * Return true when a value is a `Date`.\n */\nexport function isDate(value: unknown): value is Date {\n return hasTag(value, 'Date');\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { isDate } from './isDate';\n","/**\n * Domain boundary barrel: exposes namespaced exports for Django-style drill-down\n * imports and curated flat exports for TS-native ergonomics.\n */\n\nexport * as binary from './binary/index';\nexport * as web from './web/index';\nexport * as object from './object/index';\nexport * as error from './error/index';\nexport * as date from './date/index';\n\nexport { isArrayBuffer, isBlob, isUint8Array } from './binary/index';\nexport { isFile, isFormData, isReadableStream, isURLSearchParams } from './web/index';\nexport { isNil, isObject } from './object/index';\nexport { isError } from './error/index';\nexport { isDate } from './date/index';\n"],"mappings":";;;;;AAGA,SAAgB,MAAM,OAA2C;CAC7D,OAAO,UAAU,QAAQ,UAAU,KAAA;AACvC;;;ACHA,SAAgB,OAAO,OAAgB,KAAsB;CACzD,OAAO,CAAC,MAAM,KAAK,KAAK,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,WAAW,IAAI;AACrF;;;;;;ACCA,SAAgB,cAAc,OAAsC;CAChE,OAAO,OAAO,OAAO,aAAa;AACtC;;;;;;ACFA,SAAgB,aAAa,OAAkD;CAC3E,OAAO,OAAO,OAAO,YAAY;AACrC;;;;;;ACFA,SAAgB,OAAO,OAA+B;CAClD,OAAO,OAAO,OAAO,MAAM;AAC/B;;;;;;;;;;;;;AEFA,SAAgB,WAAW,OAAmC;CAC1D,OAAO,OAAO,OAAO,UAAU;AACnC;;;;;;ACFA,SAAgB,kBAAkB,OAA0C;CACxE,OAAO,OAAO,OAAO,iBAAiB;AAC1C;;;;;;ACFA,SAAgB,iBAAiB,OAAkE;CAC/F,OAAO,OAAO,OAAO,gBAAgB;AACzC;;;;;;ACFA,SAAgB,OAAO,OAA+B;CAClD,OAAO,OAAO,OAAO,MAAM;AAC/B;;;;;;;;;;;;;;AEJA,SAAgB,SAAS,OAAkD;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU;AAClD;;;;;;;;;;;;AEAA,SAAgB,QAAQ,OAAgC;CACpD,OACI,SAAS,KAAK,KACd,OAAQ,MAA6B,SAAS,YAC9C,OAAQ,MAAgC,YAAY;AAE5D;;;;;;;;;AENA,SAAgB,OAAO,OAA+B;CAClD,OAAO,OAAO,OAAO,MAAM;AAC/B"}
|
package/dist/sql/index.d.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export type { SqlDialect } from './SqlDialect';
|
|
5
|
-
export type { SqlIdentifierRole } from './SqlIdentifierRole';
|
|
6
|
-
export type { TrustedSqlFragment } from './TrustedSqlFragment';
|
|
7
|
-
export type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';
|
|
8
|
-
export { SqlSafetyEngine } from './SqlSafetyEngine';
|
|
9
|
-
export type { SqlIdentifierRequest, SqlLookupTokenRequest, SqlRawFragmentRequest, SqlSafetyRequest, ValidatedSqlLookupToken, ValidatedSqlSafetyResult, } from './SqlSafetyEngine';
|
|
10
|
-
export { trustedSql } from './trustedSql';
|
|
11
|
-
export { isTrustedSqlFragment } from './isTrustedSqlFragment';
|
|
12
|
-
export { validateSqlIdentifier } from './validateSqlIdentifier';
|
|
13
|
-
export { quoteSqlIdentifier } from './quoteSqlIdentifier';
|
|
1
|
+
import { a as trustedSql, c as SqlRawFragmentRequest, d as ValidatedSqlLookupToken, f as ValidatedSqlSafetyResult, g as SqlDialect, h as SqlIdentifierRole, i as isTrustedSqlFragment, l as SqlSafetyEngine, m as TrustedSqlFragment, n as quoteSqlIdentifier, o as SqlIdentifierRequest, p as ValidatedSqlIdentifier, r as validateSqlIdentifier, s as SqlLookupTokenRequest, u as SqlSafetyRequest } from "../index-DPABSINz.js";
|
|
2
|
+
export { type SqlDialect, type SqlIdentifierRequest, type SqlIdentifierRole, type SqlLookupTokenRequest, type SqlRawFragmentRequest, SqlSafetyEngine, type SqlSafetyRequest, type TrustedSqlFragment, type ValidatedSqlIdentifier, type ValidatedSqlLookupToken, type ValidatedSqlSafetyResult, isTrustedSqlFragment, quoteSqlIdentifier, trustedSql, validateSqlIdentifier };
|
package/dist/sql/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { SqlSafetyEngine, isTrustedSqlFragment, quoteSqlIdentifier, trustedSql, validateSqlIdentifier };
|
|
1
|
+
import { a as validateSqlIdentifier, i as SqlSafetyEngine, n as quoteSqlIdentifier, o as isTrustedSqlFragment, r as trustedSql } from "../sql-CIPnuTYO.js";
|
|
2
|
+
export { SqlSafetyEngine, isTrustedSqlFragment, quoteSqlIdentifier, trustedSql, validateSqlIdentifier };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as __exportAll } from "./chunk-D7D4PA-g.js";
|
|
3
2
|
//#region src/sql/TrustedSqlFragment.ts
|
|
4
3
|
const TRUSTED_SQL_FRAGMENT_BRAND = "tango.core.trusted_sql_fragment";
|
|
5
|
-
|
|
6
4
|
//#endregion
|
|
7
5
|
//#region src/sql/isTrustedSqlFragment.ts
|
|
6
|
+
/**
|
|
7
|
+
* Narrow an unknown value to a trusted raw SQL fragment.
|
|
8
|
+
*/
|
|
8
9
|
function isTrustedSqlFragment(value) {
|
|
9
|
-
return typeof value === "object" && value !== null && value.__tangoBrand ===
|
|
10
|
+
return typeof value === "object" && value !== null && value.__tangoBrand === "tango.core.trusted_sql_fragment" && typeof value.sql === "string";
|
|
10
11
|
}
|
|
11
|
-
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/sql/ValidatedSqlIdentifier.ts
|
|
14
14
|
const VALIDATED_SQL_IDENTIFIER_BRAND = "tango.core.validated_sql_identifier";
|
|
15
|
-
|
|
16
15
|
//#endregion
|
|
17
16
|
//#region src/sql/SqlIdentifierRole.ts
|
|
18
17
|
const InternalSqlIdentifierRole = {
|
|
@@ -27,7 +26,6 @@ const InternalSqlIdentifierRole = {
|
|
|
27
26
|
RELATION_FOREIGN_KEY: "relationForeignKey",
|
|
28
27
|
RELATION_TARGET_PRIMARY_KEY: "relationTargetPrimaryKey"
|
|
29
28
|
};
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
30
|
//#region src/sql/validateSqlIdentifier.ts
|
|
33
31
|
const SQL_IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -43,6 +41,9 @@ const ROLE_LABELS = {
|
|
|
43
41
|
[InternalSqlIdentifierRole.RELATION_FOREIGN_KEY]: "relation foreign key",
|
|
44
42
|
[InternalSqlIdentifierRole.RELATION_TARGET_PRIMARY_KEY]: "relation target primary key"
|
|
45
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Validate an identifier against Tango's SQL safety policy.
|
|
46
|
+
*/
|
|
46
47
|
function validateSqlIdentifier(value, role, allowlist) {
|
|
47
48
|
const label = ROLE_LABELS[role];
|
|
48
49
|
if (!SQL_IDENTIFIER_PATTERN.test(value)) throw new Error(`Invalid SQL ${label}: '${value}'.`);
|
|
@@ -53,9 +54,11 @@ function validateSqlIdentifier(value, role, allowlist) {
|
|
|
53
54
|
value
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/sql/SqlSafetyEngine.ts
|
|
59
|
+
/**
|
|
60
|
+
* Canonical SQL safety policy engine shared across Tango packages.
|
|
61
|
+
*/
|
|
59
62
|
var SqlSafetyEngine = class SqlSafetyEngine {
|
|
60
63
|
static BRAND = "tango.core.sql_safety_engine";
|
|
61
64
|
__tangoBrand = SqlSafetyEngine.BRAND;
|
|
@@ -84,33 +87,35 @@ var SqlSafetyEngine = class SqlSafetyEngine {
|
|
|
84
87
|
return entry.value;
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
|
-
|
|
88
90
|
//#endregion
|
|
89
91
|
//#region src/sql/trustedSql.ts
|
|
92
|
+
/**
|
|
93
|
+
* Explicitly opt into embedding a reviewed raw SQL fragment.
|
|
94
|
+
*/
|
|
90
95
|
function trustedSql(sql) {
|
|
91
96
|
return {
|
|
92
97
|
__tangoBrand: TRUSTED_SQL_FRAGMENT_BRAND,
|
|
93
98
|
sql
|
|
94
99
|
};
|
|
95
100
|
}
|
|
96
|
-
|
|
97
101
|
//#endregion
|
|
98
102
|
//#region src/sql/quoteSqlIdentifier.ts
|
|
103
|
+
/**
|
|
104
|
+
* Quote a validated identifier for the target SQL dialect.
|
|
105
|
+
*/
|
|
99
106
|
function quoteSqlIdentifier(identifier, _dialect) {
|
|
100
107
|
return `"${identifier.value.replaceAll("\"", "\"\"")}"`;
|
|
101
108
|
}
|
|
102
|
-
|
|
103
109
|
//#endregion
|
|
104
110
|
//#region src/sql/index.ts
|
|
105
|
-
var sql_exports = {
|
|
106
|
-
__export(sql_exports, {
|
|
111
|
+
var sql_exports = /* @__PURE__ */ __exportAll({
|
|
107
112
|
SqlSafetyEngine: () => SqlSafetyEngine,
|
|
108
113
|
isTrustedSqlFragment: () => isTrustedSqlFragment,
|
|
109
114
|
quoteSqlIdentifier: () => quoteSqlIdentifier,
|
|
110
115
|
trustedSql: () => trustedSql,
|
|
111
116
|
validateSqlIdentifier: () => validateSqlIdentifier
|
|
112
117
|
});
|
|
113
|
-
|
|
114
118
|
//#endregion
|
|
115
|
-
export {
|
|
116
|
-
|
|
119
|
+
export { validateSqlIdentifier as a, SqlSafetyEngine as i, quoteSqlIdentifier as n, isTrustedSqlFragment as o, trustedSql as r, sql_exports as t };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=sql-CIPnuTYO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-BI3ptL9-.js","names":["value: unknown","ROLE_LABELS: Record<SqlIdentifierRole, string>","value: string","role: SqlIdentifierRole","allowlist?: readonly string[]","value: unknown","request: SqlSafetyRequest","entry: SqlLookupTokenRequest","entry: SqlRawFragmentRequest","sql: string","identifier: ValidatedSqlIdentifier","_dialect: SqlDialect"],"sources":["../src/sql/TrustedSqlFragment.ts","../src/sql/isTrustedSqlFragment.ts","../src/sql/ValidatedSqlIdentifier.ts","../src/sql/SqlIdentifierRole.ts","../src/sql/validateSqlIdentifier.ts","../src/sql/SqlSafetyEngine.ts","../src/sql/trustedSql.ts","../src/sql/quoteSqlIdentifier.ts","../src/sql/index.ts"],"sourcesContent":["export const TRUSTED_SQL_FRAGMENT_BRAND = 'tango.core.trusted_sql_fragment' as const;\n\nexport type TrustedSqlFragment = {\n readonly __tangoBrand: typeof TRUSTED_SQL_FRAGMENT_BRAND;\n readonly sql: string;\n};\n","import { TRUSTED_SQL_FRAGMENT_BRAND, type TrustedSqlFragment } from './TrustedSqlFragment';\n\n/**\n * Narrow an unknown value to a trusted raw SQL fragment.\n */\nexport function isTrustedSqlFragment(value: unknown): value is TrustedSqlFragment {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === TRUSTED_SQL_FRAGMENT_BRAND &&\n typeof (value as { sql?: unknown }).sql === 'string'\n );\n}\n","import type { SqlIdentifierRole } from './SqlIdentifierRole';\n\nexport const VALIDATED_SQL_IDENTIFIER_BRAND = 'tango.core.validated_sql_identifier' as const;\n\nexport type ValidatedSqlIdentifier = {\n readonly __tangoBrand: typeof VALIDATED_SQL_IDENTIFIER_BRAND;\n readonly role: SqlIdentifierRole;\n readonly value: string;\n};\n","export const InternalSqlIdentifierRole = {\n TABLE: 'table',\n COLUMN: 'column',\n PRIMARY_KEY: 'primaryKey',\n INDEX: 'index',\n ALIAS: 'alias',\n CONSTRAINT: 'constraint',\n SCHEMA: 'schema',\n RELATION_TABLE: 'relationTable',\n RELATION_FOREIGN_KEY: 'relationForeignKey',\n RELATION_TARGET_PRIMARY_KEY: 'relationTargetPrimaryKey',\n} as const;\n\nexport type SqlIdentifierRole = (typeof InternalSqlIdentifierRole)[keyof typeof InternalSqlIdentifierRole];\n","import { VALIDATED_SQL_IDENTIFIER_BRAND, type ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\nimport { InternalSqlIdentifierRole, type SqlIdentifierRole } from './SqlIdentifierRole';\n\nconst SQL_IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nconst ROLE_LABELS: Record<SqlIdentifierRole, string> = {\n [InternalSqlIdentifierRole.TABLE]: 'table name',\n [InternalSqlIdentifierRole.COLUMN]: 'column',\n [InternalSqlIdentifierRole.PRIMARY_KEY]: 'primary key',\n [InternalSqlIdentifierRole.INDEX]: 'index',\n [InternalSqlIdentifierRole.ALIAS]: 'alias',\n [InternalSqlIdentifierRole.CONSTRAINT]: 'constraint',\n [InternalSqlIdentifierRole.SCHEMA]: 'schema',\n [InternalSqlIdentifierRole.RELATION_TABLE]: 'relation table',\n [InternalSqlIdentifierRole.RELATION_FOREIGN_KEY]: 'relation foreign key',\n [InternalSqlIdentifierRole.RELATION_TARGET_PRIMARY_KEY]: 'relation target primary key',\n};\n\n/**\n * Validate an identifier against Tango's SQL safety policy.\n */\nexport function validateSqlIdentifier(\n value: string,\n role: SqlIdentifierRole,\n allowlist?: readonly string[]\n): ValidatedSqlIdentifier {\n const label = ROLE_LABELS[role];\n\n if (!SQL_IDENTIFIER_PATTERN.test(value)) {\n throw new Error(`Invalid SQL ${label}: '${value}'.`);\n }\n\n if (allowlist && !allowlist.includes(value)) {\n throw new Error(`Unknown SQL ${label}: '${value}'.`);\n }\n\n return {\n __tangoBrand: VALIDATED_SQL_IDENTIFIER_BRAND,\n role,\n value,\n };\n}\n","import type { SqlDialect } from './SqlDialect';\nimport type { SqlIdentifierRole } from './SqlIdentifierRole';\nimport { isTrustedSqlFragment } from './isTrustedSqlFragment';\nimport type { TrustedSqlFragment } from './TrustedSqlFragment';\nimport { validateSqlIdentifier } from './validateSqlIdentifier';\nimport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\n\nexport type SqlIdentifierRequest = {\n key: string;\n role: SqlIdentifierRole;\n value: string;\n allowlist?: readonly string[];\n};\n\nexport type SqlLookupTokenRequest = {\n key: string;\n lookup: string;\n allowed: readonly string[];\n};\n\nexport type SqlRawFragmentRequest = {\n key: string;\n value: TrustedSqlFragment;\n};\n\nexport type SqlSafetyRequest = {\n dialect?: SqlDialect;\n identifiers?: readonly SqlIdentifierRequest[];\n lookupTokens?: readonly SqlLookupTokenRequest[];\n rawFragments?: readonly SqlRawFragmentRequest[];\n};\n\nexport type ValidatedSqlLookupToken = {\n lookup: string;\n};\n\nexport type ValidatedSqlSafetyResult = {\n identifiers: Record<string, ValidatedSqlIdentifier>;\n lookupTokens: Record<string, ValidatedSqlLookupToken>;\n rawFragments: Record<string, TrustedSqlFragment>;\n};\n\n/**\n * Canonical SQL safety policy engine shared across Tango packages.\n */\nexport class SqlSafetyEngine {\n static readonly BRAND = 'tango.core.sql_safety_engine' as const;\n readonly __tangoBrand: typeof SqlSafetyEngine.BRAND = SqlSafetyEngine.BRAND;\n\n /**\n * Narrow an unknown value to `SqlSafetyEngine`.\n */\n static isSqlSafetyEngine(value: unknown): value is SqlSafetyEngine {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === SqlSafetyEngine.BRAND\n );\n }\n\n /**\n * Validate a canonical SQL safety request and return trusted tokens.\n */\n validate(request: SqlSafetyRequest): ValidatedSqlSafetyResult {\n return {\n identifiers: Object.fromEntries(\n (request.identifiers ?? []).map((entry) => [\n entry.key,\n validateSqlIdentifier(entry.value, entry.role, entry.allowlist),\n ])\n ),\n lookupTokens: Object.fromEntries(\n (request.lookupTokens ?? []).map((entry) => [entry.key, this.validateLookupToken(entry)])\n ),\n rawFragments: Object.fromEntries(\n (request.rawFragments ?? []).map((entry) => [entry.key, this.validateRawFragment(entry)])\n ),\n };\n }\n\n private validateLookupToken(entry: SqlLookupTokenRequest): ValidatedSqlLookupToken {\n if (!entry.allowed.includes(entry.lookup)) {\n throw new Error(`Unknown lookup: ${entry.lookup}`);\n }\n\n return {\n lookup: entry.lookup,\n };\n }\n\n private validateRawFragment(entry: SqlRawFragmentRequest): TrustedSqlFragment {\n if (!isTrustedSqlFragment(entry.value)) {\n throw new Error(`Untrusted raw SQL fragment for '${entry.key}'.`);\n }\n\n return entry.value;\n }\n}\n","import { TRUSTED_SQL_FRAGMENT_BRAND, type TrustedSqlFragment } from './TrustedSqlFragment';\n\n/**\n * Explicitly opt into embedding a reviewed raw SQL fragment.\n */\nexport function trustedSql(sql: string): TrustedSqlFragment {\n return {\n __tangoBrand: TRUSTED_SQL_FRAGMENT_BRAND,\n sql,\n };\n}\n","import type { SqlDialect } from './SqlDialect';\nimport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\n\n/**\n * Quote a validated identifier for the target SQL dialect.\n */\nexport function quoteSqlIdentifier(identifier: ValidatedSqlIdentifier, _dialect: SqlDialect): string {\n return `\"${identifier.value.replaceAll('\"', '\"\"')}\"`;\n}\n","/**\n * Domain boundary barrel: centralizes SQL safety primitives and policy helpers.\n */\n\nexport type { SqlDialect } from './SqlDialect';\nexport type { SqlIdentifierRole } from './SqlIdentifierRole';\nexport type { TrustedSqlFragment } from './TrustedSqlFragment';\nexport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\nexport { SqlSafetyEngine } from './SqlSafetyEngine';\nexport type {\n SqlIdentifierRequest,\n SqlLookupTokenRequest,\n SqlRawFragmentRequest,\n SqlSafetyRequest,\n ValidatedSqlLookupToken,\n ValidatedSqlSafetyResult,\n} from './SqlSafetyEngine';\nexport { trustedSql } from './trustedSql';\nexport { isTrustedSqlFragment } from './isTrustedSqlFragment';\nexport { validateSqlIdentifier } from './validateSqlIdentifier';\nexport { quoteSqlIdentifier } from './quoteSqlIdentifier';\n"],"mappings":";;;MAAa,6BAA6B;;;;ACKnC,SAAS,qBAAqBA,OAA6C;AAC9E,eACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,qCAC/C,MAA4B,QAAQ;AAEnD;;;;MCVY,iCAAiC;;;;MCFjC,4BAA4B;CACrC,OAAO;CACP,QAAQ;CACR,aAAa;CACb,OAAO;CACP,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,gBAAgB;CAChB,sBAAsB;CACtB,6BAA6B;AAChC;;;;ACRD,MAAM,yBAAyB;AAE/B,MAAMC,cAAiD;EAClD,0BAA0B,QAAQ;EAClC,0BAA0B,SAAS;EACnC,0BAA0B,cAAc;EACxC,0BAA0B,QAAQ;EAClC,0BAA0B,QAAQ;EAClC,0BAA0B,aAAa;EACvC,0BAA0B,SAAS;EACnC,0BAA0B,iBAAiB;EAC3C,0BAA0B,uBAAuB;EACjD,0BAA0B,8BAA8B;AAC5D;AAKM,SAAS,sBACZC,OACAC,MACAC,WACsB;CACtB,MAAM,QAAQ,YAAY;AAE1B,MAAK,uBAAuB,KAAK,MAAM,CACnC,OAAM,IAAI,OAAO,cAAc,MAAM,KAAK,MAAM;AAGpD,KAAI,cAAc,UAAU,SAAS,MAAM,CACvC,OAAM,IAAI,OAAO,cAAc,MAAM,KAAK,MAAM;AAGpD,QAAO;EACH,cAAc;EACd;EACA;CACH;AACJ;;;;ICIY,kBAAN,MAAM,gBAAgB;CACzB,OAAgB,QAAQ;CACxB,eAAsD,gBAAgB;;;;CAKtE,OAAO,kBAAkBC,OAA0C;AAC/D,gBACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,gBAAgB;CAE9E;;;;CAKD,SAASC,SAAqD;AAC1D,SAAO;GACH,aAAa,OAAO,YAChB,CAAC,QAAQ,eAAe,CAAE,GAAE,IAAI,CAAC,UAAU,CACvC,MAAM,KACN,sBAAsB,MAAM,OAAO,MAAM,MAAM,MAAM,UAAU,AAClE,EAAC,CACL;GACD,cAAc,OAAO,YACjB,CAAC,QAAQ,gBAAgB,CAAE,GAAE,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,oBAAoB,MAAM,AAAC,EAAC,CAC5F;GACD,cAAc,OAAO,YACjB,CAAC,QAAQ,gBAAgB,CAAE,GAAE,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,oBAAoB,MAAM,AAAC,EAAC,CAC5F;EACJ;CACJ;CAED,oBAA4BC,OAAuD;AAC/E,OAAK,MAAM,QAAQ,SAAS,MAAM,OAAO,CACrC,OAAM,IAAI,OAAO,kBAAkB,MAAM,OAAO;AAGpD,SAAO,EACH,QAAQ,MAAM,OACjB;CACJ;CAED,oBAA4BC,OAAkD;AAC1E,OAAK,qBAAqB,MAAM,MAAM,CAClC,OAAM,IAAI,OAAO,kCAAkC,MAAM,IAAI;AAGjE,SAAO,MAAM;CAChB;AACJ;;;;AC5FM,SAAS,WAAWC,KAAiC;AACxD,QAAO;EACH,cAAc;EACd;CACH;AACJ;;;;ACJM,SAAS,mBAAmBC,YAAoCC,UAA8B;AACjG,SAAQ,GAAG,WAAW,MAAM,WAAW,MAAK,OAAK,CAAC;AACrD"}
|
|
1
|
+
{"version":3,"file":"sql-CIPnuTYO.js","names":[],"sources":["../src/sql/TrustedSqlFragment.ts","../src/sql/isTrustedSqlFragment.ts","../src/sql/ValidatedSqlIdentifier.ts","../src/sql/SqlIdentifierRole.ts","../src/sql/validateSqlIdentifier.ts","../src/sql/SqlSafetyEngine.ts","../src/sql/trustedSql.ts","../src/sql/quoteSqlIdentifier.ts","../src/sql/index.ts"],"sourcesContent":["export const TRUSTED_SQL_FRAGMENT_BRAND = 'tango.core.trusted_sql_fragment' as const;\n\nexport type TrustedSqlFragment = {\n readonly __tangoBrand: typeof TRUSTED_SQL_FRAGMENT_BRAND;\n readonly sql: string;\n};\n","import { TRUSTED_SQL_FRAGMENT_BRAND, type TrustedSqlFragment } from './TrustedSqlFragment';\n\n/**\n * Narrow an unknown value to a trusted raw SQL fragment.\n */\nexport function isTrustedSqlFragment(value: unknown): value is TrustedSqlFragment {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === TRUSTED_SQL_FRAGMENT_BRAND &&\n typeof (value as { sql?: unknown }).sql === 'string'\n );\n}\n","import type { SqlIdentifierRole } from './SqlIdentifierRole';\n\nexport const VALIDATED_SQL_IDENTIFIER_BRAND = 'tango.core.validated_sql_identifier' as const;\n\nexport type ValidatedSqlIdentifier = {\n readonly __tangoBrand: typeof VALIDATED_SQL_IDENTIFIER_BRAND;\n readonly role: SqlIdentifierRole;\n readonly value: string;\n};\n","export const InternalSqlIdentifierRole = {\n TABLE: 'table',\n COLUMN: 'column',\n PRIMARY_KEY: 'primaryKey',\n INDEX: 'index',\n ALIAS: 'alias',\n CONSTRAINT: 'constraint',\n SCHEMA: 'schema',\n RELATION_TABLE: 'relationTable',\n RELATION_FOREIGN_KEY: 'relationForeignKey',\n RELATION_TARGET_PRIMARY_KEY: 'relationTargetPrimaryKey',\n} as const;\n\nexport type SqlIdentifierRole = (typeof InternalSqlIdentifierRole)[keyof typeof InternalSqlIdentifierRole];\n","import { VALIDATED_SQL_IDENTIFIER_BRAND, type ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\nimport { InternalSqlIdentifierRole, type SqlIdentifierRole } from './SqlIdentifierRole';\n\nconst SQL_IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nconst ROLE_LABELS: Record<SqlIdentifierRole, string> = {\n [InternalSqlIdentifierRole.TABLE]: 'table name',\n [InternalSqlIdentifierRole.COLUMN]: 'column',\n [InternalSqlIdentifierRole.PRIMARY_KEY]: 'primary key',\n [InternalSqlIdentifierRole.INDEX]: 'index',\n [InternalSqlIdentifierRole.ALIAS]: 'alias',\n [InternalSqlIdentifierRole.CONSTRAINT]: 'constraint',\n [InternalSqlIdentifierRole.SCHEMA]: 'schema',\n [InternalSqlIdentifierRole.RELATION_TABLE]: 'relation table',\n [InternalSqlIdentifierRole.RELATION_FOREIGN_KEY]: 'relation foreign key',\n [InternalSqlIdentifierRole.RELATION_TARGET_PRIMARY_KEY]: 'relation target primary key',\n};\n\n/**\n * Validate an identifier against Tango's SQL safety policy.\n */\nexport function validateSqlIdentifier(\n value: string,\n role: SqlIdentifierRole,\n allowlist?: readonly string[]\n): ValidatedSqlIdentifier {\n const label = ROLE_LABELS[role];\n\n if (!SQL_IDENTIFIER_PATTERN.test(value)) {\n throw new Error(`Invalid SQL ${label}: '${value}'.`);\n }\n\n if (allowlist && !allowlist.includes(value)) {\n throw new Error(`Unknown SQL ${label}: '${value}'.`);\n }\n\n return {\n __tangoBrand: VALIDATED_SQL_IDENTIFIER_BRAND,\n role,\n value,\n };\n}\n","import type { SqlDialect } from './SqlDialect';\nimport type { SqlIdentifierRole } from './SqlIdentifierRole';\nimport { isTrustedSqlFragment } from './isTrustedSqlFragment';\nimport type { TrustedSqlFragment } from './TrustedSqlFragment';\nimport { validateSqlIdentifier } from './validateSqlIdentifier';\nimport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\n\nexport type SqlIdentifierRequest = {\n key: string;\n role: SqlIdentifierRole;\n value: string;\n allowlist?: readonly string[];\n};\n\nexport type SqlLookupTokenRequest = {\n key: string;\n lookup: string;\n allowed: readonly string[];\n};\n\nexport type SqlRawFragmentRequest = {\n key: string;\n value: TrustedSqlFragment;\n};\n\nexport type SqlSafetyRequest = {\n dialect?: SqlDialect;\n identifiers?: readonly SqlIdentifierRequest[];\n lookupTokens?: readonly SqlLookupTokenRequest[];\n rawFragments?: readonly SqlRawFragmentRequest[];\n};\n\nexport type ValidatedSqlLookupToken = {\n lookup: string;\n};\n\nexport type ValidatedSqlSafetyResult = {\n identifiers: Record<string, ValidatedSqlIdentifier>;\n lookupTokens: Record<string, ValidatedSqlLookupToken>;\n rawFragments: Record<string, TrustedSqlFragment>;\n};\n\n/**\n * Canonical SQL safety policy engine shared across Tango packages.\n */\nexport class SqlSafetyEngine {\n static readonly BRAND = 'tango.core.sql_safety_engine' as const;\n readonly __tangoBrand: typeof SqlSafetyEngine.BRAND = SqlSafetyEngine.BRAND;\n\n /**\n * Narrow an unknown value to `SqlSafetyEngine`.\n */\n static isSqlSafetyEngine(value: unknown): value is SqlSafetyEngine {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === SqlSafetyEngine.BRAND\n );\n }\n\n /**\n * Validate a canonical SQL safety request and return trusted tokens.\n */\n validate(request: SqlSafetyRequest): ValidatedSqlSafetyResult {\n return {\n identifiers: Object.fromEntries(\n (request.identifiers ?? []).map((entry) => [\n entry.key,\n validateSqlIdentifier(entry.value, entry.role, entry.allowlist),\n ])\n ),\n lookupTokens: Object.fromEntries(\n (request.lookupTokens ?? []).map((entry) => [entry.key, this.validateLookupToken(entry)])\n ),\n rawFragments: Object.fromEntries(\n (request.rawFragments ?? []).map((entry) => [entry.key, this.validateRawFragment(entry)])\n ),\n };\n }\n\n private validateLookupToken(entry: SqlLookupTokenRequest): ValidatedSqlLookupToken {\n if (!entry.allowed.includes(entry.lookup)) {\n throw new Error(`Unknown lookup: ${entry.lookup}`);\n }\n\n return {\n lookup: entry.lookup,\n };\n }\n\n private validateRawFragment(entry: SqlRawFragmentRequest): TrustedSqlFragment {\n if (!isTrustedSqlFragment(entry.value)) {\n throw new Error(`Untrusted raw SQL fragment for '${entry.key}'.`);\n }\n\n return entry.value;\n }\n}\n","import { TRUSTED_SQL_FRAGMENT_BRAND, type TrustedSqlFragment } from './TrustedSqlFragment';\n\n/**\n * Explicitly opt into embedding a reviewed raw SQL fragment.\n */\nexport function trustedSql(sql: string): TrustedSqlFragment {\n return {\n __tangoBrand: TRUSTED_SQL_FRAGMENT_BRAND,\n sql,\n };\n}\n","import type { SqlDialect } from './SqlDialect';\nimport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\n\n/**\n * Quote a validated identifier for the target SQL dialect.\n */\nexport function quoteSqlIdentifier(identifier: ValidatedSqlIdentifier, _dialect: SqlDialect): string {\n return `\"${identifier.value.replaceAll('\"', '\"\"')}\"`;\n}\n","/**\n * Domain boundary barrel: centralizes SQL safety primitives and policy helpers.\n */\n\nexport type { SqlDialect } from './SqlDialect';\nexport type { SqlIdentifierRole } from './SqlIdentifierRole';\nexport type { TrustedSqlFragment } from './TrustedSqlFragment';\nexport type { ValidatedSqlIdentifier } from './ValidatedSqlIdentifier';\nexport { SqlSafetyEngine } from './SqlSafetyEngine';\nexport type {\n SqlIdentifierRequest,\n SqlLookupTokenRequest,\n SqlRawFragmentRequest,\n SqlSafetyRequest,\n ValidatedSqlLookupToken,\n ValidatedSqlSafetyResult,\n} from './SqlSafetyEngine';\nexport { trustedSql } from './trustedSql';\nexport { isTrustedSqlFragment } from './isTrustedSqlFragment';\nexport { validateSqlIdentifier } from './validateSqlIdentifier';\nexport { quoteSqlIdentifier } from './quoteSqlIdentifier';\n"],"mappings":";;AAAA,MAAa,6BAA6B;;;;;;ACK1C,SAAgB,qBAAqB,OAA6C;CAC9E,OACI,OAAO,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAA,qCACtC,OAAQ,MAA4B,QAAQ;AAEpD;;;ACVA,MAAa,iCAAiC;;;ACF9C,MAAa,4BAA4B;CACrC,OAAO;CACP,QAAQ;CACR,aAAa;CACb,OAAO;CACP,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,gBAAgB;CAChB,sBAAsB;CACtB,6BAA6B;AACjC;;;ACRA,MAAM,yBAAyB;AAE/B,MAAM,cAAiD;EAClD,0BAA0B,QAAQ;EAClC,0BAA0B,SAAS;EACnC,0BAA0B,cAAc;EACxC,0BAA0B,QAAQ;EAClC,0BAA0B,QAAQ;EAClC,0BAA0B,aAAa;EACvC,0BAA0B,SAAS;EACnC,0BAA0B,iBAAiB;EAC3C,0BAA0B,uBAAuB;EACjD,0BAA0B,8BAA8B;AAC7D;;;;AAKA,SAAgB,sBACZ,OACA,MACA,WACsB;CACtB,MAAM,QAAQ,YAAY;CAE1B,IAAI,CAAC,uBAAuB,KAAK,KAAK,GAClC,MAAM,IAAI,MAAM,eAAe,MAAM,KAAK,MAAM,GAAG;CAGvD,IAAI,aAAa,CAAC,UAAU,SAAS,KAAK,GACtC,MAAM,IAAI,MAAM,eAAe,MAAM,KAAK,MAAM,GAAG;CAGvD,OAAO;EACH,cAAc;EACd;EACA;CACJ;AACJ;;;;;;ACIA,IAAa,kBAAb,MAAa,gBAAgB;CACzB,OAAgB,QAAQ;CACxB,eAAsD,gBAAgB;;;;CAKtE,OAAO,kBAAkB,OAA0C;EAC/D,OACI,OAAO,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,gBAAgB;CAE/E;;;;CAKA,SAAS,SAAqD;EAC1D,OAAO;GACH,aAAa,OAAO,aACf,QAAQ,eAAe,CAAC,GAAG,KAAK,UAAU,CACvC,MAAM,KACN,sBAAsB,MAAM,OAAO,MAAM,MAAM,MAAM,SAAS,CAClE,CAAC,CACL;GACA,cAAc,OAAO,aAChB,QAAQ,gBAAgB,CAAC,GAAG,KAAK,UAAU,CAAC,MAAM,KAAK,KAAK,oBAAoB,KAAK,CAAC,CAAC,CAC5F;GACA,cAAc,OAAO,aAChB,QAAQ,gBAAgB,CAAC,GAAG,KAAK,UAAU,CAAC,MAAM,KAAK,KAAK,oBAAoB,KAAK,CAAC,CAAC,CAC5F;EACJ;CACJ;CAEA,oBAA4B,OAAuD;EAC/E,IAAI,CAAC,MAAM,QAAQ,SAAS,MAAM,MAAM,GACpC,MAAM,IAAI,MAAM,mBAAmB,MAAM,QAAQ;EAGrD,OAAO,EACH,QAAQ,MAAM,OAClB;CACJ;CAEA,oBAA4B,OAAkD;EAC1E,IAAI,CAAC,qBAAqB,MAAM,KAAK,GACjC,MAAM,IAAI,MAAM,mCAAmC,MAAM,IAAI,GAAG;EAGpE,OAAO,MAAM;CACjB;AACJ;;;;;;AC5FA,SAAgB,WAAW,KAAiC;CACxD,OAAO;EACH,cAAc;EACd;CACJ;AACJ;;;;;;ACJA,SAAgB,mBAAmB,YAAoC,UAA8B;CACjG,OAAO,IAAI,WAAW,MAAM,WAAW,MAAK,MAAI,EAAE;AACtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danceroutine/tango-core",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Core types, errors, and result utilities for Tango",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^22.9.0",
|
|
57
|
-
"tsdown": "^0.
|
|
57
|
+
"tsdown": "^0.22.1",
|
|
58
58
|
"typescript": "^5.6.3",
|
|
59
|
-
"vitest": "^4.
|
|
59
|
+
"vitest": "^4.1.7",
|
|
60
60
|
"zod": "^4.0.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TangoError-DdQVQNZU.js","names":["err: unknown"],"sources":["../src/errors/TangoError.ts"],"sourcesContent":["import type { HttpError } from './HttpError';\n\n/** Structured error detail payload for API responses. */\nexport type ErrorDetails = Record<string, string[]> | null | undefined;\n\n/** Canonical error payload shape used by Tango HTTP error responses. */\nexport type ProblemDetails<TDetails extends ErrorDetails = null> = {\n code: string;\n message: string;\n details?: TDetails;\n fields?: Record<string, string[]>;\n};\n\n/** Envelope shape for serialized error responses. */\nexport type ErrorEnvelope<TDetails extends ErrorDetails = null> = {\n error: ProblemDetails<TDetails>;\n};\n\n/**\n * Base branded framework error.\n *\n * Subclasses provide HTTP status, stable code, and structured details.\n */\nexport abstract class TangoError extends Error {\n // String brand avoids instanceof and survives cross-package boundaries.\n readonly __tangoErrorBrand = 'tango.error' as const;\n abstract status: number;\n\n protected abstract getDetails(): ErrorDetails;\n\n protected abstract getErrorName(): string;\n\n /** Runtime guard for Tango-branded errors. */\n static isTangoError(err: unknown): err is TangoError {\n return !!err && (err as { __tangoErrorBrand?: string }).__tangoErrorBrand === 'tango.error';\n }\n\n /** Runtime guard for plain problem-details objects. */\n static isProblemDetails(err: unknown): err is ProblemDetails {\n return (\n !!err &&\n typeof err === 'object' &&\n err !== null &&\n 'code' in err &&\n typeof (err as { code: unknown }).code === 'string' &&\n 'message' in err &&\n typeof (err as { message: unknown }).message === 'string'\n );\n }\n\n /** Convert this error to wire-level envelope format. */\n toErrorEnvelope(): ErrorEnvelope<ErrorDetails> {\n return {\n error: {\n code: this.getErrorName(),\n message: this.message,\n details: this.getDetails(),\n },\n };\n }\n\n /** Convert this error to legacy `HttpError` shape. */\n toHttpError(): HttpError {\n return {\n status: this.status,\n body: {\n error: this.message,\n details: this.getDetails(),\n },\n };\n }\n}\n"],"mappings":";;IAuBsB,aAAf,cAAkC,MAAM;CAE3C,oBAA6B;;CAQ7B,OAAO,aAAaA,KAAiC;AACjD,WAAS,OAAQ,IAAuC,sBAAsB;CACjF;;CAGD,OAAO,iBAAiBA,KAAqC;AACzD,WACM,cACK,QAAQ,YACf,QAAQ,QACR,UAAU,cACF,IAA0B,SAAS,YAC3C,aAAa,cACL,IAA6B,YAAY;CAExD;;CAGD,kBAA+C;AAC3C,SAAO,EACH,OAAO;GACH,MAAM,KAAK,cAAc;GACzB,SAAS,KAAK;GACd,SAAS,KAAK,YAAY;EAC7B,EACJ;CACJ;;CAGD,cAAyB;AACrB,SAAO;GACH,QAAQ,KAAK;GACb,MAAM;IACF,OAAO,KAAK;IACZ,SAAS,KAAK,YAAY;GAC7B;EACJ;CACJ;AACJ"}
|
package/dist/chunk-BkvOhyD0.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error for missing/invalid authentication (HTTP 401). */
|
|
3
|
-
export declare class AuthenticationError extends TangoError {
|
|
4
|
-
static readonly BRAND: "tango.error.authentication";
|
|
5
|
-
readonly __tangoBrand: typeof AuthenticationError.BRAND;
|
|
6
|
-
status: number;
|
|
7
|
-
/** Create an authentication error with optional custom message. */
|
|
8
|
-
constructor(message?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Narrow an unknown value to `AuthenticationError`.
|
|
11
|
-
*/
|
|
12
|
-
static isAuthenticationError(value: unknown): value is AuthenticationError;
|
|
13
|
-
protected getErrorName(): string;
|
|
14
|
-
protected getDetails(): ErrorDetails;
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error for conflicting resource state (HTTP 409). */
|
|
3
|
-
export declare class ConflictError extends TangoError {
|
|
4
|
-
static readonly BRAND: "tango.error.conflict";
|
|
5
|
-
readonly __tangoBrand: typeof ConflictError.BRAND;
|
|
6
|
-
status: number;
|
|
7
|
-
/** Create a conflict error with optional custom message. */
|
|
8
|
-
constructor(message?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Narrow an unknown value to `ConflictError`.
|
|
11
|
-
*/
|
|
12
|
-
static isConflictError(value: unknown): value is ConflictError;
|
|
13
|
-
protected getErrorName(): string;
|
|
14
|
-
protected getDetails(): ErrorDetails;
|
|
15
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error when a queryset lookup returns more than one row (HTTP 409). */
|
|
3
|
-
export declare class MultipleObjectsReturned extends TangoError {
|
|
4
|
-
static readonly BRAND: "tango.error.multiple_objects_returned";
|
|
5
|
-
readonly __tangoBrand: typeof MultipleObjectsReturned.BRAND;
|
|
6
|
-
status: number;
|
|
7
|
-
constructor(message?: string);
|
|
8
|
-
static isMultipleObjectsReturned(value: unknown): value is MultipleObjectsReturned;
|
|
9
|
-
protected getErrorName(): string;
|
|
10
|
-
protected getDetails(): ErrorDetails;
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error for missing resources (HTTP 404). */
|
|
3
|
-
export declare class NotFoundError extends TangoError {
|
|
4
|
-
static readonly BRAND: "tango.error.not_found";
|
|
5
|
-
readonly __tangoBrand: typeof NotFoundError.BRAND;
|
|
6
|
-
status: number;
|
|
7
|
-
/** Create a not-found error with optional custom message. */
|
|
8
|
-
constructor(message?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Narrow an unknown value to `NotFoundError`.
|
|
11
|
-
*/
|
|
12
|
-
static isNotFoundError(value: unknown): value is NotFoundError;
|
|
13
|
-
protected getErrorName(): string;
|
|
14
|
-
protected getDetails(): ErrorDetails;
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error for authorization failures (HTTP 403). */
|
|
3
|
-
export declare class PermissionDenied extends TangoError {
|
|
4
|
-
static readonly BRAND: "tango.error.permission_denied";
|
|
5
|
-
readonly __tangoBrand: typeof PermissionDenied.BRAND;
|
|
6
|
-
status: number;
|
|
7
|
-
/** Create a permission-denied error with optional custom message. */
|
|
8
|
-
constructor(message?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Narrow an unknown value to `PermissionDenied`.
|
|
11
|
-
*/
|
|
12
|
-
static isPermissionDenied(value: unknown): value is PermissionDenied;
|
|
13
|
-
protected getErrorName(): string;
|
|
14
|
-
protected getDetails(): ErrorDetails;
|
|
15
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { HttpError } from './HttpError';
|
|
2
|
-
/** Structured error detail payload for API responses. */
|
|
3
|
-
export type ErrorDetails = Record<string, string[]> | null | undefined;
|
|
4
|
-
/** Canonical error payload shape used by Tango HTTP error responses. */
|
|
5
|
-
export type ProblemDetails<TDetails extends ErrorDetails = null> = {
|
|
6
|
-
code: string;
|
|
7
|
-
message: string;
|
|
8
|
-
details?: TDetails;
|
|
9
|
-
fields?: Record<string, string[]>;
|
|
10
|
-
};
|
|
11
|
-
/** Envelope shape for serialized error responses. */
|
|
12
|
-
export type ErrorEnvelope<TDetails extends ErrorDetails = null> = {
|
|
13
|
-
error: ProblemDetails<TDetails>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Base branded framework error.
|
|
17
|
-
*
|
|
18
|
-
* Subclasses provide HTTP status, stable code, and structured details.
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class TangoError extends Error {
|
|
21
|
-
readonly __tangoErrorBrand: "tango.error";
|
|
22
|
-
abstract status: number;
|
|
23
|
-
protected abstract getDetails(): ErrorDetails;
|
|
24
|
-
protected abstract getErrorName(): string;
|
|
25
|
-
/** Runtime guard for Tango-branded errors. */
|
|
26
|
-
static isTangoError(err: unknown): err is TangoError;
|
|
27
|
-
/** Runtime guard for plain problem-details objects. */
|
|
28
|
-
static isProblemDetails(err: unknown): err is ProblemDetails;
|
|
29
|
-
/** Convert this error to wire-level envelope format. */
|
|
30
|
-
toErrorEnvelope(): ErrorEnvelope<ErrorDetails>;
|
|
31
|
-
/** Convert this error to legacy `HttpError` shape. */
|
|
32
|
-
toHttpError(): HttpError;
|
|
33
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TangoError, type ErrorDetails } from './TangoError';
|
|
2
|
-
/** Error for request validation failures (HTTP 400). */
|
|
3
|
-
export declare class ValidationError extends TangoError {
|
|
4
|
-
details?: ErrorDetails;
|
|
5
|
-
readonly __tangoValidationErrorBrand: "tango.error.validation";
|
|
6
|
-
status: number;
|
|
7
|
-
constructor(message: string, details?: ErrorDetails);
|
|
8
|
-
/**
|
|
9
|
-
* Narrow an unknown value to `ValidationError`, including common legacy shapes.
|
|
10
|
-
*/
|
|
11
|
-
static isValidationError(err: unknown): err is ValidationError;
|
|
12
|
-
protected getErrorName(): string;
|
|
13
|
-
protected getDetails(): ErrorDetails;
|
|
14
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { HttpError } from '../HttpError';
|
|
2
|
-
export interface HttpErrorFactoryConfig {
|
|
3
|
-
/**
|
|
4
|
-
* When true, raw error messages are included in HTTP responses.
|
|
5
|
-
* When false, generic messages are returned for non-TangoError exceptions.
|
|
6
|
-
* Defaults to true (dev-friendly). Set to false in production.
|
|
7
|
-
*/
|
|
8
|
-
exposeErrors?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Converts errors into structured HTTP error responses.
|
|
12
|
-
* Supports TangoError subclasses out of the box, and custom error handlers
|
|
13
|
-
* can be registered for third-party or application-specific error types.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // Development (default) — exposes real error messages
|
|
18
|
-
* const devFactory = new HttpErrorFactory();
|
|
19
|
-
*
|
|
20
|
-
* // Production — hides internal error details
|
|
21
|
-
* const prodFactory = new HttpErrorFactory({ exposeErrors: false });
|
|
22
|
-
*
|
|
23
|
-
* // Register a custom handler for a third-party error
|
|
24
|
-
* prodFactory.registerHandler(ZodError, (err) => ({
|
|
25
|
-
* status: 400,
|
|
26
|
-
* body: { error: 'Validation failed', details: err.flatten().fieldErrors },
|
|
27
|
-
* }));
|
|
28
|
-
*
|
|
29
|
-
* // Quick one-shot conversion with dev defaults
|
|
30
|
-
* const httpError = HttpErrorFactory.toHttpError(new NotFoundError('missing'));
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export declare class HttpErrorFactory {
|
|
34
|
-
static readonly BRAND: "tango.error_factory.http";
|
|
35
|
-
readonly __tangoBrand: typeof HttpErrorFactory.BRAND;
|
|
36
|
-
private handlers;
|
|
37
|
-
private exposeErrors;
|
|
38
|
-
constructor(config?: HttpErrorFactoryConfig);
|
|
39
|
-
/**
|
|
40
|
-
* Narrow an unknown value to `HttpErrorFactory`.
|
|
41
|
-
*/
|
|
42
|
-
static isHttpErrorFactory(value: unknown): value is HttpErrorFactory;
|
|
43
|
-
/**
|
|
44
|
-
* Convert an unknown error into an `HttpError` using dev-friendly defaults.
|
|
45
|
-
* Shorthand for `new HttpErrorFactory().create(error)`.
|
|
46
|
-
*/
|
|
47
|
-
static toHttpError(error: unknown): HttpError;
|
|
48
|
-
private static isZodLikeValidationError;
|
|
49
|
-
private static zodLikeErrorDetails;
|
|
50
|
-
/**
|
|
51
|
-
* Register a custom mapper for an application or third-party error type.
|
|
52
|
-
*/
|
|
53
|
-
registerHandler<T extends Error>(errorClass: new (...args: any[]) => T, handler: (error: T) => HttpError): this;
|
|
54
|
-
/**
|
|
55
|
-
* Convert an unknown error into the normalized HTTP error shape Tango uses.
|
|
56
|
-
*/
|
|
57
|
-
create(error: unknown): HttpError;
|
|
58
|
-
private isErrorClassInstance;
|
|
59
|
-
}
|