@unimicro/platform-types 0.1.1 → 0.1.2

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 (3) hide show
  1. package/README.md +13 -50
  2. package/index.d.ts +6 -17
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,59 +1,22 @@
1
1
  # @unimicro/platform-types
2
2
 
3
- Type declarations for the Unimicro Platform's business entities — customers, invoices, accounts,
4
- employees, and the several hundred others. Types only: this package ships no JavaScript, and
5
- everything in it erases at build.
3
+ Type declarations for the Unimicro platform's business entities — customers, invoices, accounts,
4
+ employees and the several hundred others. Types only: the package contains no JavaScript.
6
5
 
7
- ```sh
6
+ ```bash
8
7
  npm install --save-dev @unimicro/platform-types
9
8
  ```
10
9
 
11
- ## Using it from a plugin
10
+ Generated from the platform's own model and republished when the model moves, so it is neither
11
+ hand-written nor hand-curated. The declarations describe the platform rather than any one company:
12
+ custom fields do not appear, and arrive under `CustomValues` at runtime.
12
13
 
13
- The host API client takes the entity route as a string and returns whatever you type it as:
14
+ Each entity carries the route it answers on as a literal type, because an entity's name and its
15
+ route are often not the same word.
14
16
 
15
- ```ts
16
- import type { Customer } from '@unimicro/platform-types';
17
+ Dates and times are string aliases — `LocalDate` is `"2026-09-02"`, which is what the API sends —
18
+ so they read and write as strings without a cast. The alias names the format; it does not stop a
19
+ plain string from being assigned.
17
20
 
18
- const customers = await host.api.get<Partial<Customer>[]>('customers', {
19
- expand: 'Info',
20
- select: 'ID,CustomerNumber,Info.Name',
21
- });
22
- ```
23
-
24
- **`Partial`, not the entity itself.** `select` trims the payload, so typing a selected response as a
25
- whole `Customer` claims fifty fields the object does not have — and the editor then autocompletes
26
- every one of them, which is worse than no types at all. `Partial` still refuses a field the entity
27
- does not have, which is the mistake worth catching, while leaving presence to the query.
28
-
29
- A query with no `select` returns the whole entity and can be typed as one.
30
-
31
- ## Routes are in the types
32
-
33
- Every entity carries the route it answers on as a literal type:
34
-
35
- ```ts
36
- type InvoiceRoute = typeof CustomerInvoice.RelativeUrl; // 'invoices' — not 'customerinvoices'
37
- ```
38
-
39
- Worth reading before writing a call. An entity's name and its route are often not the same word, and
40
- a plausible guess returns a 404 that says nothing about why.
41
-
42
- **This is a type, not a value.** The package ships no JavaScript, so `CustomerInvoice.RelativeUrl`
43
- cannot be read at runtime — pass the route as a string and let the literal above be what tells you
44
- which string. The literal is there so that a typed client can one day infer the route from the
45
- entity rather than being handed both.
46
-
47
- ## Where this comes from
48
-
49
- The platform generates these from its own model, and this package is that output as declarations,
50
- republished whenever the model moves. It is not hand-written and not hand-curated: if an entity is
51
- in the platform, it is here, and if a field is missing here it is missing there too.
52
-
53
- Two consequences of that worth knowing. Fields are non-optional in the declarations because the
54
- model declares them so, which is why `Partial` does the work above. And the types describe the
55
- platform, not any one company — custom fields do not appear, and arrive under `CustomValues` at
56
- runtime.
57
-
58
- For what the fields _mean_ — what a status integer says, which relations have to be expanded, what
59
- the query syntax accepts — see the `platform-api` skill that ships with the Unimicro CLI.
21
+ For what the fields mean — status values, which relations expand, the query syntax — see the
22
+ `platform-api` skill that ships with the Unimicro CLI.
package/index.d.ts CHANGED
@@ -1,23 +1,12 @@
1
1
  // Generated from the Unimicro Platform model. Do not edit.
2
2
  //
3
3
  // Source: https://test-api.unimicro.no/api/metadata/typescriptentities
4
- // Fetched: {fetched}
5
- export declare class LocalDate {
6
- private value;
7
- year: number;
8
- month: number;
9
- day: number;
10
- constructor(value?: string | Date);
11
- toJSON(): string;
12
- toDate(): Date;
13
- toString(): string;
14
- }
15
- export declare class LocalTime {
16
- private value;
17
- constructor(value: string);
18
- toJSON(): string;
19
- toString(): string;
20
- }
4
+ export type LocalDate = string & {
5
+ readonly __localDate?: never;
6
+ };
7
+ export type LocalTime = string & {
8
+ readonly __localTime?: never;
9
+ };
21
10
  export declare class UniEntity {
22
11
  }
23
12
  export declare class A06Options extends UniEntity {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimicro/platform-types",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Type declarations for the Unimicro Platform's business entities. Generated from the platform's own model — types only, this package ships no JavaScript.",
5
5
  "types": "index.d.ts",
6
6
  "files": [