drizzle-orm 0.33.0-7469abe → 0.33.0-7bea25c

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/neon/rls.cjs CHANGED
@@ -24,30 +24,21 @@ __export(rls_exports, {
24
24
  crudPolicy: () => crudPolicy
25
25
  });
26
26
  module.exports = __toCommonJS(rls_exports);
27
- var import_entity = require("../entity.cjs");
28
27
  var import_pg_core = require("../pg-core/index.cjs");
29
28
  var import_sql = require("../sql/sql.cjs");
30
29
  const crudPolicy = (options) => {
31
- const read = options.read === true ? import_sql.sql`select true` : options.read === false || options.read === void 0 ? import_sql.sql`select false` : options.read;
32
- const modify = options.modify === true ? import_sql.sql`select true` : options.modify === false || options.modify === void 0 ? import_sql.sql`select false` : options.modify;
33
- let rolesName = "";
34
- if (Array.isArray(options.role)) {
35
- rolesName = options.role.map((it) => {
36
- return (0, import_entity.is)(it, import_pg_core.PgRole) ? it.name : it;
37
- }).join("-");
38
- } else {
39
- rolesName = (0, import_entity.is)(options.role, import_pg_core.PgRole) ? options.role.name : options.role;
40
- }
30
+ const read = options.read === true ? import_sql.sql`select true` : options.read === false ? import_sql.sql`select false` : options.read;
31
+ const modify = options.modify === true ? import_sql.sql`select true` : options.modify === false ? import_sql.sql`select false` : options.modify;
41
32
  return {
42
33
  // Important to have "_drizzle_internal" prefix for any key here. Right after we will make
43
34
  // 3rd param in table as an array - we will move it to array and use ... operator
44
- [`_drizzle_internal-${rolesName}-crud-policy-modify`]: (0, import_pg_core.pgPolicy)(`crud-policy-modify`, {
35
+ [`_drizzle_internal-crud-policy-modify`]: (0, import_pg_core.pgPolicy)(`crud-policy-modify`, {
45
36
  for: "insert",
46
37
  to: options.role,
47
38
  using: modify,
48
39
  withCheck: modify
49
40
  }),
50
- [`_drizzle_internal-${rolesName}-crud-policy-read`]: (0, import_pg_core.pgPolicy)(`crud-policy-read`, {
41
+ [`_drizzle_internal-crud-policy-read`]: (0, import_pg_core.pgPolicy)(`crud-policy-read`, {
51
42
  for: "select",
52
43
  to: options.role,
53
44
  using: read
package/neon/rls.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { pgPolicy, PgRole, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread?: SQL | boolean;\n\t\tmodify?: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false || options.read === undefined\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false || options.modify === undefined\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\tlet rolesName = '';\n\tif (Array.isArray(options.role)) {\n\t\trolesName = options.role.map((it) => {\n\t\t\treturn is(it, PgRole) ? it.name : it as string;\n\t\t}).join('-');\n\t} else {\n\t\trolesName = is(options.role, PgRole) ? options.role.name : options.role as string;\n\t}\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-read`]: pgPolicy(`crud-policy-read`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\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 = (user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y, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread: SQL | boolean;\n\t\tmodify: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\t\t[`_drizzle_internal-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-crud-policy-read`]: pgPolicy(`crud-policy-read`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\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,qBAAiC;AAEjC,iBAA8B;AAEvB,MAAM,aAAa,CACzB,YAKI;AACJ,QAAM,OAAY,QAAQ,SAAS,OAChC,8BACA,QAAQ,SAAS,QACjB,+BACA,QAAQ;AAEX,QAAM,SAAc,QAAQ,WAAW,OACpC,8BACA,QAAQ,WAAW,QACnB,+BACA,QAAQ;AAGX,SAAO;AAAA;AAAA;AAAA,IAGN,CAAC,sCAAsC,OAAG,yBAAS,sBAAsB;AAAA,MACxE,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,oCAAoC,OAAG,yBAAS,oBAAoB;AAAA,MACpE,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;AAGO,MAAM,wBAAoB,uBAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,oBAAgB,uBAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,yCAA8B,YAAY;","names":[]}
package/neon/rls.d.cts CHANGED
@@ -1,13 +1,13 @@
1
- import { PgRole } from "../pg-core/index.cjs";
2
1
  import type { AnyPgColumn, PgPolicyToOption } from "../pg-core/index.cjs";
3
2
  import { type SQL } from "../sql/sql.cjs";
4
3
  export declare const crudPolicy: (options: {
5
4
  role: PgPolicyToOption;
6
- read?: SQL | boolean;
7
- modify?: SQL | boolean;
5
+ read: SQL | boolean;
6
+ modify: SQL | boolean;
8
7
  }) => {
9
- [x: string]: import("../pg-core/index.ts").PgPolicy;
8
+ "_drizzle_internal-crud-policy-modify": import("../pg-core/index.ts").PgPolicy;
9
+ "_drizzle_internal-crud-policy-read": import("../pg-core/index.ts").PgPolicy;
10
10
  };
11
- export declare const authenticatedRole: PgRole;
12
- export declare const anonymousRole: PgRole;
11
+ export declare const authenticatedRole: import("../pg-core/index.ts").PgRole;
12
+ export declare const anonymousRole: import("../pg-core/index.ts").PgRole;
13
13
  export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
package/neon/rls.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { PgRole } from "../pg-core/index.js";
2
1
  import type { AnyPgColumn, PgPolicyToOption } from "../pg-core/index.js";
3
2
  import { type SQL } from "../sql/sql.js";
4
3
  export declare const crudPolicy: (options: {
5
4
  role: PgPolicyToOption;
6
- read?: SQL | boolean;
7
- modify?: SQL | boolean;
5
+ read: SQL | boolean;
6
+ modify: SQL | boolean;
8
7
  }) => {
9
- [x: string]: import("../pg-core/index.js").PgPolicy;
8
+ "_drizzle_internal-crud-policy-modify": import("../pg-core/index.js").PgPolicy;
9
+ "_drizzle_internal-crud-policy-read": import("../pg-core/index.js").PgPolicy;
10
10
  };
11
- export declare const authenticatedRole: PgRole;
12
- export declare const anonymousRole: PgRole;
11
+ export declare const authenticatedRole: import("../pg-core/index.js").PgRole;
12
+ export declare const anonymousRole: import("../pg-core/index.js").PgRole;
13
13
  export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
package/neon/rls.js CHANGED
@@ -1,27 +1,18 @@
1
- import { is } from "../entity.js";
2
- import { pgPolicy, PgRole, pgRole } from "../pg-core/index.js";
1
+ import { pgPolicy, pgRole } from "../pg-core/index.js";
3
2
  import { sql } from "../sql/sql.js";
4
3
  const crudPolicy = (options) => {
5
- const read = options.read === true ? sql`select true` : options.read === false || options.read === void 0 ? sql`select false` : options.read;
6
- const modify = options.modify === true ? sql`select true` : options.modify === false || options.modify === void 0 ? sql`select false` : options.modify;
7
- let rolesName = "";
8
- if (Array.isArray(options.role)) {
9
- rolesName = options.role.map((it) => {
10
- return is(it, PgRole) ? it.name : it;
11
- }).join("-");
12
- } else {
13
- rolesName = is(options.role, PgRole) ? options.role.name : options.role;
14
- }
4
+ const read = options.read === true ? sql`select true` : options.read === false ? sql`select false` : options.read;
5
+ const modify = options.modify === true ? sql`select true` : options.modify === false ? sql`select false` : options.modify;
15
6
  return {
16
7
  // Important to have "_drizzle_internal" prefix for any key here. Right after we will make
17
8
  // 3rd param in table as an array - we will move it to array and use ... operator
18
- [`_drizzle_internal-${rolesName}-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {
9
+ [`_drizzle_internal-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {
19
10
  for: "insert",
20
11
  to: options.role,
21
12
  using: modify,
22
13
  withCheck: modify
23
14
  }),
24
- [`_drizzle_internal-${rolesName}-crud-policy-read`]: pgPolicy(`crud-policy-read`, {
15
+ [`_drizzle_internal-crud-policy-read`]: pgPolicy(`crud-policy-read`, {
25
16
  for: "select",
26
17
  to: options.role,
27
18
  using: read
package/neon/rls.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { pgPolicy, PgRole, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread?: SQL | boolean;\n\t\tmodify?: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false || options.read === undefined\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false || options.modify === undefined\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\tlet rolesName = '';\n\tif (Array.isArray(options.role)) {\n\t\trolesName = options.role.map((it) => {\n\t\t\treturn is(it, PgRole) ? it.name : it as string;\n\t\t}).join('-');\n\t} else {\n\t\trolesName = is(options.role, PgRole) ? options.role.name : options.role as string;\n\t}\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-read`]: pgPolicy(`crud-policy-read`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\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,SAAS,UAAU;AACnB,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAmB,WAAW;AAEvB,MAAM,aAAa,CACzB,YAKI;AACJ,QAAM,OAAY,QAAQ,SAAS,OAChC,mBACA,QAAQ,SAAS,SAAS,QAAQ,SAAS,SAC3C,oBACA,QAAQ;AAEX,QAAM,SAAc,QAAQ,WAAW,OACpC,mBACA,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAC/C,oBACA,QAAQ;AAEX,MAAI,YAAY;AAChB,MAAI,MAAM,QAAQ,QAAQ,IAAI,GAAG;AAChC,gBAAY,QAAQ,KAAK,IAAI,CAAC,OAAO;AACpC,aAAO,GAAG,IAAI,MAAM,IAAI,GAAG,OAAO;AAAA,IACnC,CAAC,EAAE,KAAK,GAAG;AAAA,EACZ,OAAO;AACN,gBAAY,GAAG,QAAQ,MAAM,MAAM,IAAI,QAAQ,KAAK,OAAO,QAAQ;AAAA,EACpE;AAGA,SAAO;AAAA;AAAA;AAAA,IAGN,CAAC,qBAAqB,SAAS,qBAAqB,GAAG,SAAS,sBAAsB;AAAA,MACrF,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,mBAAmB,GAAG,SAAS,oBAAoB;AAAA,MACjF,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;AAGO,MAAM,oBAAoB,OAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,gBAAgB,OAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,8BAA8B,YAAY;","names":[]}
1
+ {"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { pgPolicy, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread: SQL | boolean;\n\t\tmodify: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\t\t[`_drizzle_internal-crud-policy-modify`]: pgPolicy(`crud-policy-modify`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-crud-policy-read`]: pgPolicy(`crud-policy-read`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\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,SAAS,UAAU,cAAc;AAEjC,SAAmB,WAAW;AAEvB,MAAM,aAAa,CACzB,YAKI;AACJ,QAAM,OAAY,QAAQ,SAAS,OAChC,mBACA,QAAQ,SAAS,QACjB,oBACA,QAAQ;AAEX,QAAM,SAAc,QAAQ,WAAW,OACpC,mBACA,QAAQ,WAAW,QACnB,oBACA,QAAQ;AAGX,SAAO;AAAA;AAAA;AAAA,IAGN,CAAC,sCAAsC,GAAG,SAAS,sBAAsB;AAAA,MACxE,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,oCAAoC,GAAG,SAAS,oBAAoB;AAAA,MACpE,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;AAGO,MAAM,oBAAoB,OAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,gBAAgB,OAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,8BAA8B,YAAY;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.33.0-7469abe",
3
+ "version": "0.33.0-7bea25c",
4
4
  "description": "Drizzle ORM package for SQL databases",
5
5
  "type": "module",
6
6
  "scripts": {
package/version.cjs CHANGED
@@ -26,7 +26,7 @@ __export(version_exports, {
26
26
  module.exports = __toCommonJS(version_exports);
27
27
 
28
28
  // package.json
29
- var version = "0.33.0-7469abe";
29
+ var version = "0.33.0-7bea25c";
30
30
 
31
31
  // src/version.ts
32
32
  var compatibilityVersion = 8;
package/version.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.33.0-7469abe";
1
+ var version = "0.33.0-7bea25c";
2
2
 
3
3
  declare const compatibilityVersion = 8;
4
4
 
package/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.33.0-7469abe";
1
+ var version = "0.33.0-7bea25c";
2
2
 
3
3
  declare const compatibilityVersion = 8;
4
4
 
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.33.0-7469abe";
2
+ var version = "0.33.0-7bea25c";
3
3
 
4
4
  // src/version.ts
5
5
  var compatibilityVersion = 8;