@balena/pinejs 22.1.4-build-renovate-bcrypt-6-x-6b995cfc00adc4154dc008a20bc666adc18c70f5-1 → 23.0.0-build-23-x-06bf0c67151995a64e8f502ea9dfb1232abb6001-1

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.
@@ -1,4 +1,5 @@
1
1
  import type AuthModel from './user.js';
2
+ import { abstractSqlContainsNode } from '@balena/abstract-sql-compiler';
2
3
  import type {
3
4
  AbstractSqlModel,
4
5
  AbstractSqlQuery,
@@ -1102,12 +1103,33 @@ const getBoundConstrainedMemoizer = memoizeWeak(
1102
1103
  // * When the resolution reaches the last model in the chain (`<resource>$vDB$permissions"<permJson>"`) and tries to resolve it,
1103
1104
  // the `generateConstrainedAbstractSql()` that's in the `onceGetter(permissionsTable, 'definition'` below get called, which reads
1104
1105
  // the `$permissions"<permJson>"` suffix of the resource name and add a filter with the respective permissions to that last/deepest model in the chain.
1105
- onceGetter(permissionsTable, 'definition', () =>
1106
- createVersionSpecificPermissionDefinition(
1106
+ onceGetter(permissionsTable, 'definition', () => {
1107
+ const effectiveTableName =
1108
+ permissionsTable.modifyName ?? permissionsTable.name;
1109
+ if (
1110
+ abstractSqlContainsNode(
1111
+ tableDefinition.abstractSql,
1112
+ (n) => n[0] === 'Table' && n[1] === effectiveTableName,
1113
+ )
1114
+ ) {
1115
+ const permissionsAbstractSql =
1116
+ generateConstrainedAbstractSql(
1117
+ permissionsLookup,
1118
+ JSON.parse(permissionsJSON),
1119
+ finalVocabulary,
1120
+ sqlNameToODataName(effectiveTableName),
1121
+ );
1122
+ if (permissionsAbstractSql != null) {
1123
+ // If we're targeting the table directly then we can just return the permissionsAbstractSql as both should be generated using the final model
1124
+ // TODO: in practice we could have a translation that targets the table directly rather than via a `Resource` node, so we should try to handle that
1125
+ return permissionsAbstractSql;
1126
+ }
1127
+ }
1128
+ return createVersionSpecificPermissionDefinition(
1107
1129
  tableDefinition,
1108
1130
  permissionsJSON,
1109
- ),
1110
- );
1131
+ );
1132
+ });
1111
1133
  } else {
1112
1134
  onceGetter(permissionsTable, 'definition', () =>
1113
1135
  // For $filter on eg a DELETE you need read permissions on the sub-resources,
@@ -24,7 +24,7 @@ import type { TypedError } from 'typed-error';
24
24
  import { cachedCompile } from './cached-compile.js';
25
25
 
26
26
  type LFModel = any[];
27
- import AbstractSQLCompiler from '@balena/abstract-sql-compiler';
27
+ import * as AbstractSQLCompiler from '@balena/abstract-sql-compiler';
28
28
  import AbstractSqlCompilerPackage from '@balena/abstract-sql-compiler/package.json' with { type: 'json' };
29
29
  const { version: AbstractSQLCompilerVersion } = AbstractSqlCompilerPackage;
30
30
 
@@ -537,7 +537,7 @@ export const generateAbstractSqlModel = (
537
537
  () =>
538
538
  AbstractSQLCompiler.optimizeSchema(
539
539
  LF2AbstractSQLTranslator(lfModel, 'Process'),
540
- false,
540
+ { createCheckConstraints: false },
541
541
  ),
542
542
  );
543
543
 
@@ -1,4 +1,4 @@
1
- import type AbstractSQLCompiler from '@balena/abstract-sql-compiler';
1
+ import type * as AbstractSQLCompiler from '@balena/abstract-sql-compiler';
2
2
  import type {
3
3
  ODataBinds,
4
4
  ODataOptions,
@@ -1,4 +1,4 @@
1
- // These types were generated by @balena/abstract-sql-to-typescript v5.1.5
1
+ // These types were generated by @balena/abstract-sql-to-typescript v6.1.0
2
2
 
3
3
  import type { Types } from '@balena/abstract-sql-to-typescript';
4
4
 
@@ -1,4 +1,4 @@
1
- // These types were generated by @balena/abstract-sql-to-typescript v5.1.5
1
+ // These types were generated by @balena/abstract-sql-to-typescript v6.1.0
2
2
 
3
3
  import type { Types } from '@balena/abstract-sql-to-typescript';
4
4
 
@@ -1,4 +1,4 @@
1
- // These types were generated by @balena/abstract-sql-to-typescript v5.1.5
1
+ // These types were generated by @balena/abstract-sql-to-typescript v6.1.0
2
2
 
3
3
  import type { Types } from '@balena/abstract-sql-to-typescript';
4
4