@pd4castr/cli 0.0.14 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -14
  2. 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().optional().default(() => Boolean(process.env.WSL_DISTRO_NAME)),
248
- apiURL: z3.string().optional().default(() => process.env.PD4CASTR_API_URL ?? DEFAULT_API_URL),
249
- wslNetworkInterface: z3.string().optional().default(
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 payload2 = { query: querySQL, type: "AEMO_MMS" };
268
- const result = await api.post("data-fetcher/query", { json: payload2, headers }).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,14 @@ 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 payload2 = {
482
+ const payload = {
481
483
  client_id: AUTH0_CLIENT_ID,
482
484
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
483
485
  device_code: authCtx.deviceCode
484
486
  };
485
487
  async function fetchAuthResponse() {
486
488
  try {
487
- const response = await auth0API.post("oauth/token", { json: payload2 }).json();
489
+ const response = await auth0API.post("oauth/token", { json: payload }).json();
488
490
  const authPayload = {
489
491
  accessToken: response.access_token,
490
492
  expiresAt: Date.now() + response.expires_in * 1e3
@@ -511,12 +513,13 @@ async function completeAuthFlow(authCtx) {
511
513
  }
512
514
 
513
515
  // 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
516
  async function startAuthFlow() {
517
+ const env = getEnv();
518
+ const payload = {
519
+ client_id: env.auth0ClientId,
520
+ audience: env.auth0Audience,
521
+ scope: "openid email"
522
+ };
520
523
  const codeResponse = await auth0API.post("oauth/device/code", { json: payload }).json();
521
524
  const authContext = {
522
525
  deviceCode: codeResponse.device_code,
@@ -1399,7 +1402,7 @@ import { Command } from "commander";
1399
1402
  // package.json
1400
1403
  var package_default = {
1401
1404
  name: "@pd4castr/cli",
1402
- version: "0.0.14",
1405
+ version: "1.0.0",
1403
1406
  description: "CLI tool for creating, testing, and publishing pd4castr models",
1404
1407
  main: "dist/index.js",
1405
1408
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pd4castr/cli",
3
- "version": "0.0.14",
3
+ "version": "1.0.0",
4
4
  "description": "CLI tool for creating, testing, and publishing pd4castr models",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",