@go-labs-sg/event-tech 0.2.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 +79 -104
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14944,53 +14944,9 @@ var logoutCliSession = async ({
|
|
|
14944
14944
|
await store.delete();
|
|
14945
14945
|
return { remoteRevoked };
|
|
14946
14946
|
};
|
|
14947
|
-
//
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
version: "0.2.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/event-tech-api": "workspace:*",
|
|
14977
|
-
"@go-labs/typescript-config": "workspace:*",
|
|
14978
|
-
"@types/bun": "1.4.0",
|
|
14979
|
-
"@types/node": "catalog:",
|
|
14980
|
-
typescript: "catalog:"
|
|
14981
|
-
},
|
|
14982
|
-
engines: {
|
|
14983
|
-
bun: ">=1.4.0"
|
|
14984
|
-
},
|
|
14985
|
-
publishConfig: {
|
|
14986
|
-
access: "public"
|
|
14987
|
-
},
|
|
14988
|
-
repository: {
|
|
14989
|
-
type: "git",
|
|
14990
|
-
url: "https://github.com/go-labs-sg/go-labs.git",
|
|
14991
|
-
directory: "packages/event-tech/cli"
|
|
14992
|
-
}
|
|
14993
|
-
};
|
|
14947
|
+
// src/cli.ts
|
|
14948
|
+
import { readFileSync } from "fs";
|
|
14949
|
+
import { resolve } from "path";
|
|
14994
14950
|
|
|
14995
14951
|
// src/api-client.ts
|
|
14996
14952
|
import {
|
|
@@ -14998,6 +14954,8 @@ import {
|
|
|
14998
14954
|
httpBatchLink
|
|
14999
14955
|
} from "@trpc/client";
|
|
15000
14956
|
import SuperJSON from "superjson";
|
|
14957
|
+
|
|
14958
|
+
// src/config.ts
|
|
15001
14959
|
var DEFAULT_EVENT_TECH_API_BASE_URL = "https://shared-events.getout.events";
|
|
15002
14960
|
|
|
15003
14961
|
class CliConfigurationError extends Error {
|
|
@@ -15021,6 +14979,8 @@ var normalizeApiBaseUrl = (value) => {
|
|
|
15021
14979
|
url2.pathname = url2.pathname.replace(/\/$/, "");
|
|
15022
14980
|
return url2.toString().replace(/\/$/, "");
|
|
15023
14981
|
};
|
|
14982
|
+
|
|
14983
|
+
// src/api-client.ts
|
|
15024
14984
|
var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation = fetch) => createTRPCProxyClient({
|
|
15025
14985
|
links: [
|
|
15026
14986
|
httpBatchLink({
|
|
@@ -15058,26 +15018,7 @@ var api2 = new Proxy({}, {
|
|
|
15058
15018
|
get: (_target, property, receiver) => Reflect.get(testingClient ?? activeClient, property, receiver)
|
|
15059
15019
|
});
|
|
15060
15020
|
|
|
15061
|
-
// src/
|
|
15062
|
-
var booleanFlags = new Set([
|
|
15063
|
-
"allow-delete",
|
|
15064
|
-
"allow-state-change",
|
|
15065
|
-
"help",
|
|
15066
|
-
"no-browser",
|
|
15067
|
-
"version"
|
|
15068
|
-
]);
|
|
15069
|
-
var processRuntime = {
|
|
15070
|
-
stdout: process.stdout,
|
|
15071
|
-
stderr: process.stderr
|
|
15072
|
-
};
|
|
15073
|
-
|
|
15074
|
-
class CliUsageError extends Error {
|
|
15075
|
-
code = "USAGE";
|
|
15076
|
-
constructor(message) {
|
|
15077
|
-
super(message);
|
|
15078
|
-
this.name = "CliUsageError";
|
|
15079
|
-
}
|
|
15080
|
-
}
|
|
15021
|
+
// src/commands/index.ts
|
|
15081
15022
|
var usage = `Event Tech CLI
|
|
15082
15023
|
|
|
15083
15024
|
Usage:
|
|
@@ -15102,6 +15043,70 @@ Authentication:
|
|
|
15102
15043
|
Run et auth login, then approve the matching device in Event Tech.
|
|
15103
15044
|
Credentials are stored exclusively through Bun.secrets.
|
|
15104
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
|
+
]);
|
|
15105
15110
|
var parseArguments = (args) => {
|
|
15106
15111
|
const positionals = [];
|
|
15107
15112
|
const flags = new Map;
|
|
@@ -15181,41 +15186,9 @@ var parseArchiveStatus = (value) => {
|
|
|
15181
15186
|
}
|
|
15182
15187
|
return value;
|
|
15183
15188
|
};
|
|
15184
|
-
var canonicalize = (value) => {
|
|
15185
|
-
if (Array.isArray(value))
|
|
15186
|
-
return value.map(canonicalize);
|
|
15187
|
-
if (value instanceof Date)
|
|
15188
|
-
return value.toJSON();
|
|
15189
|
-
if (typeof value === "object" && value !== null) {
|
|
15190
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
|
|
15191
|
-
}
|
|
15192
|
-
return value;
|
|
15193
|
-
};
|
|
15194
|
-
var serialize = (value) => `${JSON.stringify(canonicalize(value), null, 2)}
|
|
15195
|
-
`;
|
|
15196
|
-
var writeSuccess = (runtime2, data) => {
|
|
15197
|
-
runtime2.stdout.write(serialize({ ok: true, data }));
|
|
15198
|
-
};
|
|
15199
|
-
var sanitizeErrorMessage = (message) => message.replace(/\bBearer\s+\S+/giu, "Bearer [REDACTED]");
|
|
15200
|
-
var errorCode = (error51) => {
|
|
15201
|
-
if (error51 instanceof CliUsageError)
|
|
15202
|
-
return error51.code;
|
|
15203
|
-
if (error51 instanceof CliConfigurationError)
|
|
15204
|
-
return error51.code;
|
|
15205
|
-
if (typeof error51 === "object" && error51 !== null && "data" in error51) {
|
|
15206
|
-
const data = error51.data;
|
|
15207
|
-
if (typeof data === "object" && data !== null && "code" in data && typeof data.code === "string") {
|
|
15208
|
-
return data.code;
|
|
15209
|
-
}
|
|
15210
|
-
}
|
|
15211
|
-
return "INTERNAL_ERROR";
|
|
15212
|
-
};
|
|
15213
|
-
var writeError = (runtime2, error51) => {
|
|
15214
|
-
const message = error51 instanceof Error ? sanitizeErrorMessage(error51.message) : "Unknown error.";
|
|
15215
|
-
runtime2.stderr.write(serialize({ ok: false, error: { code: errorCode(error51), message } }));
|
|
15216
|
-
};
|
|
15217
15189
|
var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configureAccessToken) => {
|
|
15218
15190
|
const [group, action, subAction] = parsed.positionals;
|
|
15191
|
+
const cliVersion = getInstalledCliVersion();
|
|
15219
15192
|
let accessToken;
|
|
15220
15193
|
const ensureAuthentication = async () => {
|
|
15221
15194
|
accessToken ??= await getAuthenticatedAccessToken({
|
|
@@ -15231,7 +15204,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configure
|
|
|
15231
15204
|
}
|
|
15232
15205
|
if (parsed.flags.has("version") || group === "version") {
|
|
15233
15206
|
assertOnlyFlags(parsed, ["version"]);
|
|
15234
|
-
writeSuccess(runtime2, { version:
|
|
15207
|
+
writeSuccess(runtime2, { version: cliVersion });
|
|
15235
15208
|
return;
|
|
15236
15209
|
}
|
|
15237
15210
|
if (group === "auth" && action === "login" && subAction === undefined) {
|
|
@@ -15239,7 +15212,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configure
|
|
|
15239
15212
|
assertOnlyFlags(parsed, ["no-browser"]);
|
|
15240
15213
|
const credentials = await loginWithBrowser({
|
|
15241
15214
|
apiBaseUrl,
|
|
15242
|
-
clientVersion:
|
|
15215
|
+
clientVersion: cliVersion,
|
|
15243
15216
|
onVerification: ({
|
|
15244
15217
|
browserOpened,
|
|
15245
15218
|
userCode,
|
|
@@ -15357,5 +15330,7 @@ var runCli = async (args, runtime2 = processRuntime, credentialStore = createBun
|
|
|
15357
15330
|
};
|
|
15358
15331
|
|
|
15359
15332
|
// src/index.ts
|
|
15360
|
-
|
|
15361
|
-
|
|
15333
|
+
if (import.meta.main) {
|
|
15334
|
+
assertBunRuntime();
|
|
15335
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
15336
|
+
}
|