@proteinjs/user 1.4.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.5.0](https://github.com/proteinjs/user/compare/@proteinjs/user@1.4.0...@proteinjs/user@1.5.0) (2026-02-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * Added utility `createScopedIndex`. ([ed02520](https://github.com/proteinjs/user/commit/ed0252072786bb3f0d9cd7f158ee15958a443d05))
12
+
13
+
14
+
15
+
16
+
6
17
  # [1.4.0](https://github.com/proteinjs/user/compare/@proteinjs/user@1.3.15...@proteinjs/user@1.4.0) (2026-01-04)
7
18
 
8
19
 
@@ -15,4 +15,17 @@ export declare function isScopedTable(table: Table<any>): boolean;
15
15
  * @returns recordColumns & sourceRecordColumns & your columns
16
16
  */
17
17
  export declare function withScopedRecordColumns<T extends ScopedRecord>(columns: Columns<Omit<T, keyof ScopedRecord>>, accessibleScopes?: string[]): Columns<ScopedRecord> & Columns<Omit<T, keyof ScopedRecord>>;
18
+ /**
19
+ * Adds the `scope` column as the first column to the provided index.
20
+ *
21
+ * @param args Index to create
22
+ * @returns Index with `scope` column added first
23
+ */
24
+ export declare function createScopedIndex<T extends ScopedRecord>(args: {
25
+ columns: (keyof T)[];
26
+ name?: string;
27
+ }): {
28
+ columns: (keyof T)[];
29
+ name?: string;
30
+ };
18
31
  //# sourceMappingURL=ScopedRecord.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedRecord.d.ts","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,EAGN,KAAK,EAGL,EAAE,EACH,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,K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iB,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE;IAC9D,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG;IAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAM1C"}
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
45
  return to.concat(ar || Array.prototype.slice.call(from));
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.withScopedRecordColumns = exports.isScopedTable = exports.getScopedTables = exports.getScopedDbAsSystem = exports.getScopedDb = void 0;
48
+ exports.createScopedIndex = exports.withScopedRecordColumns = exports.isScopedTable = exports.getScopedTables = exports.getScopedDbAsSystem = exports.getScopedDb = void 0;
49
49
  var db_1 = require("@proteinjs/db");
50
50
  var UserRepo_1 = require("./UserRepo");
51
51
  exports.getScopedDb = (db_1.getDb);
@@ -98,4 +98,17 @@ function withScopedRecordColumns(columns, accessibleScopes) {
98
98
  return Object.assign(Object.assign({}, getScopedRecordColumns(accessibleScopes)), (0, db_1.withRecordColumns)(columns));
99
99
  }
100
100
  exports.withScopedRecordColumns = withScopedRecordColumns;
101
+ /**
102
+ * Adds the `scope` column as the first column to the provided index.
103
+ *
104
+ * @param args Index to create
105
+ * @returns Index with `scope` column added first
106
+ */
107
+ function createScopedIndex(args) {
108
+ if (args.columns.includes('scope')) {
109
+ return args;
110
+ }
111
+ return { columns: __spreadArray(['scope'], args.columns, true), name: args.name };
112
+ }
113
+ exports.createScopedIndex = createScopedIndex;
101
114
  //# sourceMappingURL=ScopedRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedRecord.js","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;iBACF;YACD,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;SACrB,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO,IAAA,cAAS,GAAgB,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB,CAAC,CAAC;AAC3E,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,KAAiB;IAC7C,IAAM,WAAW,GAAG,IAAA,oBAAe,EAAC,KAAK,EAAE,sBAAsB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,CAAC,CAAC,WAAW,CAAC;AACvB,CAAC;AAHD,sCAGC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA6C,EAC7C,gBAA2B;IAE3B,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC,EAC3D,IAAA,sBAAiB,EAAS,OAAO,CAAQ,CAC1C,CAAC;AACJ,CAAC;AARD,0DAQC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAyB,IAGzD;IACC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,EAAE,OAAO,iBAAG,OAAO,GAAK,IAAI,CAAC,OAAO,OAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC;AATD,8CASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/user",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "User management",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -45,5 +45,5 @@
45
45
  },
46
46
  "main": "./dist/generated/index.js",
47
47
  "types": "./dist/generated/index.d.ts",
48
- "gitHead": "dfcaab047bd35a77afed26498258c1167a0228dc"
48
+ "gitHead": "f9c69890c428b3e09fc26a8e165aeba6db596fe8"
49
49
  }
@@ -65,3 +65,20 @@ export function withScopedRecordColumns<T extends ScopedRecord>(
65
65
  withRecordColumns<Record>(columns) as any
66
66
  );
67
67
  }
68
+
69
+ /**
70
+ * Adds the `scope` column as the first column to the provided index.
71
+ *
72
+ * @param args Index to create
73
+ * @returns Index with `scope` column added first
74
+ */
75
+ export function createScopedIndex<T extends ScopedRecord>(args: {
76
+ columns: (keyof T)[];
77
+ name?: string;
78
+ }): { columns: (keyof T)[]; name?: string } {
79
+ if (args.columns.includes('scope')) {
80
+ return args;
81
+ }
82
+
83
+ return { columns: ['scope', ...args.columns], name: args.name };
84
+ }