@pd4castr/cli 0.0.14 → 1.0.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.
- package/dist/index.js +19 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -244,11 +244,13 @@ import ky from "ky";
|
|
|
244
244
|
import { z as z3 } from "zod";
|
|
245
245
|
var envSchema = z3.object({
|
|
246
246
|
// wsl sets this environment variable on all distros that i've checked
|
|
247
|
-
isWSL: z3.boolean().
|
|
248
|
-
apiURL: z3.string().
|
|
249
|
-
wslNetworkInterface: z3.string().
|
|
247
|
+
isWSL: z3.boolean().default(() => Boolean(process.env.WSL_DISTRO_NAME)),
|
|
248
|
+
apiURL: z3.string().default(() => process.env.PD4CASTR_API_URL ?? DEFAULT_API_URL),
|
|
249
|
+
wslNetworkInterface: z3.string().default(
|
|
250
250
|
() => process.env.PD4CASTR_WSL_NETWORK_INTERFACE ?? WSL_NETWORK_INTERFACE_DEFAULT
|
|
251
|
-
)
|
|
251
|
+
),
|
|
252
|
+
auth0ClientId: z3.string().default(() => process.env.PD4CASTR_AUTH0_CLIENT_ID ?? AUTH0_CLIENT_ID),
|
|
253
|
+
auth0Audience: z3.string().default(() => process.env.PD4CASTR_AUTH0_AUDIENCE ?? AUTH0_AUDIENCE)
|
|
252
254
|
});
|
|
253
255
|
|
|
254
256
|
// src/utils/get-env.ts
|
|
@@ -264,8 +266,8 @@ var api = ky.create({
|
|
|
264
266
|
// src/api/query-data-fetcher.ts
|
|
265
267
|
async function queryDataFetcher(querySQL, authCtx) {
|
|
266
268
|
const headers = { Authorization: `Bearer ${authCtx.accessToken}` };
|
|
267
|
-
const
|
|
268
|
-
const result = await api.post("data-fetcher/query", { json:
|
|
269
|
+
const payload = { query: querySQL, type: "AEMO_MMS" };
|
|
270
|
+
const result = await api.post("data-fetcher/query", { json: payload, headers }).json();
|
|
269
271
|
return result;
|
|
270
272
|
}
|
|
271
273
|
|
|
@@ -477,14 +479,15 @@ var auth0API = ky2.create({ prefixUrl: `https://${AUTH0_DOMAIN}` });
|
|
|
477
479
|
// src/commands/login/utils/complete-auth-flow.ts
|
|
478
480
|
var FAILED_AUTH_ERRORS = /* @__PURE__ */ new Set(["expired_token", "access_denied"]);
|
|
479
481
|
async function completeAuthFlow(authCtx) {
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
+
const env = getEnv();
|
|
483
|
+
const payload = {
|
|
484
|
+
client_id: env.auth0ClientId,
|
|
482
485
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
483
486
|
device_code: authCtx.deviceCode
|
|
484
487
|
};
|
|
485
488
|
async function fetchAuthResponse() {
|
|
486
489
|
try {
|
|
487
|
-
const response = await auth0API.post("oauth/token", { json:
|
|
490
|
+
const response = await auth0API.post("oauth/token", { json: payload }).json();
|
|
488
491
|
const authPayload = {
|
|
489
492
|
accessToken: response.access_token,
|
|
490
493
|
expiresAt: Date.now() + response.expires_in * 1e3
|
|
@@ -511,12 +514,13 @@ async function completeAuthFlow(authCtx) {
|
|
|
511
514
|
}
|
|
512
515
|
|
|
513
516
|
// src/commands/login/utils/start-auth-flow.ts
|
|
514
|
-
var payload = {
|
|
515
|
-
client_id: AUTH0_CLIENT_ID,
|
|
516
|
-
audience: AUTH0_AUDIENCE,
|
|
517
|
-
scope: "openid email"
|
|
518
|
-
};
|
|
519
517
|
async function startAuthFlow() {
|
|
518
|
+
const env = getEnv();
|
|
519
|
+
const payload = {
|
|
520
|
+
client_id: env.auth0ClientId,
|
|
521
|
+
audience: env.auth0Audience,
|
|
522
|
+
scope: "openid email"
|
|
523
|
+
};
|
|
520
524
|
const codeResponse = await auth0API.post("oauth/device/code", { json: payload }).json();
|
|
521
525
|
const authContext = {
|
|
522
526
|
deviceCode: codeResponse.device_code,
|
|
@@ -1399,7 +1403,7 @@ import { Command } from "commander";
|
|
|
1399
1403
|
// package.json
|
|
1400
1404
|
var package_default = {
|
|
1401
1405
|
name: "@pd4castr/cli",
|
|
1402
|
-
version: "
|
|
1406
|
+
version: "1.0.1",
|
|
1403
1407
|
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
1404
1408
|
main: "dist/index.js",
|
|
1405
1409
|
type: "module",
|