primcli 1.38.0 → 1.38.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.
Files changed (2) hide show
  1. package/dist/oclif/index.js +107 -54
  2. package/package.json +1 -1
@@ -10741,11 +10741,27 @@ const openapiDocument = {
10741
10741
  },
10742
10742
  "quota_mb": {
10743
10743
  "type": "number",
10744
- "description": "Storage quota in megabytes (based on plan)"
10744
+ "description": "The plan's included storage in megabytes, the same value as included_mb. It is an allowance, not a limit; see limit_mb."
10745
10745
  },
10746
10746
  "percentage": {
10747
10747
  "type": "number",
10748
- "description": "Percentage of quota used (1 decimal)"
10748
+ "description": "Storage used as a percentage of the included storage (1 decimal). Can exceed 100."
10749
+ },
10750
+ "included_mb": {
10751
+ "type": "number",
10752
+ "description": "Storage included with the plan, in megabytes."
10753
+ },
10754
+ "limit_mb": {
10755
+ "type": ["number", "null"],
10756
+ "description": "Storage in megabytes past which inbound email is refused. Null when inbound email is never refused for storage."
10757
+ },
10758
+ "overage_mb": {
10759
+ "type": "number",
10760
+ "description": "Storage past included_mb, in megabytes, counting stored email and the search index."
10761
+ },
10762
+ "search_index_bytes": {
10763
+ "type": "integer",
10764
+ "description": "Storage attributed to the semantic search index, in bytes. Counted toward included_mb and overage_mb, never toward limit_mb."
10749
10765
  },
10750
10766
  "emails_count": {
10751
10767
  "type": "integer",
@@ -16888,11 +16904,27 @@ const operationManifest = [
16888
16904
  },
16889
16905
  "quota_mb": {
16890
16906
  "type": "number",
16891
- "description": "Storage quota in megabytes (based on plan)"
16907
+ "description": "The plan's included storage in megabytes, the same value as included_mb. It is an allowance, not a limit; see limit_mb."
16892
16908
  },
16893
16909
  "percentage": {
16894
16910
  "type": "number",
16895
- "description": "Percentage of quota used (1 decimal)"
16911
+ "description": "Storage used as a percentage of the included storage (1 decimal). Can exceed 100."
16912
+ },
16913
+ "included_mb": {
16914
+ "type": "number",
16915
+ "description": "Storage included with the plan, in megabytes."
16916
+ },
16917
+ "limit_mb": {
16918
+ "type": ["number", "null"],
16919
+ "description": "Storage in megabytes past which inbound email is refused. Null when inbound email is never refused for storage."
16920
+ },
16921
+ "overage_mb": {
16922
+ "type": "number",
16923
+ "description": "Storage past included_mb, in megabytes, counting stored email and the search index."
16924
+ },
16925
+ "search_index_bytes": {
16926
+ "type": "integer",
16927
+ "description": "Storage attributed to the semantic search index, in bytes. Counted toward included_mb and overage_mb, never toward limit_mb."
16896
16928
  },
16897
16929
  "emails_count": {
16898
16930
  "type": "integer",
@@ -45850,7 +45882,7 @@ const PRIMITIVE_TEAM_AUTHOR = {
45850
45882
  url: "https://primitive.dev"
45851
45883
  };
45852
45884
  const SDK_VERSION_RANGE = "^1.34.0";
45853
- const CLI_VERSION_RANGE = "^1.38.0";
45885
+ const CLI_VERSION_RANGE = "^1.38.1";
45854
45886
  const ESBUILD_VERSION_RANGE = "^0.27.0";
45855
45887
  function renderHandler() {
45856
45888
  return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
@@ -51081,6 +51113,52 @@ function retryAfterSeconds$1(result) {
51081
51113
  const parsed = Number.parseInt(raw, 10);
51082
51114
  return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
51083
51115
  }
51116
+ const SIGN_IN_EMAIL_CHANGE_REQUIRED = "sign_in_email_change_required";
51117
+ const SIGN_IN_EMAIL_CHANGE_REQUIRED_FALLBACK = "Your Primitive sign-in email is on a domain Primitive receives mail for. Change it to an external address in the browser, then log in again.";
51118
+ function errorMessage$1(payload) {
51119
+ if (!payload || typeof payload !== "object") return null;
51120
+ const inner = payload.error;
51121
+ const message = (inner && typeof inner === "object" ? inner : payload).message;
51122
+ return typeof message === "string" && message.trim() !== "" ? message.trim() : null;
51123
+ }
51124
+ async function pollCliLoginUntilApproved(params) {
51125
+ const wait = params.sleep ?? sleep;
51126
+ const { retryCommand, start } = params;
51127
+ const deadline = Date.now() + start.expires_in * 1e3;
51128
+ let interval = Math.min(Math.max(1, start.interval), MAX_CLI_LOGIN_POLL_INTERVAL_SECONDS);
51129
+ let nextPollDelay = 1;
51130
+ while (Date.now() < deadline) {
51131
+ await wait(nextPollDelay * 1e3);
51132
+ nextPollDelay = interval;
51133
+ const polled = await params.poll(start.device_code);
51134
+ if (polled.data) {
51135
+ const login = unwrapData$2(polled.data);
51136
+ if (!login) throw cliError$3("Primitive API returned an empty CLI poll response.");
51137
+ return login;
51138
+ }
51139
+ const payload = extractErrorPayload(polled.error);
51140
+ const code = extractErrorCode(payload);
51141
+ if (code === API_ERROR_CODES.authorizationPending) {
51142
+ nextPollDelay = interval;
51143
+ continue;
51144
+ }
51145
+ if (code === API_ERROR_CODES.slowDown) {
51146
+ interval = Math.min(retryAfterSeconds$1(polled) ?? interval + 5, MAX_CLI_LOGIN_POLL_INTERVAL_SECONDS);
51147
+ nextPollDelay = interval;
51148
+ continue;
51149
+ }
51150
+ if (code === "sign_in_email_change_required") throw new Errors.CLIError(errorMessage$1(payload) ?? SIGN_IN_EMAIL_CHANGE_REQUIRED_FALLBACK, {
51151
+ code: SIGN_IN_EMAIL_CHANGE_REQUIRED,
51152
+ exit: 1
51153
+ });
51154
+ if (code === API_ERROR_CODES.accessDenied) throw cliError$3("Primitive CLI login was denied in the browser.");
51155
+ if (code === API_ERROR_CODES.expiredToken) throw cliError$3(`Primitive CLI login expired. Run \`primitive ${retryCommand}\` again.`);
51156
+ if (code === API_ERROR_CODES.invalidDeviceCode) throw cliError$3(`Primitive CLI login device code is invalid. Run \`primitive ${retryCommand}\` again.`);
51157
+ writeErrorWithHints(payload);
51158
+ throw cliError$3("Primitive CLI login failed while polling for approval.");
51159
+ }
51160
+ throw cliError$3(`Primitive CLI login expired. Run \`primitive ${retryCommand}\` again.`);
51161
+ }
51084
51162
  async function checkExistingLogin(params) {
51085
51163
  const requestConfig = resolveCliApiRequestConfig({
51086
51164
  apiBaseUrl: params.apiBaseUrl,
@@ -51217,57 +51295,32 @@ var LoginCommand$1 = class extends Command {
51217
51295
  }
51218
51296
  process.stderr.write(`If the browser did not open, visit: ${start.verification_uri_complete}\n`);
51219
51297
  process.stderr.write("Waiting for browser approval...\n");
51220
- const deadline = Date.now() + start.expires_in * 1e3;
51221
- let interval = Math.min(Math.max(1, start.interval), MAX_CLI_LOGIN_POLL_INTERVAL_SECONDS);
51222
- let nextPollDelay = 1;
51223
- while (Date.now() < deadline) {
51224
- await sleep(nextPollDelay * 1e3);
51225
- nextPollDelay = interval;
51226
- const polled = await pollCliLogin({
51227
- body: { device_code: start.device_code },
51298
+ const login = await pollCliLoginUntilApproved({
51299
+ poll: (deviceCode) => pollCliLogin({
51300
+ body: { device_code: deviceCode },
51228
51301
  client: apiClient.client,
51229
51302
  responseStyle: "fields"
51230
- });
51231
- if (polled.data) {
51232
- const login = unwrapData$2(polled.data);
51233
- if (!login) throw cliError$3("Primitive API returned an empty CLI poll response.");
51234
- deleteChatState(this.config.configDir);
51235
- saveCliCredentials(this.config.configDir, {
51236
- access_token: login.access_token,
51237
- api_base_url: apiBaseUrl,
51238
- auth_method: "oauth",
51239
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
51240
- expires_at: cliAccessTokenExpiresAt(login.expires_in),
51241
- oauth_client_id: login.oauth_client_id,
51242
- oauth_grant_id: login.oauth_grant_id,
51243
- org_id: login.org_id,
51244
- org_name: login.org_name,
51245
- refresh_token: login.refresh_token,
51246
- token_type: login.token_type
51247
- });
51248
- const org = login.org_name ? ` (${login.org_name})` : "";
51249
- process.stderr.write(`Logged in to org ${login.org_id}${org}.\n`);
51250
- process.stderr.write(`Saved credentials to ${credentialsPath(this.config.configDir)}.\n`);
51251
- return;
51252
- }
51253
- const payload = extractErrorPayload(polled.error);
51254
- const code = extractErrorCode(payload);
51255
- if (code === API_ERROR_CODES.authorizationPending) {
51256
- nextPollDelay = interval;
51257
- continue;
51258
- }
51259
- if (code === API_ERROR_CODES.slowDown) {
51260
- interval = Math.min(retryAfterSeconds$1(polled) ?? interval + 5, MAX_CLI_LOGIN_POLL_INTERVAL_SECONDS);
51261
- nextPollDelay = interval;
51262
- continue;
51263
- }
51264
- if (code === API_ERROR_CODES.accessDenied) throw cliError$3("Primitive CLI login was denied in the browser.");
51265
- if (code === API_ERROR_CODES.expiredToken) throw cliError$3(`Primitive CLI login expired. Run \`primitive ${retryCommand}\` again.`);
51266
- if (code === API_ERROR_CODES.invalidDeviceCode) throw cliError$3(`Primitive CLI login device code is invalid. Run \`primitive ${retryCommand}\` again.`);
51267
- writeErrorWithHints(payload);
51268
- throw cliError$3("Primitive CLI login failed while polling for approval.");
51269
- }
51270
- throw cliError$3(`Primitive CLI login expired. Run \`primitive ${retryCommand}\` again.`);
51303
+ }),
51304
+ retryCommand,
51305
+ start
51306
+ });
51307
+ deleteChatState(this.config.configDir);
51308
+ saveCliCredentials(this.config.configDir, {
51309
+ access_token: login.access_token,
51310
+ api_base_url: apiBaseUrl,
51311
+ auth_method: "oauth",
51312
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
51313
+ expires_at: cliAccessTokenExpiresAt(login.expires_in),
51314
+ oauth_client_id: login.oauth_client_id,
51315
+ oauth_grant_id: login.oauth_grant_id,
51316
+ org_id: login.org_id,
51317
+ org_name: login.org_name,
51318
+ refresh_token: login.refresh_token,
51319
+ token_type: login.token_type
51320
+ });
51321
+ const org = login.org_name ? ` (${login.org_name})` : "";
51322
+ process.stderr.write(`Logged in to org ${login.org_id}${org}.\n`);
51323
+ process.stderr.write(`Saved credentials to ${credentialsPath(this.config.configDir)}.\n`);
51271
51324
  }
51272
51325
  };
51273
51326
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primcli",
3
- "version": "1.38.0",
3
+ "version": "1.38.1",
4
4
  "description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
5
5
  "type": "module",
6
6
  "sideEffects": false,