Skip to content

Commit 3a97096

Browse files
committed
update types
1 parent fccd0c4 commit 3a97096

File tree

11 files changed

+42
-28
lines changed

11 files changed

+42
-28
lines changed

src/auth/entries/user-role.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const userRole = new EntryType("userRole", {
8585
userRole.addAction("syncWithSystem", {
8686
label: "Sync with System Roles",
8787
async action({ userRole, inCloud }) {
88-
const roleConfig = await userRole.runAction<RoleConfig>("generateConfig");
88+
const roleConfig = await userRole.runAction("generateConfig") as RoleConfig;
8989
try {
9090
inCloud.roles.updateRole(roleConfig);
9191
} catch (e) {
@@ -118,9 +118,9 @@ userRole.addAction("generateConfig", {
118118
const apiGroups = new Map<string, string[] | true>();
119119
if (userRole.$extendsRole) {
120120
const parentRole = await orm.getEntry("userRole", userRole.$extendsRole);
121-
const parentConfig = await parentRole.runAction<RoleConfig>(
121+
const parentConfig = await parentRole.runAction(
122122
"generateConfig",
123-
);
123+
) as RoleConfig;
124124
if (parentConfig.entryTypes) {
125125
for (
126126
const [key, entryPerm] of Object.entries(parentConfig.entryTypes)

src/data-import/data-import.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,13 @@ dataImport.addAction("import", {
244244
`${subject} - ${JSON.stringify(info)} - ${response.join(", ")}`,
245245
);
246246
} else {
247-
errors.push(e.message);
247+
let message = "Unknown error";
248+
if (e instanceof Error) {
249+
message = e.message;
250+
} else if (typeof e === "string") {
251+
message = e;
252+
}
253+
errors.push(message);
248254
}
249255

250256
failedRecords++;

src/email/email-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class EmailManager {
7474
templateId,
7575
);
7676
const rendered: { content: string; subject: string } = await template
77-
.runAction("renderTemplate", { params });
77+
.runAction("renderTemplate", { params }) as any;
7878
return await this.sendEmail({
7979
recipientEmail,
8080
subject: rendered.subject || "",

src/in-queue/entry-types/in-task/in-task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async function runEntryTask(args: {
115115
orm: InSpatialORM;
116116
}) {
117117
const { entryType, id, actionName, taskData, orm } = args;
118-
const entry = await orm.getEntry(entryType as EntryName, id);
118+
const entry = await orm.getEntry(entryType, id);
119119
return await entry.runAction(actionName, taskData);
120120
}
121121
async function runSettingsTask(

src/in-queue/in-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export class InQueue extends InCloud {
352352
},
353353
});
354354
}
355-
const optimizeOptions: ListOptions = {
355+
const optimizeOptions: ListOptions<"cloudFile" | "globalCloudFile"> = {
356356
columns: [
357357
"id",
358358
"filePath",

src/orm/db/postgres/in-pg/src/wasmLoader.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ export class WasmLoader {
9090
) as WebAssembly.ModuleImports,
9191
};
9292

93-
const result = await WebAssembly.instantiate(this.inPg.wasmData, info);
93+
const result = await WebAssembly.instantiate(this.inPg.wasmData, info) as
94+
& WebAssembly.Instance
95+
& { instance: WebAssembly.Instance };
96+
9497
this.wasmExports = result.instance.exports;
9598

9699
for (const [sym, exp] of Object.entries(result.instance.exports)) {
@@ -379,7 +382,7 @@ export class WasmLoader {
379382
return this.wasmTable.length - 1;
380383
}
381384
loadWebAssemblyModule(
382-
binary: Int8Array,
385+
binary: Int8Array<ArrayBuffer>,
383386
flags: any,
384387
_libName: any,
385388
localScope: any,

src/orm/db/postgres/scram.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function encodeBase64(data: Uint8Array): string {
1+
function encodeBase64(data: Uint8Array<ArrayBuffer>): string {
22
return btoa(String.fromCharCode(...data));
33
}
44

5-
function decodeBase64(data: string): Uint8Array {
5+
function decodeBase64(data: string): Uint8Array<ArrayBuffer> {
66
return new Uint8Array(atob(data).split("").map((c) => c.charCodeAt(0)));
77
}
88

@@ -24,9 +24,9 @@ enum AuthenticationState {
2424
* in HMAC-derived binary format
2525
*/
2626
interface KeySignatures {
27-
client: Uint8Array;
28-
server: Uint8Array;
29-
stored: Uint8Array;
27+
client: Uint8Array<ArrayBuffer>;
28+
server: Uint8Array<ArrayBuffer>;
29+
stored: Uint8Array<ArrayBuffer>;
3030
}
3131

3232
/**
@@ -63,8 +63,8 @@ function assertValidScramString(str: string) {
6363

6464
async function computeScramSignature(
6565
message: string,
66-
rawKey: Uint8Array,
67-
): Promise<Uint8Array> {
66+
rawKey: Uint8Array<ArrayBuffer>,
67+
): Promise<Uint8Array<ArrayBuffer>> {
6868
const key = await crypto.subtle.importKey(
6969
"raw",
7070
rawKey,
@@ -82,7 +82,10 @@ async function computeScramSignature(
8282
);
8383
}
8484

85-
function computeScramProof(signature: Uint8Array, key: Uint8Array): Uint8Array {
85+
function computeScramProof(
86+
signature: Uint8Array<ArrayBuffer>,
87+
key: Uint8Array<ArrayBuffer>,
88+
): Uint8Array<ArrayBuffer> {
8689
const digest = new Uint8Array(signature.length);
8790
for (let i = 0; i < digest.length; i++) {
8891
digest[i] = signature[i] ^ key[i];
@@ -95,7 +98,7 @@ function computeScramProof(signature: Uint8Array, key: Uint8Array): Uint8Array {
9598
*/
9699
async function deriveKeySignatures(
97100
password: string,
98-
salt: Uint8Array,
101+
salt: Uint8Array<ArrayBuffer>,
99102
iterations: number,
100103
): Promise<KeySignatures> {
101104
const pbkdf2Password = await crypto.subtle.importKey(
@@ -217,7 +220,7 @@ export class ScramClient {
217220
}
218221
this.#serverNonce = nonce;
219222

220-
let salt: Uint8Array | undefined;
223+
let salt: Uint8Array<ArrayBuffer> | undefined;
221224
if (!attrs.s) {
222225
throw new Error(Reason.BadSalt);
223226
}

src/orm/field/field-def-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface FetchOptions {
5050
* The field in the fetched entry to get the value from.
5151
*/
5252
fetchField: string;
53+
global?: boolean;
5354
}
5455
type DependsOn<FK extends PropertyKey = PropertyKey> =
5556
| FK
@@ -72,6 +73,7 @@ type BaseField<FK extends PropertyKey = PropertyKey> = {
7273
defaultValue?: any;
7374
hidden?: boolean;
7475
placeholder?: string;
76+
global?: boolean;
7577
/**
7678
* Fetch the value from another entry, based on the id in a `ConnectionField` in this entry.
7779
*/

src/orm/inspatial-orm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class InSpatialORM {
363363
/**
364364
* Gets an entry from the database by its ID.
365365
*/
366-
async getEntry<E extends string>(
366+
async getEntry<E extends EntryName | string>(
367367
entryType: E,
368368
id: IDValue,
369369
): Promise<E extends EntryName ? EntryMap[E] : GenericEntry> {
@@ -383,7 +383,7 @@ export class InSpatialORM {
383383
const entry = await this.getEntry<E>(entryType, id);
384384
entry.update(data);
385385
await entry.save();
386-
return entry;
386+
return entry as EntryMap[E];
387387
}
388388

389389
/**
@@ -402,7 +402,7 @@ export class InSpatialORM {
402402
}
403403
return this.handlePgError(e);
404404
}
405-
return entry;
405+
return entry as EntryMap[E];
406406
}
407407

408408
/** Counts the how many entries there are in the database for all entry types that reference this one via a `ConnectionField` */
@@ -455,7 +455,7 @@ export class InSpatialORM {
455455
return null;
456456
}
457457
const entry = await this.getEntry(entryType, result.rows[0].id);
458-
return entry;
458+
return entry as EntryMap[E];
459459
}
460460
/** Finds and returns the ID of a single entry matching the provided filter. Returns null if no entry is found. */
461461
async findEntryId<E extends EntryName>(

src/serve/in-response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class InResponse {
5151
/**
5252
* The content of the response.
5353
*/
54-
#content?: string | Uint8Array | ArrayBuffer | ReadableStream;
54+
#content?: string | Uint8Array<ArrayBuffer> | ArrayBuffer | ReadableStream;
5555
/**
5656
* A map of cookies to set in the response.
5757
*/
@@ -220,7 +220,7 @@ export class InResponse {
220220
}
221221

222222
setFile(options: {
223-
content: string | Uint8Array | ArrayBuffer | ReadableStream;
223+
content: string | Uint8Array<ArrayBuffer> | ArrayBuffer | ReadableStream;
224224
fileName: string;
225225
download?: boolean;
226226
}): void {

0 commit comments

Comments
 (0)