@go-labs-sg/event-tech 0.1.0 → 0.3.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/dist/index.js +87 -108
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14944,56 +14944,18 @@ var logoutCliSession = async ({
|
|
|
14944
14944
|
await store.delete();
|
|
14945
14945
|
return { remoteRevoked };
|
|
14946
14946
|
};
|
|
14947
|
-
//
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
version: "0.1.0",
|
|
14951
|
-
description: "Event Tech CLI for managing Event Tech resources through the Go Labs API.",
|
|
14952
|
-
type: "module",
|
|
14953
|
-
bin: {
|
|
14954
|
-
"event-tech": "./dist/index.js",
|
|
14955
|
-
et: "./dist/index.js"
|
|
14956
|
-
},
|
|
14957
|
-
files: [
|
|
14958
|
-
"dist",
|
|
14959
|
-
"README.md"
|
|
14960
|
-
],
|
|
14961
|
-
scripts: {
|
|
14962
|
-
build: "rm -rf dist && bun build src/index.ts --target=bun --outfile=dist/index.js --external=@trpc/client --external=superjson",
|
|
14963
|
-
"pack:artifact": "bun run scripts/pack-package.ts",
|
|
14964
|
-
typecheck: "tsc --noEmit",
|
|
14965
|
-
check: "biome check .",
|
|
14966
|
-
"check:write": "biome check --write .",
|
|
14967
|
-
run: "bun run src/index.ts"
|
|
14968
|
-
},
|
|
14969
|
-
dependencies: {
|
|
14970
|
-
"@trpc/client": "^11.18.0",
|
|
14971
|
-
dotenv: "^17.4.2",
|
|
14972
|
-
superjson: "^2.2.6"
|
|
14973
|
-
},
|
|
14974
|
-
devDependencies: {
|
|
14975
|
-
"@go-labs/cli-auth": "workspace:*",
|
|
14976
|
-
"@go-labs/typescript-config": "workspace:*",
|
|
14977
|
-
"@types/bun": "1.4.0",
|
|
14978
|
-
"@types/node": "catalog:",
|
|
14979
|
-
typescript: "catalog:"
|
|
14980
|
-
},
|
|
14981
|
-
engines: {
|
|
14982
|
-
bun: ">=1.4.0"
|
|
14983
|
-
},
|
|
14984
|
-
publishConfig: {
|
|
14985
|
-
access: "public"
|
|
14986
|
-
},
|
|
14987
|
-
repository: {
|
|
14988
|
-
type: "git",
|
|
14989
|
-
url: "https://github.com/go-labs-sg/go-labs.git",
|
|
14990
|
-
directory: "packages/event-tech/cli"
|
|
14991
|
-
}
|
|
14992
|
-
};
|
|
14947
|
+
// src/cli.ts
|
|
14948
|
+
import { readFileSync } from "fs";
|
|
14949
|
+
import { resolve } from "path";
|
|
14993
14950
|
|
|
14994
14951
|
// src/api-client.ts
|
|
14995
|
-
import {
|
|
14952
|
+
import {
|
|
14953
|
+
createTRPCProxyClient,
|
|
14954
|
+
httpBatchLink
|
|
14955
|
+
} from "@trpc/client";
|
|
14996
14956
|
import SuperJSON from "superjson";
|
|
14957
|
+
|
|
14958
|
+
// src/config.ts
|
|
14997
14959
|
var DEFAULT_EVENT_TECH_API_BASE_URL = "https://shared-events.getout.events";
|
|
14998
14960
|
|
|
14999
14961
|
class CliConfigurationError extends Error {
|
|
@@ -15017,6 +14979,8 @@ var normalizeApiBaseUrl = (value) => {
|
|
|
15017
14979
|
url2.pathname = url2.pathname.replace(/\/$/, "");
|
|
15018
14980
|
return url2.toString().replace(/\/$/, "");
|
|
15019
14981
|
};
|
|
14982
|
+
|
|
14983
|
+
// src/api-client.ts
|
|
15020
14984
|
var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation = fetch) => createTRPCProxyClient({
|
|
15021
14985
|
links: [
|
|
15022
14986
|
httpBatchLink({
|
|
@@ -15054,26 +15018,7 @@ var api2 = new Proxy({}, {
|
|
|
15054
15018
|
get: (_target, property, receiver) => Reflect.get(testingClient ?? activeClient, property, receiver)
|
|
15055
15019
|
});
|
|
15056
15020
|
|
|
15057
|
-
// src/
|
|
15058
|
-
var booleanFlags = new Set([
|
|
15059
|
-
"allow-delete",
|
|
15060
|
-
"allow-state-change",
|
|
15061
|
-
"help",
|
|
15062
|
-
"no-browser",
|
|
15063
|
-
"version"
|
|
15064
|
-
]);
|
|
15065
|
-
var processRuntime = {
|
|
15066
|
-
stdout: process.stdout,
|
|
15067
|
-
stderr: process.stderr
|
|
15068
|
-
};
|
|
15069
|
-
|
|
15070
|
-
class CliUsageError extends Error {
|
|
15071
|
-
code = "USAGE";
|
|
15072
|
-
constructor(message) {
|
|
15073
|
-
super(message);
|
|
15074
|
-
this.name = "CliUsageError";
|
|
15075
|
-
}
|
|
15076
|
-
}
|
|
15021
|
+
// src/commands/index.ts
|
|
15077
15022
|
var usage = `Event Tech CLI
|
|
15078
15023
|
|
|
15079
15024
|
Usage:
|
|
@@ -15098,6 +15043,70 @@ Authentication:
|
|
|
15098
15043
|
Run et auth login, then approve the matching device in Event Tech.
|
|
15099
15044
|
Credentials are stored exclusively through Bun.secrets.
|
|
15100
15045
|
EVENT_TECH_API_URL defaults to ${DEFAULT_EVENT_TECH_API_BASE_URL}.`;
|
|
15046
|
+
|
|
15047
|
+
// src/runtime/index.ts
|
|
15048
|
+
var processRuntime = {
|
|
15049
|
+
stdout: process.stdout,
|
|
15050
|
+
stderr: process.stderr
|
|
15051
|
+
};
|
|
15052
|
+
|
|
15053
|
+
class CliUsageError extends Error {
|
|
15054
|
+
code = "USAGE";
|
|
15055
|
+
constructor(message) {
|
|
15056
|
+
super(message);
|
|
15057
|
+
this.name = "CliUsageError";
|
|
15058
|
+
}
|
|
15059
|
+
}
|
|
15060
|
+
var canonicalize = (value) => {
|
|
15061
|
+
if (Array.isArray(value))
|
|
15062
|
+
return value.map(canonicalize);
|
|
15063
|
+
if (value instanceof Date)
|
|
15064
|
+
return value.toJSON();
|
|
15065
|
+
if (typeof value === "object" && value !== null) {
|
|
15066
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
|
|
15067
|
+
}
|
|
15068
|
+
return value;
|
|
15069
|
+
};
|
|
15070
|
+
var serialize = (value) => `${JSON.stringify(canonicalize(value), null, 2)}
|
|
15071
|
+
`;
|
|
15072
|
+
var writeSuccess = (runtime2, data) => {
|
|
15073
|
+
runtime2.stdout.write(serialize({ ok: true, data }));
|
|
15074
|
+
};
|
|
15075
|
+
var sanitizeErrorMessage = (message) => message.replace(/\bBearer\s+\S+/giu, "Bearer [REDACTED]");
|
|
15076
|
+
var errorCode = (error51) => {
|
|
15077
|
+
if (error51 instanceof CliUsageError)
|
|
15078
|
+
return error51.code;
|
|
15079
|
+
if (error51 instanceof CliConfigurationError)
|
|
15080
|
+
return error51.code;
|
|
15081
|
+
if (typeof error51 === "object" && error51 !== null && "data" in error51) {
|
|
15082
|
+
const data = error51.data;
|
|
15083
|
+
if (typeof data === "object" && data !== null && "code" in data && typeof data.code === "string") {
|
|
15084
|
+
return data.code;
|
|
15085
|
+
}
|
|
15086
|
+
}
|
|
15087
|
+
return "INTERNAL_ERROR";
|
|
15088
|
+
};
|
|
15089
|
+
var writeError = (runtime2, error51) => {
|
|
15090
|
+
const message = error51 instanceof Error ? sanitizeErrorMessage(error51.message) : "Unknown error.";
|
|
15091
|
+
runtime2.stderr.write(serialize({ ok: false, error: { code: errorCode(error51), message } }));
|
|
15092
|
+
};
|
|
15093
|
+
|
|
15094
|
+
// src/cli.ts
|
|
15095
|
+
var getInstalledCliVersion = () => {
|
|
15096
|
+
try {
|
|
15097
|
+
const packageJson = JSON.parse(readFileSync(resolve(import.meta.dir, "../package.json"), "utf8"));
|
|
15098
|
+
return typeof packageJson.version === "string" ? packageJson.version : "unknown";
|
|
15099
|
+
} catch {
|
|
15100
|
+
return "unknown";
|
|
15101
|
+
}
|
|
15102
|
+
};
|
|
15103
|
+
var booleanFlags = new Set([
|
|
15104
|
+
"allow-delete",
|
|
15105
|
+
"allow-state-change",
|
|
15106
|
+
"help",
|
|
15107
|
+
"no-browser",
|
|
15108
|
+
"version"
|
|
15109
|
+
]);
|
|
15101
15110
|
var parseArguments = (args) => {
|
|
15102
15111
|
const positionals = [];
|
|
15103
15112
|
const flags = new Map;
|
|
@@ -15177,48 +15186,16 @@ var parseArchiveStatus = (value) => {
|
|
|
15177
15186
|
}
|
|
15178
15187
|
return value;
|
|
15179
15188
|
};
|
|
15180
|
-
var
|
|
15181
|
-
if (Array.isArray(value))
|
|
15182
|
-
return value.map(canonicalize);
|
|
15183
|
-
if (value instanceof Date)
|
|
15184
|
-
return value.toJSON();
|
|
15185
|
-
if (typeof value === "object" && value !== null) {
|
|
15186
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
|
|
15187
|
-
}
|
|
15188
|
-
return value;
|
|
15189
|
-
};
|
|
15190
|
-
var serialize = (value) => `${JSON.stringify(canonicalize(value), null, 2)}
|
|
15191
|
-
`;
|
|
15192
|
-
var writeSuccess = (runtime2, data) => {
|
|
15193
|
-
runtime2.stdout.write(serialize({ ok: true, data }));
|
|
15194
|
-
};
|
|
15195
|
-
var sanitizeErrorMessage = (message) => message.replace(/\bBearer\s+\S+/giu, "Bearer [REDACTED]");
|
|
15196
|
-
var errorCode = (error51) => {
|
|
15197
|
-
if (error51 instanceof CliUsageError)
|
|
15198
|
-
return error51.code;
|
|
15199
|
-
if (error51 instanceof CliConfigurationError)
|
|
15200
|
-
return error51.code;
|
|
15201
|
-
if (typeof error51 === "object" && error51 !== null && "data" in error51) {
|
|
15202
|
-
const data = error51.data;
|
|
15203
|
-
if (typeof data === "object" && data !== null && "code" in data && typeof data.code === "string") {
|
|
15204
|
-
return data.code;
|
|
15205
|
-
}
|
|
15206
|
-
}
|
|
15207
|
-
return "INTERNAL_ERROR";
|
|
15208
|
-
};
|
|
15209
|
-
var writeError = (runtime2, error51) => {
|
|
15210
|
-
const message = error51 instanceof Error ? sanitizeErrorMessage(error51.message) : "Unknown error.";
|
|
15211
|
-
runtime2.stderr.write(serialize({ ok: false, error: { code: errorCode(error51), message } }));
|
|
15212
|
-
};
|
|
15213
|
-
var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl) => {
|
|
15189
|
+
var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configureAccessToken) => {
|
|
15214
15190
|
const [group, action, subAction] = parsed.positionals;
|
|
15191
|
+
const cliVersion = getInstalledCliVersion();
|
|
15215
15192
|
let accessToken;
|
|
15216
15193
|
const ensureAuthentication = async () => {
|
|
15217
15194
|
accessToken ??= await getAuthenticatedAccessToken({
|
|
15218
15195
|
apiBaseUrl,
|
|
15219
15196
|
store: credentialStore
|
|
15220
15197
|
});
|
|
15221
|
-
|
|
15198
|
+
configureAccessToken(accessToken);
|
|
15222
15199
|
};
|
|
15223
15200
|
if (parsed.flags.has("help") || group === "help") {
|
|
15224
15201
|
assertOnlyFlags(parsed, ["help"]);
|
|
@@ -15227,7 +15204,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl) => {
|
|
|
15227
15204
|
}
|
|
15228
15205
|
if (parsed.flags.has("version") || group === "version") {
|
|
15229
15206
|
assertOnlyFlags(parsed, ["version"]);
|
|
15230
|
-
writeSuccess(runtime2, { version:
|
|
15207
|
+
writeSuccess(runtime2, { version: cliVersion });
|
|
15231
15208
|
return;
|
|
15232
15209
|
}
|
|
15233
15210
|
if (group === "auth" && action === "login" && subAction === undefined) {
|
|
@@ -15235,7 +15212,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl) => {
|
|
|
15235
15212
|
assertOnlyFlags(parsed, ["no-browser"]);
|
|
15236
15213
|
const credentials = await loginWithBrowser({
|
|
15237
15214
|
apiBaseUrl,
|
|
15238
|
-
clientVersion:
|
|
15215
|
+
clientVersion: cliVersion,
|
|
15239
15216
|
onVerification: ({
|
|
15240
15217
|
browserOpened,
|
|
15241
15218
|
userCode,
|
|
@@ -15336,7 +15313,7 @@ Waiting for approval\u2026
|
|
|
15336
15313
|
};
|
|
15337
15314
|
var runCli = async (args, runtime2 = processRuntime, credentialStore = createBunCredentialStore({
|
|
15338
15315
|
product: "event-tech"
|
|
15339
|
-
})) => {
|
|
15316
|
+
}), configureAccessToken = configureEventTechAccessToken) => {
|
|
15340
15317
|
try {
|
|
15341
15318
|
const parsed = parseArguments(args);
|
|
15342
15319
|
const apiUrl = getOptionalFlag(parsed, "api-url");
|
|
@@ -15344,7 +15321,7 @@ var runCli = async (args, runtime2 = processRuntime, credentialStore = createBun
|
|
|
15344
15321
|
configureEventTechApiBaseUrl(apiUrl);
|
|
15345
15322
|
else
|
|
15346
15323
|
configureEventTechApiFromEnvironment();
|
|
15347
|
-
await runCommand(parsed, runtime2, credentialStore, getEventTechApiBaseUrl());
|
|
15324
|
+
await runCommand(parsed, runtime2, credentialStore, getEventTechApiBaseUrl(), configureAccessToken);
|
|
15348
15325
|
return 0;
|
|
15349
15326
|
} catch (error51) {
|
|
15350
15327
|
writeError(runtime2, error51);
|
|
@@ -15353,5 +15330,7 @@ var runCli = async (args, runtime2 = processRuntime, credentialStore = createBun
|
|
|
15353
15330
|
};
|
|
15354
15331
|
|
|
15355
15332
|
// src/index.ts
|
|
15356
|
-
|
|
15357
|
-
|
|
15333
|
+
if (import.meta.main) {
|
|
15334
|
+
assertBunRuntime();
|
|
15335
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
15336
|
+
}
|