@opensaas/stack-cli 0.42.2 → 0.43.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.
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { withTsExtension } from './extension.js';
|
|
4
|
-
// The emitted `getContext`/`rawOpensaasContext`
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// `
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// `
|
|
15
|
-
//
|
|
16
|
-
//
|
|
4
|
+
// The emitted `getContext`/`rawOpensaasContext` call core's `getOpensaasContext`
|
|
5
|
+
// with its `TDb` type parameter (#1328) pinned to the generated `CustomDB`, so
|
|
6
|
+
// the returned value is already `StackContext<PrismaClient, CustomDB>` — no
|
|
7
|
+
// `as unknown as` needed to erase `db`'s type. A single, honest `as
|
|
8
|
+
// Context<TSession>` remains: `Context<TSession>.session` is the caller's own
|
|
9
|
+
// `TSession`, while `StackContext`'s `session` is always the wider `Session |
|
|
10
|
+
// null` (core has no session-generic parameter to narrow it with), so the two
|
|
11
|
+
// are never mutually assignable regardless of `db`. `as` (not `as unknown as`)
|
|
12
|
+
// is enough because `Context<TSession>` is itself assignable to
|
|
13
|
+
// `StackContext<PrismaClient, CustomDB>` (every field it declares — including
|
|
14
|
+
// `TSession` narrowing `Session | null`, and `CustomDB` matching `CustomDB`
|
|
15
|
+
// exactly — is a valid `StackContext` value), which is what TypeScript's `as`
|
|
16
|
+
// requires when the reverse direction doesn't hold.
|
|
17
17
|
export function generateContext(config, configImport) {
|
|
18
18
|
// Defaults to the legacy `../opensaas.config` (bundle one level below the
|
|
19
19
|
// project root); the output-path resolver supplies a recomputed value when
|
|
@@ -123,7 +123,7 @@ const storage = {
|
|
|
123
123
|
import { getContext as getOpensaasContext } from '@opensaas/stack-core'
|
|
124
124
|
import type { Session as OpensaasSession, OpenSaasConfig } from '@opensaas/stack-core'
|
|
125
125
|
import { PrismaClient } from './prisma-client/client.ts'
|
|
126
|
-
import type { Context } from './types.ts'
|
|
126
|
+
import type { Context, CustomDB } from './types.ts'
|
|
127
127
|
import configOrPromise from '${configImportPath}'
|
|
128
128
|
|
|
129
129
|
// Resolve config if it's a Promise (when plugins are present)
|
|
@@ -177,7 +177,7 @@ ${storageUtilities}
|
|
|
177
177
|
export async function getContext<TSession extends OpensaasSession = OpensaasSession>(session?: TSession): Promise<Context<TSession>> {
|
|
178
178
|
const config = await getConfig()
|
|
179
179
|
const prismaClient = await getPrisma()
|
|
180
|
-
return getOpensaasContext(config, prismaClient, session ?? null, storage) as
|
|
180
|
+
return getOpensaasContext<typeof config, PrismaClient, CustomDB>(config, prismaClient, session ?? null, storage) as Context<TSession>
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/**
|
|
@@ -189,7 +189,7 @@ export async function getContext<TSession extends OpensaasSession = OpensaasSess
|
|
|
189
189
|
export const rawOpensaasContext = (async () => {
|
|
190
190
|
const config = await getConfig()
|
|
191
191
|
const prismaClient = await getPrisma()
|
|
192
|
-
return getOpensaasContext(config, prismaClient, null, storage) as
|
|
192
|
+
return getOpensaasContext<typeof config, PrismaClient, CustomDB>(config, prismaClient, null, storage) as Context
|
|
193
193
|
})()
|
|
194
194
|
|
|
195
195
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,I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,EACtB,UAAkB,EAClB,YAAqB;IAErB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAErD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensaas/stack-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "CLI tools for OpenSaas Stack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"ora": "^9.4.1",
|
|
56
56
|
"prompts": "^2.4.2",
|
|
57
57
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
58
|
-
"zod": "^4.4
|
|
59
|
-
"@opensaas/stack-core": "0.
|
|
58
|
+
"zod": "^4.5.4",
|
|
59
|
+
"@opensaas/stack-core": "0.43.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/fs-extra": "^11.0.4",
|