@go-labs-sg/event-tech 0.2.0 → 0.3.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 +99 -108
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14750,6 +14750,22 @@ var assertBunRuntime = (runtime = globalThis.Bun) => {
|
|
|
14750
14750
|
};
|
|
14751
14751
|
|
|
14752
14752
|
// ../../cli-auth/src/client/credential-store.ts
|
|
14753
|
+
class CliCredentialStoreUnavailableError extends Error {
|
|
14754
|
+
code = "CLI_CREDENTIAL_STORE_UNAVAILABLE";
|
|
14755
|
+
constructor(product, options) {
|
|
14756
|
+
super(`Secure credential storage is unavailable for the ${product} CLI. Bun.secrets requires the operating system credential store, including Secret Service on Linux. Browser authentication cannot continue without a supported secure store.`, options);
|
|
14757
|
+
this.name = "CliCredentialStoreUnavailableError";
|
|
14758
|
+
}
|
|
14759
|
+
}
|
|
14760
|
+
var useSecrets = async (product, operation) => {
|
|
14761
|
+
try {
|
|
14762
|
+
return await operation();
|
|
14763
|
+
} catch (cause) {
|
|
14764
|
+
if (cause instanceof CliCredentialStoreUnavailableError)
|
|
14765
|
+
throw cause;
|
|
14766
|
+
throw new CliCredentialStoreUnavailableError(product, { cause });
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14753
14769
|
var defaultSecrets = () => {
|
|
14754
14770
|
assertBunRuntime();
|
|
14755
14771
|
return Bun.secrets;
|
|
@@ -14762,10 +14778,10 @@ var createBunCredentialStore = ({
|
|
|
14762
14778
|
const service = `go-labs-cli:${product}`;
|
|
14763
14779
|
return {
|
|
14764
14780
|
delete: async () => {
|
|
14765
|
-
await secrets.delete({ name: account, service });
|
|
14781
|
+
await useSecrets(product, () => secrets.delete({ name: account, service }));
|
|
14766
14782
|
},
|
|
14767
14783
|
get: async () => {
|
|
14768
|
-
const value = await secrets.get({ name: account, service });
|
|
14784
|
+
const value = await useSecrets(product, () => secrets.get({ name: account, service }));
|
|
14769
14785
|
if (value === null)
|
|
14770
14786
|
return null;
|
|
14771
14787
|
try {
|
|
@@ -14776,11 +14792,11 @@ var createBunCredentialStore = ({
|
|
|
14776
14792
|
},
|
|
14777
14793
|
set: async (credentials) => {
|
|
14778
14794
|
const parsed = storedCliCredentialsSchema.parse(credentials);
|
|
14779
|
-
await secrets.set({
|
|
14795
|
+
await useSecrets(product, () => secrets.set({
|
|
14780
14796
|
name: account,
|
|
14781
14797
|
service,
|
|
14782
14798
|
value: JSON.stringify(parsed)
|
|
14783
|
-
});
|
|
14799
|
+
}));
|
|
14784
14800
|
}
|
|
14785
14801
|
};
|
|
14786
14802
|
};
|
|
@@ -14944,53 +14960,9 @@ var logoutCliSession = async ({
|
|
|
14944
14960
|
await store.delete();
|
|
14945
14961
|
return { remoteRevoked };
|
|
14946
14962
|
};
|
|
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
|
-
};
|
|
14963
|
+
// src/cli.ts
|
|
14964
|
+
import { readFileSync } from "fs";
|
|
14965
|
+
import { resolve } from "path";
|
|
14994
14966
|
|
|
14995
14967
|
// src/api-client.ts
|
|
14996
14968
|
import {
|
|
@@ -14998,6 +14970,8 @@ import {
|
|
|
14998
14970
|
httpBatchLink
|
|
14999
14971
|
} from "@trpc/client";
|
|
15000
14972
|
import SuperJSON from "superjson";
|
|
14973
|
+
|
|
14974
|
+
// src/config.ts
|
|
15001
14975
|
var DEFAULT_EVENT_TECH_API_BASE_URL = "https://shared-events.getout.events";
|
|
15002
14976
|
|
|
15003
14977
|
class CliConfigurationError extends Error {
|
|
@@ -15021,6 +14995,8 @@ var normalizeApiBaseUrl = (value) => {
|
|
|
15021
14995
|
url2.pathname = url2.pathname.replace(/\/$/, "");
|
|
15022
14996
|
return url2.toString().replace(/\/$/, "");
|
|
15023
14997
|
};
|
|
14998
|
+
|
|
14999
|
+
// src/api-client.ts
|
|
15024
15000
|
var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation = fetch) => createTRPCProxyClient({
|
|
15025
15001
|
links: [
|
|
15026
15002
|
httpBatchLink({
|
|
@@ -15058,26 +15034,7 @@ var api2 = new Proxy({}, {
|
|
|
15058
15034
|
get: (_target, property, receiver) => Reflect.get(testingClient ?? activeClient, property, receiver)
|
|
15059
15035
|
});
|
|
15060
15036
|
|
|
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
|
-
}
|
|
15037
|
+
// src/commands/index.ts
|
|
15081
15038
|
var usage = `Event Tech CLI
|
|
15082
15039
|
|
|
15083
15040
|
Usage:
|
|
@@ -15102,6 +15059,70 @@ Authentication:
|
|
|
15102
15059
|
Run et auth login, then approve the matching device in Event Tech.
|
|
15103
15060
|
Credentials are stored exclusively through Bun.secrets.
|
|
15104
15061
|
EVENT_TECH_API_URL defaults to ${DEFAULT_EVENT_TECH_API_BASE_URL}.`;
|
|
15062
|
+
|
|
15063
|
+
// src/runtime/index.ts
|
|
15064
|
+
var processRuntime = {
|
|
15065
|
+
stdout: process.stdout,
|
|
15066
|
+
stderr: process.stderr
|
|
15067
|
+
};
|
|
15068
|
+
|
|
15069
|
+
class CliUsageError extends Error {
|
|
15070
|
+
code = "USAGE";
|
|
15071
|
+
constructor(message) {
|
|
15072
|
+
super(message);
|
|
15073
|
+
this.name = "CliUsageError";
|
|
15074
|
+
}
|
|
15075
|
+
}
|
|
15076
|
+
var canonicalize = (value) => {
|
|
15077
|
+
if (Array.isArray(value))
|
|
15078
|
+
return value.map(canonicalize);
|
|
15079
|
+
if (value instanceof Date)
|
|
15080
|
+
return value.toJSON();
|
|
15081
|
+
if (typeof value === "object" && value !== null) {
|
|
15082
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
|
|
15083
|
+
}
|
|
15084
|
+
return value;
|
|
15085
|
+
};
|
|
15086
|
+
var serialize = (value) => `${JSON.stringify(canonicalize(value), null, 2)}
|
|
15087
|
+
`;
|
|
15088
|
+
var writeSuccess = (runtime2, data) => {
|
|
15089
|
+
runtime2.stdout.write(serialize({ ok: true, data }));
|
|
15090
|
+
};
|
|
15091
|
+
var sanitizeErrorMessage = (message) => message.replace(/\bBearer\s+\S+/giu, "Bearer [REDACTED]");
|
|
15092
|
+
var errorCode = (error51) => {
|
|
15093
|
+
if (error51 instanceof CliUsageError)
|
|
15094
|
+
return error51.code;
|
|
15095
|
+
if (error51 instanceof CliConfigurationError)
|
|
15096
|
+
return error51.code;
|
|
15097
|
+
if (typeof error51 === "object" && error51 !== null && "data" in error51) {
|
|
15098
|
+
const data = error51.data;
|
|
15099
|
+
if (typeof data === "object" && data !== null && "code" in data && typeof data.code === "string") {
|
|
15100
|
+
return data.code;
|
|
15101
|
+
}
|
|
15102
|
+
}
|
|
15103
|
+
return "INTERNAL_ERROR";
|
|
15104
|
+
};
|
|
15105
|
+
var writeError = (runtime2, error51) => {
|
|
15106
|
+
const message = error51 instanceof Error ? sanitizeErrorMessage(error51.message) : "Unknown error.";
|
|
15107
|
+
runtime2.stderr.write(serialize({ ok: false, error: { code: errorCode(error51), message } }));
|
|
15108
|
+
};
|
|
15109
|
+
|
|
15110
|
+
// src/cli.ts
|
|
15111
|
+
var getInstalledCliVersion = () => {
|
|
15112
|
+
try {
|
|
15113
|
+
const packageJson = JSON.parse(readFileSync(resolve(import.meta.dir, "../package.json"), "utf8"));
|
|
15114
|
+
return typeof packageJson.version === "string" ? packageJson.version : "unknown";
|
|
15115
|
+
} catch {
|
|
15116
|
+
return "unknown";
|
|
15117
|
+
}
|
|
15118
|
+
};
|
|
15119
|
+
var booleanFlags = new Set([
|
|
15120
|
+
"allow-delete",
|
|
15121
|
+
"allow-state-change",
|
|
15122
|
+
"help",
|
|
15123
|
+
"no-browser",
|
|
15124
|
+
"version"
|
|
15125
|
+
]);
|
|
15105
15126
|
var parseArguments = (args) => {
|
|
15106
15127
|
const positionals = [];
|
|
15107
15128
|
const flags = new Map;
|
|
@@ -15181,41 +15202,9 @@ var parseArchiveStatus = (value) => {
|
|
|
15181
15202
|
}
|
|
15182
15203
|
return value;
|
|
15183
15204
|
};
|
|
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
15205
|
var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configureAccessToken) => {
|
|
15218
15206
|
const [group, action, subAction] = parsed.positionals;
|
|
15207
|
+
const cliVersion = getInstalledCliVersion();
|
|
15219
15208
|
let accessToken;
|
|
15220
15209
|
const ensureAuthentication = async () => {
|
|
15221
15210
|
accessToken ??= await getAuthenticatedAccessToken({
|
|
@@ -15231,7 +15220,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configure
|
|
|
15231
15220
|
}
|
|
15232
15221
|
if (parsed.flags.has("version") || group === "version") {
|
|
15233
15222
|
assertOnlyFlags(parsed, ["version"]);
|
|
15234
|
-
writeSuccess(runtime2, { version:
|
|
15223
|
+
writeSuccess(runtime2, { version: cliVersion });
|
|
15235
15224
|
return;
|
|
15236
15225
|
}
|
|
15237
15226
|
if (group === "auth" && action === "login" && subAction === undefined) {
|
|
@@ -15239,7 +15228,7 @@ var runCommand = async (parsed, runtime2, credentialStore, apiBaseUrl, configure
|
|
|
15239
15228
|
assertOnlyFlags(parsed, ["no-browser"]);
|
|
15240
15229
|
const credentials = await loginWithBrowser({
|
|
15241
15230
|
apiBaseUrl,
|
|
15242
|
-
clientVersion:
|
|
15231
|
+
clientVersion: cliVersion,
|
|
15243
15232
|
onVerification: ({
|
|
15244
15233
|
browserOpened,
|
|
15245
15234
|
userCode,
|
|
@@ -15357,5 +15346,7 @@ var runCli = async (args, runtime2 = processRuntime, credentialStore = createBun
|
|
|
15357
15346
|
};
|
|
15358
15347
|
|
|
15359
15348
|
// src/index.ts
|
|
15360
|
-
|
|
15361
|
-
|
|
15349
|
+
if (import.meta.main) {
|
|
15350
|
+
assertBunRuntime();
|
|
15351
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
15352
|
+
}
|