@primitive.ai/prim 0.1.0-alpha.76 → 0.1.0-alpha.77

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 CHANGED
@@ -5582,7 +5582,8 @@ function validate42(data, { instancePath = "", parentData, parentDataProperty, r
5582
5582
  return errors === 0;
5583
5583
  }
5584
5584
  validate42.evaluated = { "dynamicProps": true, "dynamicItems": false };
5585
- var schema77 = { "anyOf": [{ "type": "object", "properties": { "error": { "type": "string", "const": "Unauthorized" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "interactive_workos_authority_required" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "feature_disabled" }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "enum": ["github_connect_unavailable", "feature_check_unavailable"] }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "github_install_intent_conflict" } }, "required": ["error"], "additionalProperties": false }] };
5585
+ var isGitHubInstallIntentStartErrorResponse = validate43;
5586
+ var schema77 = { "anyOf": [{ "type": "object", "properties": { "error": { "type": "string", "const": "Unauthorized" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "interactive_workos_authority_required" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "feature_disabled" }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "enum": ["github_connect_unavailable", "feature_check_unavailable"] }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "WorkOS identity authority is temporarily unavailable" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "github_install_intent_conflict" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "github_install_intent_rate_limited" }, "retryAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["error", "retryAt"], "additionalProperties": false }] };
5586
5587
  function validate43(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
5587
5588
  ;
5588
5589
  let vErrors = null;
@@ -5962,8 +5963,8 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
5962
5963
  }
5963
5964
  errors++;
5964
5965
  }
5965
- if ("github_install_intent_conflict" !== data6) {
5966
- const err27 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_conflict" }, message: "must be equal to constant" };
5966
+ if ("WorkOS identity authority is temporarily unavailable" !== data6) {
5967
+ const err27 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/const", keyword: "const", params: { allowedValue: "WorkOS identity authority is temporarily unavailable" }, message: "must be equal to constant" };
5967
5968
  if (vErrors === null) {
5968
5969
  vErrors = [err27];
5969
5970
  } else {
@@ -5991,12 +5992,191 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
5991
5992
  props0 = true;
5992
5993
  }
5993
5994
  }
5995
+ const _errs31 = errors;
5996
+ if (errors === _errs31) {
5997
+ if (data && typeof data == "object" && !Array.isArray(data)) {
5998
+ let missing5;
5999
+ if (data.error === void 0 && (missing5 = "error")) {
6000
+ const err29 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/required", keyword: "required", params: { missingProperty: missing5 }, message: "must have required property '" + missing5 + "'" };
6001
+ if (vErrors === null) {
6002
+ vErrors = [err29];
6003
+ } else {
6004
+ vErrors.push(err29);
6005
+ }
6006
+ errors++;
6007
+ } else {
6008
+ const _errs33 = errors;
6009
+ for (const key5 in data) {
6010
+ if (!(key5 === "error")) {
6011
+ const err30 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
6012
+ if (vErrors === null) {
6013
+ vErrors = [err30];
6014
+ } else {
6015
+ vErrors.push(err30);
6016
+ }
6017
+ errors++;
6018
+ break;
6019
+ }
6020
+ }
6021
+ if (_errs33 === errors) {
6022
+ if (data.error !== void 0) {
6023
+ let data7 = data.error;
6024
+ if (typeof data7 !== "string") {
6025
+ const err31 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
6026
+ if (vErrors === null) {
6027
+ vErrors = [err31];
6028
+ } else {
6029
+ vErrors.push(err31);
6030
+ }
6031
+ errors++;
6032
+ }
6033
+ if ("github_install_intent_conflict" !== data7) {
6034
+ const err32 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_conflict" }, message: "must be equal to constant" };
6035
+ if (vErrors === null) {
6036
+ vErrors = [err32];
6037
+ } else {
6038
+ vErrors.push(err32);
6039
+ }
6040
+ errors++;
6041
+ }
6042
+ }
6043
+ }
6044
+ }
6045
+ } else {
6046
+ const err33 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
6047
+ if (vErrors === null) {
6048
+ vErrors = [err33];
6049
+ } else {
6050
+ vErrors.push(err33);
6051
+ }
6052
+ errors++;
6053
+ }
6054
+ }
6055
+ var _valid0 = _errs31 === errors;
6056
+ valid1 = valid1 || _valid0;
6057
+ if (_valid0) {
6058
+ if (props0 !== true) {
6059
+ props0 = true;
6060
+ }
6061
+ }
6062
+ const _errs36 = errors;
6063
+ if (errors === _errs36) {
6064
+ if (data && typeof data == "object" && !Array.isArray(data)) {
6065
+ let missing6;
6066
+ if (data.error === void 0 && (missing6 = "error") || data.retryAt === void 0 && (missing6 = "retryAt")) {
6067
+ const err34 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/required", keyword: "required", params: { missingProperty: missing6 }, message: "must have required property '" + missing6 + "'" };
6068
+ if (vErrors === null) {
6069
+ vErrors = [err34];
6070
+ } else {
6071
+ vErrors.push(err34);
6072
+ }
6073
+ errors++;
6074
+ } else {
6075
+ const _errs38 = errors;
6076
+ for (const key6 in data) {
6077
+ if (!(key6 === "error" || key6 === "retryAt")) {
6078
+ const err35 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key6 }, message: "must NOT have additional properties" };
6079
+ if (vErrors === null) {
6080
+ vErrors = [err35];
6081
+ } else {
6082
+ vErrors.push(err35);
6083
+ }
6084
+ errors++;
6085
+ break;
6086
+ }
6087
+ }
6088
+ if (_errs38 === errors) {
6089
+ if (data.error !== void 0) {
6090
+ let data8 = data.error;
6091
+ const _errs39 = errors;
6092
+ if (typeof data8 !== "string") {
6093
+ const err36 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
6094
+ if (vErrors === null) {
6095
+ vErrors = [err36];
6096
+ } else {
6097
+ vErrors.push(err36);
6098
+ }
6099
+ errors++;
6100
+ }
6101
+ if ("github_install_intent_rate_limited" !== data8) {
6102
+ const err37 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_rate_limited" }, message: "must be equal to constant" };
6103
+ if (vErrors === null) {
6104
+ vErrors = [err37];
6105
+ } else {
6106
+ vErrors.push(err37);
6107
+ }
6108
+ errors++;
6109
+ }
6110
+ var valid8 = _errs39 === errors;
6111
+ } else {
6112
+ var valid8 = true;
6113
+ }
6114
+ if (valid8) {
6115
+ if (data.retryAt !== void 0) {
6116
+ let data9 = data.retryAt;
6117
+ const _errs41 = errors;
6118
+ if (!(typeof data9 == "number" && (!(data9 % 1) && !isNaN(data9)) && isFinite(data9))) {
6119
+ const err38 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
6120
+ if (vErrors === null) {
6121
+ vErrors = [err38];
6122
+ } else {
6123
+ vErrors.push(err38);
6124
+ }
6125
+ errors++;
6126
+ }
6127
+ if (errors === _errs41) {
6128
+ if (typeof data9 == "number" && isFinite(data9)) {
6129
+ if (data9 > 9007199254740991 || isNaN(data9)) {
6130
+ const err39 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
6131
+ if (vErrors === null) {
6132
+ vErrors = [err39];
6133
+ } else {
6134
+ vErrors.push(err39);
6135
+ }
6136
+ errors++;
6137
+ } else {
6138
+ if (data9 < 0 || isNaN(data9)) {
6139
+ const err40 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
6140
+ if (vErrors === null) {
6141
+ vErrors = [err40];
6142
+ } else {
6143
+ vErrors.push(err40);
6144
+ }
6145
+ errors++;
6146
+ }
6147
+ }
6148
+ }
6149
+ }
6150
+ var valid8 = _errs41 === errors;
6151
+ } else {
6152
+ var valid8 = true;
6153
+ }
6154
+ }
6155
+ }
6156
+ }
6157
+ } else {
6158
+ const err41 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/type", keyword: "type", params: { type: "object" }, message: "must be object" };
6159
+ if (vErrors === null) {
6160
+ vErrors = [err41];
6161
+ } else {
6162
+ vErrors.push(err41);
6163
+ }
6164
+ errors++;
6165
+ }
6166
+ }
6167
+ var _valid0 = _errs36 === errors;
6168
+ valid1 = valid1 || _valid0;
6169
+ if (_valid0) {
6170
+ if (props0 !== true) {
6171
+ props0 = true;
6172
+ }
6173
+ }
5994
6174
  if (!valid1) {
5995
- const err29 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
6175
+ const err42 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
5996
6176
  if (vErrors === null) {
5997
- vErrors = [err29];
6177
+ vErrors = [err42];
5998
6178
  } else {
5999
- vErrors.push(err29);
6179
+ vErrors.push(err42);
6000
6180
  }
6001
6181
  errors++;
6002
6182
  validate43.errors = vErrors;
@@ -6373,8 +6553,8 @@ function validate45(data, { instancePath = "", parentData, parentDataProperty, r
6373
6553
  }
6374
6554
  errors++;
6375
6555
  }
6376
- if ("github_install_intent_not_found" !== data2) {
6377
- const err13 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/2/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_not_found" }, message: "must be equal to constant" };
6556
+ if ("WorkOS identity authority is temporarily unavailable" !== data2) {
6557
+ const err13 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/2/properties/error/const", keyword: "const", params: { allowedValue: "WorkOS identity authority is temporarily unavailable" }, message: "must be equal to constant" };
6378
6558
  if (vErrors === null) {
6379
6559
  vErrors = [err13];
6380
6560
  } else {
@@ -6402,12 +6582,79 @@ function validate45(data, { instancePath = "", parentData, parentDataProperty, r
6402
6582
  props0 = true;
6403
6583
  }
6404
6584
  }
6585
+ const _errs17 = errors;
6586
+ if (errors === _errs17) {
6587
+ if (data && typeof data == "object" && !Array.isArray(data)) {
6588
+ let missing3;
6589
+ if (data.error === void 0 && (missing3 = "error")) {
6590
+ const err15 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/3/required", keyword: "required", params: { missingProperty: missing3 }, message: "must have required property '" + missing3 + "'" };
6591
+ if (vErrors === null) {
6592
+ vErrors = [err15];
6593
+ } else {
6594
+ vErrors.push(err15);
6595
+ }
6596
+ errors++;
6597
+ } else {
6598
+ const _errs19 = errors;
6599
+ for (const key3 in data) {
6600
+ if (!(key3 === "error")) {
6601
+ const err16 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
6602
+ if (vErrors === null) {
6603
+ vErrors = [err16];
6604
+ } else {
6605
+ vErrors.push(err16);
6606
+ }
6607
+ errors++;
6608
+ break;
6609
+ }
6610
+ }
6611
+ if (_errs19 === errors) {
6612
+ if (data.error !== void 0) {
6613
+ let data3 = data.error;
6614
+ if (typeof data3 !== "string") {
6615
+ const err17 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/3/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
6616
+ if (vErrors === null) {
6617
+ vErrors = [err17];
6618
+ } else {
6619
+ vErrors.push(err17);
6620
+ }
6621
+ errors++;
6622
+ }
6623
+ if ("github_install_intent_not_found" !== data3) {
6624
+ const err18 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/3/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_not_found" }, message: "must be equal to constant" };
6625
+ if (vErrors === null) {
6626
+ vErrors = [err18];
6627
+ } else {
6628
+ vErrors.push(err18);
6629
+ }
6630
+ errors++;
6631
+ }
6632
+ }
6633
+ }
6634
+ }
6635
+ } else {
6636
+ const err19 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
6637
+ if (vErrors === null) {
6638
+ vErrors = [err19];
6639
+ } else {
6640
+ vErrors.push(err19);
6641
+ }
6642
+ errors++;
6643
+ }
6644
+ }
6645
+ var _valid0 = _errs17 === errors;
6646
+ valid1 = valid1 || _valid0;
6647
+ if (_valid0) {
6648
+ if (props0 !== true) {
6649
+ props0 = true;
6650
+ }
6651
+ }
6405
6652
  if (!valid1) {
6406
- const err15 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
6653
+ const err20 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
6407
6654
  if (vErrors === null) {
6408
- vErrors = [err15];
6655
+ vErrors = [err20];
6409
6656
  } else {
6410
- vErrors.push(err15);
6657
+ vErrors.push(err20);
6411
6658
  }
6412
6659
  errors++;
6413
6660
  validate45.errors = vErrors;
@@ -6482,7 +6729,7 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
6482
6729
  }
6483
6730
  validate46.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
6484
6731
  var isGitHubInstallIntentStatusResponseStructure = validate47;
6485
- var schema85 = { "anyOf": [{ "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "pending" } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status"], "additionalProperties": false }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "claimed" }, "leaseExpiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "leaseExpiresAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["claim_lease_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "consumed" }, "completedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "repositoryCount": { "type": "integer", "minimum": 1, "maximum": 256 }, "adminRepositoryCount": { "type": "integer", "minimum": 1, "maximum": 128 }, "nonAdminRepositoryCount": { "type": "integer", "minimum": 0, "maximum": 256 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "completedAt", "repositoryCount", "adminRepositoryCount", "nonAdminRepositoryCount"], "additionalProperties": false, "x-primitive-runtime-refinements": ["repository_count_partition", "completion_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "expired" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["expiry_not_before_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "cancelled" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["cancellation_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "failed_terminal" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "failureCode": { "type": "string", "enum": ["claim_lease_expired", "authority_changed", "oauth_exchange_failed", "installation_not_administered", "repository_enumeration_failed", "repository_bound_exceeded", "installation_changed", "proof_commit_failed"] } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt", "failureCode"], "additionalProperties": false, "x-primitive-runtime-refinements": ["terminal_failure_within_intent_ttl_except_claim_lease_expired"] }] };
6732
+ var schema85 = { "anyOf": [{ "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "pending" } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status"], "additionalProperties": false }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "claimed" }, "leaseExpiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "leaseExpiresAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["claim_lease_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "consumed" }, "completedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "repositoryCount": { "type": "integer", "minimum": 1, "maximum": 256 }, "adminRepositoryCount": { "type": "integer", "minimum": 1, "maximum": 128 }, "nonAdminRepositoryCount": { "type": "integer", "minimum": 0, "maximum": 256 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "completedAt", "repositoryCount", "adminRepositoryCount", "nonAdminRepositoryCount"], "additionalProperties": false, "x-primitive-runtime-refinements": ["repository_count_partition", "completion_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "expired" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["expiry_not_before_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "cancelled" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt"], "additionalProperties": false, "x-primitive-runtime-refinements": ["cancellation_within_intent_ttl"] }, { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 1 }, "mode": { "type": "string", "const": "install_intent_v1" }, "found": { "type": "boolean", "const": true }, "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "status": { "type": "string", "const": "failed_terminal" }, "closedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "failureCode": { "type": "string", "enum": ["claim_lease_expired", "authority_changed", "oauth_exchange_failed", "installation_not_administered", "repository_enumeration_failed", "repository_bound_exceeded", "installation_changed", "repository_identity_migration_required", "proof_commit_failed"] } }, "required": ["protocolVersion", "mode", "found", "expiresAt", "status", "closedAt", "failureCode"], "additionalProperties": false, "x-primitive-runtime-refinements": ["terminal_failure_within_intent_ttl_except_claim_lease_expired"] }] };
6486
6733
  var func32 = Object.prototype.hasOwnProperty;
6487
6734
  function validate47(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
6488
6735
  ;
@@ -7970,7 +8217,7 @@ function validate47(data, { instancePath = "", parentData, parentDataProperty, r
7970
8217
  }
7971
8218
  errors++;
7972
8219
  }
7973
- if (!(data38 === "claim_lease_expired" || data38 === "authority_changed" || data38 === "oauth_exchange_failed" || data38 === "installation_not_administered" || data38 === "repository_enumeration_failed" || data38 === "repository_bound_exceeded" || data38 === "installation_changed" || data38 === "proof_commit_failed")) {
8220
+ if (!(data38 === "claim_lease_expired" || data38 === "authority_changed" || data38 === "oauth_exchange_failed" || data38 === "installation_not_administered" || data38 === "repository_enumeration_failed" || data38 === "repository_bound_exceeded" || data38 === "installation_changed" || data38 === "repository_identity_migration_required" || data38 === "proof_commit_failed")) {
7974
8221
  const err108 = { instancePath: instancePath + "/failureCode", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusResponse/anyOf/5/properties/failureCode/enum", keyword: "enum", params: { allowedValues: schema85.anyOf[5].properties.failureCode.enum }, message: "must be equal to one of the allowed values" };
7975
8222
  if (vErrors === null) {
7976
8223
  vErrors = [err108];
@@ -9876,67 +10123,1804 @@ function validate54(data, { instancePath = "", parentData, parentDataProperty, r
9876
10123
  return errors === 0;
9877
10124
  }
9878
10125
  validate54.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
9879
-
9880
- // src/contract/cli-http-v1.ts
9881
- function isGitHubInstallIntentStatusResponse(value) {
9882
- if (!isGitHubInstallIntentStatusResponseStructure(value)) {
9883
- return false;
10126
+ var pattern17 = new RegExp("^[a-f0-9]{64}$", "u");
10127
+ var pattern18 = new RegExp("^api_key_[A-Za-z0-9_-]+$", "u");
10128
+ function validate55(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
10129
+ ;
10130
+ let vErrors = null;
10131
+ let errors = 0;
10132
+ const evaluated0 = validate55.evaluated;
10133
+ if (evaluated0.dynamicProps) {
10134
+ evaluated0.props = void 0;
9884
10135
  }
9885
- switch (value.status) {
9886
- case "claimed":
9887
- return value.leaseExpiresAt <= value.expiresAt;
9888
- case "consumed":
9889
- return value.repositoryCount === value.adminRepositoryCount + value.nonAdminRepositoryCount && value.completedAt <= value.expiresAt;
9890
- case "expired":
9891
- return value.closedAt >= value.expiresAt;
9892
- case "cancelled":
9893
- return value.closedAt <= value.expiresAt;
9894
- case "failed_terminal":
9895
- return value.failureCode === "claim_lease_expired" || value.closedAt <= value.expiresAt;
9896
- case "pending":
9897
- return true;
10136
+ if (evaluated0.dynamicItems) {
10137
+ evaluated0.items = void 0;
10138
+ }
10139
+ const _errs0 = errors;
10140
+ if (errors === _errs0) {
10141
+ if (data && typeof data == "object" && !Array.isArray(data)) {
10142
+ let missing0;
10143
+ if (data.requestId === void 0 && (missing0 = "requestId") || data.limit === void 0 && (missing0 = "limit")) {
10144
+ validate55.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
10145
+ return false;
10146
+ } else {
10147
+ const _errs2 = errors;
10148
+ for (const key0 in data) {
10149
+ if (!(key0 === "requestId" || key0 === "limit" || key0 === "after")) {
10150
+ validate55.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
10151
+ return false;
10152
+ break;
10153
+ }
10154
+ }
10155
+ if (_errs2 === errors) {
10156
+ if (data.requestId !== void 0) {
10157
+ let data0 = data.requestId;
10158
+ const _errs3 = errors;
10159
+ if (errors === _errs3) {
10160
+ if (typeof data0 === "string") {
10161
+ if (!pattern17.test(data0)) {
10162
+ validate55.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/requestId/pattern", keyword: "pattern", params: { pattern: "^[a-f0-9]{64}$" }, message: 'must match pattern "^[a-f0-9]{64}$"' }];
10163
+ return false;
10164
+ }
10165
+ } else {
10166
+ validate55.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/requestId/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10167
+ return false;
10168
+ }
10169
+ }
10170
+ var valid1 = _errs3 === errors;
10171
+ } else {
10172
+ var valid1 = true;
10173
+ }
10174
+ if (valid1) {
10175
+ if (data.limit !== void 0) {
10176
+ let data1 = data.limit;
10177
+ const _errs5 = errors;
10178
+ if (!(typeof data1 == "number" && (!(data1 % 1) && !isNaN(data1)) && isFinite(data1))) {
10179
+ validate55.errors = [{ instancePath: instancePath + "/limit", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/limit/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
10180
+ return false;
10181
+ }
10182
+ if (errors === _errs5) {
10183
+ if (typeof data1 == "number" && isFinite(data1)) {
10184
+ if (data1 > 100 || isNaN(data1)) {
10185
+ validate55.errors = [{ instancePath: instancePath + "/limit", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/limit/maximum", keyword: "maximum", params: { comparison: "<=", limit: 100 }, message: "must be <= 100" }];
10186
+ return false;
10187
+ } else {
10188
+ if (data1 < 1 || isNaN(data1)) {
10189
+ validate55.errors = [{ instancePath: instancePath + "/limit", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/limit/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" }];
10190
+ return false;
10191
+ }
10192
+ }
10193
+ }
10194
+ }
10195
+ var valid1 = _errs5 === errors;
10196
+ } else {
10197
+ var valid1 = true;
10198
+ }
10199
+ if (valid1) {
10200
+ if (data.after !== void 0) {
10201
+ let data2 = data.after;
10202
+ const _errs7 = errors;
10203
+ if (errors === _errs7) {
10204
+ if (typeof data2 === "string") {
10205
+ if (func1(data2) > 256) {
10206
+ validate55.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
10207
+ return false;
10208
+ } else {
10209
+ if (func1(data2) < 9) {
10210
+ validate55.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
10211
+ return false;
10212
+ } else {
10213
+ if (!pattern18.test(data2)) {
10214
+ validate55.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
10215
+ return false;
10216
+ }
10217
+ }
10218
+ }
10219
+ } else {
10220
+ validate55.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10221
+ return false;
10222
+ }
10223
+ }
10224
+ var valid1 = _errs7 === errors;
10225
+ } else {
10226
+ var valid1 = true;
10227
+ }
10228
+ }
10229
+ }
10230
+ }
10231
+ }
10232
+ } else {
10233
+ validate55.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
10234
+ return false;
10235
+ }
9898
10236
  }
10237
+ validate55.errors = vErrors;
10238
+ return errors === 0;
9899
10239
  }
9900
-
9901
- // src/lib/github-install-intent.ts
9902
- var PROTOCOL_VERSION = 1;
10240
+ validate55.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
10241
+ var pattern20 = new RegExp("^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$", "u");
10242
+ var pattern21 = new RegExp("^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$", "u");
10243
+ var pattern22 = new RegExp("^[\\x21-\\x7e]+$", "u");
10244
+ function validate56(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
10245
+ ;
10246
+ let vErrors = null;
10247
+ let errors = 0;
10248
+ const evaluated0 = validate56.evaluated;
10249
+ if (evaluated0.dynamicProps) {
10250
+ evaluated0.props = void 0;
10251
+ }
10252
+ if (evaluated0.dynamicItems) {
10253
+ evaluated0.items = void 0;
10254
+ }
10255
+ const _errs0 = errors;
10256
+ if (errors === _errs0) {
10257
+ if (data && typeof data == "object" && !Array.isArray(data)) {
10258
+ let missing0;
10259
+ if (data.apiKeys === void 0 && (missing0 = "apiKeys") || data.nextCursor === void 0 && (missing0 = "nextCursor")) {
10260
+ validate56.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
10261
+ return false;
10262
+ } else {
10263
+ const _errs2 = errors;
10264
+ for (const key0 in data) {
10265
+ if (!(key0 === "apiKeys" || key0 === "nextCursor")) {
10266
+ validate56.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
10267
+ return false;
10268
+ break;
10269
+ }
10270
+ }
10271
+ if (_errs2 === errors) {
10272
+ if (data.apiKeys !== void 0) {
10273
+ let data0 = data.apiKeys;
10274
+ const _errs3 = errors;
10275
+ if (errors === _errs3) {
10276
+ if (Array.isArray(data0)) {
10277
+ if (data0.length > 100) {
10278
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/maxItems", keyword: "maxItems", params: { limit: 100 }, message: "must NOT have more than 100 items" }];
10279
+ return false;
10280
+ } else {
10281
+ var valid2 = true;
10282
+ const len0 = data0.length;
10283
+ for (let i0 = 0; i0 < len0; i0++) {
10284
+ let data1 = data0[i0];
10285
+ const _errs5 = errors;
10286
+ if (errors === _errs5) {
10287
+ if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
10288
+ let missing1;
10289
+ if (data1.id === void 0 && (missing1 = "id") || data1.name === void 0 && (missing1 = "name") || data1.obfuscatedValue === void 0 && (missing1 = "obfuscatedValue") || data1.permissions === void 0 && (missing1 = "permissions") || data1.lastUsedAt === void 0 && (missing1 = "lastUsedAt") || data1.expiresAt === void 0 && (missing1 = "expiresAt") || data1.createdAt === void 0 && (missing1 = "createdAt") || data1.updatedAt === void 0 && (missing1 = "updatedAt")) {
10290
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
10291
+ return false;
10292
+ } else {
10293
+ const _errs7 = errors;
10294
+ for (const key1 in data1) {
10295
+ if (!(key1 === "id" || key1 === "name" || key1 === "obfuscatedValue" || key1 === "permissions" || key1 === "lastUsedAt" || key1 === "expiresAt" || key1 === "createdAt" || key1 === "updatedAt")) {
10296
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" }];
10297
+ return false;
10298
+ break;
10299
+ }
10300
+ }
10301
+ if (_errs7 === errors) {
10302
+ if (data1.id !== void 0) {
10303
+ let data2 = data1.id;
10304
+ const _errs8 = errors;
10305
+ if (errors === _errs8) {
10306
+ if (typeof data2 === "string") {
10307
+ if (func1(data2) > 256) {
10308
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
10309
+ return false;
10310
+ } else {
10311
+ if (func1(data2) < 9) {
10312
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
10313
+ return false;
10314
+ } else {
10315
+ if (!pattern18.test(data2)) {
10316
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
10317
+ return false;
10318
+ }
10319
+ }
10320
+ }
10321
+ } else {
10322
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10323
+ return false;
10324
+ }
10325
+ }
10326
+ var valid3 = _errs8 === errors;
10327
+ } else {
10328
+ var valid3 = true;
10329
+ }
10330
+ if (valid3) {
10331
+ if (data1.name !== void 0) {
10332
+ let data3 = data1.name;
10333
+ const _errs10 = errors;
10334
+ if (errors === _errs10) {
10335
+ if (typeof data3 === "string") {
10336
+ if (func1(data3) > 128) {
10337
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
10338
+ return false;
10339
+ } else {
10340
+ if (func1(data3) < 1) {
10341
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10342
+ return false;
10343
+ } else {
10344
+ if (!pattern20.test(data3)) {
10345
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
10346
+ return false;
10347
+ }
10348
+ }
10349
+ }
10350
+ } else {
10351
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10352
+ return false;
10353
+ }
10354
+ }
10355
+ var valid3 = _errs10 === errors;
10356
+ } else {
10357
+ var valid3 = true;
10358
+ }
10359
+ if (valid3) {
10360
+ if (data1.obfuscatedValue !== void 0) {
10361
+ let data4 = data1.obfuscatedValue;
10362
+ const _errs12 = errors;
10363
+ if (errors === _errs12) {
10364
+ if (typeof data4 === "string") {
10365
+ if (func1(data4) > 256) {
10366
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
10367
+ return false;
10368
+ } else {
10369
+ if (func1(data4) < 1) {
10370
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10371
+ return false;
10372
+ } else {
10373
+ if (!pattern21.test(data4)) {
10374
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
10375
+ return false;
10376
+ }
10377
+ }
10378
+ }
10379
+ } else {
10380
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10381
+ return false;
10382
+ }
10383
+ }
10384
+ var valid3 = _errs12 === errors;
10385
+ } else {
10386
+ var valid3 = true;
10387
+ }
10388
+ if (valid3) {
10389
+ if (data1.permissions !== void 0) {
10390
+ let data5 = data1.permissions;
10391
+ const _errs14 = errors;
10392
+ if (errors === _errs14) {
10393
+ if (Array.isArray(data5)) {
10394
+ if (data5.length > 100) {
10395
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/maxItems", keyword: "maxItems", params: { limit: 100 }, message: "must NOT have more than 100 items" }];
10396
+ return false;
10397
+ } else {
10398
+ var valid4 = true;
10399
+ const len1 = data5.length;
10400
+ for (let i1 = 0; i1 < len1; i1++) {
10401
+ let data6 = data5[i1];
10402
+ const _errs16 = errors;
10403
+ if (errors === _errs16) {
10404
+ if (typeof data6 === "string") {
10405
+ if (func1(data6) > 128) {
10406
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
10407
+ return false;
10408
+ } else {
10409
+ if (func1(data6) < 1) {
10410
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10411
+ return false;
10412
+ } else {
10413
+ if (!pattern22.test(data6)) {
10414
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
10415
+ return false;
10416
+ }
10417
+ }
10418
+ }
10419
+ } else {
10420
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10421
+ return false;
10422
+ }
10423
+ }
10424
+ var valid4 = _errs16 === errors;
10425
+ if (!valid4) {
10426
+ break;
10427
+ }
10428
+ }
10429
+ }
10430
+ } else {
10431
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/type", keyword: "type", params: { type: "array" }, message: "must be array" }];
10432
+ return false;
10433
+ }
10434
+ }
10435
+ var valid3 = _errs14 === errors;
10436
+ } else {
10437
+ var valid3 = true;
10438
+ }
10439
+ if (valid3) {
10440
+ if (data1.lastUsedAt !== void 0) {
10441
+ let data7 = data1.lastUsedAt;
10442
+ const _errs18 = errors;
10443
+ const _errs19 = errors;
10444
+ let valid5 = false;
10445
+ const _errs20 = errors;
10446
+ if (!(typeof data7 == "number" && (!(data7 % 1) && !isNaN(data7)) && isFinite(data7))) {
10447
+ const err0 = { instancePath: instancePath + "/apiKeys/" + i0 + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/lastUsedAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
10448
+ if (vErrors === null) {
10449
+ vErrors = [err0];
10450
+ } else {
10451
+ vErrors.push(err0);
10452
+ }
10453
+ errors++;
10454
+ }
10455
+ if (errors === _errs20) {
10456
+ if (typeof data7 == "number" && isFinite(data7)) {
10457
+ if (data7 > 9007199254740991 || isNaN(data7)) {
10458
+ const err1 = { instancePath: instancePath + "/apiKeys/" + i0 + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/lastUsedAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
10459
+ if (vErrors === null) {
10460
+ vErrors = [err1];
10461
+ } else {
10462
+ vErrors.push(err1);
10463
+ }
10464
+ errors++;
10465
+ } else {
10466
+ if (data7 < 0 || isNaN(data7)) {
10467
+ const err2 = { instancePath: instancePath + "/apiKeys/" + i0 + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/lastUsedAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
10468
+ if (vErrors === null) {
10469
+ vErrors = [err2];
10470
+ } else {
10471
+ vErrors.push(err2);
10472
+ }
10473
+ errors++;
10474
+ }
10475
+ }
10476
+ }
10477
+ }
10478
+ var _valid0 = _errs20 === errors;
10479
+ valid5 = valid5 || _valid0;
10480
+ const _errs22 = errors;
10481
+ if (data7 !== null) {
10482
+ const err3 = { instancePath: instancePath + "/apiKeys/" + i0 + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/lastUsedAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
10483
+ if (vErrors === null) {
10484
+ vErrors = [err3];
10485
+ } else {
10486
+ vErrors.push(err3);
10487
+ }
10488
+ errors++;
10489
+ }
10490
+ var _valid0 = _errs22 === errors;
10491
+ valid5 = valid5 || _valid0;
10492
+ if (!valid5) {
10493
+ const err4 = { instancePath: instancePath + "/apiKeys/" + i0 + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/lastUsedAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
10494
+ if (vErrors === null) {
10495
+ vErrors = [err4];
10496
+ } else {
10497
+ vErrors.push(err4);
10498
+ }
10499
+ errors++;
10500
+ validate56.errors = vErrors;
10501
+ return false;
10502
+ } else {
10503
+ errors = _errs19;
10504
+ if (vErrors !== null) {
10505
+ if (_errs19) {
10506
+ vErrors.length = _errs19;
10507
+ } else {
10508
+ vErrors = null;
10509
+ }
10510
+ }
10511
+ }
10512
+ var valid3 = _errs18 === errors;
10513
+ } else {
10514
+ var valid3 = true;
10515
+ }
10516
+ if (valid3) {
10517
+ if (data1.expiresAt !== void 0) {
10518
+ let data8 = data1.expiresAt;
10519
+ const _errs24 = errors;
10520
+ const _errs25 = errors;
10521
+ let valid6 = false;
10522
+ const _errs26 = errors;
10523
+ if (!(typeof data8 == "number" && (!(data8 % 1) && !isNaN(data8)) && isFinite(data8))) {
10524
+ const err5 = { instancePath: instancePath + "/apiKeys/" + i0 + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/expiresAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
10525
+ if (vErrors === null) {
10526
+ vErrors = [err5];
10527
+ } else {
10528
+ vErrors.push(err5);
10529
+ }
10530
+ errors++;
10531
+ }
10532
+ if (errors === _errs26) {
10533
+ if (typeof data8 == "number" && isFinite(data8)) {
10534
+ if (data8 > 9007199254740991 || isNaN(data8)) {
10535
+ const err6 = { instancePath: instancePath + "/apiKeys/" + i0 + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/expiresAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
10536
+ if (vErrors === null) {
10537
+ vErrors = [err6];
10538
+ } else {
10539
+ vErrors.push(err6);
10540
+ }
10541
+ errors++;
10542
+ } else {
10543
+ if (data8 < 0 || isNaN(data8)) {
10544
+ const err7 = { instancePath: instancePath + "/apiKeys/" + i0 + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/expiresAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
10545
+ if (vErrors === null) {
10546
+ vErrors = [err7];
10547
+ } else {
10548
+ vErrors.push(err7);
10549
+ }
10550
+ errors++;
10551
+ }
10552
+ }
10553
+ }
10554
+ }
10555
+ var _valid1 = _errs26 === errors;
10556
+ valid6 = valid6 || _valid1;
10557
+ const _errs28 = errors;
10558
+ if (data8 !== null) {
10559
+ const err8 = { instancePath: instancePath + "/apiKeys/" + i0 + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/expiresAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
10560
+ if (vErrors === null) {
10561
+ vErrors = [err8];
10562
+ } else {
10563
+ vErrors.push(err8);
10564
+ }
10565
+ errors++;
10566
+ }
10567
+ var _valid1 = _errs28 === errors;
10568
+ valid6 = valid6 || _valid1;
10569
+ if (!valid6) {
10570
+ const err9 = { instancePath: instancePath + "/apiKeys/" + i0 + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/expiresAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
10571
+ if (vErrors === null) {
10572
+ vErrors = [err9];
10573
+ } else {
10574
+ vErrors.push(err9);
10575
+ }
10576
+ errors++;
10577
+ validate56.errors = vErrors;
10578
+ return false;
10579
+ } else {
10580
+ errors = _errs25;
10581
+ if (vErrors !== null) {
10582
+ if (_errs25) {
10583
+ vErrors.length = _errs25;
10584
+ } else {
10585
+ vErrors = null;
10586
+ }
10587
+ }
10588
+ }
10589
+ var valid3 = _errs24 === errors;
10590
+ } else {
10591
+ var valid3 = true;
10592
+ }
10593
+ if (valid3) {
10594
+ if (data1.createdAt !== void 0) {
10595
+ let data9 = data1.createdAt;
10596
+ const _errs30 = errors;
10597
+ if (!(typeof data9 == "number" && (!(data9 % 1) && !isNaN(data9)) && isFinite(data9))) {
10598
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/createdAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
10599
+ return false;
10600
+ }
10601
+ if (errors === _errs30) {
10602
+ if (typeof data9 == "number" && isFinite(data9)) {
10603
+ if (data9 > 9007199254740991 || isNaN(data9)) {
10604
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/createdAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
10605
+ return false;
10606
+ } else {
10607
+ if (data9 < 0 || isNaN(data9)) {
10608
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/createdAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
10609
+ return false;
10610
+ }
10611
+ }
10612
+ }
10613
+ }
10614
+ var valid3 = _errs30 === errors;
10615
+ } else {
10616
+ var valid3 = true;
10617
+ }
10618
+ if (valid3) {
10619
+ if (data1.updatedAt !== void 0) {
10620
+ let data10 = data1.updatedAt;
10621
+ const _errs32 = errors;
10622
+ if (!(typeof data10 == "number" && (!(data10 % 1) && !isNaN(data10)) && isFinite(data10))) {
10623
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/updatedAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
10624
+ return false;
10625
+ }
10626
+ if (errors === _errs32) {
10627
+ if (typeof data10 == "number" && isFinite(data10)) {
10628
+ if (data10 > 9007199254740991 || isNaN(data10)) {
10629
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/updatedAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
10630
+ return false;
10631
+ } else {
10632
+ if (data10 < 0 || isNaN(data10)) {
10633
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/updatedAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
10634
+ return false;
10635
+ }
10636
+ }
10637
+ }
10638
+ }
10639
+ var valid3 = _errs32 === errors;
10640
+ } else {
10641
+ var valid3 = true;
10642
+ }
10643
+ }
10644
+ }
10645
+ }
10646
+ }
10647
+ }
10648
+ }
10649
+ }
10650
+ }
10651
+ }
10652
+ } else {
10653
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
10654
+ return false;
10655
+ }
10656
+ }
10657
+ var valid2 = _errs5 === errors;
10658
+ if (!valid2) {
10659
+ break;
10660
+ }
10661
+ }
10662
+ }
10663
+ } else {
10664
+ validate56.errors = [{ instancePath: instancePath + "/apiKeys", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/type", keyword: "type", params: { type: "array" }, message: "must be array" }];
10665
+ return false;
10666
+ }
10667
+ }
10668
+ var valid1 = _errs3 === errors;
10669
+ } else {
10670
+ var valid1 = true;
10671
+ }
10672
+ if (valid1) {
10673
+ if (data.nextCursor !== void 0) {
10674
+ let data11 = data.nextCursor;
10675
+ const _errs34 = errors;
10676
+ const _errs35 = errors;
10677
+ let valid7 = false;
10678
+ const _errs36 = errors;
10679
+ if (errors === _errs36) {
10680
+ if (typeof data11 === "string") {
10681
+ if (func1(data11) > 256) {
10682
+ const err10 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/0/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" };
10683
+ if (vErrors === null) {
10684
+ vErrors = [err10];
10685
+ } else {
10686
+ vErrors.push(err10);
10687
+ }
10688
+ errors++;
10689
+ } else {
10690
+ if (func1(data11) < 9) {
10691
+ const err11 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/0/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" };
10692
+ if (vErrors === null) {
10693
+ vErrors = [err11];
10694
+ } else {
10695
+ vErrors.push(err11);
10696
+ }
10697
+ errors++;
10698
+ } else {
10699
+ if (!pattern18.test(data11)) {
10700
+ const err12 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/0/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' };
10701
+ if (vErrors === null) {
10702
+ vErrors = [err12];
10703
+ } else {
10704
+ vErrors.push(err12);
10705
+ }
10706
+ errors++;
10707
+ }
10708
+ }
10709
+ }
10710
+ } else {
10711
+ const err13 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
10712
+ if (vErrors === null) {
10713
+ vErrors = [err13];
10714
+ } else {
10715
+ vErrors.push(err13);
10716
+ }
10717
+ errors++;
10718
+ }
10719
+ }
10720
+ var _valid2 = _errs36 === errors;
10721
+ valid7 = valid7 || _valid2;
10722
+ const _errs38 = errors;
10723
+ if (data11 !== null) {
10724
+ const err14 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
10725
+ if (vErrors === null) {
10726
+ vErrors = [err14];
10727
+ } else {
10728
+ vErrors.push(err14);
10729
+ }
10730
+ errors++;
10731
+ }
10732
+ var _valid2 = _errs38 === errors;
10733
+ valid7 = valid7 || _valid2;
10734
+ if (!valid7) {
10735
+ const err15 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
10736
+ if (vErrors === null) {
10737
+ vErrors = [err15];
10738
+ } else {
10739
+ vErrors.push(err15);
10740
+ }
10741
+ errors++;
10742
+ validate56.errors = vErrors;
10743
+ return false;
10744
+ } else {
10745
+ errors = _errs35;
10746
+ if (vErrors !== null) {
10747
+ if (_errs35) {
10748
+ vErrors.length = _errs35;
10749
+ } else {
10750
+ vErrors = null;
10751
+ }
10752
+ }
10753
+ }
10754
+ var valid1 = _errs34 === errors;
10755
+ } else {
10756
+ var valid1 = true;
10757
+ }
10758
+ }
10759
+ }
10760
+ }
10761
+ } else {
10762
+ validate56.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
10763
+ return false;
10764
+ }
10765
+ }
10766
+ validate56.errors = vErrors;
10767
+ return errors === 0;
10768
+ }
10769
+ validate56.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
10770
+ function validate57(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
10771
+ ;
10772
+ let vErrors = null;
10773
+ let errors = 0;
10774
+ const evaluated0 = validate57.evaluated;
10775
+ if (evaluated0.dynamicProps) {
10776
+ evaluated0.props = void 0;
10777
+ }
10778
+ if (evaluated0.dynamicItems) {
10779
+ evaluated0.items = void 0;
10780
+ }
10781
+ const _errs0 = errors;
10782
+ if (errors === _errs0) {
10783
+ if (data && typeof data == "object" && !Array.isArray(data)) {
10784
+ let missing0;
10785
+ if (data.id === void 0 && (missing0 = "id") || data.name === void 0 && (missing0 = "name") || data.obfuscatedValue === void 0 && (missing0 = "obfuscatedValue") || data.permissions === void 0 && (missing0 = "permissions") || data.lastUsedAt === void 0 && (missing0 = "lastUsedAt") || data.expiresAt === void 0 && (missing0 = "expiresAt") || data.createdAt === void 0 && (missing0 = "createdAt") || data.updatedAt === void 0 && (missing0 = "updatedAt")) {
10786
+ validate57.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
10787
+ return false;
10788
+ } else {
10789
+ const _errs2 = errors;
10790
+ for (const key0 in data) {
10791
+ if (!(key0 === "id" || key0 === "name" || key0 === "obfuscatedValue" || key0 === "permissions" || key0 === "lastUsedAt" || key0 === "expiresAt" || key0 === "createdAt" || key0 === "updatedAt")) {
10792
+ validate57.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
10793
+ return false;
10794
+ break;
10795
+ }
10796
+ }
10797
+ if (_errs2 === errors) {
10798
+ if (data.id !== void 0) {
10799
+ let data0 = data.id;
10800
+ const _errs3 = errors;
10801
+ if (errors === _errs3) {
10802
+ if (typeof data0 === "string") {
10803
+ if (func1(data0) > 256) {
10804
+ validate57.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
10805
+ return false;
10806
+ } else {
10807
+ if (func1(data0) < 9) {
10808
+ validate57.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
10809
+ return false;
10810
+ } else {
10811
+ if (!pattern18.test(data0)) {
10812
+ validate57.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
10813
+ return false;
10814
+ }
10815
+ }
10816
+ }
10817
+ } else {
10818
+ validate57.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10819
+ return false;
10820
+ }
10821
+ }
10822
+ var valid1 = _errs3 === errors;
10823
+ } else {
10824
+ var valid1 = true;
10825
+ }
10826
+ if (valid1) {
10827
+ if (data.name !== void 0) {
10828
+ let data1 = data.name;
10829
+ const _errs5 = errors;
10830
+ if (errors === _errs5) {
10831
+ if (typeof data1 === "string") {
10832
+ if (func1(data1) > 128) {
10833
+ validate57.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
10834
+ return false;
10835
+ } else {
10836
+ if (func1(data1) < 1) {
10837
+ validate57.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10838
+ return false;
10839
+ } else {
10840
+ if (!pattern20.test(data1)) {
10841
+ validate57.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
10842
+ return false;
10843
+ }
10844
+ }
10845
+ }
10846
+ } else {
10847
+ validate57.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10848
+ return false;
10849
+ }
10850
+ }
10851
+ var valid1 = _errs5 === errors;
10852
+ } else {
10853
+ var valid1 = true;
10854
+ }
10855
+ if (valid1) {
10856
+ if (data.obfuscatedValue !== void 0) {
10857
+ let data2 = data.obfuscatedValue;
10858
+ const _errs7 = errors;
10859
+ if (errors === _errs7) {
10860
+ if (typeof data2 === "string") {
10861
+ if (func1(data2) > 256) {
10862
+ validate57.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
10863
+ return false;
10864
+ } else {
10865
+ if (func1(data2) < 1) {
10866
+ validate57.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10867
+ return false;
10868
+ } else {
10869
+ if (!pattern21.test(data2)) {
10870
+ validate57.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
10871
+ return false;
10872
+ }
10873
+ }
10874
+ }
10875
+ } else {
10876
+ validate57.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10877
+ return false;
10878
+ }
10879
+ }
10880
+ var valid1 = _errs7 === errors;
10881
+ } else {
10882
+ var valid1 = true;
10883
+ }
10884
+ if (valid1) {
10885
+ if (data.permissions !== void 0) {
10886
+ let data3 = data.permissions;
10887
+ const _errs9 = errors;
10888
+ if (errors === _errs9) {
10889
+ if (Array.isArray(data3)) {
10890
+ if (data3.length > 100) {
10891
+ validate57.errors = [{ instancePath: instancePath + "/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/maxItems", keyword: "maxItems", params: { limit: 100 }, message: "must NOT have more than 100 items" }];
10892
+ return false;
10893
+ } else {
10894
+ var valid2 = true;
10895
+ const len0 = data3.length;
10896
+ for (let i0 = 0; i0 < len0; i0++) {
10897
+ let data4 = data3[i0];
10898
+ const _errs11 = errors;
10899
+ if (errors === _errs11) {
10900
+ if (typeof data4 === "string") {
10901
+ if (func1(data4) > 128) {
10902
+ validate57.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
10903
+ return false;
10904
+ } else {
10905
+ if (func1(data4) < 1) {
10906
+ validate57.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
10907
+ return false;
10908
+ } else {
10909
+ if (!pattern22.test(data4)) {
10910
+ validate57.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
10911
+ return false;
10912
+ }
10913
+ }
10914
+ }
10915
+ } else {
10916
+ validate57.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
10917
+ return false;
10918
+ }
10919
+ }
10920
+ var valid2 = _errs11 === errors;
10921
+ if (!valid2) {
10922
+ break;
10923
+ }
10924
+ }
10925
+ }
10926
+ } else {
10927
+ validate57.errors = [{ instancePath: instancePath + "/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/type", keyword: "type", params: { type: "array" }, message: "must be array" }];
10928
+ return false;
10929
+ }
10930
+ }
10931
+ var valid1 = _errs9 === errors;
10932
+ } else {
10933
+ var valid1 = true;
10934
+ }
10935
+ if (valid1) {
10936
+ if (data.lastUsedAt !== void 0) {
10937
+ let data5 = data.lastUsedAt;
10938
+ const _errs13 = errors;
10939
+ const _errs14 = errors;
10940
+ let valid3 = false;
10941
+ const _errs15 = errors;
10942
+ if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
10943
+ const err0 = { instancePath: instancePath + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/lastUsedAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
10944
+ if (vErrors === null) {
10945
+ vErrors = [err0];
10946
+ } else {
10947
+ vErrors.push(err0);
10948
+ }
10949
+ errors++;
10950
+ }
10951
+ if (errors === _errs15) {
10952
+ if (typeof data5 == "number" && isFinite(data5)) {
10953
+ if (data5 > 9007199254740991 || isNaN(data5)) {
10954
+ const err1 = { instancePath: instancePath + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/lastUsedAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
10955
+ if (vErrors === null) {
10956
+ vErrors = [err1];
10957
+ } else {
10958
+ vErrors.push(err1);
10959
+ }
10960
+ errors++;
10961
+ } else {
10962
+ if (data5 < 0 || isNaN(data5)) {
10963
+ const err2 = { instancePath: instancePath + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/lastUsedAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
10964
+ if (vErrors === null) {
10965
+ vErrors = [err2];
10966
+ } else {
10967
+ vErrors.push(err2);
10968
+ }
10969
+ errors++;
10970
+ }
10971
+ }
10972
+ }
10973
+ }
10974
+ var _valid0 = _errs15 === errors;
10975
+ valid3 = valid3 || _valid0;
10976
+ const _errs17 = errors;
10977
+ if (data5 !== null) {
10978
+ const err3 = { instancePath: instancePath + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/lastUsedAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
10979
+ if (vErrors === null) {
10980
+ vErrors = [err3];
10981
+ } else {
10982
+ vErrors.push(err3);
10983
+ }
10984
+ errors++;
10985
+ }
10986
+ var _valid0 = _errs17 === errors;
10987
+ valid3 = valid3 || _valid0;
10988
+ if (!valid3) {
10989
+ const err4 = { instancePath: instancePath + "/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/lastUsedAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
10990
+ if (vErrors === null) {
10991
+ vErrors = [err4];
10992
+ } else {
10993
+ vErrors.push(err4);
10994
+ }
10995
+ errors++;
10996
+ validate57.errors = vErrors;
10997
+ return false;
10998
+ } else {
10999
+ errors = _errs14;
11000
+ if (vErrors !== null) {
11001
+ if (_errs14) {
11002
+ vErrors.length = _errs14;
11003
+ } else {
11004
+ vErrors = null;
11005
+ }
11006
+ }
11007
+ }
11008
+ var valid1 = _errs13 === errors;
11009
+ } else {
11010
+ var valid1 = true;
11011
+ }
11012
+ if (valid1) {
11013
+ if (data.expiresAt !== void 0) {
11014
+ let data6 = data.expiresAt;
11015
+ const _errs19 = errors;
11016
+ const _errs20 = errors;
11017
+ let valid4 = false;
11018
+ const _errs21 = errors;
11019
+ if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) {
11020
+ const err5 = { instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/expiresAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
11021
+ if (vErrors === null) {
11022
+ vErrors = [err5];
11023
+ } else {
11024
+ vErrors.push(err5);
11025
+ }
11026
+ errors++;
11027
+ }
11028
+ if (errors === _errs21) {
11029
+ if (typeof data6 == "number" && isFinite(data6)) {
11030
+ if (data6 > 9007199254740991 || isNaN(data6)) {
11031
+ const err6 = { instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/expiresAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
11032
+ if (vErrors === null) {
11033
+ vErrors = [err6];
11034
+ } else {
11035
+ vErrors.push(err6);
11036
+ }
11037
+ errors++;
11038
+ } else {
11039
+ if (data6 < 0 || isNaN(data6)) {
11040
+ const err7 = { instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/expiresAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
11041
+ if (vErrors === null) {
11042
+ vErrors = [err7];
11043
+ } else {
11044
+ vErrors.push(err7);
11045
+ }
11046
+ errors++;
11047
+ }
11048
+ }
11049
+ }
11050
+ }
11051
+ var _valid1 = _errs21 === errors;
11052
+ valid4 = valid4 || _valid1;
11053
+ const _errs23 = errors;
11054
+ if (data6 !== null) {
11055
+ const err8 = { instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/expiresAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
11056
+ if (vErrors === null) {
11057
+ vErrors = [err8];
11058
+ } else {
11059
+ vErrors.push(err8);
11060
+ }
11061
+ errors++;
11062
+ }
11063
+ var _valid1 = _errs23 === errors;
11064
+ valid4 = valid4 || _valid1;
11065
+ if (!valid4) {
11066
+ const err9 = { instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/expiresAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
11067
+ if (vErrors === null) {
11068
+ vErrors = [err9];
11069
+ } else {
11070
+ vErrors.push(err9);
11071
+ }
11072
+ errors++;
11073
+ validate57.errors = vErrors;
11074
+ return false;
11075
+ } else {
11076
+ errors = _errs20;
11077
+ if (vErrors !== null) {
11078
+ if (_errs20) {
11079
+ vErrors.length = _errs20;
11080
+ } else {
11081
+ vErrors = null;
11082
+ }
11083
+ }
11084
+ }
11085
+ var valid1 = _errs19 === errors;
11086
+ } else {
11087
+ var valid1 = true;
11088
+ }
11089
+ if (valid1) {
11090
+ if (data.createdAt !== void 0) {
11091
+ let data7 = data.createdAt;
11092
+ const _errs25 = errors;
11093
+ if (!(typeof data7 == "number" && (!(data7 % 1) && !isNaN(data7)) && isFinite(data7))) {
11094
+ validate57.errors = [{ instancePath: instancePath + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/createdAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
11095
+ return false;
11096
+ }
11097
+ if (errors === _errs25) {
11098
+ if (typeof data7 == "number" && isFinite(data7)) {
11099
+ if (data7 > 9007199254740991 || isNaN(data7)) {
11100
+ validate57.errors = [{ instancePath: instancePath + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/createdAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
11101
+ return false;
11102
+ } else {
11103
+ if (data7 < 0 || isNaN(data7)) {
11104
+ validate57.errors = [{ instancePath: instancePath + "/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/createdAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
11105
+ return false;
11106
+ }
11107
+ }
11108
+ }
11109
+ }
11110
+ var valid1 = _errs25 === errors;
11111
+ } else {
11112
+ var valid1 = true;
11113
+ }
11114
+ if (valid1) {
11115
+ if (data.updatedAt !== void 0) {
11116
+ let data8 = data.updatedAt;
11117
+ const _errs27 = errors;
11118
+ if (!(typeof data8 == "number" && (!(data8 % 1) && !isNaN(data8)) && isFinite(data8))) {
11119
+ validate57.errors = [{ instancePath: instancePath + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/updatedAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
11120
+ return false;
11121
+ }
11122
+ if (errors === _errs27) {
11123
+ if (typeof data8 == "number" && isFinite(data8)) {
11124
+ if (data8 > 9007199254740991 || isNaN(data8)) {
11125
+ validate57.errors = [{ instancePath: instancePath + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/updatedAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
11126
+ return false;
11127
+ } else {
11128
+ if (data8 < 0 || isNaN(data8)) {
11129
+ validate57.errors = [{ instancePath: instancePath + "/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/updatedAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
11130
+ return false;
11131
+ }
11132
+ }
11133
+ }
11134
+ }
11135
+ var valid1 = _errs27 === errors;
11136
+ } else {
11137
+ var valid1 = true;
11138
+ }
11139
+ }
11140
+ }
11141
+ }
11142
+ }
11143
+ }
11144
+ }
11145
+ }
11146
+ }
11147
+ }
11148
+ } else {
11149
+ validate57.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11150
+ return false;
11151
+ }
11152
+ }
11153
+ validate57.errors = vErrors;
11154
+ return errors === 0;
11155
+ }
11156
+ validate57.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11157
+ function validate58(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
11158
+ ;
11159
+ let vErrors = null;
11160
+ let errors = 0;
11161
+ const evaluated0 = validate58.evaluated;
11162
+ if (evaluated0.dynamicProps) {
11163
+ evaluated0.props = void 0;
11164
+ }
11165
+ if (evaluated0.dynamicItems) {
11166
+ evaluated0.items = void 0;
11167
+ }
11168
+ const _errs0 = errors;
11169
+ if (errors === _errs0) {
11170
+ if (data && typeof data == "object" && !Array.isArray(data)) {
11171
+ let missing0;
11172
+ if (data.requestId === void 0 && (missing0 = "requestId") || data.name === void 0 && (missing0 = "name")) {
11173
+ validate58.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
11174
+ return false;
11175
+ } else {
11176
+ const _errs2 = errors;
11177
+ for (const key0 in data) {
11178
+ if (!(key0 === "requestId" || key0 === "name" || key0 === "expiresAt")) {
11179
+ validate58.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
11180
+ return false;
11181
+ break;
11182
+ }
11183
+ }
11184
+ if (_errs2 === errors) {
11185
+ if (data.requestId !== void 0) {
11186
+ let data0 = data.requestId;
11187
+ const _errs3 = errors;
11188
+ if (errors === _errs3) {
11189
+ if (typeof data0 === "string") {
11190
+ if (!pattern17.test(data0)) {
11191
+ validate58.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/requestId/pattern", keyword: "pattern", params: { pattern: "^[a-f0-9]{64}$" }, message: 'must match pattern "^[a-f0-9]{64}$"' }];
11192
+ return false;
11193
+ }
11194
+ } else {
11195
+ validate58.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/requestId/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11196
+ return false;
11197
+ }
11198
+ }
11199
+ var valid1 = _errs3 === errors;
11200
+ } else {
11201
+ var valid1 = true;
11202
+ }
11203
+ if (valid1) {
11204
+ if (data.name !== void 0) {
11205
+ let data1 = data.name;
11206
+ const _errs5 = errors;
11207
+ if (errors === _errs5) {
11208
+ if (typeof data1 === "string") {
11209
+ if (func1(data1) > 128) {
11210
+ validate58.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
11211
+ return false;
11212
+ } else {
11213
+ if (func1(data1) < 1) {
11214
+ validate58.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
11215
+ return false;
11216
+ } else {
11217
+ if (!pattern20.test(data1)) {
11218
+ validate58.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
11219
+ return false;
11220
+ }
11221
+ }
11222
+ }
11223
+ } else {
11224
+ validate58.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11225
+ return false;
11226
+ }
11227
+ }
11228
+ var valid1 = _errs5 === errors;
11229
+ } else {
11230
+ var valid1 = true;
11231
+ }
11232
+ if (valid1) {
11233
+ if (data.expiresAt !== void 0) {
11234
+ let data2 = data.expiresAt;
11235
+ const _errs7 = errors;
11236
+ if (!(typeof data2 == "number" && (!(data2 % 1) && !isNaN(data2)) && isFinite(data2))) {
11237
+ validate58.errors = [{ instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/expiresAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
11238
+ return false;
11239
+ }
11240
+ if (errors === _errs7) {
11241
+ if (typeof data2 == "number" && isFinite(data2)) {
11242
+ if (data2 > 9007199254740991 || isNaN(data2)) {
11243
+ validate58.errors = [{ instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/expiresAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
11244
+ return false;
11245
+ } else {
11246
+ if (data2 < 0 || isNaN(data2)) {
11247
+ validate58.errors = [{ instancePath: instancePath + "/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/expiresAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
11248
+ return false;
11249
+ }
11250
+ }
11251
+ }
11252
+ }
11253
+ var valid1 = _errs7 === errors;
11254
+ } else {
11255
+ var valid1 = true;
11256
+ }
11257
+ }
11258
+ }
11259
+ }
11260
+ }
11261
+ } else {
11262
+ validate58.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11263
+ return false;
11264
+ }
11265
+ }
11266
+ validate58.errors = vErrors;
11267
+ return errors === 0;
11268
+ }
11269
+ validate58.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11270
+ var pattern34 = new RegExp("^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$", "u");
11271
+ function validate59(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
11272
+ ;
11273
+ let vErrors = null;
11274
+ let errors = 0;
11275
+ const evaluated0 = validate59.evaluated;
11276
+ if (evaluated0.dynamicProps) {
11277
+ evaluated0.props = void 0;
11278
+ }
11279
+ if (evaluated0.dynamicItems) {
11280
+ evaluated0.items = void 0;
11281
+ }
11282
+ const _errs0 = errors;
11283
+ if (errors === _errs0) {
11284
+ if (data && typeof data == "object" && !Array.isArray(data)) {
11285
+ let missing0;
11286
+ if (data.apiKey === void 0 && (missing0 = "apiKey") || data.secret === void 0 && (missing0 = "secret")) {
11287
+ validate59.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
11288
+ return false;
11289
+ } else {
11290
+ const _errs2 = errors;
11291
+ for (const key0 in data) {
11292
+ if (!(key0 === "apiKey" || key0 === "secret")) {
11293
+ validate59.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
11294
+ return false;
11295
+ break;
11296
+ }
11297
+ }
11298
+ if (_errs2 === errors) {
11299
+ if (data.apiKey !== void 0) {
11300
+ let data0 = data.apiKey;
11301
+ const _errs3 = errors;
11302
+ if (errors === _errs3) {
11303
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
11304
+ let missing1;
11305
+ if (data0.id === void 0 && (missing1 = "id") || data0.name === void 0 && (missing1 = "name") || data0.obfuscatedValue === void 0 && (missing1 = "obfuscatedValue") || data0.permissions === void 0 && (missing1 = "permissions") || data0.lastUsedAt === void 0 && (missing1 = "lastUsedAt") || data0.expiresAt === void 0 && (missing1 = "expiresAt") || data0.createdAt === void 0 && (missing1 = "createdAt") || data0.updatedAt === void 0 && (missing1 = "updatedAt")) {
11306
+ validate59.errors = [{ instancePath: instancePath + "/apiKey", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
11307
+ return false;
11308
+ } else {
11309
+ const _errs5 = errors;
11310
+ for (const key1 in data0) {
11311
+ if (!(key1 === "id" || key1 === "name" || key1 === "obfuscatedValue" || key1 === "permissions" || key1 === "lastUsedAt" || key1 === "expiresAt" || key1 === "createdAt" || key1 === "updatedAt")) {
11312
+ validate59.errors = [{ instancePath: instancePath + "/apiKey", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" }];
11313
+ return false;
11314
+ break;
11315
+ }
11316
+ }
11317
+ if (_errs5 === errors) {
11318
+ if (data0.id !== void 0) {
11319
+ let data1 = data0.id;
11320
+ const _errs6 = errors;
11321
+ if (errors === _errs6) {
11322
+ if (typeof data1 === "string") {
11323
+ if (func1(data1) > 256) {
11324
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
11325
+ return false;
11326
+ } else {
11327
+ if (func1(data1) < 9) {
11328
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
11329
+ return false;
11330
+ } else {
11331
+ if (!pattern18.test(data1)) {
11332
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
11333
+ return false;
11334
+ }
11335
+ }
11336
+ }
11337
+ } else {
11338
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11339
+ return false;
11340
+ }
11341
+ }
11342
+ var valid2 = _errs6 === errors;
11343
+ } else {
11344
+ var valid2 = true;
11345
+ }
11346
+ if (valid2) {
11347
+ if (data0.name !== void 0) {
11348
+ let data2 = data0.name;
11349
+ const _errs8 = errors;
11350
+ if (errors === _errs8) {
11351
+ if (typeof data2 === "string") {
11352
+ if (func1(data2) > 128) {
11353
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
11354
+ return false;
11355
+ } else {
11356
+ if (func1(data2) < 1) {
11357
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
11358
+ return false;
11359
+ } else {
11360
+ if (!pattern20.test(data2)) {
11361
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
11362
+ return false;
11363
+ }
11364
+ }
11365
+ }
11366
+ } else {
11367
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11368
+ return false;
11369
+ }
11370
+ }
11371
+ var valid2 = _errs8 === errors;
11372
+ } else {
11373
+ var valid2 = true;
11374
+ }
11375
+ if (valid2) {
11376
+ if (data0.obfuscatedValue !== void 0) {
11377
+ let data3 = data0.obfuscatedValue;
11378
+ const _errs10 = errors;
11379
+ if (errors === _errs10) {
11380
+ if (typeof data3 === "string") {
11381
+ if (func1(data3) > 256) {
11382
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
11383
+ return false;
11384
+ } else {
11385
+ if (func1(data3) < 1) {
11386
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
11387
+ return false;
11388
+ } else {
11389
+ if (!pattern21.test(data3)) {
11390
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
11391
+ return false;
11392
+ }
11393
+ }
11394
+ }
11395
+ } else {
11396
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11397
+ return false;
11398
+ }
11399
+ }
11400
+ var valid2 = _errs10 === errors;
11401
+ } else {
11402
+ var valid2 = true;
11403
+ }
11404
+ if (valid2) {
11405
+ if (data0.permissions !== void 0) {
11406
+ let data4 = data0.permissions;
11407
+ const _errs12 = errors;
11408
+ if (errors === _errs12) {
11409
+ if (Array.isArray(data4)) {
11410
+ if (data4.length > 100) {
11411
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/maxItems", keyword: "maxItems", params: { limit: 100 }, message: "must NOT have more than 100 items" }];
11412
+ return false;
11413
+ } else {
11414
+ var valid3 = true;
11415
+ const len0 = data4.length;
11416
+ for (let i0 = 0; i0 < len0; i0++) {
11417
+ let data5 = data4[i0];
11418
+ const _errs14 = errors;
11419
+ if (errors === _errs14) {
11420
+ if (typeof data5 === "string") {
11421
+ if (func1(data5) > 128) {
11422
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" }];
11423
+ return false;
11424
+ } else {
11425
+ if (func1(data5) < 1) {
11426
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
11427
+ return false;
11428
+ } else {
11429
+ if (!pattern22.test(data5)) {
11430
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
11431
+ return false;
11432
+ }
11433
+ }
11434
+ }
11435
+ } else {
11436
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11437
+ return false;
11438
+ }
11439
+ }
11440
+ var valid3 = _errs14 === errors;
11441
+ if (!valid3) {
11442
+ break;
11443
+ }
11444
+ }
11445
+ }
11446
+ } else {
11447
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/permissions", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/type", keyword: "type", params: { type: "array" }, message: "must be array" }];
11448
+ return false;
11449
+ }
11450
+ }
11451
+ var valid2 = _errs12 === errors;
11452
+ } else {
11453
+ var valid2 = true;
11454
+ }
11455
+ if (valid2) {
11456
+ if (data0.lastUsedAt !== void 0) {
11457
+ let data6 = data0.lastUsedAt;
11458
+ const _errs16 = errors;
11459
+ const _errs17 = errors;
11460
+ let valid4 = false;
11461
+ const _errs18 = errors;
11462
+ if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) {
11463
+ const err0 = { instancePath: instancePath + "/apiKey/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/lastUsedAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
11464
+ if (vErrors === null) {
11465
+ vErrors = [err0];
11466
+ } else {
11467
+ vErrors.push(err0);
11468
+ }
11469
+ errors++;
11470
+ }
11471
+ if (errors === _errs18) {
11472
+ if (typeof data6 == "number" && isFinite(data6)) {
11473
+ if (data6 > 9007199254740991 || isNaN(data6)) {
11474
+ const err1 = { instancePath: instancePath + "/apiKey/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/lastUsedAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
11475
+ if (vErrors === null) {
11476
+ vErrors = [err1];
11477
+ } else {
11478
+ vErrors.push(err1);
11479
+ }
11480
+ errors++;
11481
+ } else {
11482
+ if (data6 < 0 || isNaN(data6)) {
11483
+ const err2 = { instancePath: instancePath + "/apiKey/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/lastUsedAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
11484
+ if (vErrors === null) {
11485
+ vErrors = [err2];
11486
+ } else {
11487
+ vErrors.push(err2);
11488
+ }
11489
+ errors++;
11490
+ }
11491
+ }
11492
+ }
11493
+ }
11494
+ var _valid0 = _errs18 === errors;
11495
+ valid4 = valid4 || _valid0;
11496
+ const _errs20 = errors;
11497
+ if (data6 !== null) {
11498
+ const err3 = { instancePath: instancePath + "/apiKey/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/lastUsedAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
11499
+ if (vErrors === null) {
11500
+ vErrors = [err3];
11501
+ } else {
11502
+ vErrors.push(err3);
11503
+ }
11504
+ errors++;
11505
+ }
11506
+ var _valid0 = _errs20 === errors;
11507
+ valid4 = valid4 || _valid0;
11508
+ if (!valid4) {
11509
+ const err4 = { instancePath: instancePath + "/apiKey/lastUsedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/lastUsedAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
11510
+ if (vErrors === null) {
11511
+ vErrors = [err4];
11512
+ } else {
11513
+ vErrors.push(err4);
11514
+ }
11515
+ errors++;
11516
+ validate59.errors = vErrors;
11517
+ return false;
11518
+ } else {
11519
+ errors = _errs17;
11520
+ if (vErrors !== null) {
11521
+ if (_errs17) {
11522
+ vErrors.length = _errs17;
11523
+ } else {
11524
+ vErrors = null;
11525
+ }
11526
+ }
11527
+ }
11528
+ var valid2 = _errs16 === errors;
11529
+ } else {
11530
+ var valid2 = true;
11531
+ }
11532
+ if (valid2) {
11533
+ if (data0.expiresAt !== void 0) {
11534
+ let data7 = data0.expiresAt;
11535
+ const _errs22 = errors;
11536
+ const _errs23 = errors;
11537
+ let valid5 = false;
11538
+ const _errs24 = errors;
11539
+ if (!(typeof data7 == "number" && (!(data7 % 1) && !isNaN(data7)) && isFinite(data7))) {
11540
+ const err5 = { instancePath: instancePath + "/apiKey/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/expiresAt/anyOf/0/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
11541
+ if (vErrors === null) {
11542
+ vErrors = [err5];
11543
+ } else {
11544
+ vErrors.push(err5);
11545
+ }
11546
+ errors++;
11547
+ }
11548
+ if (errors === _errs24) {
11549
+ if (typeof data7 == "number" && isFinite(data7)) {
11550
+ if (data7 > 9007199254740991 || isNaN(data7)) {
11551
+ const err6 = { instancePath: instancePath + "/apiKey/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/expiresAt/anyOf/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
11552
+ if (vErrors === null) {
11553
+ vErrors = [err6];
11554
+ } else {
11555
+ vErrors.push(err6);
11556
+ }
11557
+ errors++;
11558
+ } else {
11559
+ if (data7 < 0 || isNaN(data7)) {
11560
+ const err7 = { instancePath: instancePath + "/apiKey/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/expiresAt/anyOf/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
11561
+ if (vErrors === null) {
11562
+ vErrors = [err7];
11563
+ } else {
11564
+ vErrors.push(err7);
11565
+ }
11566
+ errors++;
11567
+ }
11568
+ }
11569
+ }
11570
+ }
11571
+ var _valid1 = _errs24 === errors;
11572
+ valid5 = valid5 || _valid1;
11573
+ const _errs26 = errors;
11574
+ if (data7 !== null) {
11575
+ const err8 = { instancePath: instancePath + "/apiKey/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/expiresAt/anyOf/1/type", keyword: "type", params: { type: "null" }, message: "must be null" };
11576
+ if (vErrors === null) {
11577
+ vErrors = [err8];
11578
+ } else {
11579
+ vErrors.push(err8);
11580
+ }
11581
+ errors++;
11582
+ }
11583
+ var _valid1 = _errs26 === errors;
11584
+ valid5 = valid5 || _valid1;
11585
+ if (!valid5) {
11586
+ const err9 = { instancePath: instancePath + "/apiKey/expiresAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/expiresAt/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
11587
+ if (vErrors === null) {
11588
+ vErrors = [err9];
11589
+ } else {
11590
+ vErrors.push(err9);
11591
+ }
11592
+ errors++;
11593
+ validate59.errors = vErrors;
11594
+ return false;
11595
+ } else {
11596
+ errors = _errs23;
11597
+ if (vErrors !== null) {
11598
+ if (_errs23) {
11599
+ vErrors.length = _errs23;
11600
+ } else {
11601
+ vErrors = null;
11602
+ }
11603
+ }
11604
+ }
11605
+ var valid2 = _errs22 === errors;
11606
+ } else {
11607
+ var valid2 = true;
11608
+ }
11609
+ if (valid2) {
11610
+ if (data0.createdAt !== void 0) {
11611
+ let data8 = data0.createdAt;
11612
+ const _errs28 = errors;
11613
+ if (!(typeof data8 == "number" && (!(data8 % 1) && !isNaN(data8)) && isFinite(data8))) {
11614
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/createdAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
11615
+ return false;
11616
+ }
11617
+ if (errors === _errs28) {
11618
+ if (typeof data8 == "number" && isFinite(data8)) {
11619
+ if (data8 > 9007199254740991 || isNaN(data8)) {
11620
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/createdAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
11621
+ return false;
11622
+ } else {
11623
+ if (data8 < 0 || isNaN(data8)) {
11624
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/createdAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/createdAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
11625
+ return false;
11626
+ }
11627
+ }
11628
+ }
11629
+ }
11630
+ var valid2 = _errs28 === errors;
11631
+ } else {
11632
+ var valid2 = true;
11633
+ }
11634
+ if (valid2) {
11635
+ if (data0.updatedAt !== void 0) {
11636
+ let data9 = data0.updatedAt;
11637
+ const _errs30 = errors;
11638
+ if (!(typeof data9 == "number" && (!(data9 % 1) && !isNaN(data9)) && isFinite(data9))) {
11639
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/updatedAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
11640
+ return false;
11641
+ }
11642
+ if (errors === _errs30) {
11643
+ if (typeof data9 == "number" && isFinite(data9)) {
11644
+ if (data9 > 9007199254740991 || isNaN(data9)) {
11645
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/updatedAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" }];
11646
+ return false;
11647
+ } else {
11648
+ if (data9 < 0 || isNaN(data9)) {
11649
+ validate59.errors = [{ instancePath: instancePath + "/apiKey/updatedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/updatedAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
11650
+ return false;
11651
+ }
11652
+ }
11653
+ }
11654
+ }
11655
+ var valid2 = _errs30 === errors;
11656
+ } else {
11657
+ var valid2 = true;
11658
+ }
11659
+ }
11660
+ }
11661
+ }
11662
+ }
11663
+ }
11664
+ }
11665
+ }
11666
+ }
11667
+ }
11668
+ } else {
11669
+ validate59.errors = [{ instancePath: instancePath + "/apiKey", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11670
+ return false;
11671
+ }
11672
+ }
11673
+ var valid1 = _errs3 === errors;
11674
+ } else {
11675
+ var valid1 = true;
11676
+ }
11677
+ if (valid1) {
11678
+ if (data.secret !== void 0) {
11679
+ let data10 = data.secret;
11680
+ const _errs32 = errors;
11681
+ if (errors === _errs32) {
11682
+ if (typeof data10 === "string") {
11683
+ if (func1(data10) > 4096) {
11684
+ validate59.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/maxLength", keyword: "maxLength", params: { limit: 4096 }, message: "must NOT have more than 4096 characters" }];
11685
+ return false;
11686
+ } else {
11687
+ if (func1(data10) < 4) {
11688
+ validate59.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/minLength", keyword: "minLength", params: { limit: 4 }, message: "must NOT have fewer than 4 characters" }];
11689
+ return false;
11690
+ } else {
11691
+ if (!pattern34.test(data10)) {
11692
+ validate59.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/pattern", keyword: "pattern", params: { pattern: "^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$" }, message: 'must match pattern "^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$"' }];
11693
+ return false;
11694
+ }
11695
+ }
11696
+ }
11697
+ } else {
11698
+ validate59.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11699
+ return false;
11700
+ }
11701
+ }
11702
+ var valid1 = _errs32 === errors;
11703
+ } else {
11704
+ var valid1 = true;
11705
+ }
11706
+ }
11707
+ }
11708
+ }
11709
+ } else {
11710
+ validate59.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11711
+ return false;
11712
+ }
11713
+ }
11714
+ validate59.errors = vErrors;
11715
+ return errors === 0;
11716
+ }
11717
+ validate59.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11718
+ function validate60(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
11719
+ ;
11720
+ let vErrors = null;
11721
+ let errors = 0;
11722
+ const evaluated0 = validate60.evaluated;
11723
+ if (evaluated0.dynamicProps) {
11724
+ evaluated0.props = void 0;
11725
+ }
11726
+ if (evaluated0.dynamicItems) {
11727
+ evaluated0.items = void 0;
11728
+ }
11729
+ const _errs0 = errors;
11730
+ if (errors === _errs0) {
11731
+ if (data && typeof data == "object" && !Array.isArray(data)) {
11732
+ let missing0;
11733
+ if (data.requestId === void 0 && (missing0 = "requestId")) {
11734
+ validate60.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeRequest/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
11735
+ return false;
11736
+ } else {
11737
+ const _errs2 = errors;
11738
+ for (const key0 in data) {
11739
+ if (!(key0 === "requestId")) {
11740
+ validate60.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeRequest/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
11741
+ return false;
11742
+ break;
11743
+ }
11744
+ }
11745
+ if (_errs2 === errors) {
11746
+ if (data.requestId !== void 0) {
11747
+ let data0 = data.requestId;
11748
+ const _errs3 = errors;
11749
+ if (errors === _errs3) {
11750
+ if (typeof data0 === "string") {
11751
+ if (!pattern17.test(data0)) {
11752
+ validate60.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeRequest/properties/requestId/pattern", keyword: "pattern", params: { pattern: "^[a-f0-9]{64}$" }, message: 'must match pattern "^[a-f0-9]{64}$"' }];
11753
+ return false;
11754
+ }
11755
+ } else {
11756
+ validate60.errors = [{ instancePath: instancePath + "/requestId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeRequest/properties/requestId/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11757
+ return false;
11758
+ }
11759
+ }
11760
+ }
11761
+ }
11762
+ }
11763
+ } else {
11764
+ validate60.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeRequest/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11765
+ return false;
11766
+ }
11767
+ }
11768
+ validate60.errors = vErrors;
11769
+ return errors === 0;
11770
+ }
11771
+ validate60.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11772
+ function validate61(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
11773
+ ;
11774
+ let vErrors = null;
11775
+ let errors = 0;
11776
+ const evaluated0 = validate61.evaluated;
11777
+ if (evaluated0.dynamicProps) {
11778
+ evaluated0.props = void 0;
11779
+ }
11780
+ if (evaluated0.dynamicItems) {
11781
+ evaluated0.items = void 0;
11782
+ }
11783
+ const _errs0 = errors;
11784
+ if (errors === _errs0) {
11785
+ if (data && typeof data == "object" && !Array.isArray(data)) {
11786
+ let missing0;
11787
+ if (data.apiKeyId === void 0 && (missing0 = "apiKeyId") || data.revoked === void 0 && (missing0 = "revoked")) {
11788
+ validate61.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
11789
+ return false;
11790
+ } else {
11791
+ const _errs2 = errors;
11792
+ for (const key0 in data) {
11793
+ if (!(key0 === "apiKeyId" || key0 === "revoked")) {
11794
+ validate61.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }];
11795
+ return false;
11796
+ break;
11797
+ }
11798
+ }
11799
+ if (_errs2 === errors) {
11800
+ if (data.apiKeyId !== void 0) {
11801
+ let data0 = data.apiKeyId;
11802
+ const _errs3 = errors;
11803
+ if (errors === _errs3) {
11804
+ if (typeof data0 === "string") {
11805
+ if (func1(data0) > 256) {
11806
+ validate61.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
11807
+ return false;
11808
+ } else {
11809
+ if (func1(data0) < 9) {
11810
+ validate61.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
11811
+ return false;
11812
+ } else {
11813
+ if (!pattern18.test(data0)) {
11814
+ validate61.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
11815
+ return false;
11816
+ }
11817
+ }
11818
+ }
11819
+ } else {
11820
+ validate61.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
11821
+ return false;
11822
+ }
11823
+ }
11824
+ var valid1 = _errs3 === errors;
11825
+ } else {
11826
+ var valid1 = true;
11827
+ }
11828
+ if (valid1) {
11829
+ if (data.revoked !== void 0) {
11830
+ let data1 = data.revoked;
11831
+ const _errs5 = errors;
11832
+ if (typeof data1 !== "boolean") {
11833
+ validate61.errors = [{ instancePath: instancePath + "/revoked", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/revoked/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
11834
+ return false;
11835
+ }
11836
+ if (true !== data1) {
11837
+ validate61.errors = [{ instancePath: instancePath + "/revoked", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/revoked/const", keyword: "const", params: { allowedValue: true }, message: "must be equal to constant" }];
11838
+ return false;
11839
+ }
11840
+ var valid1 = _errs5 === errors;
11841
+ } else {
11842
+ var valid1 = true;
11843
+ }
11844
+ }
11845
+ }
11846
+ }
11847
+ } else {
11848
+ validate61.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
11849
+ return false;
11850
+ }
11851
+ }
11852
+ validate61.errors = vErrors;
11853
+ return errors === 0;
11854
+ }
11855
+ validate61.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11856
+
11857
+ // src/contract/cli-http-v1.ts
11858
+ function isGitHubInstallIntentStatusResponse(value) {
11859
+ if (!isGitHubInstallIntentStatusResponseStructure(value)) {
11860
+ return false;
11861
+ }
11862
+ switch (value.status) {
11863
+ case "claimed":
11864
+ return value.leaseExpiresAt <= value.expiresAt;
11865
+ case "consumed":
11866
+ return value.repositoryCount === value.adminRepositoryCount + value.nonAdminRepositoryCount && value.completedAt <= value.expiresAt;
11867
+ case "expired":
11868
+ return value.closedAt >= value.expiresAt;
11869
+ case "cancelled":
11870
+ return value.closedAt <= value.expiresAt;
11871
+ case "failed_terminal":
11872
+ return value.failureCode === "claim_lease_expired" || value.closedAt <= value.expiresAt;
11873
+ case "pending":
11874
+ return true;
11875
+ }
11876
+ }
11877
+
11878
+ // src/lib/github-install-intent.ts
11879
+ var PROTOCOL_VERSION = 1;
9903
11880
  var MODE = "install_intent_v1";
9904
11881
  var START_PATH = "/api/cli/github/install-intents";
9905
11882
  var POLL_REQUEST_TIMEOUT_MS = 1e4;
9906
11883
  var MAX_INTENT_LIFETIME_MS = 15 * 6e4;
9907
11884
  var MAX_SERVER_CLOCK_AHEAD_MS = 3e4;
9908
- var REPOSITORY_IDENTITY_MIGRATION_REQUIRED = "repository_identity_migration_required";
9909
- function isRepositoryIdentityMigrationRequiredStatus(value) {
9910
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
9911
- return false;
9912
- }
9913
- const record2 = value;
9914
- if (record2.failureCode !== REPOSITORY_IDENTITY_MIGRATION_REQUIRED) {
9915
- return false;
11885
+ var GITHUB_INSTALL_INTENT_RATE_LIMITED = "github_install_intent_rate_limited";
11886
+ var HTTP_CONFLICT = 409;
11887
+ var GitHubInstallIntentRateLimitedError = class extends Error {
11888
+ code = GITHUB_INSTALL_INTENT_RATE_LIMITED;
11889
+ retryAt;
11890
+ constructor(retryAt) {
11891
+ super("GitHub connection is temporarily rate limited");
11892
+ this.name = "GitHubInstallIntentRateLimitedError";
11893
+ this.retryAt = retryAt;
9916
11894
  }
9917
- return isGitHubInstallIntentStatusResponse({
9918
- ...record2,
9919
- failureCode: "proof_commit_failed"
9920
- });
9921
- }
11895
+ };
9922
11896
  function parseGitHubInstallIntentStart(value, now = Date.now()) {
9923
11897
  if (!isGitHubInstallIntentStartResponse(value) || value.expiresAt <= now || value.expiresAt - now > MAX_INTENT_LIFETIME_MS + MAX_SERVER_CLOCK_AHEAD_MS) {
9924
11898
  return null;
9925
11899
  }
9926
11900
  return value;
9927
11901
  }
9928
- function parseGitHubInstallIntentStatus(value, expectedExpiresAt) {
9929
- if (isGitHubInstallIntentStatusResponse(value)) {
9930
- return value.expiresAt === expectedExpiresAt ? value : null;
11902
+ function parseGitHubInstallIntentRateLimit(value, now = Date.now()) {
11903
+ if (!isGitHubInstallIntentStartErrorResponse(value) || value.error !== GITHUB_INSTALL_INTENT_RATE_LIMITED || value.retryAt <= now || value.retryAt - now > MAX_INTENT_LIFETIME_MS + MAX_SERVER_CLOCK_AHEAD_MS) {
11904
+ return null;
9931
11905
  }
9932
- if (!isRepositoryIdentityMigrationRequiredStatus(value) || value.expiresAt !== expectedExpiresAt) {
11906
+ return value;
11907
+ }
11908
+ function parseGitHubInstallIntentStatus(value, expectedExpiresAt) {
11909
+ if (!isGitHubInstallIntentStatusResponse(value) || value.expiresAt !== expectedExpiresAt) {
9933
11910
  return null;
9934
11911
  }
9935
11912
  return value;
9936
11913
  }
9937
11914
  async function createGitHubInstallIntent(client, options = {}) {
9938
11915
  const { now = Date.now, ...requestOptions } = options;
9939
- const raw = await client.post(START_PATH, void 0, requestOptions);
11916
+ let raw;
11917
+ try {
11918
+ raw = await client.post(START_PATH, void 0, requestOptions);
11919
+ } catch (error) {
11920
+ const rateLimit = error instanceof HttpError && error.status === HTTP_CONFLICT ? parseGitHubInstallIntentRateLimit(error.body, now()) : null;
11921
+ if (rateLimit) throw new GitHubInstallIntentRateLimitedError(rateLimit.retryAt);
11922
+ throw error;
11923
+ }
9940
11924
  const parsed = parseGitHubInstallIntentStart(raw, now());
9941
11925
  if (!parsed) throw new Error("server returned an invalid GitHub install-intent response");
9942
11926
  return parsed;
@@ -10913,7 +12897,29 @@ var defaultDependencies2 = {
10913
12897
  function errorMessage(error) {
10914
12898
  return error instanceof Error ? error.message : String(error);
10915
12899
  }
12900
+ function rateLimitMessage(retryAt) {
12901
+ return [
12902
+ "GitHub connection is temporarily busy.",
12903
+ "Finish any GitHub authorization already open, then run `prim github connect` again after",
12904
+ `${new Date(retryAt).toISOString()}.`
12905
+ ].join(" ");
12906
+ }
10916
12907
  function reportConnectFailure(error) {
12908
+ if (error instanceof GitHubInstallIntentRateLimitedError) {
12909
+ const message2 = rateLimitMessage(error.retryAt);
12910
+ process.stderr.write(`[prim] github connect failed: ${message2}
12911
+ `);
12912
+ printJson({
12913
+ status: "error",
12914
+ error: message2,
12915
+ code: error.code,
12916
+ retryAt: error.retryAt,
12917
+ retryCommand: "prim github connect",
12918
+ resume: "Finish any GitHub authorization already open, then retry."
12919
+ });
12920
+ process.exitCode = EXIT_FAILURE;
12921
+ return;
12922
+ }
10917
12923
  const message = errorMessage(error);
10918
12924
  const human = boundedHealthError(message) ?? "unknown error";
10919
12925
  process.stderr.write(`[prim] github connect failed: ${human}
@@ -10945,6 +12951,11 @@ function reportBinding(binding, installAttempted = false) {
10945
12951
  }
10946
12952
  function terminalInstallError(status) {
10947
12953
  if (status.status === "failed_terminal") {
12954
+ if (status.failureCode === "repository_identity_migration_required") {
12955
+ return new Error(
12956
+ "Selected repos include an older Primitive connection needing a one-time repair; none changed. In GitHub App settings, exclude that existing repo to connect others, or retry after repair. If it persists, contact an admin or support."
12957
+ );
12958
+ }
10948
12959
  return new Error(`GitHub installation failed: ${status.failureCode}`);
10949
12960
  }
10950
12961
  return new Error(`GitHub installation ${status.status}`);