@stackin-io/stackin-node-sdk 0.21.0 → 0.23.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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The issuer itself: PATCH /company.
3
+ *
4
+ * Fixes what Invoice.readiness() reports missing. Reading stays
5
+ * Invoice.readiness(); this client only writes. Company data, so update
6
+ * takes company for one call over the client's own.
7
+ */
8
+ import { Client, CompanyOption } from "./client";
9
+ /**
10
+ * The issuer address fields an API credential may fix. There is no
11
+ * complement, and the state changes only in the dashboard: it decides
12
+ * the authorizer.
13
+ */
14
+ export interface CompanyAddress {
15
+ street?: string;
16
+ number?: string;
17
+ neighborhood?: string;
18
+ /** 7-digit IBGE code of a city in the company's state. */
19
+ municipalityCode?: string;
20
+ /**
21
+ * Derived from municipalityCode when left out; resolved to its code
22
+ * when sent alone; must be that city's when both are sent.
23
+ */
24
+ municipalityName?: string;
25
+ /** CEP, 8 digits; a mask (01310-100) is accepted and stripped. */
26
+ zipCode?: string;
27
+ }
28
+ /** The fiscal fields only the company owner may set. */
29
+ export interface FiscalFields {
30
+ /** CRT: 1 Simples, 2 Simples excesso, 3 normal, 4 MEI. */
31
+ taxRegime?: string;
32
+ /** NFS-e opSimpNac: 1 no, 2 MEI, 3 ME/EPP. */
33
+ simplesNacional?: string;
34
+ /** NFS-e regApTribSN for ME/EPP: 1 to 3. */
35
+ simplesApuracao?: string;
36
+ /** Inscrição estadual (IE), or ISENTO. */
37
+ stateRegistration?: string;
38
+ /** Default cTribNac, e.g. 1.07 or 01.07.00. */
39
+ serviceCode?: string;
40
+ }
41
+ /** What update changes; only what is given is sent. */
42
+ export interface CompanyUpdate {
43
+ address?: CompanyAddress;
44
+ fiscalFields?: FiscalFields;
45
+ }
46
+ /** Client for the issuer's own address and fiscal fields. */
47
+ export declare class Company extends Client {
48
+ /**
49
+ * Fixes the issuer's address and, for the owner, its fiscal fields,
50
+ * and answers whether the company can issue now.
51
+ *
52
+ * The result is every readiness() field (ready, missing,
53
+ * by_document_type, fix_url, ...) plus address (the six fields and
54
+ * state) and fiscal_fields (where set). A call with nothing sends {}:
55
+ * the API changes nothing and answers the company as it is.
56
+ *
57
+ * fiscalFields are the owner's alone: anyone else gets a 403 APIError,
58
+ * even when the address in the same call would pass. An OAuth token
59
+ * without company:write is an InsufficientPermissionError. A city the
60
+ * IBGE table cannot be read for right now is a 503 with Retry-After;
61
+ * nothing was written.
62
+ */
63
+ update(changes?: CompanyUpdate, options?: CompanyOption): Promise<Record<string, unknown>>;
64
+ }
65
+ //# sourceMappingURL=company.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.d.ts","sourceRoot":"","sources":["../src/company.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAoHD,6DAA6D;AAC7D,qBAAa,OAAQ,SAAQ,MAAM;IACjC;;;;;;;;;;;;;;OAcG;IACG,MAAM,CACV,OAAO,GAAE,aAAkB,EAC3B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAMpC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Company = void 0;
4
+ /**
5
+ * The issuer itself: PATCH /company.
6
+ *
7
+ * Fixes what Invoice.readiness() reports missing. Reading stays
8
+ * Invoice.readiness(); this client only writes. Company data, so update
9
+ * takes company for one call over the client's own.
10
+ */
11
+ const client_1 = require("./client");
12
+ const errors_1 = require("./errors");
13
+ const ADDRESS_KEYS = {
14
+ street: "street",
15
+ number: "number",
16
+ neighborhood: "neighborhood",
17
+ municipalityCode: "municipality_code",
18
+ municipalityName: "municipality_name",
19
+ zipCode: "zip_code",
20
+ };
21
+ const FISCAL_KEYS = {
22
+ taxRegime: "tax_regime",
23
+ simplesNacional: "simples_nacional",
24
+ simplesApuracao: "simples_apuracao",
25
+ stateRegistration: "state_registration",
26
+ serviceCode: "service_code",
27
+ };
28
+ const UPDATE_KEYS = ["address", "fiscalFields"];
29
+ const ENUMS = {
30
+ taxRegime: ["1", "2", "3", "4"],
31
+ simplesNacional: ["1", "2", "3"],
32
+ simplesApuracao: ["1", "2", "3"],
33
+ };
34
+ function companyBody(given) {
35
+ const changes = given ?? {};
36
+ refuseUnknown("update", changes, UPDATE_KEYS);
37
+ const body = {};
38
+ const address = group("address", changes.address, ADDRESS_KEYS);
39
+ if (address) {
40
+ if (address.municipality_code !== undefined) {
41
+ if (!/^[0-9]{7}$/.test(address.municipality_code)) {
42
+ throw new errors_1.ValidationError("municipalityCode must be the 7-digit IBGE code");
43
+ }
44
+ }
45
+ if (address.zip_code !== undefined) {
46
+ const digits = address.zip_code.replace(/[\s.-]/g, "");
47
+ if (!/^[0-9]{8}$/.test(digits)) {
48
+ throw new errors_1.ValidationError("zipCode must be the 8-digit CEP");
49
+ }
50
+ address.zip_code = digits;
51
+ }
52
+ body.address = address;
53
+ }
54
+ const fiscal = group("fiscalFields", changes.fiscalFields, FISCAL_KEYS);
55
+ if (fiscal) {
56
+ for (const [name, allowed] of Object.entries(ENUMS)) {
57
+ const value = fiscal[FISCAL_KEYS[name]];
58
+ if (value !== undefined && !allowed.includes(value)) {
59
+ throw new errors_1.ValidationError(`${name} must be one of ${allowed.join(", ")}`);
60
+ }
61
+ }
62
+ body.fiscal_fields = fiscal;
63
+ }
64
+ return body;
65
+ }
66
+ /** One group on the wire, or undefined when nothing in it is set. */
67
+ function group(name, fields, keys) {
68
+ if (fields === undefined || fields === null) {
69
+ return undefined;
70
+ }
71
+ if (typeof fields !== "object" || Array.isArray(fields)) {
72
+ throw new errors_1.ValidationError(`${name} must be an object`);
73
+ }
74
+ refuseUnknown(name, fields, Object.keys(keys));
75
+ const out = {};
76
+ for (const [key, value] of Object.entries(fields)) {
77
+ if (value === undefined || value === null) {
78
+ continue;
79
+ }
80
+ if (typeof value !== "string") {
81
+ throw new errors_1.ValidationError(`${name}.${key} must be a string`);
82
+ }
83
+ out[keys[key]] = value;
84
+ }
85
+ return Object.keys(out).length > 0 ? out : undefined;
86
+ }
87
+ function refuseUnknown(name, fields, known) {
88
+ const unknown = Object.keys(fields)
89
+ .filter((key) => !known.includes(key))
90
+ .sort();
91
+ if (unknown.length > 0) {
92
+ throw new errors_1.ValidationError(`${name} does not take ${unknown.join(", ")}. Known: ${known.join(", ")}`);
93
+ }
94
+ }
95
+ /** Client for the issuer's own address and fiscal fields. */
96
+ class Company extends client_1.Client {
97
+ /**
98
+ * Fixes the issuer's address and, for the owner, its fiscal fields,
99
+ * and answers whether the company can issue now.
100
+ *
101
+ * The result is every readiness() field (ready, missing,
102
+ * by_document_type, fix_url, ...) plus address (the six fields and
103
+ * state) and fiscal_fields (where set). A call with nothing sends {}:
104
+ * the API changes nothing and answers the company as it is.
105
+ *
106
+ * fiscalFields are the owner's alone: anyone else gets a 403 APIError,
107
+ * even when the address in the same call would pass. An OAuth token
108
+ * without company:write is an InsufficientPermissionError. A city the
109
+ * IBGE table cannot be read for right now is a 503 with Retry-After;
110
+ * nothing was written.
111
+ */
112
+ async update(changes = {}, options = {}) {
113
+ return this.request("PATCH", "/company", {
114
+ body: companyBody(changes),
115
+ company: options.company,
116
+ });
117
+ }
118
+ }
119
+ exports.Company = Company;
120
+ //# sourceMappingURL=company.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.js","sourceRoot":"","sources":["../src/company.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,qCAAiD;AACjD,qCAA2C;AA0C3C,MAAM,YAAY,GAA2B;IAC3C,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,mBAAmB;IACrC,gBAAgB,EAAE,mBAAmB;IACrC,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF,MAAM,WAAW,GAA2B;IAC1C,SAAS,EAAE,YAAY;IACvB,eAAe,EAAE,kBAAkB;IACnC,eAAe,EAAE,kBAAkB;IACnC,iBAAiB,EAAE,oBAAoB;IACvC,WAAW,EAAE,cAAc;CAC5B,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAEhD,MAAM,KAAK,GAAsC;IAC/C,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC/B,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAChC,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;CACjC,CAAC;AAEF,SAAS,WAAW,CAAC,KAA2B;IAC9C,MAAM,OAAO,GAAG,KAAK,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AS,aAAa,CACpB,IAAY,EACZ,MAA+B,EAC/B,KAAwB;IAExB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SAChC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SACrC,IAAI,EAAE,CAAC;IACV,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,wBAAe,CACvB,GAAG,IAAI,kBAAkB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,6DAA6D;AAC7D,MAAa,OAAQ,SAAQ,eAAM;IACjC;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CACV,UAAyB,EAAE,EAC3B,UAAyB,EAAE;QAE3B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE;YACvC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;IACL,CAAC;CACF;AAzBD,0BAyBC"}
package/dist/errors.d.ts CHANGED
@@ -89,4 +89,62 @@ export declare class ClientNotFoundError extends APIError {
89
89
  readonly clientId: string;
90
90
  constructor(statusCode: number, detail: string, clientId: string);
91
91
  }
92
+ /**
93
+ * A 409 with detail.code ITEM_EXISTS: the company already has an item
94
+ * with this code or externalReference (a deactivated one still holds
95
+ * it). itemId names it and field says which of the two collided, to
96
+ * read or reactivate it instead of searching.
97
+ */
98
+ export declare class ItemAlreadyExistsError extends APIError {
99
+ readonly itemId: string;
100
+ readonly field: string;
101
+ constructor(statusCode: number, detail: string, itemId: string, field: string);
102
+ }
103
+ /**
104
+ * A 404 with detail.code ITEM_NOT_FOUND: the itemId names no item of
105
+ * this company (another company's counts as none).
106
+ */
107
+ export declare class ItemNotFoundError extends APIError {
108
+ readonly itemId: string;
109
+ constructor(statusCode: number, detail: string, itemId: string);
110
+ }
111
+ /**
112
+ * A 422 with detail.code ITEM_INACTIVE: the itemId on an issue line
113
+ * names a deactivated item. Reactivate it (Items.reactivate) or issue
114
+ * the line without it.
115
+ */
116
+ export declare class ItemInactiveError extends APIError {
117
+ readonly itemId: string;
118
+ constructor(statusCode: number, detail: string, itemId: string);
119
+ }
120
+ /**
121
+ * A 422 with detail.code ITEM_KIND_MISMATCH: an issue line names a
122
+ * service on an NF-e or a product on an NFS-e. index is the line.
123
+ */
124
+ export declare class ItemKindMismatchError extends APIError {
125
+ readonly itemId: string;
126
+ readonly index?: number;
127
+ constructor(statusCode: number, detail: string, itemId: string, index?: number);
128
+ }
129
+ /**
130
+ * A 422 with detail.code ITEM_TAX_REQUIRED: the item's taxSituation
131
+ * carries ICMS amounts the catalog does not keep, so the issue line
132
+ * must send its own product.br.tax. index is the line.
133
+ */
134
+ export declare class ItemTaxRequiredError extends APIError {
135
+ readonly itemId: string;
136
+ readonly index?: number;
137
+ constructor(statusCode: number, detail: string, itemId: string, index?: number);
138
+ }
139
+ /**
140
+ * A 422 with detail.code ITEM_TAX_REGIME_MISMATCH: the item's
141
+ * taxSituation does not fit the company's tax regime (a CSOSN is for
142
+ * Simples Nacional, a CST for the rest), or is not allowed on an export
143
+ * CFOP. Send tax on that line, or fix the item. index is the line.
144
+ */
145
+ export declare class ItemTaxRegimeMismatchError extends APIError {
146
+ readonly itemId: string;
147
+ readonly index?: number;
148
+ constructor(statusCode: number, detail: string, itemId: string, index?: number);
149
+ }
92
150
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM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AOjB;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,QAAQ;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAGtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM;CAOjB"}
package/dist/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientNotFoundError = exports.ClientInactiveError = exports.RateLimitedError = exports.PaymentRequiredError = exports.ClientAlreadyExistsError = exports.InsufficientPermissionError = exports.CompanyNotInScopeError = exports.CompanyRequiredError = exports.ValidationError = exports.ConnectionFailedError = exports.APIError = exports.InvoiceError = void 0;
3
+ exports.ItemTaxRegimeMismatchError = exports.ItemTaxRequiredError = exports.ItemKindMismatchError = exports.ItemInactiveError = exports.ItemNotFoundError = exports.ItemAlreadyExistsError = exports.ClientNotFoundError = exports.ClientInactiveError = exports.RateLimitedError = exports.PaymentRequiredError = exports.ClientAlreadyExistsError = exports.InsufficientPermissionError = exports.CompanyNotInScopeError = exports.CompanyRequiredError = exports.ValidationError = exports.ConnectionFailedError = exports.APIError = exports.InvoiceError = void 0;
4
4
  class InvoiceError extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -145,4 +145,96 @@ class ClientNotFoundError extends APIError {
145
145
  }
146
146
  }
147
147
  exports.ClientNotFoundError = ClientNotFoundError;
148
+ /**
149
+ * A 409 with detail.code ITEM_EXISTS: the company already has an item
150
+ * with this code or externalReference (a deactivated one still holds
151
+ * it). itemId names it and field says which of the two collided, to
152
+ * read or reactivate it instead of searching.
153
+ */
154
+ class ItemAlreadyExistsError extends APIError {
155
+ itemId;
156
+ field;
157
+ constructor(statusCode, detail, itemId, field) {
158
+ super(statusCode, detail);
159
+ this.name = "ItemAlreadyExistsError";
160
+ this.itemId = itemId;
161
+ this.field = field;
162
+ }
163
+ }
164
+ exports.ItemAlreadyExistsError = ItemAlreadyExistsError;
165
+ /**
166
+ * A 404 with detail.code ITEM_NOT_FOUND: the itemId names no item of
167
+ * this company (another company's counts as none).
168
+ */
169
+ class ItemNotFoundError extends APIError {
170
+ itemId;
171
+ constructor(statusCode, detail, itemId) {
172
+ super(statusCode, detail);
173
+ this.name = "ItemNotFoundError";
174
+ this.itemId = itemId;
175
+ }
176
+ }
177
+ exports.ItemNotFoundError = ItemNotFoundError;
178
+ /**
179
+ * A 422 with detail.code ITEM_INACTIVE: the itemId on an issue line
180
+ * names a deactivated item. Reactivate it (Items.reactivate) or issue
181
+ * the line without it.
182
+ */
183
+ class ItemInactiveError extends APIError {
184
+ itemId;
185
+ constructor(statusCode, detail, itemId) {
186
+ super(statusCode, detail);
187
+ this.name = "ItemInactiveError";
188
+ this.itemId = itemId;
189
+ }
190
+ }
191
+ exports.ItemInactiveError = ItemInactiveError;
192
+ /**
193
+ * A 422 with detail.code ITEM_KIND_MISMATCH: an issue line names a
194
+ * service on an NF-e or a product on an NFS-e. index is the line.
195
+ */
196
+ class ItemKindMismatchError extends APIError {
197
+ itemId;
198
+ index;
199
+ constructor(statusCode, detail, itemId, index) {
200
+ super(statusCode, detail);
201
+ this.name = "ItemKindMismatchError";
202
+ this.itemId = itemId;
203
+ this.index = index;
204
+ }
205
+ }
206
+ exports.ItemKindMismatchError = ItemKindMismatchError;
207
+ /**
208
+ * A 422 with detail.code ITEM_TAX_REQUIRED: the item's taxSituation
209
+ * carries ICMS amounts the catalog does not keep, so the issue line
210
+ * must send its own product.br.tax. index is the line.
211
+ */
212
+ class ItemTaxRequiredError extends APIError {
213
+ itemId;
214
+ index;
215
+ constructor(statusCode, detail, itemId, index) {
216
+ super(statusCode, detail);
217
+ this.name = "ItemTaxRequiredError";
218
+ this.itemId = itemId;
219
+ this.index = index;
220
+ }
221
+ }
222
+ exports.ItemTaxRequiredError = ItemTaxRequiredError;
223
+ /**
224
+ * A 422 with detail.code ITEM_TAX_REGIME_MISMATCH: the item's
225
+ * taxSituation does not fit the company's tax regime (a CSOSN is for
226
+ * Simples Nacional, a CST for the rest), or is not allowed on an export
227
+ * CFOP. Send tax on that line, or fix the item. index is the line.
228
+ */
229
+ class ItemTaxRegimeMismatchError extends APIError {
230
+ itemId;
231
+ index;
232
+ constructor(statusCode, detail, itemId, index) {
233
+ super(statusCode, detail);
234
+ this.name = "ItemTaxRegimeMismatchError";
235
+ this.itemId = itemId;
236
+ this.index = index;
237
+ }
238
+ }
239
+ exports.ItemTaxRegimeMismatchError = ItemTaxRegimeMismatchError;
148
240
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,QAAS,SAAQ,YAAY;IAC/B,UAAU,CAAS;IACnB,MAAM,CAAS;IAExB,YAAY,UAAkB,EAAE,MAAc;QAC5C,KAAK,CAAC,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAVD,4BAUC;AAED,MAAa,qBAAsB,SAAQ,YAAY;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,eAAgB,SAAQ,YAAY;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,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,8 +2,12 @@ export { Invoice, DEFAULT_BASE_URL, COMPANY_HEADER } from "./client";
2
2
  export type { ClassifyRequest, ClientOptions, CompanyOption, ExportInfo, InvoiceOptions, IssueRequest, PageQuery, } from "./client";
3
3
  export { Clients } from "./clients";
4
4
  export type { ClientChanges, ClientFields, ClientListQuery, ClientSource, } from "./clients";
5
+ export { Items } from "./items";
6
+ export type { CatalogItem, ItemChanges, ItemFields, ItemKind, ItemListQuery, ItemSaved, ItemSource, } from "./items";
5
7
  export { Webhooks, WEBHOOK_EVENTS } from "./webhooks";
6
8
  export type { WebhookEndpoint, WebhookEvent } from "./webhooks";
9
+ export { Company } from "./company";
10
+ export type { CompanyAddress, CompanyUpdate, FiscalFields } from "./company";
7
11
  export { FiscalReference, Kind, KINDS } from "./reference";
8
12
  export type { SearchQuery } from "./reference";
9
13
  export { Taxpayer } from "./taxpayer";
@@ -11,6 +15,6 @@ export { Address } from "./address";
11
15
  export type { AddressFields } from "./address";
12
16
  export { Direction, DocumentType, Environment, Manifestation, Purpose, } from "./types";
13
17
  export type { AuthorizedCompanies, AuthorizedCompany, ReceivedSync, Usage, } from "./types";
14
- export { InvoiceError, APIError, ClientAlreadyExistsError, ClientInactiveError, ClientNotFoundError, CompanyNotInScopeError, CompanyRequiredError, ConnectionFailedError, InsufficientPermissionError, PaymentRequiredError, RateLimitedError, ValidationError, } from "./errors";
18
+ export { InvoiceError, APIError, ClientAlreadyExistsError, ClientInactiveError, ClientNotFoundError, CompanyNotInScopeError, CompanyRequiredError, ConnectionFailedError, InsufficientPermissionError, ItemAlreadyExistsError, ItemInactiveError, ItemKindMismatchError, ItemNotFoundError, ItemTaxRegimeMismatchError, ItemTaxRequiredError, PaymentRequiredError, RateLimitedError, ValidationError, } from "./errors";
15
19
  export * as br from "./br";
16
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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B,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -33,16 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.br = exports.ValidationError = exports.RateLimitedError = exports.PaymentRequiredError = exports.InsufficientPermissionError = exports.ConnectionFailedError = exports.CompanyRequiredError = exports.CompanyNotInScopeError = exports.ClientNotFoundError = exports.ClientInactiveError = exports.ClientAlreadyExistsError = exports.APIError = exports.InvoiceError = exports.Purpose = exports.Manifestation = exports.Environment = exports.DocumentType = exports.Direction = exports.Address = exports.Taxpayer = exports.KINDS = exports.Kind = exports.FiscalReference = exports.WEBHOOK_EVENTS = exports.Webhooks = exports.Clients = exports.COMPANY_HEADER = exports.DEFAULT_BASE_URL = exports.Invoice = void 0;
36
+ exports.br = exports.ValidationError = exports.RateLimitedError = exports.PaymentRequiredError = exports.ItemTaxRequiredError = exports.ItemTaxRegimeMismatchError = exports.ItemNotFoundError = exports.ItemKindMismatchError = exports.ItemInactiveError = exports.ItemAlreadyExistsError = exports.InsufficientPermissionError = exports.ConnectionFailedError = exports.CompanyRequiredError = exports.CompanyNotInScopeError = exports.ClientNotFoundError = exports.ClientInactiveError = exports.ClientAlreadyExistsError = exports.APIError = exports.InvoiceError = exports.Purpose = exports.Manifestation = exports.Environment = exports.DocumentType = exports.Direction = exports.Address = exports.Taxpayer = exports.KINDS = exports.Kind = exports.FiscalReference = exports.Company = exports.WEBHOOK_EVENTS = exports.Webhooks = exports.Items = exports.Clients = exports.COMPANY_HEADER = exports.DEFAULT_BASE_URL = exports.Invoice = void 0;
37
37
  var client_1 = require("./client");
38
38
  Object.defineProperty(exports, "Invoice", { enumerable: true, get: function () { return client_1.Invoice; } });
39
39
  Object.defineProperty(exports, "DEFAULT_BASE_URL", { enumerable: true, get: function () { return client_1.DEFAULT_BASE_URL; } });
40
40
  Object.defineProperty(exports, "COMPANY_HEADER", { enumerable: true, get: function () { return client_1.COMPANY_HEADER; } });
41
41
  var clients_1 = require("./clients");
42
42
  Object.defineProperty(exports, "Clients", { enumerable: true, get: function () { return clients_1.Clients; } });
43
+ var items_1 = require("./items");
44
+ Object.defineProperty(exports, "Items", { enumerable: true, get: function () { return items_1.Items; } });
43
45
  var webhooks_1 = require("./webhooks");
44
46
  Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return webhooks_1.Webhooks; } });
45
47
  Object.defineProperty(exports, "WEBHOOK_EVENTS", { enumerable: true, get: function () { return webhooks_1.WEBHOOK_EVENTS; } });
48
+ var company_1 = require("./company");
49
+ Object.defineProperty(exports, "Company", { enumerable: true, get: function () { return company_1.Company; } });
46
50
  var reference_1 = require("./reference");
47
51
  Object.defineProperty(exports, "FiscalReference", { enumerable: true, get: function () { return reference_1.FiscalReference; } });
48
52
  Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return reference_1.Kind; } });
@@ -67,6 +71,12 @@ Object.defineProperty(exports, "CompanyNotInScopeError", { enumerable: true, get
67
71
  Object.defineProperty(exports, "CompanyRequiredError", { enumerable: true, get: function () { return errors_1.CompanyRequiredError; } });
68
72
  Object.defineProperty(exports, "ConnectionFailedError", { enumerable: true, get: function () { return errors_1.ConnectionFailedError; } });
69
73
  Object.defineProperty(exports, "InsufficientPermissionError", { enumerable: true, get: function () { return errors_1.InsufficientPermissionError; } });
74
+ Object.defineProperty(exports, "ItemAlreadyExistsError", { enumerable: true, get: function () { return errors_1.ItemAlreadyExistsError; } });
75
+ Object.defineProperty(exports, "ItemInactiveError", { enumerable: true, get: function () { return errors_1.ItemInactiveError; } });
76
+ Object.defineProperty(exports, "ItemKindMismatchError", { enumerable: true, get: function () { return errors_1.ItemKindMismatchError; } });
77
+ Object.defineProperty(exports, "ItemNotFoundError", { enumerable: true, get: function () { return errors_1.ItemNotFoundError; } });
78
+ Object.defineProperty(exports, "ItemTaxRegimeMismatchError", { enumerable: true, get: function () { return errors_1.ItemTaxRegimeMismatchError; } });
79
+ Object.defineProperty(exports, "ItemTaxRequiredError", { enumerable: true, get: function () { return errors_1.ItemTaxRequiredError; } });
70
80
  Object.defineProperty(exports, "PaymentRequiredError", { enumerable: true, get: function () { return errors_1.PaymentRequiredError; } });
71
81
  Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return errors_1.RateLimitedError; } });
72
82
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqE;AAA5D,iGAAA,OAAO,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAUlD,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAOhB,uCAAsD;AAA7C,oGAAA,QAAQ,OAAA;AAAE,0GAAA,cAAc,OAAA;AAEjC,yCAA2D;AAAlD,4GAAA,eAAe,OAAA;AAAE,iGAAA,IAAI,OAAA;AAAE,kGAAA,KAAK,OAAA;AAErC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,iCAMiB;AALf,kGAAA,SAAS,OAAA;AACT,qGAAA,YAAY,OAAA;AACZ,oGAAA,WAAW,OAAA;AACX,sGAAA,aAAa,OAAA;AACb,gGAAA,OAAO,OAAA;AAQT,mCAakB;AAZhB,sGAAA,YAAY,OAAA;AACZ,kGAAA,QAAQ,OAAA;AACR,kHAAA,wBAAwB,OAAA;AACxB,6GAAA,mBAAmB,OAAA;AACnB,6G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GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,2GAAA,iBAAiB,OAAA;AACjB,oHAAA,0BAA0B,OAAA;AAC1B,8GAAA,oBAAoB,OAAA;AACpB,8GAAA,oBAAoB,OAAA;AACpB,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AAEjB,2CAA2B"}
@@ -0,0 +1,156 @@
1
+ import { Client, ClientOptions, CompanyOption } from "./client";
2
+ /** Goods (NF-e) or services (NFS-e). */
3
+ export type ItemKind = "product" | "service";
4
+ /** Where an item came from. Set on creation, never by an update. */
5
+ export type ItemSource = "manual" | "import" | "nuvemshop" | "invoice";
6
+ /** A catalog item, as the API returns it from every read and write. */
7
+ export interface CatalogItem {
8
+ id: string;
9
+ company_id: string;
10
+ kind: ItemKind;
11
+ description: string;
12
+ code: string | null;
13
+ /** A JSON number, stored with up to 10 decimal places. */
14
+ unit_price: number | null;
15
+ unit: string | null;
16
+ source: ItemSource;
17
+ external_reference: string | null;
18
+ notes: string | null;
19
+ /** Product only. */
20
+ ncm: string | null;
21
+ cfop: string | null;
22
+ tax_situation: string | null;
23
+ origin: string | null;
24
+ cest: string | null;
25
+ gtin: string | null;
26
+ /** Service only. */
27
+ service_code: string | null;
28
+ iss_retained: boolean | null;
29
+ is_active: boolean;
30
+ uses_count: number;
31
+ last_used_at: string | null;
32
+ created_at: string;
33
+ updated_at: string;
34
+ }
35
+ /** Narrows the item listing. Every field is optional. */
36
+ export interface ItemListQuery extends CompanyOption {
37
+ kind?: ItemKind;
38
+ /** Part of the description, code or externalReference; digits also match ncm and gtin. */
39
+ search?: string;
40
+ source?: ItemSource;
41
+ /** The API lists active items when left out; false lists the deactivated ones. */
42
+ isActive?: boolean;
43
+ limit?: number;
44
+ offset?: number;
45
+ /** description (the default), code, unit_price, last_used_at, created_at or uses_count. */
46
+ sortBy?: string;
47
+ orderBy?: string;
48
+ }
49
+ /**
50
+ * An item's fields, as create takes them. Only kind and description are
51
+ * required; the fiscal fields belong to one kind (the other kind's are a
52
+ * 422), and every rule on them, like the limits, is the API's.
53
+ */
54
+ export interface ItemFields {
55
+ kind: ItemKind;
56
+ /** At most 120 characters for a product (xProd), 2000 for a service. */
57
+ description: string;
58
+ /** SKU / cProd, at most 60; unique within the company. */
59
+ code?: string;
60
+ /** A number or a decimal string (up to 10 places); sent as a decimal string. */
61
+ unitPrice?: number | string;
62
+ /** At most 6 characters (uCom); the API upper-cases it. */
63
+ unit?: string;
64
+ /** Another system's id, e.g. an e-commerce variant; unique within the company. */
65
+ externalReference?: string;
66
+ notes?: string;
67
+ /** Used only when the item is created; an existing one keeps its source. */
68
+ source?: ItemSource;
69
+ /** Product: 8 digits. */
70
+ ncm?: string;
71
+ /** Product: 4 digits, or the last 3. */
72
+ cfop?: string;
73
+ /** Product: an ICMS CST (2 digits) or CSOSN (3 digits). */
74
+ taxSituation?: string;
75
+ /** Product: 0 to 8, needs taxSituation. */
76
+ origin?: string;
77
+ cest?: string;
78
+ /** Product: 8, 12, 13 or 14 digits with a valid check digit. */
79
+ gtin?: string;
80
+ /** Service: LC 116, such as 1.07 or 1.03.02. */
81
+ serviceCode?: string;
82
+ issRetained?: boolean;
83
+ }
84
+ /**
85
+ * The fields update changes. Only the keys present are sent; null clears a
86
+ * field. source cannot be changed.
87
+ */
88
+ export interface ItemChanges {
89
+ kind?: ItemKind;
90
+ description?: string;
91
+ code?: string | null;
92
+ /** A number or a decimal string (up to 10 places); null clears. */
93
+ unitPrice?: number | string | null;
94
+ unit?: string | null;
95
+ externalReference?: string | null;
96
+ notes?: string | null;
97
+ ncm?: string | null;
98
+ cfop?: string | null;
99
+ taxSituation?: string | null;
100
+ origin?: string | null;
101
+ cest?: string | null;
102
+ gtin?: string | null;
103
+ serviceCode?: string | null;
104
+ issRetained?: boolean | null;
105
+ /** true brings a deactivated item back; see reactivate. */
106
+ isActive?: boolean;
107
+ }
108
+ /** What upsert answers: the item, and whether this call created it. */
109
+ export interface ItemSaved {
110
+ item: CatalogItem;
111
+ /** true for a 201 (created), false for a 200 (an existing item updated). */
112
+ created: boolean;
113
+ }
114
+ /**
115
+ * The company's catalog of products and services: what it sells, kept
116
+ * once and named on an issue line by itemId.
117
+ *
118
+ * Company data, like everything on Invoice, so every call takes a
119
+ * company over the client's own. Reading needs invoice:read; saving,
120
+ * editing and deactivating need invoice:issue.
121
+ */
122
+ export declare class Items extends Client {
123
+ constructor(options?: ClientOptions);
124
+ /** A page of the company's items, by description unless sortBy says otherwise. */
125
+ list(query?: ItemListQuery): Promise<Record<string, unknown>>;
126
+ /** One item, deactivated or not. Another company's is a 404. */
127
+ get(itemId: string, options?: CompanyOption): Promise<CatalogItem>;
128
+ /**
129
+ * Saves an item (POST /items), and it is an upsert. It updates the company's item with the same
130
+ * externalReference (or, when none is sent, the same code) with only
131
+ * the fields given, and otherwise creates one, so the same call twice
132
+ * never makes two items. The item keeps its source and isActive.
133
+ * Answers the item alone; upsert also says whether it was created.
134
+ */
135
+ create(fields: ItemFields, options?: CompanyOption): Promise<CatalogItem>;
136
+ /**
137
+ * Like create, but answers { item, created }: created is true for a
138
+ * 201 (a new item) and false for a 200 (an existing one, updated).
139
+ */
140
+ upsert(fields: ItemFields, options?: CompanyOption): Promise<ItemSaved>;
141
+ /**
142
+ * Changes only the fields given. The API checks the item as a whole,
143
+ * so turning a product into a service while it still has an ncm is
144
+ * refused; taking another item's code is an ItemAlreadyExistsError.
145
+ */
146
+ update(itemId: string, changes: ItemChanges, options?: CompanyOption): Promise<CatalogItem>;
147
+ /**
148
+ * Deactivates an item: kept, left out of list by default, still
149
+ * holding its code, and refused on issue until reactivate brings it
150
+ * back.
151
+ */
152
+ deactivate(itemId: string, options?: CompanyOption): Promise<void>;
153
+ /** Brings a deactivated item back, and returns it. */
154
+ reactivate(itemId: string, options?: CompanyOption): Promise<CatalogItem>;
155
+ }
156
+ //# sourceMappingURL=items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":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