@vectros-ai/cli 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1619,7 +1619,7 @@ var require_proper_lockfile = __commonJS({
1619
1619
  // src/cli-bootstrap.ts
1620
1620
  import * as readline from "readline/promises";
1621
1621
 
1622
- // ../../node_modules/@vectros-ai/sdk/dist/index.mjs
1622
+ // node_modules/@vectros-ai/sdk/dist/index.mjs
1623
1623
  var __defProp2 = Object.defineProperty;
1624
1624
  var __export = (target, all) => {
1625
1625
  for (var name in all)
@@ -6229,7 +6229,7 @@ var DocumentsClient = class {
6229
6229
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents");
6230
6230
  }
6231
6231
  /**
6232
- * Creates a document from a raw text string and queues it for asynchronous indexing so it becomes searchable. Optionally supply an `externalId` to make the create idempotent — if a document with the same `externalId` already exists in your context, that existing document is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing document was returned) tells the two apart. To overwrite an existing document's content instead of returning it unchanged, set `?upsert=true` (this also requires the `documents:u` scope). Requires the `documents:c` scope.
6232
+ * Creates a document from a raw text string and queues it for asynchronous indexing so it becomes searchable. Optionally supply an `externalId` to make the create idempotent — if a document with the same `externalId` already exists in your context, that existing document is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing document was returned) tells the two apart. To overwrite an existing document's content instead of returning it unchanged, set `?upsert=true` (this also requires the `documents:u` scope). Requires the `documents:c` scope to create. Being returned the existing document on a collision is a read of that document's data and additionally requires the `documents:r` scope — a credential holding `documents:c` alone receives a `400` ("already exists") on collision instead of the document.
6233
6233
  *
6234
6234
  * @param {Vectros.IngestDocumentRequest} request
6235
6235
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6555,25 +6555,29 @@ var DocumentsClient = class {
6555
6555
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v1/documents/{id}");
6556
6556
  }
6557
6557
  /**
6558
- * Finds documents of a given type by field value. Supported fields: `externalId` (the document's first-class external identifier — no schema declaration required) and any field declared as a lookup field on the bound schema. A lookup on a sensitive field is rejected here because the value would appear in the URL query string; use POST /v1/documents/lookup (the request-body variant) for a sensitive field instead. Results are paginated: set `limit` for the page size and feed the returned `nextCursor` back as `startFrom` to fetch the next page. The response is a `{data, nextCursor}` envelope. Requires the `documents:r` scope.
6558
+ * Finds documents of a given type by field value. Supported fields: `externalId` (the document's first-class external identifier — no schema declaration required) and any field declared as a lookup field on the bound schema. A lookup on a sensitive field is rejected here because the value would appear in the URL query string; use POST /v1/documents/lookup (the request-body variant) for a sensitive field instead. `type`'s schema resolves with basedOn-aware shadowing: your own `userId`- or `scope`-owned variant if you have one, otherwise the shared base — for a scoped credential the owner is always your own token identity; `userId`/`scope` here only apply as an explicit owner selector for a root API key. Results are paginated: set `limit` for the page size and feed the returned `nextCursor` back as `startFrom` to fetch the next page. The response is a `{data, nextCursor}` envelope. Requires the `documents:r` scope.
6559
6559
  *
6560
6560
  * @param {Vectros.LookupDocumentsRequest} request
6561
6561
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
6562
6562
  *
6563
+ * @throws {@link Vectros.BadRequestError}
6564
+ *
6563
6565
  * @example
6564
6566
  * await client.documents.lookupDocuments({
6565
6567
  * type: "invoice",
6566
6568
  * field: "po_number",
6567
6569
  * value: "PO-1001",
6568
6570
  * prefix: "PO-2024",
6569
- * startFrom: "550e8400-e29b-41d4-a716-446655440000"
6571
+ * startFrom: "550e8400-e29b-41d4-a716-446655440000",
6572
+ * userId: "550e8400-e29b-41d4-a716-446655440000",
6573
+ * scope: "org:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
6570
6574
  * })
6571
6575
  */
6572
6576
  lookupDocuments(request, requestOptions) {
6573
6577
  return HttpResponsePromise.fromPromise(this.__lookupDocuments(request, requestOptions));
6574
6578
  }
6575
6579
  async __lookupDocuments(request, requestOptions) {
6576
- const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order } = request;
6580
+ const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order, userId, scope } = request;
6577
6581
  const _queryParams = {
6578
6582
  type: type_,
6579
6583
  field,
@@ -6583,7 +6587,9 @@ var DocumentsClient = class {
6583
6587
  prefix,
6584
6588
  startFrom,
6585
6589
  limit,
6586
- order: order != null ? order : void 0
6590
+ order: order != null ? order : void 0,
6591
+ userId,
6592
+ scope
6587
6593
  };
6588
6594
  const _authRequest = await this._options.authProvider.getAuthRequest();
6589
6595
  const _headers = mergeHeaders(
@@ -6609,11 +6615,16 @@ var DocumentsClient = class {
6609
6615
  return { data: _response.body, rawResponse: _response.rawResponse };
6610
6616
  }
6611
6617
  if (_response.error.reason === "status-code") {
6612
- throw new VectrosError({
6613
- statusCode: _response.error.statusCode,
6614
- body: _response.error.body,
6615
- rawResponse: _response.rawResponse
6616
- });
6618
+ switch (_response.error.statusCode) {
6619
+ case 400:
6620
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
6621
+ default:
6622
+ throw new VectrosError({
6623
+ statusCode: _response.error.statusCode,
6624
+ body: _response.error.body,
6625
+ rawResponse: _response.rawResponse
6626
+ });
6627
+ }
6617
6628
  }
6618
6629
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/lookup");
6619
6630
  }
@@ -6981,7 +6992,7 @@ var FoldersClient = class {
6981
6992
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/folders");
6982
6993
  }
6983
6994
  /**
6984
- * Creates a folder to organize your documents and records. If `parentFolderId` is omitted, the folder is created under your context's default root folder. Folder creation is idempotent by (slug + parent): if a folder with the same slug already exists under the same parent, that existing folder is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing folder was returned) tells the two apart. To overwrite an existing folder's mutable fields instead of returning it unchanged, set `?upsert=true` (this also requires the `folders:u` scope). Requires the `folders:c` scope.
6995
+ * Creates a folder to organize your documents and records. If `parentFolderId` is omitted, the folder is created under your context's default root folder. Folder creation is idempotent by (slug + parent): if a folder with the same slug already exists under the same parent, that existing folder is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing folder was returned) tells the two apart. To overwrite an existing folder's mutable fields instead of returning it unchanged, set `?upsert=true` (this also requires the `folders:u` scope). Requires the `folders:c` scope to create. Being returned the existing folder on a collision is a read of that folder's data and additionally requires the `folders:r` scope — a credential holding `folders:c` alone receives a `400` ("already exists") on collision instead of the folder.
6985
6996
  *
6986
6997
  * @param {Vectros.CreateFolderRequest} request
6987
6998
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7439,7 +7450,7 @@ var IdentityClient = class {
7439
7450
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}");
7440
7451
  }
7441
7452
  /**
7442
- * Creates a new entity in the given namespace. This call is idempotent on `externalId` within the namespace: if an entity with the same `externalId` already exists, the existing record is returned instead of creating a duplicate (`created: false`, HTTP 200). To overwrite an existing entity's content instead of returning it unchanged, set `?upsert=true` (also requires the `entities:u:<namespace>` scope). The namespace must be entity-backed (`org`/`client`, or registered via `POST /v1/namespaces`). Requires the `entities:c:<namespace>` scope.
7453
+ * Creates a new entity in the given namespace. This call is idempotent on `externalId` within the namespace: if an entity with the same `externalId` already exists, the existing record is returned instead of creating a duplicate (`created: false`, HTTP 200). To overwrite an existing entity's content instead of returning it unchanged, set `?upsert=true` (also requires the `entities:u:<namespace>` scope). The namespace must be entity-backed (`org`/`client`, or registered via `POST /v1/namespaces`). Requires the `entities:c:<namespace>` scope to create. Being returned the existing entity on a collision is a read of that entity's data and additionally requires the `entities:r:<namespace>` scope — a credential holding `entities:c:<namespace>` alone receives a `400` ("already in use") on collision instead of the entity.
7443
7454
  *
7444
7455
  * @param {Vectros.CreateEntityRequest} request
7445
7456
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7883,7 +7894,7 @@ var IdentityClient = class {
7883
7894
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
7884
7895
  }
7885
7896
  /**
7886
- * Updates the mutable fields (`entityBacked`, `defaultSchemaId`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
7897
+ * Updates the mutable fields (`entityBacked`, `defaultSchemaId`, `specificityRank`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
7887
7898
  *
7888
7899
  * @param {Vectros.UpdateNamespaceRequest} request
7889
7900
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7896,7 +7907,8 @@ var IdentityClient = class {
7896
7907
  * await client.identity.updateNamespace({
7897
7908
  * namespace: "team",
7898
7909
  * body: {
7899
- * namespace: "team"
7910
+ * namespace: "team",
7911
+ * specificityRank: 1500
7900
7912
  * }
7901
7913
  * })
7902
7914
  */
@@ -8061,7 +8073,7 @@ var IdentityClient = class {
8061
8073
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
8062
8074
  }
8063
8075
  /**
8064
- * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
8076
+ * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Also requires `specificityRank`, an explicit, account-unique position in the specificity order used to break recordType schema-resolution ties. Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
8065
8077
  *
8066
8078
  * @param {Vectros.NamespaceRequest} request
8067
8079
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8072,7 +8084,8 @@ var IdentityClient = class {
8072
8084
  *
8073
8085
  * @example
8074
8086
  * await client.identity.registerNamespace({
8075
- * namespace: "team"
8087
+ * namespace: "team",
8088
+ * specificityRank: 1500
8076
8089
  * })
8077
8090
  */
8078
8091
  registerNamespace(request, requestOptions) {
@@ -8189,7 +8202,7 @@ var IdentityClient = class {
8189
8202
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users");
8190
8203
  }
8191
8204
  /**
8192
- * Creates a user identity in your account. The operation is idempotent on `externalId`: if a user with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing user was returned) tells the two apart. To overwrite an existing user's mutable fields (email, status, payload, schema binding) instead of returning it unchanged, set `?upsert=true` (this also requires the `users:u` scope). Requires the `users:c` scope.
8205
+ * Creates a user identity in your account. The operation is idempotent on `externalId`: if a user with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing user was returned) tells the two apart. To overwrite an existing user's mutable fields (email, status, payload, schema binding) instead of returning it unchanged, set `?upsert=true` (this also requires the `users:u` scope). Requires the `users:c` scope to create. Being returned the existing user on a collision is a read of that user's data and additionally requires the `users:r` scope — a credential holding `users:c` alone receives a `400` ("already exists") on collision instead of the user.
8193
8206
  *
8194
8207
  * @param {Vectros.CreateUserRequest} request
8195
8208
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9060,7 +9073,7 @@ var RecordsClient = class {
9060
9073
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/records");
9061
9074
  }
9062
9075
  /**
9063
- * Creates a new record of a given type. The `payload` is validated against that type's schema before the record is stored. Identify the type by sending `typeName`, `schemaId`, or both (they must agree); if you send only `schemaId`, the type is taken from that schema. Optionally supply an `externalId` to make the create idempotent — if a record with the same `externalId` already exists in your context, that existing record is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing record was returned) tells the two apart. To overwrite an existing record's content instead of returning it unchanged, set `?upsert=true` (this also requires the `records:u:<type>` scope). Requires the `records:c:<type>` scope.
9076
+ * Creates a new record of a given type. The `payload` is validated against that type's schema before the record is stored. Identify the type by sending `typeName`, `schemaId`, or both (they must agree); if you send only `schemaId`, the type is taken from that schema. Optionally supply an `externalId` to make the create idempotent — if a record with the same `externalId` already exists in your context, that existing record is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing record was returned) tells the two apart. To overwrite an existing record's content instead of returning it unchanged, set `?upsert=true` (this also requires the `records:u:<type>` scope). Requires the `records:c:<type>` scope to create. Being returned the existing record on a collision is a read of that record's data and additionally requires the `records:r:<type>` scope — a credential holding `records:c:<type>` alone receives a `400` ("already exists") on collision instead of the record.
9064
9077
  *
9065
9078
  * @param {Vectros.CreateRecordRequest} request
9066
9079
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9651,6 +9664,8 @@ var SchemasClient = class {
9651
9664
  * @param {Vectros.ListSchemasRequest} request
9652
9665
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
9653
9666
  *
9667
+ * @throws {@link Vectros.BadRequestError}
9668
+ *
9654
9669
  * @example
9655
9670
  * await client.schemas.listSchemas({
9656
9671
  * userId: "550e8400-e29b-41d4-a716-446655440000",
@@ -9697,16 +9712,21 @@ var SchemasClient = class {
9697
9712
  return { data: _response.body, rawResponse: _response.rawResponse };
9698
9713
  }
9699
9714
  if (_response.error.reason === "status-code") {
9700
- throw new VectrosError({
9701
- statusCode: _response.error.statusCode,
9702
- body: _response.error.body,
9703
- rawResponse: _response.rawResponse
9704
- });
9715
+ switch (_response.error.statusCode) {
9716
+ case 400:
9717
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9718
+ default:
9719
+ throw new VectrosError({
9720
+ statusCode: _response.error.statusCode,
9721
+ body: _response.error.body,
9722
+ rawResponse: _response.rawResponse
9723
+ });
9724
+ }
9705
9725
  }
9706
9726
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas");
9707
9727
  }
9708
9728
  /**
9709
- * Defines a new record type with optional field definitions, validation rules, and lookup indexes. Idempotent by `typeName` within the same ownership scope: re-creating an existing `typeName` returns the existing schema rather than failing. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing schema was returned) tells the two apart. To reconcile an existing schema to the submitted shape instead of returning it unchanged, set `?upsert=true` (this also requires the `schemas:w` scope; only legal schema changes are applied — migration-locked changes are rejected). Requires the `schemas:w` scope.
9729
+ * Defines a new record type with optional field definitions, validation rules, and lookup indexes. Idempotent by `typeName` within the same ownership scope: re-creating an existing `typeName` returns the existing schema rather than failing. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing schema was returned) tells the two apart. To reconcile an existing schema to the submitted shape instead of returning it unchanged, set `?upsert=true` (this also requires the `schemas:u` scope; only legal schema changes are applied — migration-locked changes are rejected). Requires the `schemas:c` scope to create. Being returned the existing schema on a collision is a read of that schema's data and additionally requires the `schemas:r` scope — a credential holding `schemas:c` alone receives a `400` ("already in use") on collision instead of the schema.
9710
9730
  *
9711
9731
  * @param {Vectros.CreateSchemaRequest} request
9712
9732
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9850,7 +9870,7 @@ var SchemasClient = class {
9850
9870
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
9851
9871
  }
9852
9872
  /**
9853
- * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Requires the `schemas:w` scope.
9873
+ * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Requires the `schemas:u` scope.
9854
9874
  *
9855
9875
  * @param {Vectros.UpdateSchemaRequest} request
9856
9876
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9919,7 +9939,7 @@ var SchemasClient = class {
9919
9939
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
9920
9940
  }
9921
9941
  /**
9922
- * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. Requires the `schemas:w` scope.
9942
+ * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. A lineage base (a schema other schemas declare `basedOn`) also cannot be deleted while any such variant still exists — delete the variant schema(s) first. Requires the `schemas:d` scope.
9923
9943
  *
9924
9944
  * @param {Vectros.DeleteSchemaRequest} request
9925
9945
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -10316,7 +10336,14 @@ var BlueprintSchemaSchema = z.object({
10316
10336
  // With a scoped token these must be consistent with the profile's dataScope
10317
10337
  // (a cross-consistency lint is deferred to the lint slice).
10318
10338
  userId: z.string().min(1).optional(),
10319
- scopes: z.array(z.string().min(1)).max(2).optional()
10339
+ scopes: z.array(z.string().min(1)).max(2).optional(),
10340
+ // The id of an existing schema this one is a CUSTOMIZATION of, when a schema
10341
+ // named `typeName` already exists in this context — required in that case,
10342
+ // and must be omitted when this create is the first schema under that name
10343
+ // (it becomes that name's shared base). Must point directly at the base (one
10344
+ // hop); immutable once set. Mirrors the `basedOn` field on the platform's
10345
+ // schema-create request.
10346
+ basedOn: z.string().min(1).optional()
10320
10347
  }).strict();
10321
10348
  var BlueprintAccessProfileSchema = z.object({
10322
10349
  // Validated structurally here; the SCOPE GATE (in @vectros-ai/cli) is
@@ -13474,7 +13501,8 @@ async function runLoader(client, input) {
13474
13501
  capabilities: toCapabilities(s.capabilities),
13475
13502
  active: s.active,
13476
13503
  userId: s.userId,
13477
- scopes: s.scopes
13504
+ scopes: s.scopes,
13505
+ basedOn: s.basedOn
13478
13506
  };
13479
13507
  const resp = await ctxClient.schemas.createSchema({ upsert: true, body: schemaBody });
13480
13508
  if (resp.id) schemaIds[s.typeName] = resp.id;
@@ -18351,9 +18379,9 @@ function emitJoined(alias, context, principalId, role, keyId, reused) {
18351
18379
 
18352
18380
  // src/build-info.ts
18353
18381
  var BUILD_INFO = {
18354
- cli: true ? "0.11.0" : "dev",
18355
- sdk: true ? "0.36.0" : "dev",
18356
- blueprints: true ? "0.8.0" : "dev"
18382
+ cli: true ? "0.12.0" : "dev",
18383
+ sdk: true ? "0.37.0" : "dev",
18384
+ blueprints: true ? "0.9.0" : "dev"
18357
18385
  };
18358
18386
  function formatBuildInfo() {
18359
18387
  return `vectros ${BUILD_INFO.cli} (sdk ${BUILD_INFO.sdk}, blueprints ${BUILD_INFO.blueprints})`;