@assinafy/cli 2.6.0 → 2.7.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.
Files changed (37) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.en.md +50 -20
  3. package/README.md +38 -10
  4. package/THIRD_PARTY_NOTICES.md +1 -1
  5. package/dist/api.cjs +235 -34
  6. package/dist/api.cjs.map +1 -1
  7. package/dist/api.js +234 -34
  8. package/dist/api.js.map +1 -1
  9. package/dist/cli.cjs +365 -68
  10. package/dist/types/api/client.d.ts +2 -0
  11. package/dist/types/api/client.d.ts.map +1 -1
  12. package/dist/types/api/contract-types.d.ts +110 -0
  13. package/dist/types/api/contract-types.d.ts.map +1 -0
  14. package/dist/types/api/index.d.ts +2 -0
  15. package/dist/types/api/index.d.ts.map +1 -1
  16. package/dist/types/api/resources/assignments.d.ts +2 -2
  17. package/dist/types/api/resources/assignments.d.ts.map +1 -1
  18. package/dist/types/api/resources/authentication.d.ts +3 -3
  19. package/dist/types/api/resources/authentication.d.ts.map +1 -1
  20. package/dist/types/api/resources/contracts.d.ts +19 -0
  21. package/dist/types/api/resources/contracts.d.ts.map +1 -0
  22. package/dist/types/api/resources/documents.d.ts +4 -3
  23. package/dist/types/api/resources/documents.d.ts.map +1 -1
  24. package/dist/types/api/resources/webhooks.d.ts +4 -3
  25. package/dist/types/api/resources/webhooks.d.ts.map +1 -1
  26. package/dist/types/api/types.d.ts +69 -18
  27. package/dist/types/api/types.d.ts.map +1 -1
  28. package/dist/types/api/utils.d.ts +8 -2
  29. package/dist/types/api/utils.d.ts.map +1 -1
  30. package/docs/README.md +2 -1
  31. package/docs/api-operations.json +49 -1
  32. package/docs/api-reference.md +1454 -295
  33. package/docs/contracts.md +128 -0
  34. package/docs/documents.md +7 -4
  35. package/docs/oauth-guide.md +5 -5
  36. package/docs/sdk-reference.md +156 -15
  37. package/package.json +2 -2
package/dist/cli.cjs CHANGED
@@ -11747,8 +11747,14 @@ var require_follow_redirects = __commonJS({
11747
11747
  RedirectableRequest.prototype._sanitizeOptions = function(options) {
11748
11748
  if (!options.headers) {
11749
11749
  options.headers = {};
11750
+ } else if (Array.isArray(options.headers)) {
11751
+ var headerList = options.headers;
11752
+ options.headers = {};
11753
+ for (var i2 = 0; i2 < headerList.length; i2 += 2) {
11754
+ options.headers[headerList[i2]] = headerList[i2 + 1];
11755
+ }
11750
11756
  }
11751
- if (!isArray2(options.sensitiveHeaders)) {
11757
+ if (!Array.isArray(options.sensitiveHeaders)) {
11752
11758
  options.sensitiveHeaders = [];
11753
11759
  }
11754
11760
  if (options.host) {
@@ -12005,9 +12011,6 @@ var require_follow_redirects = __commonJS({
12005
12011
  var dot = subdomain.length - domain.length - 1;
12006
12012
  return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
12007
12013
  }
12008
- function isArray2(value) {
12009
- return value instanceof Array;
12010
- }
12011
12014
  function isString2(value) {
12012
12015
  return typeof value === "string" || value instanceof String;
12013
12016
  }
@@ -12021,7 +12024,7 @@ var require_follow_redirects = __commonJS({
12021
12024
  return URL2 && value instanceof URL2;
12022
12025
  }
12023
12026
  function escapeRegex(regex) {
12024
- return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
12027
+ return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
12025
12028
  }
12026
12029
  module2.exports = wrap({ http: http3, https: https2 });
12027
12030
  module2.exports.wrap = wrap;
@@ -21267,6 +21270,11 @@ function requireIso8601(value, name = "timestamp") {
21267
21270
  }
21268
21271
  return value;
21269
21272
  }
21273
+ function requireExpiration(value, name = "expires_at") {
21274
+ const timestamp = /^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T23:59:00Z` : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(value) ? `${value}Z` : value;
21275
+ requireIso8601(timestamp, name);
21276
+ return value;
21277
+ }
21270
21278
  function requireEmail(value) {
21271
21279
  if (!value || !EMAIL_RE.test(value)) {
21272
21280
  throw new ValidationError("Invalid email address", { email: value });
@@ -21300,6 +21308,13 @@ function validateSignerOptions(input) {
21300
21308
  throw new ValidationError("step must be an integer");
21301
21309
  }
21302
21310
  }
21311
+ function validateDigitalCertificateMethod(method, signers) {
21312
+ if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
21313
+ throw new ValidationError("DigitalCertificate signers require method: virtual", {
21314
+ code: "digital_certificate_requires_virtual"
21315
+ });
21316
+ }
21317
+ }
21303
21318
  function validateSigningSteps(signers) {
21304
21319
  const withSteps = signers.filter((signer) => signer.step !== void 0);
21305
21320
  if (withSteps.length > 0) {
@@ -21476,18 +21491,20 @@ function buildAssignmentPayload(payload, options = {}) {
21476
21491
  signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
21477
21492
  });
21478
21493
  }
21479
- if (payload.method === "collect" && !Array.isArray(payload.entries)) {
21494
+ const method = payload.method ?? "virtual";
21495
+ const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
21496
+ validateDigitalCertificateMethod(method, normalisedSigners);
21497
+ if (method === "collect" && !Array.isArray(payload.entries)) {
21480
21498
  throw new ValidationError("entries are required for collect assignments");
21481
21499
  }
21482
- const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
21483
21500
  if (!options.skipDigitalCertificateStepValidation) {
21484
21501
  validateSigningSteps(normalisedSigners);
21485
21502
  }
21486
21503
  return stripEmpty({
21487
- method: payload.method ?? "virtual",
21504
+ method,
21488
21505
  signers: normalisedSigners,
21489
21506
  message: payload.message,
21490
- expires_at: payload.expires_at === void 0 ? void 0 : requireIso8601(payload.expires_at, "expires_at"),
21507
+ expires_at: payload.expires_at === void 0 ? void 0 : requireExpiration(payload.expires_at),
21491
21508
  copy_receivers: payload.copy_receivers,
21492
21509
  entries: payload.entries
21493
21510
  });
@@ -21625,13 +21642,13 @@ var AssignmentResource = class extends BaseResource {
21625
21642
  }
21626
21643
  /**
21627
21644
  * Update the expiration date of an existing assignment.
21628
- * The published API accepts an ISO 8601 timestamp. Deployments that support
21629
- * clearing an expiration also accept `null`.
21645
+ * Accepts an ISO 8601 timestamp, a UTC date/time without an offset, a date
21646
+ * (23:59 UTC), or `null` to clear the expiration.
21630
21647
  */
21631
21648
  async resetExpiration(documentId, assignmentId, expiresAt) {
21632
21649
  const docId = this.requireId(documentId, "Document ID");
21633
21650
  const asgId = this.requireId(assignmentId, "Assignment ID");
21634
- if (expiresAt !== null) requireIso8601(expiresAt, "expiresAt");
21651
+ if (expiresAt !== null) requireExpiration(expiresAt, "expiresAt");
21635
21652
  return this.call(
21636
21653
  "Failed to update assignment expiration",
21637
21654
  () => this.http.put(`/documents/${docId}/assignments/${asgId}/reset-expiration`, {
@@ -21683,7 +21700,7 @@ function requireReauth(payload) {
21683
21700
  return payload;
21684
21701
  }
21685
21702
  var AuthenticationResource = class extends BaseResource {
21686
- /** `POST /login` — exchange email + password for a JWT access token. */
21703
+ /** `POST /login` — return an authenticated session or a two-factor challenge. */
21687
21704
  async login(email, password2) {
21688
21705
  if (!email) throw new ValidationError("email is required");
21689
21706
  if (!password2) throw new ValidationError("password is required");
@@ -21826,6 +21843,156 @@ var AuthenticationResource = class extends BaseResource {
21826
21843
  }
21827
21844
  };
21828
21845
 
21846
+ // src/api/resources/contracts.ts
21847
+ var statuses = ["draft", "active", "expired", "terminated"];
21848
+ var ContractResource = class extends BaseResource {
21849
+ /** List terms, optionally embedding documents; supports pagination and comma-separated statuses. */
21850
+ async list(params = {}, accountId) {
21851
+ const id = this.accountId(accountId);
21852
+ const status = Array.isArray(params.status) ? params.status.join(",") : params.status;
21853
+ if (status !== void 0 && (typeof status !== "string" || status.split(",").some((s) => !statuses.includes(s)))) {
21854
+ throw new ValidationError("status must contain draft, active, expired or terminated");
21855
+ }
21856
+ for (const field of ["end_date_from", "end_date_to"]) {
21857
+ if (params[field] !== void 0) requireDate(params[field], field, 0);
21858
+ }
21859
+ if (params.ending_within_days !== void 0)
21860
+ requireInteger(params.ending_within_days, "ending_within_days", 0, 3650);
21861
+ requireSort(params.sort, ["end_date", "-end_date", "updated_at", "-updated_at"]);
21862
+ if (params.expand !== void 0 && params.expand !== "document")
21863
+ throw new ValidationError("expand must be document");
21864
+ return this.callList(
21865
+ "Failed to list contracts",
21866
+ () => this.http.get(`/accounts/${id}/contracts`, { params: cleanParams({ ...params, status }) })
21867
+ );
21868
+ }
21869
+ /** Read a document's own terms or its amendment link. Missing terms return ApiError 404. */
21870
+ async get(documentId, accountId) {
21871
+ const id = this.accountId(accountId);
21872
+ const did = this.requireId(documentId, "Document ID");
21873
+ return this.call(
21874
+ "Failed to get contract",
21875
+ () => this.http.get(`/accounts/${id}/documents/${did}/contract`)
21876
+ );
21877
+ }
21878
+ /** Set only supplied terms, or link/update/unlink a pending amendment. Preserve null clearing. */
21879
+ async set(documentId, payload, accountId) {
21880
+ const id = this.accountId(accountId);
21881
+ const did = this.requireId(documentId, "Document ID");
21882
+ requireBody(payload, true);
21883
+ validateTerms(payload);
21884
+ return this.call(
21885
+ "Failed to set contract terms",
21886
+ () => this.http.put(`/accounts/${id}/documents/${did}/contract`, payload)
21887
+ );
21888
+ }
21889
+ /** Read the root contract and its amendments from any document in that family. */
21890
+ async related(documentId, accountId) {
21891
+ const id = this.accountId(accountId);
21892
+ const did = this.requireId(documentId, "Document ID");
21893
+ return this.call(
21894
+ "Failed to get related contracts",
21895
+ () => this.http.get(`/accounts/${id}/documents/${did}/contract/related`)
21896
+ );
21897
+ }
21898
+ /** Advance from the supplied current term or to a later end date. No automatic retry. */
21899
+ async renew(documentId, payload, accountId) {
21900
+ const id = this.accountId(accountId);
21901
+ const did = this.requireId(documentId, "Document ID");
21902
+ requireBody(payload, true);
21903
+ if (payload.term === void 0 && !payload.end_date)
21904
+ throw new ValidationError("Renewal requires term or end_date");
21905
+ if (payload.term !== void 0)
21906
+ requireInteger(payload.term, "term", 1, Number.MAX_SAFE_INTEGER);
21907
+ validateTerms({ ...payload, end_date: payload.end_date === "" ? null : payload.end_date });
21908
+ return this.call(
21909
+ "Failed to renew contract",
21910
+ () => this.http.post(`/accounts/${id}/documents/${did}/contract/renew`, payload)
21911
+ );
21912
+ }
21913
+ /** Terminate existing terms; an optional reason is recorded in document activities. */
21914
+ async terminate(documentId, payload = {}, accountId) {
21915
+ const id = this.accountId(accountId);
21916
+ const did = this.requireId(documentId, "Document ID");
21917
+ requireBody(payload);
21918
+ if (payload.reason != null && (typeof payload.reason !== "string" || [...payload.reason].length > 500))
21919
+ throw new ValidationError("reason must be text of at most 500 characters");
21920
+ if (payload.updated_at != null) requireIso8601(payload.updated_at, "updated_at");
21921
+ return this.call(
21922
+ "Failed to terminate contract",
21923
+ () => this.http.post(`/accounts/${id}/documents/${did}/contract/terminate`, payload)
21924
+ );
21925
+ }
21926
+ };
21927
+ function requireBody(value, nonempty = false) {
21928
+ if (!value || typeof value !== "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
21929
+ throw new ValidationError("Contract body must be a JSON object");
21930
+ }
21931
+ if (nonempty && !Object.values(value).some((v) => v !== void 0))
21932
+ throw new ValidationError("At least one contract attribute is required");
21933
+ }
21934
+ function requireDate(value, field, minYear = 1e3) {
21935
+ if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value) || Number(value.slice(0, 4)) < minYear)
21936
+ throw new ValidationError(`${field} must be a YYYY-MM-DD date from year ${minYear}`);
21937
+ requireIso8601(`${value}T00:00:00Z`, field);
21938
+ }
21939
+ function requireInteger(value, field, min, max) {
21940
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max)
21941
+ throw new ValidationError(`${field} must be an integer from ${min} to ${max}`);
21942
+ }
21943
+ function validateTerms(payload) {
21944
+ for (const field of ["start_date", "end_date"])
21945
+ if (payload[field] != null) requireDate(payload[field], field);
21946
+ if (payload.start_date && payload.end_date && payload.end_date < payload.start_date)
21947
+ throw new ValidationError("end_date must not precede start_date");
21948
+ if (payload.updated_at != null) requireIso8601(payload.updated_at, "updated_at");
21949
+ if (payload.status !== void 0 && !statuses.includes(payload.status))
21950
+ throw new ValidationError("Invalid contract status");
21951
+ if (payload.relation_type !== void 0 && !["amendment", "renewal", "termination"].includes(payload.relation_type))
21952
+ throw new ValidationError("Invalid relation_type");
21953
+ if (payload.auto_renew != null && typeof payload.auto_renew !== "boolean")
21954
+ throw new ValidationError("auto_renew must be boolean or null");
21955
+ if (payload.renewal_term_months != null)
21956
+ requireInteger(payload.renewal_term_months, "renewal_term_months", 1, 600);
21957
+ if (payload.notice_period_days != null)
21958
+ requireInteger(payload.notice_period_days, "notice_period_days", 0, 3650);
21959
+ if (payload.value != null && (typeof payload.value !== "number" || !Number.isFinite(payload.value) || payload.value < 0 || payload.value > 999999999999999e-2 || Number(payload.value.toFixed(2)) !== payload.value))
21960
+ throw new ValidationError(
21961
+ "value must be from 0 to 9999999999999.99 with at most two decimal places"
21962
+ );
21963
+ for (const [field, max] of [
21964
+ ["counterparty_name", 255],
21965
+ ["counterparty_taxpayer_id", 20],
21966
+ ["owner_id", Infinity],
21967
+ ["parent_document_id", Infinity]
21968
+ ]) {
21969
+ const value = payload[field];
21970
+ if (value != null && (typeof value !== "string" || [...value].length > max))
21971
+ throw new ValidationError(`${field} must be text of at most ${max} characters`);
21972
+ }
21973
+ if (payload.currency != null && (typeof payload.currency !== "string" || !/^[a-z]{3}$/i.test(payload.currency)))
21974
+ throw new ValidationError("currency must be a three-letter code");
21975
+ if (payload.metadata != null) {
21976
+ requireBody(payload.metadata);
21977
+ const entries = Object.entries(payload.metadata);
21978
+ if (entries.length > 50 || entries.some(
21979
+ ([key, value]) => !/^[a-z\d_.-]{1,40}$/i.test(key) || typeof value !== "string" || [...value].length > 500
21980
+ ))
21981
+ throw new ValidationError(
21982
+ "metadata requires at most 50 valid keys with text values of at most 500 characters"
21983
+ );
21984
+ }
21985
+ if (payload.external_references != null) {
21986
+ if (!Array.isArray(payload.external_references) || payload.external_references.length > 20)
21987
+ throw new ValidationError("external_references must be a list of at most 20 items");
21988
+ for (const reference of payload.external_references) {
21989
+ requireBody(reference);
21990
+ if (typeof reference.system !== "string" || !/^[a-z\d_.-]{1,64}$/i.test(reference.system) || typeof reference.id !== "string" || !reference.id || [...reference.id].length > 255 || /[\u{10000}-\u{10ffff}]/u.test(reference.id))
21991
+ throw new ValidationError("Each external reference requires a valid system and id");
21992
+ }
21993
+ }
21994
+ }
21995
+
21829
21996
  // src/api/resources/documents.ts
21830
21997
  var import_node_fs2 = require("fs");
21831
21998
  var import_node_path2 = __toESM(require("path"), 1);
@@ -21921,7 +22088,7 @@ var DocumentResource = class extends BaseResource {
21921
22088
  if (!name?.trim()) throw new ValidationError("name is required");
21922
22089
  return this.call(
21923
22090
  "Failed to rename document",
21924
- () => this.http.patch(`/documents/${id}`, { name })
22091
+ () => this.http.patch(`/documents/${id}`, { name }, { params: { expand: "assignment" } })
21925
22092
  );
21926
22093
  }
21927
22094
  /** Alias for {@link details}. */
@@ -22009,12 +22176,13 @@ var DocumentResource = class extends BaseResource {
22009
22176
  })
22010
22177
  );
22011
22178
  }
22012
- /** Fetch the document activity log. */
22013
- async activities(documentId) {
22179
+ /** Fetch one page of the document activity log (20 entries by default). */
22180
+ async activities(documentId, params = {}) {
22014
22181
  const id = this.requireId(documentId, "Document ID");
22182
+ requireSort(params.sort, ["id", "-id"]);
22015
22183
  const result = await this.call(
22016
22184
  "Failed to fetch document activities",
22017
- () => this.http.get(`/documents/${id}/activities`)
22185
+ () => this.http.get(`/documents/${id}/activities`, { params: cleanParams({ ...params }) })
22018
22186
  );
22019
22187
  return result ?? [];
22020
22188
  }
@@ -22080,14 +22248,15 @@ var DocumentResource = class extends BaseResource {
22080
22248
  async createFromTemplate(templateId, signers, options = {}, accountId) {
22081
22249
  const tmplId = this.requireId(templateId, "Template ID");
22082
22250
  const accId = this.accountId(accountId);
22083
- validateTemplateSigners(signers, { requireId: true });
22084
- if (options.expires_at !== void 0) requireIso8601(options.expires_at, "expires_at");
22251
+ validateTemplateSigners(signers, { requireIdentity: true });
22252
+ if (options.expires_at !== void 0) requireExpiration(options.expires_at);
22085
22253
  if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
22086
22254
  throw new ValidationError("editor_fields must contain field_id and value");
22087
22255
  }
22088
22256
  if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag))) {
22089
22257
  throw new ValidationError("tags must contain non-empty tag names");
22090
22258
  }
22259
+ await this.validateCertificateTemplateMethod(tmplId, accId, signers);
22091
22260
  const body = { ...options, signers };
22092
22261
  this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
22093
22262
  return this.call(
@@ -22099,7 +22268,8 @@ var DocumentResource = class extends BaseResource {
22099
22268
  async estimateCostFromTemplate(templateId, signers, accountId) {
22100
22269
  const tmplId = this.requireId(templateId, "Template ID");
22101
22270
  const accId = this.accountId(accountId);
22102
- validateTemplateSigners(signers, { requireId: false });
22271
+ validateTemplateSigners(signers, { requireIdentity: false });
22272
+ await this.validateCertificateTemplateMethod(tmplId, accId, signers);
22103
22273
  return this.call(
22104
22274
  "Failed to estimate cost from template",
22105
22275
  () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents/estimate-cost`, { signers })
@@ -22178,6 +22348,25 @@ var DocumentResource = class extends BaseResource {
22178
22348
  const percentage = total > 0 ? Math.round(signed / total * 1e4) / 100 : 0;
22179
22349
  return { signed, total, pending, percentage };
22180
22350
  }
22351
+ async validateCertificateTemplateMethod(templateId, accountId, signers) {
22352
+ if (!signers.some((signer) => signer.verification_method === "DigitalCertificate")) return;
22353
+ const template = await this.call(
22354
+ "Failed to fetch template",
22355
+ () => this.http.get(`/accounts/${accountId}/templates/${templateId}`)
22356
+ );
22357
+ const nonSignerRoles = new Set(
22358
+ template.roles?.filter(
22359
+ (role) => role.assignment_type === "Editor" || role.assignment_type === "CopyReceiver"
22360
+ ).map((role) => role.id)
22361
+ );
22362
+ const method = template.pages?.some(
22363
+ (page) => page.fields.some((field) => !nonSignerRoles.has(field.role_id))
22364
+ ) ? "collect" : "virtual";
22365
+ validateDigitalCertificateMethod(
22366
+ method,
22367
+ signers.filter((signer) => !nonSignerRoles.has(signer.role_id))
22368
+ );
22369
+ }
22181
22370
  };
22182
22371
  function validateTemplateSigners(signers, options) {
22183
22372
  if (!Array.isArray(signers)) throw new ValidationError("signers must be an array");
@@ -22189,17 +22378,20 @@ function validateTemplateSigners(signers, options) {
22189
22378
  if (typeof signer.role_id !== "string" || !signer.role_id) {
22190
22379
  throw new ValidationError("each template signer requires role_id");
22191
22380
  }
22192
- if ((options.requireId || signer.id !== void 0) && (typeof signer.id !== "string" || !signer.id)) {
22193
- throw new ValidationError("each template signer requires a valid id");
22194
- }
22195
- validateSignerOptions(signer);
22196
- if (options.requireId && signer.step !== void 0 && Number(signer.step) < 1) {
22197
- throw new ValidationError("template signer step must be a positive integer");
22381
+ if (signer.id !== void 0) {
22382
+ if (typeof signer.id !== "string" || !signer.id) {
22383
+ throw new ValidationError("each template signer requires a valid id");
22384
+ }
22385
+ } else if (options.requireIdentity) {
22386
+ if (typeof signer.email !== "string") {
22387
+ throw new ValidationError("each template signer requires an id or email");
22388
+ }
22389
+ requireEmail(signer.email);
22390
+ if (signer.name !== void 0 && (typeof signer.name !== "string" || !signer.name.trim())) {
22391
+ throw new ValidationError("template signer name cannot be blank");
22392
+ }
22198
22393
  }
22199
22394
  }
22200
- if (options.requireId) {
22201
- validateSigningSteps(signers);
22202
- }
22203
22395
  }
22204
22396
  async function loadSource(source) {
22205
22397
  if ("buffer" in source) {
@@ -23120,7 +23312,11 @@ var NOTIFICATION_PREFERENCE_CODES = [
23120
23312
  "DocumentExpirationReset",
23121
23313
  "DocumentProcessingFailed",
23122
23314
  "TemplateProcessingFailed",
23123
- "SignerWhatsappFailed"
23315
+ "SignerWhatsappFailed",
23316
+ "ContractRenewalNotice",
23317
+ "ContractExpiring",
23318
+ "ContractExpired",
23319
+ "ContractRenewed"
23124
23320
  ];
23125
23321
 
23126
23322
  // src/api/resources/users.ts
@@ -23282,6 +23478,7 @@ var WebhookResource = class extends BaseResource {
23282
23478
  * `PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}` — update only
23283
23479
  * the fields sent. Enabling signing creates a secret when none exists;
23284
23480
  * disabling it discards the secret.
23481
+ * Enabling signing returns the new secret once, including to OAuth applications.
23285
23482
  */
23286
23483
  async updateEndpoint(endpointId, payload, accountId) {
23287
23484
  const id = this.accountId(accountId);
@@ -23328,7 +23525,7 @@ var WebhookResource = class extends BaseResource {
23328
23525
  }
23329
23526
  /**
23330
23527
  * `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
23331
- * The old secret stops working immediately. Not available to OAuth applications.
23528
+ * The old secret stops working immediately. Requires `webhooks:write` for OAuth.
23332
23529
  */
23333
23530
  async rotateEndpointSecret(endpointId, accountId) {
23334
23531
  const id = this.accountId(accountId);
@@ -23580,6 +23777,7 @@ var AssinafyClient = class _AssinafyClient {
23580
23777
  logger;
23581
23778
  webhookSecret;
23582
23779
  documents;
23780
+ contracts;
23583
23781
  signers;
23584
23782
  workspaces;
23585
23783
  assignments;
@@ -23646,6 +23844,7 @@ var AssinafyClient = class _AssinafyClient {
23646
23844
  maxRedirects: 0
23647
23845
  });
23648
23846
  this.documents = new DocumentResource(this.axiosInstance, this.defaultAccountId, this.logger);
23847
+ this.contracts = new ContractResource(this.axiosInstance, this.defaultAccountId, this.logger);
23649
23848
  this.signers = new SignerResource(this.axiosInstance, this.defaultAccountId, this.logger);
23650
23849
  this.workspaces = new WorkspaceResource(this.axiosInstance, void 0, this.logger);
23651
23850
  this.assignments = new AssignmentResource(
@@ -23703,12 +23902,11 @@ var AssinafyClient = class _AssinafyClient {
23703
23902
  if (!Array.isArray(options.signers) || options.signers.length === 0) {
23704
23903
  throw new ValidationError("At least one signer is required");
23705
23904
  }
23706
- if (options.expiresAt !== void 0) requireIso8601(options.expiresAt, "expiresAt");
23905
+ if (options.expiresAt !== void 0) requireExpiration(options.expiresAt, "expiresAt");
23707
23906
  const preparedSigners = options.signers.map((signer) => {
23708
23907
  if (!signer || typeof signer !== "object") {
23709
23908
  throw new ValidationError("Each signer must be an object");
23710
23909
  }
23711
- validateSignerOptions(signer);
23712
23910
  const payload = { full_name: signer.name };
23713
23911
  if (signer.email !== void 0) payload.email = signer.email;
23714
23912
  const phone = signer.whatsapp_phone_number ?? signer.phone;
@@ -23717,7 +23915,14 @@ var AssinafyClient = class _AssinafyClient {
23717
23915
  if (signer.government_id !== void 0) payload.government_id = signer.government_id;
23718
23916
  if (signer.metadata !== void 0) payload.metadata = signer.metadata;
23719
23917
  validateCreateSignerPayload(payload);
23720
- return { signer, payload, phone };
23918
+ const useWhatsapp = phone !== void 0 && signer.email === void 0;
23919
+ const reference = {
23920
+ verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
23921
+ notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
23922
+ step: signer.step
23923
+ };
23924
+ validateSignerOptions(reference);
23925
+ return { reference, payload };
23721
23926
  });
23722
23927
  validateSigningSteps(options.signers);
23723
23928
  this.logger.info("Starting upload + signature workflow", {
@@ -23733,15 +23938,12 @@ var AssinafyClient = class _AssinafyClient {
23733
23938
  await this.documents.waitUntilReady(document2.id);
23734
23939
  }
23735
23940
  const assignmentSigners = [];
23736
- for (const { signer, payload, phone } of preparedSigners) {
23941
+ for (const { reference, payload } of preparedSigners) {
23737
23942
  const created = await this.signers.create(payload, options.accountId);
23738
23943
  signerIds.push(created.id);
23739
- const useWhatsapp = phone !== void 0 && signer.email === void 0;
23740
23944
  assignmentSigners.push({
23741
23945
  id: created.id,
23742
- verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
23743
- notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
23744
- step: signer.step
23946
+ ...reference
23745
23947
  });
23746
23948
  }
23747
23949
  const assignmentPayload = {
@@ -24963,7 +25165,18 @@ function readBinary(inputPath) {
24963
25165
  function writeBinary(outputPath, data, options = {}) {
24964
25166
  const resolved = import_node_path4.default.resolve(outputPath);
24965
25167
  try {
24966
- (0, import_node_fs4.writeFileSync)(resolved, data, { flag: options.force ? "w" : "wx" });
25168
+ const descriptor = (0, import_node_fs4.openSync)(
25169
+ resolved,
25170
+ options.force ? import_node_fs4.constants.O_WRONLY | import_node_fs4.constants.O_CREAT : "wx",
25171
+ 384
25172
+ );
25173
+ try {
25174
+ if (process.platform !== "win32") (0, import_node_fs4.fchmodSync)(descriptor, 384);
25175
+ if (options.force) (0, import_node_fs4.ftruncateSync)(descriptor, 0);
25176
+ (0, import_node_fs4.writeFileSync)(descriptor, data);
25177
+ } finally {
25178
+ (0, import_node_fs4.closeSync)(descriptor);
25179
+ }
24967
25180
  } catch (err) {
24968
25181
  if (err && typeof err === "object" && "code" in err && err.code === "EEXIST") {
24969
25182
  throw new CliError(`File "${resolved}" already exists. Pass --force to overwrite it.`);
@@ -25605,6 +25818,7 @@ var loginCommand = new Command("login").description(
25605
25818
  () => client.auth.verifyMfa({ mfa_token: mfaToken, code })
25606
25819
  );
25607
25820
  }
25821
+ if (!result.access_token) throw new CliError("Login did not return an access token.");
25608
25822
  printSession(result, config);
25609
25823
  });
25610
25824
  });
@@ -25970,6 +26184,86 @@ var pathCommand = new Command("path").description("Print the config file path").
25970
26184
  });
25971
26185
  var configCommand = new Command("config").description("Manage credentials, profiles, and settings").addCommand(setCommand).addCommand(getCommand).addCommand(listCommand2).addCommand(useCommand).addCommand(removeCommand).addCommand(pathCommand);
25972
26186
 
26187
+ // src/commands/contracts.ts
26188
+ var listCommand3 = addListOptions(
26189
+ new Command("list").description("List workspace contract terms"),
26190
+ "end_date or updated_at; prefix with - for descending"
26191
+ ).option("--status <csv>", "draft, active, expired, terminated (comma-separated)").option("--counterparty <query>", "Counterparty name or exact CPF/CNPJ").option("--end-date-from <date>", "Earliest end date (YYYY-MM-DD)").option("--end-date-to <date>", "Latest end date (YYYY-MM-DD)").option("--ending-within-days <n>", "Ends within 0\u20133650 days; 0 includes today in Bras\xEDlia").option("--external-system <system>", "External reference system").option("--external-id <id>", "External reference ID").option("--expand <relation>", "Embed document").action(async (opts, command) => {
26192
+ await runWithClient(command, async ({ client, config }) => {
26193
+ const params = {
26194
+ ...listParams(opts),
26195
+ status: opts.status,
26196
+ counterparty: opts.counterparty,
26197
+ end_date_from: opts.endDateFrom,
26198
+ end_date_to: opts.endDateTo,
26199
+ ending_within_days: parseInteger(opts.endingWithinDays, "--ending-within-days", { min: 0 }),
26200
+ external_system: opts.externalSystem,
26201
+ external_id: opts.externalId,
26202
+ expand: opts.expand
26203
+ };
26204
+ const result = await withSpinner(
26205
+ "Fetching contracts",
26206
+ config,
26207
+ () => client.contracts.list(params, requireAccountId(config))
26208
+ );
26209
+ printData(
26210
+ result,
26211
+ config,
26212
+ (page) => tableWithFooter(
26213
+ renderTable(page.data, [
26214
+ { header: "DOCUMENT", value: (r2) => r2.document_id },
26215
+ { header: "STATUS", value: (r2) => r2.status },
26216
+ { header: "COUNTERPARTY", value: (r2) => r2.counterparty_name },
26217
+ { header: "END DATE", value: (r2) => r2.end_date },
26218
+ { header: "TERM", value: (r2) => r2.term }
26219
+ ]),
26220
+ page
26221
+ )
26222
+ );
26223
+ });
26224
+ });
26225
+ var getCommand2 = new Command("get").description("Read a document\u2019s contract terms or amendment link").argument("<documentId>", "Document ID").action(async (documentId, _opts, command) => {
26226
+ await runWithClient(command, async ({ client, config }) => {
26227
+ printData(await client.contracts.get(documentId, requireAccountId(config)), config);
26228
+ });
26229
+ });
26230
+ var setCommand2 = new Command("set").description("Set terms or link an amendment; null clears, omitted fields stay unchanged").argument("<documentId>", "Document ID").requiredOption(
26231
+ "--data <json>",
26232
+ "JSON terms or amendment link; include updated_at for conflict detection"
26233
+ ).action(async (documentId, opts, command) => {
26234
+ await runWithClient(command, async ({ client, config }) => {
26235
+ const payload = parseJsonObject(opts.data, "--data");
26236
+ printData(await client.contracts.set(documentId, payload, requireAccountId(config)), config);
26237
+ });
26238
+ });
26239
+ var relatedCommand = new Command("related").description("Read the root contract and every linked instrument").argument("<documentId>", "Contract or amendment document ID").action(async (documentId, _opts, command) => {
26240
+ await runWithClient(command, async ({ client, config }) => {
26241
+ printData(await client.contracts.related(documentId, requireAccountId(config)), config);
26242
+ });
26243
+ });
26244
+ var renewCommand = new Command("renew").description("Start the next term using the current term or a later end_date").argument("<documentId>", "Document ID").requiredOption("--data <json>", "JSON with term or end_date, optional value and updated_at").option("-y, --yes", "Skip confirmation").action(async (documentId, opts, command) => {
26245
+ await runWithClient(command, async ({ client, config }) => {
26246
+ const payload = parseJsonObject(opts.data, "--data");
26247
+ if (!await confirmDestructive(`Renew contract ${documentId}?`, Boolean(opts.yes))) return;
26248
+ printData(
26249
+ await client.contracts.renew(documentId, payload, requireAccountId(config)),
26250
+ config
26251
+ );
26252
+ });
26253
+ });
26254
+ var terminateCommand = new Command("terminate").description("Terminate tracked terms and stop lifecycle alerts").argument("<documentId>", "Document ID").option("--data <json>", "JSON with optional reason and updated_at").option("-y, --yes", "Skip confirmation").action(async (documentId, opts, command) => {
26255
+ await runWithClient(command, async ({ client, config }) => {
26256
+ const payload = parseJsonObject(opts.data, "--data") ?? {};
26257
+ if (!await confirmDestructive(`Terminate contract ${documentId}?`, Boolean(opts.yes)))
26258
+ return;
26259
+ printData(
26260
+ await client.contracts.terminate(documentId, payload, requireAccountId(config)),
26261
+ config
26262
+ );
26263
+ });
26264
+ });
26265
+ var contractsCommand = new Command("contracts").description("Track contract terms, amendments, renewals and terminations (CLM)").addCommand(listCommand3).addCommand(getCommand2).addCommand(setCommand2).addCommand(relatedCommand).addCommand(renewCommand).addCommand(terminateCommand);
26266
+
25973
26267
  // src/lib/oauth-browser.ts
25974
26268
  var import_node_child_process2 = require("child_process");
25975
26269
  var import_node_crypto4 = require("crypto");
@@ -26196,7 +26490,7 @@ function renderDocumentListTable(result) {
26196
26490
  ]);
26197
26491
  return tableWithFooter(table, result);
26198
26492
  }
26199
- var listCommand3 = addListOptions(
26493
+ var listCommand4 = addListOptions(
26200
26494
  new Command("list").description("List workspace documents").option("--status <status>", "Filter by document status").addOption(
26201
26495
  new Option("--method <method>", "Filter by signature method (virtual or collect)").choices([
26202
26496
  "virtual",
@@ -26234,7 +26528,7 @@ var searchCommand = addListOptions(
26234
26528
  printPaginatedData(result, config, () => renderDocumentListTable(result));
26235
26529
  });
26236
26530
  });
26237
- var getCommand2 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").action(async (id, _opts, command) => {
26531
+ var getCommand3 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").action(async (id, _opts, command) => {
26238
26532
  await runWithClient(command, async ({ client, config }) => {
26239
26533
  const doc = await withSpinner(
26240
26534
  "Fetching document",
@@ -26312,12 +26606,15 @@ var downloadPageCommand = addDownloadOptions(
26312
26606
  });
26313
26607
  });
26314
26608
  });
26315
- var activitiesCommand = new Command("activities").description("Show the activity log for a document").argument("<id>", "Document ID").action(async (id, _opts, command) => {
26609
+ var activitiesCommand = addSortableListOptions(
26610
+ new Command("activities").description("Show one page of the activity log for a document").argument("<id>", "Document ID"),
26611
+ "Sort by id or -id (default: -id, newest first)"
26612
+ ).action(async (id, opts, command) => {
26316
26613
  await runWithClient(command, async ({ client, config }) => {
26317
26614
  const activities = await withSpinner(
26318
26615
  "Fetching activities",
26319
26616
  config,
26320
- () => client.documents.activities(id)
26617
+ () => client.documents.activities(id, listParams(opts))
26321
26618
  );
26322
26619
  printData(
26323
26620
  activities,
@@ -26442,13 +26739,13 @@ var verifyCommand = new Command("verify").description("Verify a document by its
26442
26739
  });
26443
26740
  var statusesCommand = new Command("statuses").description("List every possible document status").action(async (_opts, command) => {
26444
26741
  await runWithClient(command, async ({ client, config }) => {
26445
- const statuses = await withSpinner(
26742
+ const statuses2 = await withSpinner(
26446
26743
  "Fetching statuses",
26447
26744
  config,
26448
26745
  () => client.documents.statuses()
26449
26746
  );
26450
26747
  printData(
26451
- statuses,
26748
+ statuses2,
26452
26749
  config,
26453
26750
  (rows) => renderTable(rows, [
26454
26751
  { header: "CODE", value: (r2) => r2.code },
@@ -26522,7 +26819,7 @@ var waitCommand = new Command("wait").description("Poll a document until it is r
26522
26819
  printData(doc, config, (d) => renderKeyValue({ id: d.id, status: d.status }));
26523
26820
  });
26524
26821
  });
26525
- var documentsCommand = new Command("documents").description("Upload, list, download, and manage documents").addCommand(uploadCommand).addCommand(listCommand3).addCommand(searchCommand).addCommand(getCommand2).addCommand(renameCommand).addCommand(downloadCommand).addCommand(thumbnailCommand).addCommand(downloadPageCommand).addCommand(activitiesCommand).addCommand(deleteCommand).addCommand(tagsCommand).addCommand(tagsSetCommand).addCommand(tagsAddCommand).addCommand(tagsRemoveCommand).addCommand(createFromTemplateCommand).addCommand(estimateTemplateCostCommand).addCommand(verifyCommand).addCommand(statusesCommand).addCommand(publicCommand).addCommand(sendTokenCommand).addCommand(progressCommand).addCommand(waitCommand);
26822
+ var documentsCommand = new Command("documents").description("Upload, list, download, and manage documents").addCommand(uploadCommand).addCommand(listCommand4).addCommand(searchCommand).addCommand(getCommand3).addCommand(renameCommand).addCommand(downloadCommand).addCommand(thumbnailCommand).addCommand(downloadPageCommand).addCommand(activitiesCommand).addCommand(deleteCommand).addCommand(tagsCommand).addCommand(tagsSetCommand).addCommand(tagsAddCommand).addCommand(tagsRemoveCommand).addCommand(createFromTemplateCommand).addCommand(estimateTemplateCostCommand).addCommand(verifyCommand).addCommand(statusesCommand).addCommand(publicCommand).addCommand(sendTokenCommand).addCommand(progressCommand).addCommand(waitCommand);
26526
26823
 
26527
26824
  // src/commands/fields.ts
26528
26825
  var fieldColumns = [
@@ -26551,7 +26848,7 @@ var createCommand2 = new Command("create").description("Create a custom field de
26551
26848
  printData(field, config, (f) => renderKeyValue({ id: f.id, name: f.name, type: f.type }));
26552
26849
  });
26553
26850
  });
26554
- var listCommand4 = new Command("list").description("List field definitions").option("--include-inactive", "Include inactive fields").option("--include-standard", "Include standard fields (signature, initial, \u2026)").action(async (opts, command) => {
26851
+ var listCommand5 = new Command("list").description("List field definitions").option("--include-inactive", "Include inactive fields").option("--include-standard", "Include standard fields (signature, initial, \u2026)").action(async (opts, command) => {
26555
26852
  await runWithClient(command, async ({ client, config }) => {
26556
26853
  const accountId = requireAccountId(config);
26557
26854
  const fields = await withSpinner(
@@ -26565,7 +26862,7 @@ var listCommand4 = new Command("list").description("List field definitions").opt
26565
26862
  printData(fields, config, (rows) => renderTable(rows, fieldColumns));
26566
26863
  });
26567
26864
  });
26568
- var getCommand3 = new Command("get").description("Show a field definition by ID").argument("<id>", "Field ID").action(async (id, _opts, command) => {
26865
+ var getCommand4 = new Command("get").description("Show a field definition by ID").argument("<id>", "Field ID").action(async (id, _opts, command) => {
26569
26866
  await runWithClient(command, async ({ client, config }) => {
26570
26867
  const accountId = requireAccountId(config);
26571
26868
  const field = await withSpinner(
@@ -26663,7 +26960,7 @@ var typesCommand = new Command("types").description("List the platform's support
26663
26960
  );
26664
26961
  });
26665
26962
  });
26666
- var fieldsCommand = new Command("fields").description("Manage custom field definitions used by collect assignments").addCommand(createCommand2).addCommand(listCommand4).addCommand(getCommand3).addCommand(updateCommand).addCommand(deleteCommand2).addCommand(validateCommand).addCommand(validateMultipleCommand).addCommand(typesCommand);
26963
+ var fieldsCommand = new Command("fields").description("Manage custom field definitions used by collect assignments").addCommand(createCommand2).addCommand(listCommand5).addCommand(getCommand4).addCommand(updateCommand).addCommand(deleteCommand2).addCommand(validateCommand).addCommand(validateMultipleCommand).addCommand(typesCommand);
26667
26964
 
26668
26965
  // src/commands/login.ts
26669
26966
  var loginCommand2 = new Command("login").description(
@@ -26671,10 +26968,10 @@ var loginCommand2 = new Command("login").description(
26671
26968
  ).action(async (_opts, command) => {
26672
26969
  await runAction(command, async ({ config }) => {
26673
26970
  const merged = command.optsWithGlobals();
26674
- const file = readConfigFile({ strict: true });
26971
+ const profileName = activeProfileName(getGlobals(command), readConfigFile({ strict: true }));
26675
26972
  const apiKey = merged.apiKey ?? await promptSecret("Enter your Assinafy API key");
26676
26973
  const accountId = merged.accountId ?? await promptText("Default account/workspace ID (optional)");
26677
- const profileName = activeProfileName(getGlobals(command), file);
26974
+ const file = readConfigFile({ strict: true });
26678
26975
  const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
26679
26976
  const profile = { ...profiles[profileName], api_key: apiKey };
26680
26977
  if (accountId) profile.account_id = accountId;
@@ -27216,7 +27513,7 @@ var createCommand3 = new Command("create").description("Create a signer (reuses
27216
27513
  );
27217
27514
  });
27218
27515
  });
27219
- var listCommand5 = addListOptions(
27516
+ var listCommand6 = addListOptions(
27220
27517
  new Command("list").description("List signers in the workspace"),
27221
27518
  "Sort by full_name (prefix with - for descending)"
27222
27519
  ).action(async (opts, command) => {
@@ -27233,7 +27530,7 @@ var listCommand5 = addListOptions(
27233
27530
  });
27234
27531
  });
27235
27532
  });
27236
- var getCommand4 = new Command("get").description("Show a signer by ID").argument("<id>", "Signer ID").action(async (id, _opts, command) => {
27533
+ var getCommand5 = new Command("get").description("Show a signer by ID").argument("<id>", "Signer ID").action(async (id, _opts, command) => {
27237
27534
  await runWithClient(command, async ({ client, config }) => {
27238
27535
  const accountId = requireAccountId(config);
27239
27536
  const signer = await withSpinner(
@@ -27296,7 +27593,7 @@ var findCommand = new Command("find-by-email").description("Find a signer by ema
27296
27593
  );
27297
27594
  });
27298
27595
  });
27299
- var signersCommand = new Command("signers").description("Create, list, and manage signers").addCommand(createCommand3).addCommand(listCommand5).addCommand(getCommand4).addCommand(updateCommand2).addCommand(deleteCommand3).addCommand(findCommand);
27596
+ var signersCommand = new Command("signers").description("Create, list, and manage signers").addCommand(createCommand3).addCommand(listCommand6).addCommand(getCommand5).addCommand(updateCommand2).addCommand(deleteCommand3).addCommand(findCommand);
27300
27597
 
27301
27598
  // src/commands/tags.ts
27302
27599
  var tagColumns = [
@@ -27304,7 +27601,7 @@ var tagColumns = [
27304
27601
  { header: "NAME", value: (r2) => r2.name },
27305
27602
  { header: "COLOR", value: (r2) => r2.color }
27306
27603
  ];
27307
- var listCommand6 = new Command("list").description("List workspace tags (alphabetical)").option("--search <query>", "Case-insensitive name filter").action(async (opts, command) => {
27604
+ var listCommand7 = new Command("list").description("List workspace tags (alphabetical)").option("--search <query>", "Case-insensitive name filter").action(async (opts, command) => {
27308
27605
  await runWithClient(command, async ({ client, config }) => {
27309
27606
  const accountId = requireAccountId(config);
27310
27607
  const params = opts.search ? { search: opts.search } : {};
@@ -27357,10 +27654,10 @@ var deleteCommand4 = new Command("delete").alias("rm").description("Delete a tag
27357
27654
  printData(result, config);
27358
27655
  });
27359
27656
  });
27360
- var tagsCommand2 = new Command("tags").description("Manage workspace tags").addCommand(listCommand6).addCommand(createCommand4).addCommand(updateCommand3).addCommand(deleteCommand4);
27657
+ var tagsCommand2 = new Command("tags").description("Manage workspace tags").addCommand(listCommand7).addCommand(createCommand4).addCommand(updateCommand3).addCommand(deleteCommand4);
27361
27658
 
27362
27659
  // src/commands/templates.ts
27363
- var listCommand7 = addListOptions(
27660
+ var listCommand8 = addListOptions(
27364
27661
  new Command("list").description("List templates in the workspace"),
27365
27662
  "Sort by name (prefix with - for descending)"
27366
27663
  ).action(async (opts, command) => {
@@ -27382,7 +27679,7 @@ var listCommand7 = addListOptions(
27382
27679
  });
27383
27680
  });
27384
27681
  });
27385
- var getCommand5 = new Command("get").description("Show a template by ID").argument("<id>", "Template ID").action(async (id, _opts, command) => {
27682
+ var getCommand6 = new Command("get").description("Show a template by ID").argument("<id>", "Template ID").action(async (id, _opts, command) => {
27386
27683
  await runWithClient(command, async ({ client, config }) => {
27387
27684
  const accountId = requireAccountId(config);
27388
27685
  const template = await withSpinner(
@@ -27416,7 +27713,7 @@ var downloadPageCommand2 = addDownloadOptions(
27416
27713
  });
27417
27714
  });
27418
27715
  });
27419
- var templatesCommand = new Command("templates").description("List and inspect document templates").addCommand(listCommand7).addCommand(getCommand5).addCommand(downloadPageCommand2);
27716
+ var templatesCommand = new Command("templates").description("List and inspect document templates").addCommand(listCommand8).addCommand(getCommand6).addCommand(downloadPageCommand2);
27420
27717
 
27421
27718
  // src/commands/users.ts
27422
27719
  var selfCommand2 = new Command("self").description("Show the authenticated user's profile and accounts").action(async (_opts, command) => {
@@ -27497,7 +27794,7 @@ var registerCommand = new Command("register").description("Register (or replace)
27497
27794
  );
27498
27795
  });
27499
27796
  });
27500
- var getCommand6 = new Command("get").description("Show the account's oldest webhook endpoint").action(async (_opts, command) => {
27797
+ var getCommand7 = new Command("get").description("Show the account's oldest webhook endpoint").action(async (_opts, command) => {
27501
27798
  await runWithClient(command, async ({ client, config }) => {
27502
27799
  const accountId = requireAccountId(config);
27503
27800
  const sub = await withSpinner(
@@ -27775,7 +28072,7 @@ var verifyCommand2 = new Command("verify").description(
27775
28072
  });
27776
28073
  });
27777
28074
  var endpointsCommand = new Command("endpoints").description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsDeleteByUrlCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
27778
- var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand6).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand).addCommand(verifyCommand2);
28075
+ var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand7).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand).addCommand(verifyCommand2);
27779
28076
 
27780
28077
  // src/commands/whoami.ts
27781
28078
  var whoamiCommand = new Command("whoami").description("Verify credentials and list the workspaces they can access").action(async (_opts, command) => {
@@ -27821,7 +28118,7 @@ var createCommand5 = new Command("create").description("Create a workspace (acco
27821
28118
  printData(workspace, config, (w) => renderKeyValue({ id: w.id, name: w.name }));
27822
28119
  });
27823
28120
  });
27824
- var listCommand8 = new Command("list").description("List workspaces you can access").action(async (_opts, command) => {
28121
+ var listCommand9 = new Command("list").description("List workspaces you can access").action(async (_opts, command) => {
27825
28122
  await runWithClient(command, async ({ client, config }) => {
27826
28123
  const result = await withSpinner(
27827
28124
  "Fetching workspaces",
@@ -27840,7 +28137,7 @@ var listCommand8 = new Command("list").description("List workspaces you can acce
27840
28137
  );
27841
28138
  });
27842
28139
  });
27843
- var getCommand7 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
28140
+ var getCommand8 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
27844
28141
  await runWithClient(command, async ({ client, config }) => {
27845
28142
  const workspace = await withSpinner(
27846
28143
  "Fetching workspace",
@@ -27951,7 +28248,7 @@ var deleteCommand5 = new Command("delete").alias("rm").description("Delete a wor
27951
28248
  printData({ deleted: id }, config);
27952
28249
  });
27953
28250
  });
27954
- var workspacesCommand = new Command("workspaces").alias("accounts").description("Manage workspaces (accounts)").addCommand(createCommand5).addCommand(listCommand8).addCommand(getCommand7).addCommand(themeCommand).addCommand(statsCommand2).addCommand(logoCommand).addCommand(updateCommand4).addCommand(deleteCommand5);
28251
+ var workspacesCommand = new Command("workspaces").alias("accounts").description("Manage workspaces (accounts)").addCommand(createCommand5).addCommand(listCommand9).addCommand(getCommand8).addCommand(themeCommand).addCommand(statsCommand2).addCommand(logoCommand).addCommand(updateCommand4).addCommand(deleteCommand5);
27955
28252
  function logoContentType(file) {
27956
28253
  return {
27957
28254
  ".gif": "image/gif",
@@ -27998,7 +28295,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
27998
28295
  // package.json
27999
28296
  var package_default = {
28000
28297
  name: "@assinafy/cli",
28001
- version: "2.6.0",
28298
+ version: "2.7.0",
28002
28299
  description: "The official command-line interface for the Assinafy digital-signature API",
28003
28300
  license: "MIT",
28004
28301
  type: "module",
@@ -28084,7 +28381,7 @@ var package_default = {
28084
28381
  tsup: "^8.3.5",
28085
28382
  tsx: "^4.23.12",
28086
28383
  typescript: "^7.0.2",
28087
- vitest: "^4.1.11"
28384
+ vitest: "^4.1.12"
28088
28385
  },
28089
28386
  overrides: {
28090
28387
  esbuild: "^0.28.2"
@@ -28114,7 +28411,7 @@ ${import_picocolors7.default.gray("Examples:")}
28114
28411
 
28115
28412
  ${import_picocolors7.default.gray("Sandbox:")} target it with ${import_picocolors7.default.blue("--base-url https://sandbox.assinafy.com.br/v1")}
28116
28413
  `
28117
- ).addCommand(sendCommand).addCommand(documentsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
28414
+ ).addCommand(sendCommand).addCommand(documentsCommand).addCommand(contractsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
28118
28415
  program2.parseAsync().catch((err) => {
28119
28416
  process.stderr.write(
28120
28417
  `${import_picocolors7.default.red("error:")} ${sanitizeTerminalText(err instanceof Error ? err.message : String(err))}