@idfkit/core 0.0.1 → 0.2.0-rc.1
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 +16 -7
- package/dist/collection.d.ts +0 -13
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +1 -1
- package/dist/conformance.d.ts +20 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +20 -0
- package/dist/conformance.js.map +1 -0
- package/dist/docs-url/index.d.ts +81 -0
- package/dist/docs-url/index.d.ts.map +1 -0
- package/dist/docs-url/index.js +201 -0
- package/dist/docs-url/index.js.map +1 -0
- package/dist/docs-url/locations.d.ts +2 -0
- package/dist/docs-url/locations.d.ts.map +1 -0
- package/dist/docs-url/locations.js +272 -0
- package/dist/docs-url/locations.js.map +1 -0
- package/dist/document.d.ts +40 -14
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +0 -0
- package/dist/document.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/introspect/describe.d.ts +106 -0
- package/dist/introspect/describe.d.ts.map +1 -0
- package/dist/introspect/describe.js +168 -0
- package/dist/introspect/describe.js.map +1 -0
- package/dist/node.d.ts +5 -5
- package/dist/node.js +4 -4
- package/dist/node.js.map +1 -1
- package/dist/object.d.ts +1 -1
- package/dist/parse/epjson.d.ts +1 -1
- package/dist/parse/epjson.d.ts.map +1 -1
- package/dist/parse/epjson.js +3 -3
- package/dist/parse/epjson.js.map +1 -1
- package/dist/parse/idf.d.ts +3 -3
- package/dist/parse/idf.js +3 -3
- package/dist/typemap.d.ts +7 -5
- package/dist/typemap.d.ts.map +1 -1
- package/dist/typemap.js +7 -5
- package/dist/typemap.js.map +1 -1
- package/dist/validate/index.d.ts +11 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +10 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/types.d.ts +63 -0
- package/dist/validate/types.d.ts.map +1 -0
- package/dist/validate/types.js +25 -0
- package/dist/validate/types.js.map +1 -0
- package/dist/validate/validate.d.ts +82 -0
- package/dist/validate/validate.d.ts.map +1 -0
- package/dist/validate/validate.js +574 -0
- package/dist/validate/validate.js.map +1 -0
- package/dist/write/epjson.d.ts +3 -3
- package/dist/write/idf.d.ts +2 -2
- package/package.json +11 -8
- package/dist/types/v26-1.d.ts +0 -65896
- package/dist/types/v26-1.d.ts.map +0 -1
- package/dist/types/v26-1.js +0 -5
- package/dist/types/v26-1.js.map +0 -1
- package/dist/types/v9-4.d.ts +0 -61414
- package/dist/types/v9-4.d.ts.map +0 -1
- package/dist/types/v9-4.js +0 -5
- package/dist/types/v9-4.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,17 +16,26 @@ npm install @idfkit/core @idfkit/schemas
|
|
|
16
16
|
|
|
17
17
|
## Entry points
|
|
18
18
|
|
|
19
|
-
| Import
|
|
20
|
-
|
|
|
21
|
-
| `@idfkit/core`
|
|
22
|
-
| `@idfkit/core/node`
|
|
23
|
-
|
|
19
|
+
| Import | Contents | Environment |
|
|
20
|
+
| ------------------- | -------------------------------------------------------- | ----------- |
|
|
21
|
+
| `@idfkit/core` | Parsing, writing, the object model. Synchronous, no I/O. | Anywhere |
|
|
22
|
+
| `@idfkit/core/node` | `loadIdf`, `saveIdf`, schema discovery from disk | Node |
|
|
23
|
+
|
|
24
|
+
Generated per-version field types are **not** in this package. They are opt-in,
|
|
25
|
+
one package per EnergyPlus version, installed by name:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install --save-dev @idfkit/types-v26-1 # or @idfkit/types-v9-4
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install neither and this package is complete: a document with no type map is
|
|
32
|
+
typed permissively, and every operation below works unchanged.
|
|
24
33
|
|
|
25
34
|
## Usage
|
|
26
35
|
|
|
27
36
|
```ts
|
|
28
37
|
import { loadIdf, saveIdf } from '@idfkit/core/node';
|
|
29
|
-
import type { TypeMap } from '@idfkit/
|
|
38
|
+
import type { TypeMap } from '@idfkit/types-v26-1';
|
|
30
39
|
|
|
31
40
|
const doc = await loadIdf<TypeMap>('model.idf');
|
|
32
41
|
|
|
@@ -97,7 +106,7 @@ The full API is generated from the source and published at
|
|
|
97
106
|
|
|
98
107
|
The main entry points:
|
|
99
108
|
|
|
100
|
-
- **`
|
|
109
|
+
- **`IdfDocument<M>`** — collections by type, a live reference graph, bound to
|
|
101
110
|
one EnergyPlus version. `M` is an optional generated type map; omit it and
|
|
102
111
|
everything still works, just untyped.
|
|
103
112
|
- **`IdfObject`** — one EnergyPlus object. Fields are real properties;
|
package/dist/collection.d.ts
CHANGED
|
@@ -31,18 +31,5 @@ export declare class IdfCollection<T extends IdfObject = IdfObject> implements I
|
|
|
31
31
|
find(predicate: (obj: T, index: number) => boolean): T | undefined;
|
|
32
32
|
/** Objects whose `field` equals `value`, compared case-insensitively. */
|
|
33
33
|
where(field: string, value: string): T[];
|
|
34
|
-
/** @internal */
|
|
35
|
-
insert(obj: T): void;
|
|
36
|
-
/** @internal */
|
|
37
|
-
delete(name: string): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Re-key an object after a rename, preserving insertion order.
|
|
40
|
-
*
|
|
41
|
-
* A plain delete-then-insert would move the object to the end of the
|
|
42
|
-
* collection, which shows up as a spurious reordering when the document is
|
|
43
|
-
* written back out.
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
rekey(previous: string, next: string): void;
|
|
47
34
|
}
|
|
48
35
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;GASG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,S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=== 'string' && actual.toLowerCase() === needle;
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
// --- mutation, used by
|
|
74
|
+
// --- mutation, used by IdfDocument -------------------------------------
|
|
75
75
|
/** @internal */
|
|
76
76
|
insert(obj) {
|
|
77
77
|
this.#byName.set(obj.key.toLowerCase(), obj);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated conformance declaration.
|
|
3
|
+
*
|
|
4
|
+
* DO NOT EDIT. Regenerate with:
|
|
5
|
+
* node scripts/emit-conformance.mjs
|
|
6
|
+
*
|
|
7
|
+
* The value is derived from `idfkit.conformance` in `packages/core/package.json`, which is the
|
|
8
|
+
* one place the level is authored. `npm run check:conformance-level` regenerates this file and
|
|
9
|
+
* diffs it, so the declaration and the export cannot drift apart.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The conformance corpus level this release is checked against, as an immutable tag in
|
|
13
|
+
* idfkit/idfkit-conformance. A release asserts this claim in its own checks (FR-024): the corpus
|
|
14
|
+
* at this tag passes against this library, or the release does not ship.
|
|
15
|
+
*
|
|
16
|
+
* This is not a version number and it is not compared to one. Two installed libraries agree on the
|
|
17
|
+
* formats when they declare the same level, whatever their own versions say (FR-025).
|
|
18
|
+
*/
|
|
19
|
+
export declare const CONFORMANCE_LEVEL = "conformance-2026.7";
|
|
20
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated conformance declaration.
|
|
3
|
+
*
|
|
4
|
+
* DO NOT EDIT. Regenerate with:
|
|
5
|
+
* node scripts/emit-conformance.mjs
|
|
6
|
+
*
|
|
7
|
+
* The value is derived from `idfkit.conformance` in `packages/core/package.json`, which is the
|
|
8
|
+
* one place the level is authored. `npm run check:conformance-level` regenerates this file and
|
|
9
|
+
* diffs it, so the declaration and the export cannot drift apart.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The conformance corpus level this release is checked against, as an immutable tag in
|
|
13
|
+
* idfkit/idfkit-conformance. A release asserts this claim in its own checks (FR-024): the corpus
|
|
14
|
+
* at this tag passes against this library, or the release does not ship.
|
|
15
|
+
*
|
|
16
|
+
* This is not a version number and it is not compared to one. Two installed libraries agree on the
|
|
17
|
+
* formats when they declare the same level, whatever their own versions say (FR-025).
|
|
18
|
+
*/
|
|
19
|
+
export const CONFORMANCE_LEVEL = 'conformance-2026.7';
|
|
20
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation URL builder for docs.idfkit.com.
|
|
3
|
+
*
|
|
4
|
+
* Port of `idfkit/src/idfkit/docs.py`. The two libraries must produce
|
|
5
|
+
* byte-identical addresses, so every rule here mirrors the Python one exactly:
|
|
6
|
+
* the same version gate, the same bundled object-type mapping, the same
|
|
7
|
+
* schema-group fallback, and the same labels down to the em dash.
|
|
8
|
+
*
|
|
9
|
+
* Synchronous and free of I/O, like the rest of the `@idfkit/core` root entry.
|
|
10
|
+
* The one place Python is not — it lazily loads the latest schema when the
|
|
11
|
+
* caller omits one — is the single documented divergence; see
|
|
12
|
+
* {@link ioReferenceUrl}.
|
|
13
|
+
*/
|
|
14
|
+
import type { Schema } from '@idfkit/schemas';
|
|
15
|
+
/** A resolved documentation URL with metadata. */
|
|
16
|
+
export interface DocsUrl {
|
|
17
|
+
readonly url: string;
|
|
18
|
+
/** Python spells this `doc_set`; the field-casing rule renames it here. */
|
|
19
|
+
readonly docSet: 'io-reference' | 'engineering-reference' | 'search';
|
|
20
|
+
/** Short version used in the URL path, e.g. `v25.2`. */
|
|
21
|
+
readonly version: string;
|
|
22
|
+
/** Human-readable label, e.g. `Zone — I/O Reference`. */
|
|
23
|
+
readonly label: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build a docs.idfkit.com URL for an object's I/O Reference page.
|
|
27
|
+
*
|
|
28
|
+
* Uses a bundled mapping from the documentation search index for accurate URLs.
|
|
29
|
+
* Falls back to schema-based group slug construction when the object type is
|
|
30
|
+
* not in the mapping.
|
|
31
|
+
*
|
|
32
|
+
* Returns undefined when the object type cannot be resolved or the version has
|
|
33
|
+
* no documentation.
|
|
34
|
+
*
|
|
35
|
+
* DIVERGENCE FROM PYTHON. `idfkit.docs.io_reference_url` also takes an optional
|
|
36
|
+
* schema, but when it is omitted and the mapping misses, it loads the schema for
|
|
37
|
+
* the latest EnergyPlus version from disk and tries the group fallback against
|
|
38
|
+
* that. Loading a schema is I/O and asynchronous here, and the `@idfkit/core`
|
|
39
|
+
* root entry is neither, so this returns undefined in that case instead. Pass a
|
|
40
|
+
* schema to get the fallback. The two libraries agree whenever the object type
|
|
41
|
+
* is in the mapping (which is every type the search index covers) and whenever
|
|
42
|
+
* a schema is supplied.
|
|
43
|
+
*
|
|
44
|
+
* @param objType EnergyPlus object type name, e.g. `Zone`.
|
|
45
|
+
* @param version EnergyPlus version, e.g. `26.1.0`.
|
|
46
|
+
* @param schema Schema for the fallback group lookup. Without it, an object
|
|
47
|
+
* type outside the bundled mapping resolves to undefined.
|
|
48
|
+
* @param options `baseUrl` overrides the documentation site root, for tests.
|
|
49
|
+
*/
|
|
50
|
+
export declare function ioReferenceUrl(objType: string, version: string, schema?: Schema, options?: {
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
}): DocsUrl | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Build a docs.idfkit.com URL for the Engineering Reference landing page.
|
|
55
|
+
*
|
|
56
|
+
* Returns undefined if the version has no documentation.
|
|
57
|
+
*/
|
|
58
|
+
export declare function engineeringReferenceUrl(version: string, options?: {
|
|
59
|
+
baseUrl?: string;
|
|
60
|
+
}): DocsUrl | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Build a docs.idfkit.com URL for searching or browsing documentation.
|
|
63
|
+
*
|
|
64
|
+
* Links to the version's I/O Reference overview page, where the reader can
|
|
65
|
+
* browse or search for the object type. Returns undefined if the version has no
|
|
66
|
+
* documentation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function searchUrl(query: string, version: string, options?: {
|
|
69
|
+
baseUrl?: string;
|
|
70
|
+
}): DocsUrl | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The best documentation URL for an object type.
|
|
73
|
+
*
|
|
74
|
+
* Tries the I/O Reference; returns undefined if the object type cannot be
|
|
75
|
+
* resolved or the version has no documentation. Carries the same omitted-schema
|
|
76
|
+
* divergence as {@link ioReferenceUrl}.
|
|
77
|
+
*/
|
|
78
|
+
export declare function docsUrlForObject(objType: string, version: string, schema?: Schema, options?: {
|
|
79
|
+
baseUrl?: string;
|
|
80
|
+
}): DocsUrl | undefined;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docs-url/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,kDAAkD;AAClD,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,uBAAuB,GAAG,QAAQ,CAAC;IACrE,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,GAAG,SAAS,CAmBrB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,GAAG,SAAS,CASrB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,GAAG,SAAS,CASrB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,GAAG,SAAS,CAErB"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation URL builder for docs.idfkit.com.
|
|
3
|
+
*
|
|
4
|
+
* Port of `idfkit/src/idfkit/docs.py`. The two libraries must produce
|
|
5
|
+
* byte-identical addresses, so every rule here mirrors the Python one exactly:
|
|
6
|
+
* the same version gate, the same bundled object-type mapping, the same
|
|
7
|
+
* schema-group fallback, and the same labels down to the em dash.
|
|
8
|
+
*
|
|
9
|
+
* Synchronous and free of I/O, like the rest of the `@idfkit/core` root entry.
|
|
10
|
+
* The one place Python is not — it lazily loads the latest schema when the
|
|
11
|
+
* caller omits one — is the single documented divergence; see
|
|
12
|
+
* {@link ioReferenceUrl}.
|
|
13
|
+
*/
|
|
14
|
+
import { versionKey } from '../versions.js';
|
|
15
|
+
import { DOC_LOCATIONS } from './locations.js';
|
|
16
|
+
/** @internal Not public API: `baseUrl` overrides exist for tests. */
|
|
17
|
+
const BASE_URL = 'https://docs.idfkit.com';
|
|
18
|
+
/**
|
|
19
|
+
* EnergyPlus versions that have documentation on docs.idfkit.com.
|
|
20
|
+
*
|
|
21
|
+
* Mirrors `ENERGYPLUS_VERSIONS` in `idfkit/src/idfkit/versions.py`, which is
|
|
22
|
+
* what `is_supported_version` gates on. The set has to be identical in both
|
|
23
|
+
* libraries: a version in one and not the other means one emits a link where
|
|
24
|
+
* the other emits nothing. `docs-url.test.ts` holds this against the versions
|
|
25
|
+
* the schema bundle actually ships.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
const DOCUMENTED_VERSIONS = [
|
|
30
|
+
'8.9.0',
|
|
31
|
+
'9.0.1',
|
|
32
|
+
'9.1.0',
|
|
33
|
+
'9.2.0',
|
|
34
|
+
'9.3.0',
|
|
35
|
+
'9.4.0',
|
|
36
|
+
'9.5.0',
|
|
37
|
+
'9.6.0',
|
|
38
|
+
'22.1.0',
|
|
39
|
+
'22.2.0',
|
|
40
|
+
'23.1.0',
|
|
41
|
+
'23.2.0',
|
|
42
|
+
'24.1.0',
|
|
43
|
+
'24.2.0',
|
|
44
|
+
'25.1.0',
|
|
45
|
+
'25.2.0',
|
|
46
|
+
'26.1.0',
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Numeric version key -> the `vM.m` path segment.
|
|
50
|
+
*
|
|
51
|
+
* Keyed numerically rather than by string so that `9.01.0` and `9.1.0` are the
|
|
52
|
+
* same version, the way the Python tuple `(9, 1, 0)` is one value however it
|
|
53
|
+
* was spelled. The short form is taken from the registered version rather than
|
|
54
|
+
* from the caller's string, so the emitted path is canonical either way.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
const SHORT_VERSIONS = new Map(DOCUMENTED_VERSIONS.map((version) => {
|
|
59
|
+
const [major, minor] = version.split('.');
|
|
60
|
+
return [versionKey(version), `v${major}.${minor}`];
|
|
61
|
+
}));
|
|
62
|
+
/**
|
|
63
|
+
* Object type -> documentation location, built on first use.
|
|
64
|
+
*
|
|
65
|
+
* Deferred the way Python defers reading `doc_locations.json`, so importing
|
|
66
|
+
* `@idfkit/core` costs nothing until something asks for a documentation URL.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
let locations;
|
|
71
|
+
/** @internal */
|
|
72
|
+
function docLocations() {
|
|
73
|
+
if (locations === undefined) {
|
|
74
|
+
locations = new Map();
|
|
75
|
+
for (const [path, types] of DOC_LOCATIONS) {
|
|
76
|
+
for (const objType of types.split('\t')) {
|
|
77
|
+
locations.set(objType, `${path}${objectAnchor(objType)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return locations;
|
|
82
|
+
}
|
|
83
|
+
/** @internal Mirrors `_object_anchor`: strip `:`, `/`, `(`, `)` and spaces. */
|
|
84
|
+
function objectAnchor(objType) {
|
|
85
|
+
return objType.toLowerCase().replace(/[:/() ]/g, '');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The `vM.m` path segment, or undefined when the version has no documentation.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
function resolveDocVersion(version) {
|
|
93
|
+
return SHORT_VERSIONS.get(versionKey(version));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The IDD group for an object type, matching Python's `schema.get_group`.
|
|
97
|
+
*
|
|
98
|
+
* That lookup is a plain dict access, so it is exact-case. `Schema.get` is
|
|
99
|
+
* case-insensitive, which would make this library emit a URL for `zone` where
|
|
100
|
+
* Python emits nothing, so the case check is reinstated here. `resolve` returns
|
|
101
|
+
* the input unchanged exactly when the schema holds that spelling.
|
|
102
|
+
*
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
function resolveGroup(objType, schema) {
|
|
106
|
+
if (schema === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
if (schema.resolve(objType) !== objType)
|
|
109
|
+
return undefined;
|
|
110
|
+
return schema.get(objType)?.g;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build a docs.idfkit.com URL for an object's I/O Reference page.
|
|
114
|
+
*
|
|
115
|
+
* Uses a bundled mapping from the documentation search index for accurate URLs.
|
|
116
|
+
* Falls back to schema-based group slug construction when the object type is
|
|
117
|
+
* not in the mapping.
|
|
118
|
+
*
|
|
119
|
+
* Returns undefined when the object type cannot be resolved or the version has
|
|
120
|
+
* no documentation.
|
|
121
|
+
*
|
|
122
|
+
* DIVERGENCE FROM PYTHON. `idfkit.docs.io_reference_url` also takes an optional
|
|
123
|
+
* schema, but when it is omitted and the mapping misses, it loads the schema for
|
|
124
|
+
* the latest EnergyPlus version from disk and tries the group fallback against
|
|
125
|
+
* that. Loading a schema is I/O and asynchronous here, and the `@idfkit/core`
|
|
126
|
+
* root entry is neither, so this returns undefined in that case instead. Pass a
|
|
127
|
+
* schema to get the fallback. The two libraries agree whenever the object type
|
|
128
|
+
* is in the mapping (which is every type the search index covers) and whenever
|
|
129
|
+
* a schema is supplied.
|
|
130
|
+
*
|
|
131
|
+
* @param objType EnergyPlus object type name, e.g. `Zone`.
|
|
132
|
+
* @param version EnergyPlus version, e.g. `26.1.0`.
|
|
133
|
+
* @param schema Schema for the fallback group lookup. Without it, an object
|
|
134
|
+
* type outside the bundled mapping resolves to undefined.
|
|
135
|
+
* @param options `baseUrl` overrides the documentation site root, for tests.
|
|
136
|
+
*/
|
|
137
|
+
export function ioReferenceUrl(objType, version, schema, options) {
|
|
138
|
+
const ver = resolveDocVersion(version);
|
|
139
|
+
if (ver === undefined)
|
|
140
|
+
return undefined;
|
|
141
|
+
const baseUrl = options?.baseUrl ?? BASE_URL;
|
|
142
|
+
const label = `${objType} — I/O Reference`;
|
|
143
|
+
// Primary: the bundled mapping, which is accurate because it comes from the
|
|
144
|
+
// documentation search index rather than from a guess about the URL shape.
|
|
145
|
+
const location = docLocations().get(objType);
|
|
146
|
+
if (location !== undefined) {
|
|
147
|
+
return { url: `${baseUrl}/${ver}/${location}`, docSet: 'io-reference', version: ver, label };
|
|
148
|
+
}
|
|
149
|
+
// Fallback: derive from the schema group. May be inaccurate for some groups.
|
|
150
|
+
const group = resolveGroup(objType, schema);
|
|
151
|
+
if (group === undefined)
|
|
152
|
+
return undefined;
|
|
153
|
+
const slug = group.toLowerCase().replaceAll(' ', '-');
|
|
154
|
+
const url = `${baseUrl}/${ver}/io-reference/overview/group-${slug}/#${objectAnchor(objType)}`;
|
|
155
|
+
return { url, docSet: 'io-reference', version: ver, label };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Build a docs.idfkit.com URL for the Engineering Reference landing page.
|
|
159
|
+
*
|
|
160
|
+
* Returns undefined if the version has no documentation.
|
|
161
|
+
*/
|
|
162
|
+
export function engineeringReferenceUrl(version, options) {
|
|
163
|
+
const ver = resolveDocVersion(version);
|
|
164
|
+
if (ver === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
return {
|
|
167
|
+
url: `${options?.baseUrl ?? BASE_URL}/${ver}/engineering-reference/`,
|
|
168
|
+
docSet: 'engineering-reference',
|
|
169
|
+
version: ver,
|
|
170
|
+
label: 'Engineering Reference',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Build a docs.idfkit.com URL for searching or browsing documentation.
|
|
175
|
+
*
|
|
176
|
+
* Links to the version's I/O Reference overview page, where the reader can
|
|
177
|
+
* browse or search for the object type. Returns undefined if the version has no
|
|
178
|
+
* documentation.
|
|
179
|
+
*/
|
|
180
|
+
export function searchUrl(query, version, options) {
|
|
181
|
+
const ver = resolveDocVersion(version);
|
|
182
|
+
if (ver === undefined)
|
|
183
|
+
return undefined;
|
|
184
|
+
return {
|
|
185
|
+
url: `${options?.baseUrl ?? BASE_URL}/${ver}/io-reference/overview/`,
|
|
186
|
+
docSet: 'search',
|
|
187
|
+
version: ver,
|
|
188
|
+
label: `Search: ${query}`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The best documentation URL for an object type.
|
|
193
|
+
*
|
|
194
|
+
* Tries the I/O Reference; returns undefined if the object type cannot be
|
|
195
|
+
* resolved or the version has no documentation. Carries the same omitted-schema
|
|
196
|
+
* divergence as {@link ioReferenceUrl}.
|
|
197
|
+
*/
|
|
198
|
+
export function docsUrlForObject(objType, version, schema, options) {
|
|
199
|
+
return ioReferenceUrl(objType, version, schema, options);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docs-url/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qEAAqE;AACrE,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAa3C;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAsB;IAC7C,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,cAAc,GAAgC,IAAI,GAAG,CACzD,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,E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