@weclapp/sdk 2.0.0-dev.29 → 2.0.0-dev.30

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 (4) hide show
  1. package/README.md +68 -73
  2. package/bin/cli.js +1 -1
  3. package/dist/cli.js +311 -391
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -40,26 +40,26 @@ This way, every time someone installs or updates dependencies, the SDK is genera
40
40
  {
41
41
  // in your package.json
42
42
  scripts: {
43
- "sdk:generate": "build-weclapp-sdk company.weclapp.com --key [your api key] --cache --target browser",
44
- postinstall: "npm run sdk:generate",
45
- },
43
+ 'sdk:generate': 'build-weclapp-sdk company.weclapp.com --key [your api key] --cache --target browser',
44
+ postinstall: 'npm run sdk:generate'
45
+ }
46
46
  }
47
47
  ```
48
48
 
49
49
  ## Available flags
50
50
 
51
- | Flag | Description | Value / Type |
52
- | --------------------- | ----------------------------------------------------------------------------- | -------------------------------------------- |
53
- | `--cache` / `-c` | Extra query params when fetching the openapi.json from a server. | `boolean` |
54
- | `--deprecated` / `-d` | Include deprecated functions and services. | `boolean` |
55
- | `--from-env` / `-e` | Use env variables `WECLAPP_BACKEND_URL` and `WECLAPP_API_KEY` as credentials. | `boolean` |
56
- | `--generate-unique` | Generate additional `.unique` functions. | `boolean` |
57
- | `--use-query-language`| Use the advanced query language. The property _filter_ will be removed from _SomeQuery_ and _CountQuery_ and the property _where_ will be added instead. | `boolean` |
58
- | `--help` / `-h` | Show help. | `boolean` |
59
- | `--key` / `-k` | API Key in case of using a remote. | `string` |
60
- | `--target` / `-t` | Specify the target platform. | `browser`, `browser.rx`, `node` or `node.rx` |
61
- | `--query` / `-q` | Extra query params when fetching the openapi.json from a server | `string` |
62
- | `--version` / `-v` | Show version of SDK. | `boolean` |
51
+ | Flag | Description | Value / Type |
52
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
53
+ | `--cache` / `-c` | Extra query params when fetching the openapi.json from a server. | `boolean` |
54
+ | `--deprecated` / `-d` | Include deprecated functions and services. | `boolean` |
55
+ | `--from-env` / `-e` | Use env variables `WECLAPP_BACKEND_URL` and `WECLAPP_API_KEY` as credentials. | `boolean` |
56
+ | `--generate-unique` | Generate additional `.unique` functions. | `boolean` |
57
+ | `--use-query-language` | Use the advanced query language. The property _filter_ will be removed from _SomeQuery_ and _CountQuery_ and the property _where_ will be added instead. | `boolean` |
58
+ | `--help` / `-h` | Show help. | `boolean` |
59
+ | `--key` / `-k` | API Key in case of using a remote. | `string` |
60
+ | `--target` / `-t` | Specify the target platform. | `browser`, `browser.rx`, `node` or `node.rx` |
61
+ | `--query` / `-q` | Extra query params when fetching the openapi.json from a server | `string` |
62
+ | `--version` / `-v` | Show version of SDK. | `boolean` |
63
63
 
64
64
  After that, you can import the sdk via `@weclapp/sdk`.
65
65
  Check out the [docs](docs) for how the generated SDK looks like and how to use it!
@@ -98,14 +98,12 @@ interface ServiceConfig {
98
98
  // The payload contains the raw input generated by the SDK.
99
99
  request?: (
100
100
  request: Request,
101
- payload: RequestPayload,
101
+ payload: RequestPayload
102
102
  ) => Request | Response | void | Promise<Request | Response | void>;
103
103
 
104
104
  // Takes the response. This can either be the one from the server or an
105
105
  // artificially-crafted one by the request interceptor.
106
- response?: (
107
- response: Response,
108
- ) => Response | void | Promise<Response | void>;
106
+ response?: (response: Response) => Response | void | Promise<Response | void>;
109
107
  };
110
108
  }
111
109
  ```
@@ -117,11 +115,11 @@ There are three ways of accessing a service through the SDK:
117
115
  #### Using a Global Config
118
116
 
119
117
  ```ts
120
- import { setGlobalConfig, partyService } from "@weclapp/sdk";
118
+ import { setGlobalConfig, partyService } from '@weclapp/sdk';
121
119
 
122
120
  setGlobalConfig({
123
- key: "mykey",
124
- domain: "myweclapp.com",
121
+ key: 'mykey',
122
+ domain: 'myweclapp.com'
125
123
  });
126
124
 
127
125
  const party = partyService();
@@ -132,11 +130,11 @@ console.log(`Total amount of parties: ${await party.count()}`);
132
130
  #### Using a Config per Service
133
131
 
134
132
  ```ts
135
- import { partyService } from "@weclapp/sdk";
133
+ import { partyService } from '@weclapp/sdk';
136
134
 
137
135
  const party = partyService({
138
- key: "mykey",
139
- domain: "myweclapp.com",
136
+ key: 'mykey',
137
+ domain: 'myweclapp.com'
140
138
  });
141
139
 
142
140
  console.log(`Total amount of parties: ${await party.count()}`);
@@ -237,45 +235,45 @@ interface PartyService {
237
235
  ## Comparison
238
236
 
239
237
  ```ts
240
- import { PartyType, setGlobalConfig, wServices } from "@weclapp/sdk";
238
+ import { PartyType, setGlobalConfig, wServices } from '@weclapp/sdk';
241
239
 
242
240
  setGlobalConfig({
243
- domain: "company.weclapp.com",
244
- secure: true,
241
+ domain: 'company.weclapp.com',
242
+ secure: true
245
243
  });
246
244
 
247
245
  // to get the count of parties via service
248
- const serviceN = await wServices["party"].count();
246
+ const serviceN = await wServices['party'].count();
249
247
 
250
248
  // to get the count of parties via raw
251
- const rawN = await raw(undefined, "/party/count");
249
+ const rawN = await raw(undefined, '/party/count');
252
250
 
253
251
  // to get all parties via service
254
- const partiesService = await wServices["party"].some();
252
+ const partiesService = await wServices['party'].some();
255
253
 
256
254
  // to get all parties via raw
257
- const partiesRaw = await raw(undefined, "/party");
255
+ const partiesRaw = await raw(undefined, '/party');
258
256
 
259
257
  // to create a party via service
260
- const contact = await wServices["party"].create({
258
+ const contact = await wServices['party'].create({
261
259
  partyType: PartyType.PERSON,
262
- lastName: "Mueller",
260
+ lastName: 'Mueller'
263
261
  }); // the returned object is already typed as Party
264
262
 
265
263
  // to create a party via raw
266
- const contactRaw = await await raw(undefined, "/party", {
264
+ const contactRaw = await await raw(undefined, '/party', {
267
265
  // the returned object has the type any.
268
- method: "POST",
269
- body: { partyType: PartyType.PERSON, lastName: "Mueller" },
266
+ method: 'POST',
267
+ body: { partyType: PartyType.PERSON, lastName: 'Mueller' }
270
268
  });
271
269
 
272
270
  // to delete a party via service
273
- await wServices["party"].remove(contact.id);
271
+ await wServices['party'].remove(contact.id);
274
272
 
275
273
  // to delete a party via raw
276
- if (contactRaw && typeof contactRaw.id === "string") {
274
+ if (contactRaw && typeof contactRaw.id === 'string') {
277
275
  await raw(undefined, `/party/id/${contactRaw.id}`, {
278
- method: "DELETE",
276
+ method: 'DELETE'
279
277
  });
280
278
  }
281
279
  ```
@@ -287,11 +285,11 @@ if (contactRaw && typeof contactRaw.id === "string") {
287
285
  With the some and count functions you can filter the requested data.
288
286
 
289
287
  ```ts
290
- wServices["article"].some({
288
+ wServices['article'].some({
291
289
  filter: {
292
- name: { EQ: "toy 1" },
293
- articleNumber: { EQ: "12345" },
294
- },
290
+ name: { EQ: 'toy 1' },
291
+ articleNumber: { EQ: '12345' }
292
+ }
295
293
  });
296
294
  ```
297
295
 
@@ -302,13 +300,13 @@ The SDK makes an AND operator between the properties. So this equivalent to the
302
300
  If you want an OR operator you have to set an array in the or property:
303
301
 
304
302
  ```ts
305
- wServices["article"].some({
303
+ wServices['article'].some({
306
304
  or: [
307
305
  {
308
- name: { EQ: "toy 1" },
309
- articleNumber: { EQ: "12345" },
310
- },
311
- ],
306
+ name: { EQ: 'toy 1' },
307
+ articleNumber: { EQ: '12345' }
308
+ }
309
+ ]
312
310
  });
313
311
  ```
314
312
 
@@ -319,16 +317,16 @@ The above example is the equivalent of the expression
319
317
  To combine OR and AND clauses, you can also group OR expressions by adding several objects to the array:
320
318
 
321
319
  ```ts
322
- wServices["article"].some({
320
+ wServices['article'].some({
323
321
  or: [
324
322
  {
325
- name: { EQ: "toy 1" },
326
- articleNumber: { EQ: "12345" },
323
+ name: { EQ: 'toy 1' },
324
+ articleNumber: { EQ: '12345' }
327
325
  },
328
326
  {
329
- batchNumberRequired: { EQ: true },
330
- },
331
- ],
327
+ batchNumberRequired: { EQ: true }
328
+ }
329
+ ]
332
330
  });
333
331
  ```
334
332
 
@@ -342,18 +340,15 @@ This is evaluated to:
342
340
  It is also possible to specify complex filter expressions that can combine multiple conditions and express relations between properties:
343
341
 
344
342
  ```ts
345
- wServices["article"].some({
343
+ wServices['article'].some({
346
344
  where: {
347
345
  AND: [
348
346
  {
349
- OR: [
350
- { name: { LIKE: "%test%", lower: true } },
351
- { articleNumber: { LIKE: "%345%" } },
352
- ],
347
+ OR: [{ name: { LIKE: '%test%', lower: true } }, { articleNumber: { LIKE: '%345%' } }]
353
348
  },
354
- { batchNumberRequired: { EQ: true } },
355
- ],
356
- },
349
+ { batchNumberRequired: { EQ: true } }
350
+ ]
351
+ }
357
352
  });
358
353
  ```
359
354
 
@@ -364,8 +359,8 @@ wServices["article"].some({
364
359
  You can sort your requested data with an array properties.
365
360
 
366
361
  ```ts
367
- wServices["article"].some({
368
- sort: [{ name: "asc" }, { minimumPurchaseQuantity: "desc" }],
362
+ wServices['article'].some({
363
+ sort: [{ name: 'asc' }, { minimumPurchaseQuantity: 'desc' }]
369
364
  });
370
365
  ```
371
366
 
@@ -376,11 +371,11 @@ Sort by name (ascending) and then minimumPurchaseQuantity descending.
376
371
  By default the API returns only the first 100 entities. You can increase the size of one response to the maximum of 1000. To get the next 1000 entities you have increase the page number.
377
372
 
378
373
  ```ts
379
- wServices["article"].some({
374
+ wServices['article'].some({
380
375
  pagination: {
381
376
  page: 2,
382
- pageSize: 10,
383
- },
377
+ pageSize: 10
378
+ }
384
379
  });
385
380
  ```
386
381
 
@@ -391,8 +386,8 @@ This returns the first 10 articles of the second page.
391
386
  With the select option you can fetch specific subset of properties:
392
387
 
393
388
  ```ts
394
- wServices["article"].some({
395
- select: { articleNumber: true },
389
+ wServices['article'].some({
390
+ select: { articleNumber: true }
396
391
  });
397
392
  ```
398
393
 
@@ -403,10 +398,10 @@ This only returns the articleNumber property of all articles.
403
398
  The generated enums are a good posibility to check if an entity is of a specific type. For example, you can get all articles of a certain article type:
404
399
 
405
400
  ```ts
406
- wServices["article"].some({
401
+ wServices['article'].some({
407
402
  filter: {
408
- articleType: { EQ: ArticleType.STORABLE },
409
- },
403
+ articleType: { EQ: ArticleType.STORABLE }
404
+ }
410
405
  });
411
406
  ```
412
407
 
package/bin/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import "../dist/cli.js";
2
+ import '../dist/cli.js';