@cerebruminc/yates 3.3.0-beta.dangerous.2bc5218 → 3.3.0
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/.prettierrc +8 -0
- package/eslint.config.ts +4 -0
- package/package.json +2 -7
- package/renovate.json +6 -0
- package/dist/src/ast-fragments.d.ts +0 -68
- package/dist/src/ast-fragments.js +0 -84
- package/dist/src/ast-fragments.js.map +0 -1
- package/dist/src/escape.d.ts +0 -2
- package/dist/src/escape.js +0 -36
- package/dist/src/escape.js.map +0 -1
- package/dist/src/expressions.d.ts +0 -11
- package/dist/src/expressions.js +0 -431
- package/dist/src/expressions.js.map +0 -1
- package/dist/src/index.d.ts +0 -103
- package/dist/src/index.js +0 -557
- package/dist/src/index.js.map +0 -1
- package/dist/test/types/index.d.ts +0 -1
- package/dist/test/types/index.js +0 -171
- package/dist/test/types/index.js.map +0 -1
package/.prettierrc
ADDED
package/eslint.config.ts
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerebruminc/yates",
|
|
3
|
-
"version": "3.3.0
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Role based access control for Prisma Apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"CHANGELOG.md",
|
|
8
|
-
"dist",
|
|
9
|
-
"images"
|
|
10
|
-
],
|
|
11
6
|
"scripts": {
|
|
12
7
|
"generate": "prisma generate",
|
|
13
8
|
"build": "tsc",
|
|
@@ -45,4 +40,4 @@
|
|
|
45
40
|
"@prisma/client": "^5.0.0",
|
|
46
41
|
"prisma": "^5.0.0"
|
|
47
42
|
}
|
|
48
|
-
}
|
|
43
|
+
}
|
package/renovate.json
ADDED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates an AST fragment that will check if a column value exists in a JSONB array stored in a `current_setting`
|
|
3
|
-
* The AST fragment represents SQL that looks like this:
|
|
4
|
-
* = ANY (SELECT jsonb_array_elements_text(current_setting('ctx.my_context_value')::jsonb))
|
|
5
|
-
*/
|
|
6
|
-
export declare const jsonb_array_elements_text: (setting: string) => {
|
|
7
|
-
type: string;
|
|
8
|
-
name: string;
|
|
9
|
-
args: {
|
|
10
|
-
type: string;
|
|
11
|
-
value: {
|
|
12
|
-
ast: {
|
|
13
|
-
with: null;
|
|
14
|
-
type: string;
|
|
15
|
-
options: null;
|
|
16
|
-
distinct: {
|
|
17
|
-
type: null;
|
|
18
|
-
};
|
|
19
|
-
columns: {
|
|
20
|
-
type: string;
|
|
21
|
-
expr: {
|
|
22
|
-
type: string;
|
|
23
|
-
name: string;
|
|
24
|
-
args: {
|
|
25
|
-
type: string;
|
|
26
|
-
value: {
|
|
27
|
-
type: string;
|
|
28
|
-
keyword: string;
|
|
29
|
-
expr: {
|
|
30
|
-
type: string;
|
|
31
|
-
name: string;
|
|
32
|
-
args: {
|
|
33
|
-
type: string;
|
|
34
|
-
value: {
|
|
35
|
-
type: string;
|
|
36
|
-
value: string;
|
|
37
|
-
}[];
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
as: null;
|
|
41
|
-
symbol: string;
|
|
42
|
-
target: {
|
|
43
|
-
dataType: string;
|
|
44
|
-
};
|
|
45
|
-
arrows: never[];
|
|
46
|
-
properties: never[];
|
|
47
|
-
}[];
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
as: null;
|
|
51
|
-
}[];
|
|
52
|
-
into: {
|
|
53
|
-
position: null;
|
|
54
|
-
};
|
|
55
|
-
from: null;
|
|
56
|
-
where: null;
|
|
57
|
-
groupby: null;
|
|
58
|
-
having: null;
|
|
59
|
-
orderby: null;
|
|
60
|
-
limit: {
|
|
61
|
-
seperator: string;
|
|
62
|
-
value: never[];
|
|
63
|
-
};
|
|
64
|
-
window: null;
|
|
65
|
-
};
|
|
66
|
-
}[];
|
|
67
|
-
};
|
|
68
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonb_array_elements_text = void 0;
|
|
4
|
-
var escape_1 = require("./escape");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an AST fragment that will check if a column value exists in a JSONB array stored in a `current_setting`
|
|
7
|
-
* The AST fragment represents SQL that looks like this:
|
|
8
|
-
* = ANY (SELECT jsonb_array_elements_text(current_setting('ctx.my_context_value')::jsonb))
|
|
9
|
-
*/
|
|
10
|
-
var jsonb_array_elements_text = function (setting) {
|
|
11
|
-
return {
|
|
12
|
-
type: "function",
|
|
13
|
-
name: "ANY",
|
|
14
|
-
args: {
|
|
15
|
-
type: "expr_list",
|
|
16
|
-
value: [
|
|
17
|
-
{
|
|
18
|
-
ast: {
|
|
19
|
-
with: null,
|
|
20
|
-
type: "select",
|
|
21
|
-
options: null,
|
|
22
|
-
distinct: {
|
|
23
|
-
type: null,
|
|
24
|
-
},
|
|
25
|
-
columns: [
|
|
26
|
-
{
|
|
27
|
-
type: "expr",
|
|
28
|
-
expr: {
|
|
29
|
-
type: "function",
|
|
30
|
-
name: "jsonb_array_elements_text",
|
|
31
|
-
args: {
|
|
32
|
-
type: "expr_list",
|
|
33
|
-
value: [
|
|
34
|
-
{
|
|
35
|
-
type: "cast",
|
|
36
|
-
keyword: "cast",
|
|
37
|
-
expr: {
|
|
38
|
-
type: "function",
|
|
39
|
-
name: "current_setting",
|
|
40
|
-
args: {
|
|
41
|
-
type: "expr_list",
|
|
42
|
-
value: [
|
|
43
|
-
{
|
|
44
|
-
type: "parameter",
|
|
45
|
-
value: (0, escape_1.escapeLiteral)(setting.replace(/^___yates_context_/, "")),
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
as: null,
|
|
51
|
-
symbol: "::",
|
|
52
|
-
target: {
|
|
53
|
-
dataType: "jsonb",
|
|
54
|
-
},
|
|
55
|
-
arrows: [],
|
|
56
|
-
properties: [],
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
as: null,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
into: {
|
|
65
|
-
position: null,
|
|
66
|
-
},
|
|
67
|
-
from: null,
|
|
68
|
-
where: null,
|
|
69
|
-
groupby: null,
|
|
70
|
-
having: null,
|
|
71
|
-
orderby: null,
|
|
72
|
-
limit: {
|
|
73
|
-
seperator: "",
|
|
74
|
-
value: [],
|
|
75
|
-
},
|
|
76
|
-
window: null,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
exports.jsonb_array_elements_text = jsonb_array_elements_text;
|
|
84
|
-
//# sourceMappingURL=ast-fragments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-fragments.js","sourceRoot":"","sources":["../../src/ast-fragments.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AAEzC;;;;GAIG;AACI,IAAM,yBAAyB,GAAG,UAAC,OAAe;IACxD,OAAO;QACN,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACN;oBACC,GAAG,EAAE;wBACJ,IAAI,EAAE,IAAI;wBACV,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,IAAI;wBACb,QAAQ,EAAE;4BACT,IAAI,EAAE,IAAI;yBACV;wBACD,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE;oCACL,IAAI,EAAE,UAAU;oCAChB,IAAI,EAAE,2BAA2B;oCACjC,IAAI,EAAE;wCACL,IAAI,EAAE,WAAW;wCACjB,KAAK,EAAE;4CACN;gDACC,IAAI,EAAE,MAAM;gDACZ,OAAO,EAAE,MAAM;gDACf,IAAI,EAAE;oDACL,IAAI,EAAE,UAAU;oDAChB,IAAI,EAAE,iBAAiB;oDACvB,IAAI,EAAE;wDACL,IAAI,EAAE,WAAW;wDACjB,KAAK,EAAE;4DACN;gEACC,IAAI,EAAE,WAAW;gEACjB,KAAK,EAAE,IAAA,sBAAa,EAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;6DAC/D;yDACD;qDACD;iDACD;gDACD,EAAE,EAAE,IAAI;gDACR,MAAM,EAAE,IAAI;gDACZ,MAAM,EAAE;oDACP,QAAQ,EAAE,OAAO;iDACjB;gDACD,MAAM,EAAE,EAAE;gDACV,UAAU,EAAE,EAAE;6CACd;yCACD;qCACD;iCACD;gCACD,EAAE,EAAE,IAAI;6BACR;yBACD;wBACD,IAAI,EAAE;4BACL,QAAQ,EAAE,IAAI;yBACd;wBACD,IAAI,EAAE,IAAI;wBACV,KAAK,EAAE,IAAI;wBACX,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE,IAAI;wBACZ,OAAO,EAAE,IAAI;wBACb,KAAK,EAAE;4BACN,SAAS,EAAE,EAAE;4BACb,KAAK,EAAE,EAAE;yBACT;wBACD,MAAM,EAAE,IAAI;qBACZ;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC,CAAC;AAxEW,QAAA,yBAAyB,6BAwEpC"}
|
package/dist/src/escape.d.ts
DELETED
package/dist/src/escape.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Source borrowed from node-postgrs (which borrows from PG itself)
|
|
3
|
-
// https://github.com/brianc/node-postgres/blob/3f6760c62ee2a901d374b5e50c2f025b7d550315/packages/pg/lib/client.js#L408-L437
|
|
4
|
-
// We need to manually escape strings because we're interpolating client values into SQL statements that don't support `PREPARE`, such as `CREATE POLICY`
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.escapeLiteral = exports.escapeIdentifier = void 0;
|
|
7
|
-
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
|
|
8
|
-
var escapeIdentifier = function (str) {
|
|
9
|
-
return "\"".concat(str.replace(/"/g, '""'), "\"");
|
|
10
|
-
};
|
|
11
|
-
exports.escapeIdentifier = escapeIdentifier;
|
|
12
|
-
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
|
|
13
|
-
var escapeLiteral = function (str) {
|
|
14
|
-
var hasBackslash = false;
|
|
15
|
-
var escaped = "'";
|
|
16
|
-
for (var i = 0; i < str.length; i++) {
|
|
17
|
-
var c = str[i];
|
|
18
|
-
if (c === "'") {
|
|
19
|
-
escaped += c + c;
|
|
20
|
-
}
|
|
21
|
-
else if (c === "\\") {
|
|
22
|
-
escaped += c + c;
|
|
23
|
-
hasBackslash = true;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
escaped += c;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
escaped += "'";
|
|
30
|
-
if (hasBackslash === true) {
|
|
31
|
-
escaped = " E".concat(escaped);
|
|
32
|
-
}
|
|
33
|
-
return escaped;
|
|
34
|
-
};
|
|
35
|
-
exports.escapeLiteral = escapeLiteral;
|
|
36
|
-
//# sourceMappingURL=escape.js.map
|
package/dist/src/escape.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":";AAAA,mEAAmE;AACnE,4HAA4H;AAC5H,yJAAyJ;;;AAEzJ,6EAA6E;AACtE,IAAM,gBAAgB,GAAG,UAAU,GAAW;IACpD,OAAO,YAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAG,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF,6EAA6E;AACtE,IAAM,aAAa,GAAG,UAAU,GAAW;IACjD,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;aAAM,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,YAAY,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,OAAO,IAAI,CAAC,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,IAAI,GAAG,CAAC;IAEf,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,GAAG,YAAK,OAAO,CAAE,CAAC;IAC1B,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAvBW,QAAA,aAAa,iBAuBxB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Prisma, PrismaClient } from "@prisma/client";
|
|
2
|
-
import { AsyncReturnType } from "type-fest";
|
|
3
|
-
import { defineDmmfProperty } from "@prisma/client/runtime/library";
|
|
4
|
-
export type RuntimeDataModel = Parameters<typeof defineDmmfProperty>[1];
|
|
5
|
-
type FFMeta<M extends Prisma.ModelName> = PrismaClient[Uncapitalize<M>]["findFirst"];
|
|
6
|
-
type ModelWhereArgs<M extends Prisma.ModelName> = Exclude<Parameters<FFMeta<M>>["0"], undefined>["where"];
|
|
7
|
-
type ModelResult<M extends Prisma.ModelName> = AsyncReturnType<FFMeta<M>>;
|
|
8
|
-
type NonNullableModelResult<M extends Prisma.ModelName> = Exclude<ModelResult<M>, null>;
|
|
9
|
-
export type Expression<ContextKeys extends string, M extends Prisma.ModelName> = string | ((client: PrismaClient, row: <K extends keyof NonNullableModelResult<M>>(col: K) => NonNullableModelResult<M>[K], context: (key: ContextKeys) => string) => Promise<ModelResult<Exclude<Prisma.ModelName, M>>> | ModelWhereArgs<M>);
|
|
10
|
-
export declare const expressionToSQL: <ContextKeys extends string, YModel extends Prisma.ModelName>(getExpression: Expression<ContextKeys, YModel>, table: string) => Promise<string>;
|
|
11
|
-
export {};
|