ksef-client-ts 0.2.0 → 0.3.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TypeScript client for the Polish National e-Invoice System (KSeF) API v2.
4
4
 
5
- **[Documentation](https://flopsstuff.github.io/ksef-client-ts)**
5
+ **[Documentation](https://flopsstuff.github.io/ksef-client-ts)** · **[NPM](https://www.npmjs.com/package/ksef-client-ts)**
6
6
 
7
7
  ## Features
8
8
 
@@ -82,12 +82,16 @@ yarn test # Run all tests (vitest)
82
82
  - [ksef-client-csharp](https://github.com/CIRFMF/ksef-client-csharp) — official C# reference client
83
83
  - [ksef-client-java](https://github.com/CIRFMF/ksef-client-java) — official Java reference client
84
84
 
85
- ## Status
86
-
87
- [![Unit Tests](https://github.com/Flopsstuff/ksef-client-ts/actions/workflows/test.yml/badge.svg)](https://github.com/Flopsstuff/ksef-client-ts/actions/workflows/test.yml)
88
-
89
- ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Fl0p/1558034ac67a11548c7f8f0c05e8d4c0/raw/ksef-client-ts-coverage.json&cacheSeconds=300)
90
-
91
85
  ## License
92
86
 
93
87
  [MIT](LICENSE)
88
+
89
+ ---
90
+
91
+ [![Tests](https://github.com/Flopsstuff/ksef-client-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/Flopsstuff/ksef-client-ts/actions/workflows/ci.yml)
92
+ ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Fl0p/1558034ac67a11548c7f8f0c05e8d4c0/raw/ksef-client-ts-coverage.json&cacheSeconds=300)
93
+ ![NPM Version](https://img.shields.io/npm/v/ksef-client-ts)
94
+ ![NPM Downloads](https://img.shields.io/npm/dm/ksef-client-ts)
95
+ ![GitHub Stars](https://img.shields.io/github/stars/Flopsstuff/ksef-client-ts)
96
+ ![GitHub Forks](https://img.shields.io/github/forks/Flopsstuff/ksef-client-ts)
97
+ ![GitHub License](https://img.shields.io/github/license/Flopsstuff/ksef-client-ts)
package/dist/cli.js CHANGED
@@ -5179,7 +5179,8 @@ function resolveOptions(options = {}) {
5179
5179
  lighthouseUrl: options.lighthouseUrl ?? env.lighthouseUrl,
5180
5180
  apiVersion: options.apiVersion ?? DEFAULT_API_VERSION,
5181
5181
  timeout: options.timeout ?? DEFAULT_TIMEOUT,
5182
- customHeaders: options.customHeaders ?? {}
5182
+ customHeaders: options.customHeaders ?? {},
5183
+ environmentName: options.environment ?? (options.baseUrl ? void 0 : "TEST")
5183
5184
  };
5184
5185
  }
5185
5186
 
@@ -6310,82 +6311,108 @@ var PeppolService = class {
6310
6311
  // src/services/test-data.ts
6311
6312
  var TestDataService = class {
6312
6313
  restClient;
6313
- constructor(restClient) {
6314
+ environmentName;
6315
+ constructor(restClient, environmentName) {
6314
6316
  this.restClient = restClient;
6317
+ this.environmentName = environmentName;
6318
+ }
6319
+ ensureTestEnvironment() {
6320
+ if (this.environmentName && this.environmentName !== "TEST") {
6321
+ throw new KSeFError(
6322
+ `Test data APIs are only available on the TEST environment (current: ${this.environmentName})`
6323
+ );
6324
+ }
6315
6325
  }
6316
6326
  // Subject management
6317
6327
  async createSubject(request) {
6328
+ this.ensureTestEnvironment();
6318
6329
  const req = RestRequest.post(Routes.TestData.createSubject).body(request);
6319
6330
  await this.restClient.executeVoid(req);
6320
6331
  }
6321
6332
  async removeSubject(request) {
6333
+ this.ensureTestEnvironment();
6322
6334
  const req = RestRequest.post(Routes.TestData.removeSubject).body(request);
6323
6335
  await this.restClient.executeVoid(req);
6324
6336
  }
6325
6337
  // Person management
6326
6338
  async createPerson(request) {
6339
+ this.ensureTestEnvironment();
6327
6340
  const req = RestRequest.post(Routes.TestData.createPerson).body(request);
6328
6341
  await this.restClient.executeVoid(req);
6329
6342
  }
6330
6343
  async removePerson(request) {
6344
+ this.ensureTestEnvironment();
6331
6345
  const req = RestRequest.post(Routes.TestData.removePerson).body(request);
6332
6346
  await this.restClient.executeVoid(req);
6333
6347
  }
6334
6348
  // Permissions
6335
6349
  async grantPermissions(request) {
6350
+ this.ensureTestEnvironment();
6336
6351
  const req = RestRequest.post(Routes.TestData.grantPerms).body(request);
6337
6352
  await this.restClient.executeVoid(req);
6338
6353
  }
6339
6354
  async revokePermissions(request) {
6355
+ this.ensureTestEnvironment();
6340
6356
  const req = RestRequest.post(Routes.TestData.revokePerms).body(request);
6341
6357
  await this.restClient.executeVoid(req);
6342
6358
  }
6343
6359
  // Attachment permissions
6344
6360
  async enableAttachment(request) {
6361
+ this.ensureTestEnvironment();
6345
6362
  const req = RestRequest.post(Routes.TestData.enableAttach).body(request);
6346
6363
  await this.restClient.executeVoid(req);
6347
6364
  }
6348
6365
  async disableAttachment(request) {
6366
+ this.ensureTestEnvironment();
6349
6367
  const req = RestRequest.post(Routes.TestData.disableAttach).body(request);
6350
6368
  await this.restClient.executeVoid(req);
6351
6369
  }
6352
6370
  // Session limits
6353
6371
  async changeSessionLimits(request) {
6372
+ this.ensureTestEnvironment();
6354
6373
  const req = RestRequest.post(Routes.TestData.changeSessionLimitsInCurrentContext).body(request);
6355
6374
  await this.restClient.executeVoid(req);
6356
6375
  }
6357
6376
  async restoreDefaultSessionLimits() {
6377
+ this.ensureTestEnvironment();
6358
6378
  const req = RestRequest.delete(Routes.TestData.restoreDefaultSessionLimitsInCurrentContext);
6359
6379
  await this.restClient.executeVoid(req);
6360
6380
  }
6361
6381
  // Certificate limits
6362
6382
  async changeCertificatesLimit(request) {
6383
+ this.ensureTestEnvironment();
6363
6384
  const req = RestRequest.post(Routes.TestData.changeCertificatesLimitInCurrentSubject).body(request);
6364
6385
  await this.restClient.executeVoid(req);
6365
6386
  }
6366
6387
  async restoreDefaultCertificatesLimit() {
6388
+ this.ensureTestEnvironment();
6367
6389
  const req = RestRequest.delete(Routes.TestData.restoreDefaultCertificatesLimitInCurrentSubject);
6368
6390
  await this.restClient.executeVoid(req);
6369
6391
  }
6370
6392
  // Rate limits
6371
6393
  async setRateLimits(request) {
6394
+ this.ensureTestEnvironment();
6372
6395
  const req = RestRequest.post(Routes.TestData.rateLimits).body(request);
6373
6396
  await this.restClient.executeVoid(req);
6374
6397
  }
6375
6398
  async restoreDefaultRateLimits() {
6399
+ this.ensureTestEnvironment();
6376
6400
  const req = RestRequest.delete(Routes.TestData.rateLimits);
6377
6401
  await this.restClient.executeVoid(req);
6378
6402
  }
6379
6403
  async setProductionRateLimits() {
6404
+ this.ensureTestEnvironment();
6380
6405
  const req = RestRequest.post(Routes.TestData.productionRateLimits);
6381
6406
  await this.restClient.executeVoid(req);
6382
6407
  }
6383
6408
  // Context blocking
6384
6409
  async blockContext(request) {
6410
+ this.ensureTestEnvironment();
6385
6411
  const req = RestRequest.post(Routes.TestData.blockContext).body(request);
6386
6412
  await this.restClient.executeVoid(req);
6387
6413
  }
6388
6414
  async unblockContext(request) {
6415
+ this.ensureTestEnvironment();
6389
6416
  const req = RestRequest.post(Routes.TestData.unblockContext).body(request);
6390
6417
  await this.restClient.executeVoid(req);
6391
6418
  }
@@ -6762,7 +6789,7 @@ var KSeFClient = class {
6762
6789
  this.lighthouse = new LighthouseService(this.options);
6763
6790
  this.limits = new LimitsService(restClient);
6764
6791
  this.peppol = new PeppolService(restClient);
6765
- this.testData = new TestDataService(restClient);
6792
+ this.testData = new TestDataService(restClient, this.options.environmentName);
6766
6793
  this.qr = new VerificationLinkService(this.options.baseQrUrl);
6767
6794
  }
6768
6795
  async loginWithToken(token, nip) {