@uncefact/untp-utils 0.1.0 → 0.2.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 +23 -1
- package/build/artefacts/detect-version-from-context.d.ts +46 -0
- package/build/artefacts/detect-version-from-context.js +77 -0
- package/build/artefacts/detect-version-from-context.js.map +1 -0
- package/build/artefacts/detect-version-from-context.test.d.ts +1 -0
- package/build/artefacts/detect-version-from-context.test.js +69 -0
- package/build/artefacts/detect-version-from-context.test.js.map +1 -0
- package/build/artefacts/index.d.ts +3 -0
- package/build/artefacts/index.js +4 -0
- package/build/artefacts/index.js.map +1 -0
- package/build/artefacts/urls.d.ts +79 -0
- package/build/artefacts/urls.js +133 -0
- package/build/artefacts/urls.js.map +1 -0
- package/build/artefacts/urls.test.d.ts +1 -0
- package/build/artefacts/urls.test.js +91 -0
- package/build/artefacts/urls.test.js.map +1 -0
- package/build/artefacts/version.d.ts +9 -0
- package/build/artefacts/version.js +17 -0
- package/build/artefacts/version.js.map +1 -0
- package/build/artefacts/version.test.d.ts +1 -0
- package/build/artefacts/version.test.js +16 -0
- package/build/artefacts/version.test.js.map +1 -0
- package/build/cache/in-memory-ttl-cache.d.ts +2 -0
- package/build/cache/in-memory-ttl-cache.js +76 -0
- package/build/cache/in-memory-ttl-cache.js.map +1 -0
- package/build/cache/in-memory-ttl-cache.test.d.ts +1 -0
- package/build/cache/in-memory-ttl-cache.test.js +236 -0
- package/build/cache/in-memory-ttl-cache.test.js.map +1 -0
- package/build/cache/index.d.ts +2 -0
- package/build/cache/index.js +2 -0
- package/build/cache/index.js.map +1 -0
- package/build/cache/ttl-cache.d.ts +22 -0
- package/build/cache/ttl-cache.js +2 -0
- package/build/cache/ttl-cache.js.map +1 -0
- package/build/common/as-non-empty-string.d.ts +7 -0
- package/build/common/as-non-empty-string.js +10 -0
- package/build/common/as-non-empty-string.js.map +1 -0
- package/build/common/as-non-empty-string.test.d.ts +1 -0
- package/build/common/as-non-empty-string.test.js +25 -0
- package/build/common/as-non-empty-string.test.js.map +1 -0
- package/build/common/require-string.d.ts +12 -0
- package/build/common/require-string.js +27 -0
- package/build/common/require-string.js.map +1 -0
- package/build/common/require-string.test.d.ts +1 -0
- package/build/common/require-string.test.js +53 -0
- package/build/common/require-string.test.js.map +1 -0
- package/build/conformity-vocabulary/codes.d.ts +10 -0
- package/build/conformity-vocabulary/codes.js +10 -0
- package/build/conformity-vocabulary/codes.js.map +1 -0
- package/build/conformity-vocabulary/errors.d.ts +44 -0
- package/build/conformity-vocabulary/errors.js +68 -0
- package/build/conformity-vocabulary/errors.js.map +1 -0
- package/build/conformity-vocabulary/index.d.ts +6 -0
- package/build/conformity-vocabulary/index.js +7 -0
- package/build/conformity-vocabulary/index.js.map +1 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.d.ts +26 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.js +106 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.js.map +1 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.test.d.ts +1 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.test.js +327 -0
- package/build/conformity-vocabulary/parse-conformity-catalogue.test.js.map +1 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.d.ts +28 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.js +47 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.js.map +1 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.test.d.ts +1 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.test.js +284 -0
- package/build/conformity-vocabulary/parse-conformity-scheme.test.js.map +1 -0
- package/build/conformity-vocabulary/parsers/v0-7-0.parser.d.ts +19 -0
- package/build/conformity-vocabulary/parsers/v0-7-0.parser.js +219 -0
- package/build/conformity-vocabulary/parsers/v0-7-0.parser.js.map +1 -0
- package/build/conformity-vocabulary/types.d.ts +180 -0
- package/build/conformity-vocabulary/types.js +2 -0
- package/build/conformity-vocabulary/types.js.map +1 -0
- package/build/conformity-vocabulary/validate-conformity-claim.d.ts +26 -0
- package/build/conformity-vocabulary/validate-conformity-claim.js +165 -0
- package/build/conformity-vocabulary/validate-conformity-claim.js.map +1 -0
- package/build/conformity-vocabulary/validate-conformity-claim.test.d.ts +1 -0
- package/build/conformity-vocabulary/validate-conformity-claim.test.js +478 -0
- package/build/conformity-vocabulary/validate-conformity-claim.test.js.map +1 -0
- package/build/http-headers/index.d.ts +5 -0
- package/build/http-headers/index.js +6 -0
- package/build/http-headers/index.js.map +1 -0
- package/build/http-headers/is-safe-header-value.d.ts +10 -0
- package/build/http-headers/is-safe-header-value.js +15 -0
- package/build/http-headers/is-safe-header-value.js.map +1 -0
- package/build/http-headers/is-safe-header-value.test.d.ts +1 -0
- package/build/http-headers/is-safe-header-value.test.js +37 -0
- package/build/http-headers/is-safe-header-value.test.js.map +1 -0
- package/build/http-headers/parse-entity-tag.d.ts +9 -0
- package/build/http-headers/parse-entity-tag.js +18 -0
- package/build/http-headers/parse-entity-tag.js.map +1 -0
- package/build/http-headers/parse-entity-tag.test.d.ts +1 -0
- package/build/http-headers/parse-entity-tag.test.js +41 -0
- package/build/http-headers/parse-entity-tag.test.js.map +1 -0
- package/build/http-headers/parse-imf-date.d.ts +13 -0
- package/build/http-headers/parse-imf-date.js +23 -0
- package/build/http-headers/parse-imf-date.js.map +1 -0
- package/build/http-headers/parse-imf-date.test.d.ts +1 -0
- package/build/http-headers/parse-imf-date.test.js +31 -0
- package/build/http-headers/parse-imf-date.test.js.map +1 -0
- package/build/http-headers/parse-media-type.d.ts +8 -0
- package/build/http-headers/parse-media-type.js +21 -0
- package/build/http-headers/parse-media-type.js.map +1 -0
- package/build/http-headers/parse-media-type.test.d.ts +1 -0
- package/build/http-headers/parse-media-type.test.js +39 -0
- package/build/http-headers/parse-media-type.test.js.map +1 -0
- package/build/http-headers/user-agent.d.ts +35 -0
- package/build/http-headers/user-agent.js +45 -0
- package/build/http-headers/user-agent.js.map +1 -0
- package/build/http-headers/user-agent.test.d.ts +1 -0
- package/build/http-headers/user-agent.test.js +27 -0
- package/build/http-headers/user-agent.test.js.map +1 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/loaders/errors.d.ts +21 -0
- package/build/loaders/errors.js +45 -0
- package/build/loaders/errors.js.map +1 -0
- package/build/loaders/index.d.ts +3 -0
- package/build/loaders/index.js +4 -0
- package/build/loaders/index.js.map +1 -0
- package/build/loaders/jsonld-document-loader.d.ts +46 -0
- package/build/loaders/jsonld-document-loader.js +34 -0
- package/build/loaders/jsonld-document-loader.js.map +1 -0
- package/build/loaders/jsonld-document-loader.test.d.ts +1 -0
- package/build/loaders/jsonld-document-loader.test.js +71 -0
- package/build/loaders/jsonld-document-loader.test.js.map +1 -0
- package/build/loaders/schema-loader.d.ts +21 -0
- package/build/loaders/schema-loader.js +67 -0
- package/build/loaders/schema-loader.js.map +1 -0
- package/build/loaders/schema-loader.ssrf.test.d.ts +1 -0
- package/build/loaders/schema-loader.ssrf.test.js +55 -0
- package/build/loaders/schema-loader.ssrf.test.js.map +1 -0
- package/build/loaders/schema-loader.test.d.ts +1 -0
- package/build/loaders/schema-loader.test.js +162 -0
- package/build/loaders/schema-loader.test.js.map +1 -0
- package/build/multibase-digest/multibase-digest.d.ts +23 -0
- package/build/multibase-digest/multibase-digest.js +40 -0
- package/build/multibase-digest/multibase-digest.js.map +1 -1
- package/build/multibase-digest/multibase-digest.test.js +46 -0
- package/build/multibase-digest/multibase-digest.test.js.map +1 -1
- package/build/node/errors.d.ts +41 -0
- package/build/node/errors.js +80 -0
- package/build/node/errors.js.map +1 -0
- package/build/node/index.d.ts +3 -0
- package/build/node/index.js +4 -0
- package/build/node/index.js.map +1 -0
- package/build/node/is-private-ip.d.ts +41 -0
- package/build/node/is-private-ip.js +138 -0
- package/build/node/is-private-ip.js.map +1 -0
- package/build/node/is-private-ip.test.d.ts +1 -0
- package/build/node/is-private-ip.test.js +96 -0
- package/build/node/is-private-ip.test.js.map +1 -0
- package/build/node/validate-public-url.d.ts +49 -0
- package/build/node/validate-public-url.js +94 -0
- package/build/node/validate-public-url.js.map +1 -0
- package/build/node/validate-public-url.test.d.ts +1 -0
- package/build/node/validate-public-url.test.js +177 -0
- package/build/node/validate-public-url.test.js.map +1 -0
- package/build/resolvers/errors.d.ts +43 -0
- package/build/resolvers/errors.js +99 -0
- package/build/resolvers/errors.js.map +1 -0
- package/build/resolvers/index.d.ts +5 -0
- package/build/resolvers/index.js +6 -0
- package/build/resolvers/index.js.map +1 -0
- package/build/resolvers/resolve-document-if-changed.d.ts +48 -0
- package/build/resolvers/resolve-document-if-changed.js +42 -0
- package/build/resolvers/resolve-document-if-changed.js.map +1 -0
- package/build/resolvers/resolve-document-if-changed.test.d.ts +1 -0
- package/build/resolvers/resolve-document-if-changed.test.js +109 -0
- package/build/resolvers/resolve-document-if-changed.test.js.map +1 -0
- package/build/resolvers/resolve-document.d.ts +86 -0
- package/build/resolvers/resolve-document.js +239 -0
- package/build/resolvers/resolve-document.js.map +1 -0
- package/build/resolvers/resolve-document.test.d.ts +1 -0
- package/build/resolvers/resolve-document.test.js +299 -0
- package/build/resolvers/resolve-document.test.js.map +1 -0
- package/build/resolvers/resolve-json-document.d.ts +40 -0
- package/build/resolvers/resolve-json-document.js +42 -0
- package/build/resolvers/resolve-json-document.js.map +1 -0
- package/build/resolvers/resolve-json-document.test.d.ts +1 -0
- package/build/resolvers/resolve-json-document.test.js +61 -0
- package/build/resolvers/resolve-json-document.test.js.map +1 -0
- package/build/structured-error.d.ts +49 -0
- package/build/structured-error.js +17 -0
- package/build/structured-error.js.map +1 -0
- package/build/structured-error.test.d.ts +1 -0
- package/build/structured-error.test.js +112 -0
- package/build/structured-error.test.js.map +1 -0
- package/build/validation/describe-jsonld-failure.d.ts +50 -0
- package/build/validation/describe-jsonld-failure.js +104 -0
- package/build/validation/describe-jsonld-failure.js.map +1 -0
- package/build/validation/describe-jsonld-failure.test.d.ts +1 -0
- package/build/validation/describe-jsonld-failure.test.js +141 -0
- package/build/validation/describe-jsonld-failure.test.js.map +1 -0
- package/build/validation/errors.d.ts +40 -0
- package/build/validation/errors.js +75 -0
- package/build/validation/errors.js.map +1 -0
- package/build/validation/index.d.ts +4 -0
- package/build/validation/index.js +5 -0
- package/build/validation/index.js.map +1 -0
- package/build/validation/validate-against-schemas.d.ts +22 -0
- package/build/validation/validate-against-schemas.js +65 -0
- package/build/validation/validate-against-schemas.js.map +1 -0
- package/build/validation/validate-against-schemas.test.d.ts +1 -0
- package/build/validation/validate-against-schemas.test.js +169 -0
- package/build/validation/validate-against-schemas.test.js.map +1 -0
- package/build/validation/validate-jsonld.context-cache.test.d.ts +1 -0
- package/build/validation/validate-jsonld.context-cache.test.js +32 -0
- package/build/validation/validate-jsonld.context-cache.test.js.map +1 -0
- package/build/validation/validate-jsonld.d.ts +33 -0
- package/build/validation/validate-jsonld.js +99 -0
- package/build/validation/validate-jsonld.js.map +1 -0
- package/build/validation/validate-jsonld.ssrf.test.d.ts +1 -0
- package/build/validation/validate-jsonld.ssrf.test.js +108 -0
- package/build/validation/validate-jsonld.ssrf.test.js.map +1 -0
- package/build/validation/validate-jsonld.test.d.ts +1 -0
- package/build/validation/validate-jsonld.test.js +200 -0
- package/build/validation/validate-jsonld.test.js.map +1 -0
- package/package.json +64 -3
package/README.md
CHANGED
|
@@ -8,12 +8,34 @@ Shared utility primitives for UNTP packages and consumers.
|
|
|
8
8
|
yarn add @uncefact/untp-utils
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Sub-entries
|
|
12
|
+
|
|
13
|
+
The package root exports only `StructuredError`, the base class every
|
|
14
|
+
sub-entry throws from. Each capability is imported from its own subpath so a
|
|
15
|
+
consumer only pulls in the dependencies it needs.
|
|
16
|
+
|
|
17
|
+
| Subpath | Provides |
|
|
18
|
+
| -------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
19
|
+
| `@uncefact/untp-utils/multibase-digest` | `MultibaseDigest`: encode, decode and verify multibase-encoded multihashes. |
|
|
20
|
+
| `@uncefact/untp-utils/artefacts` | UNTP schema, context and docs URL helpers, and `detectVersionFromContext`. |
|
|
21
|
+
| `@uncefact/untp-utils/conformity-vocabulary` | Parses a UNTP conformity scheme or catalogue and validates a conformity claim against it. |
|
|
22
|
+
| `@uncefact/untp-utils/validation` | Validates a payload against JSON Schema and expands it as JSON-LD, both guarded against SSRF. |
|
|
23
|
+
| `@uncefact/untp-utils/loaders` | The schema and JSON-LD document loaders `validation` runs on. |
|
|
24
|
+
| `@uncefact/untp-utils/resolvers` | IP-pinned document fetching with a conditional-fetch skip chain. |
|
|
25
|
+
| `@uncefact/untp-utils/node` | `validatePublicUrl`, the SSRF guard the other sub-entries fetch through. |
|
|
26
|
+
| `@uncefact/untp-utils/cache` | `createInMemoryTtlCache`, a bounded in-memory TTL cache. |
|
|
27
|
+
| `@uncefact/untp-utils/http-headers` | HTTP header parsing, and the default `User-Agent` guarded fetches send. |
|
|
28
|
+
|
|
29
|
+
Every sub-entry throws a typed error class on failure rather than returning
|
|
30
|
+
an outcome object. See [RELEASE_NOTES.md](./RELEASE_NOTES.md) for what each
|
|
31
|
+
release changes and [CHANGELOG.md](./CHANGELOG.md) for the full history.
|
|
32
|
+
|
|
11
33
|
## MultibaseDigest
|
|
12
34
|
|
|
13
35
|
Encode, decode and verify multibase-encoded multihashes.
|
|
14
36
|
|
|
15
37
|
```ts
|
|
16
|
-
import { MultibaseDigest } from '@uncefact/untp-utils';
|
|
38
|
+
import { MultibaseDigest } from '@uncefact/untp-utils/multibase-digest';
|
|
17
39
|
|
|
18
40
|
// Hash some data, wrap as a multihash, encode as a multibase string.
|
|
19
41
|
const digest = await MultibaseDigest.fromData(new TextEncoder().encode('hello'), {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domains UNTP publishes versioned contexts under. UNTP v0.7 and above
|
|
3
|
+
* publish to `vocabulary.uncefact.org`; earlier versions (pre-0.7) were
|
|
4
|
+
* published to `test.uncefact.org`. Both are kept in the matcher so
|
|
5
|
+
* documents from either era resolve to a version string.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UNTP_CONTEXT_DOMAINS: readonly ["vocabulary.uncefact.org", "test.uncefact.org"];
|
|
8
|
+
/**
|
|
9
|
+
* Options for {@link detectVersionFromContext}.
|
|
10
|
+
*/
|
|
11
|
+
export interface DetectVersionFromContextOptions {
|
|
12
|
+
/**
|
|
13
|
+
* When set, only context URLs whose hostname contains this substring are
|
|
14
|
+
* considered. Useful for extensions, where each extension publishes its own
|
|
15
|
+
* versioned context under a domain distinct from the UNTP core context.
|
|
16
|
+
*
|
|
17
|
+
* When omitted, any UNTP context domain ({@link UNTP_CONTEXT_DOMAINS}) is
|
|
18
|
+
* considered.
|
|
19
|
+
*/
|
|
20
|
+
domain?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Derives the spec version from a UNTP document's `@context` by looking for a
|
|
24
|
+
* path segment shaped `/{major}.{minor}.{patch}[-prerelease]/` inside a known
|
|
25
|
+
* UNTP context URL.
|
|
26
|
+
*
|
|
27
|
+
* Works for any UNTP artefact that publishes a versioned context: credentials
|
|
28
|
+
* (DPP, DCC, DFR, DIA, DTE), conformity schemes, identifier scheme registers,
|
|
29
|
+
* etc. The function is data-only: it never fetches, never resolves contexts.
|
|
30
|
+
*
|
|
31
|
+
* @param doc - Any object that may carry an `@context` field. The field may
|
|
32
|
+
* be a string or an array; non-string entries in arrays are ignored.
|
|
33
|
+
* Non-object inputs return `undefined`.
|
|
34
|
+
* @param options - {@link DetectVersionFromContextOptions}.
|
|
35
|
+
* @returns The detected version string (for example `0.7.0` or `0.7.0-rc1`),
|
|
36
|
+
* or `undefined` when no matching UNTP context URL is found.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* detectVersionFromContext({ '@context': ['https://vocabulary.uncefact.org/untp/0.7.0/context/'] });
|
|
40
|
+
* // → '0.7.0'
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* detectVersionFromContext(extensionCredential, { domain: 'aatp.example.com' });
|
|
44
|
+
* // → '0.5.0' (or whatever the extension publishes)
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectVersionFromContext(doc: unknown, options?: DetectVersionFromContextOptions): string | undefined;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domains UNTP publishes versioned contexts under. UNTP v0.7 and above
|
|
3
|
+
* publish to `vocabulary.uncefact.org`; earlier versions (pre-0.7) were
|
|
4
|
+
* published to `test.uncefact.org`. Both are kept in the matcher so
|
|
5
|
+
* documents from either era resolve to a version string.
|
|
6
|
+
*/
|
|
7
|
+
export const UNTP_CONTEXT_DOMAINS = ['vocabulary.uncefact.org', 'test.uncefact.org'];
|
|
8
|
+
/**
|
|
9
|
+
* A version segment in a UNTP-published context path. Matches a path segment
|
|
10
|
+
* shaped `/{major}.{minor}.{patch}[-prerelease]/`. The pre-release suffix
|
|
11
|
+
* captures common forms (`-rc1`, `-alpha.2`, `-2024-05-21`, etc.).
|
|
12
|
+
*/
|
|
13
|
+
const UNTP_VERSION_PATH_SEGMENT = /\/(\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?)\//;
|
|
14
|
+
/**
|
|
15
|
+
* Derives the spec version from a UNTP document's `@context` by looking for a
|
|
16
|
+
* path segment shaped `/{major}.{minor}.{patch}[-prerelease]/` inside a known
|
|
17
|
+
* UNTP context URL.
|
|
18
|
+
*
|
|
19
|
+
* Works for any UNTP artefact that publishes a versioned context: credentials
|
|
20
|
+
* (DPP, DCC, DFR, DIA, DTE), conformity schemes, identifier scheme registers,
|
|
21
|
+
* etc. The function is data-only: it never fetches, never resolves contexts.
|
|
22
|
+
*
|
|
23
|
+
* @param doc - Any object that may carry an `@context` field. The field may
|
|
24
|
+
* be a string or an array; non-string entries in arrays are ignored.
|
|
25
|
+
* Non-object inputs return `undefined`.
|
|
26
|
+
* @param options - {@link DetectVersionFromContextOptions}.
|
|
27
|
+
* @returns The detected version string (for example `0.7.0` or `0.7.0-rc1`),
|
|
28
|
+
* or `undefined` when no matching UNTP context URL is found.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* detectVersionFromContext({ '@context': ['https://vocabulary.uncefact.org/untp/0.7.0/context/'] });
|
|
32
|
+
* // → '0.7.0'
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* detectVersionFromContext(extensionCredential, { domain: 'aatp.example.com' });
|
|
36
|
+
* // → '0.5.0' (or whatever the extension publishes)
|
|
37
|
+
*/
|
|
38
|
+
export function detectVersionFromContext(doc, options = {}) {
|
|
39
|
+
if (!doc || typeof doc !== 'object') {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const contextField = doc['@context'];
|
|
43
|
+
const candidates = collectContextStrings(contextField);
|
|
44
|
+
const matchesDomain = buildDomainMatcher(options.domain);
|
|
45
|
+
for (const url of candidates) {
|
|
46
|
+
if (!matchesDomain(url)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const match = url.match(UNTP_VERSION_PATH_SEGMENT);
|
|
50
|
+
if (match) {
|
|
51
|
+
return match[1];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
function collectContextStrings(context) {
|
|
57
|
+
if (typeof context === 'string') {
|
|
58
|
+
return [context];
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(context)) {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const entry of context) {
|
|
63
|
+
if (typeof entry === 'string') {
|
|
64
|
+
out.push(entry);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
function buildDomainMatcher(domain) {
|
|
72
|
+
if (domain) {
|
|
73
|
+
return (url) => url.includes(domain);
|
|
74
|
+
}
|
|
75
|
+
return (url) => UNTP_CONTEXT_DOMAINS.some((d) => url.includes(d));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=detect-version-from-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-version-from-context.js","sourceRoot":"","sources":["../../src/artefacts/detect-version-from-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,yBAAyB,EAAE,mBAAmB,CAAU,CAAC;AAE9F;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,yCAAyC,CAAC;AAiB5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAY,EACZ,UAA2C,EAAE;IAE7C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,YAAY,GAAI,GAAgC,CAAC,UAAU,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACnD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgB;IAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAA0B;IACpD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { detectVersionFromContext } from './detect-version-from-context.js';
|
|
2
|
+
describe('detectVersionFromContext', () => {
|
|
3
|
+
describe('UNTP context detection (default domain set)', () => {
|
|
4
|
+
it('returns the version from a single string @context', () => {
|
|
5
|
+
const doc = { '@context': 'https://vocabulary.uncefact.org/untp/0.7.0/context/' };
|
|
6
|
+
expect(detectVersionFromContext(doc)).toBe('0.7.0');
|
|
7
|
+
});
|
|
8
|
+
it('returns the version when @context is an array including the UNTP context', () => {
|
|
9
|
+
const doc = {
|
|
10
|
+
'@context': ['https://www.w3.org/ns/credentials/v2', 'https://vocabulary.uncefact.org/untp/0.7.0/context/'],
|
|
11
|
+
};
|
|
12
|
+
expect(detectVersionFromContext(doc)).toBe('0.7.0');
|
|
13
|
+
});
|
|
14
|
+
it('recognises pre-release versions', () => {
|
|
15
|
+
const doc = { '@context': 'https://vocabulary.uncefact.org/untp/0.7.0-rc.1/context/' };
|
|
16
|
+
expect(detectVersionFromContext(doc)).toBe('0.7.0-rc.1');
|
|
17
|
+
});
|
|
18
|
+
it('recognises the test.uncefact.org domain', () => {
|
|
19
|
+
const doc = { '@context': 'https://test.uncefact.org/untp/0.7.0/context/' };
|
|
20
|
+
expect(detectVersionFromContext(doc)).toBe('0.7.0');
|
|
21
|
+
});
|
|
22
|
+
it('returns undefined for non-UNTP context domains', () => {
|
|
23
|
+
const doc = { '@context': ['https://schema.org/', 'https://example.com/0.7.0/'] };
|
|
24
|
+
expect(detectVersionFromContext(doc)).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
it('skips non-string entries within an array @context', () => {
|
|
27
|
+
const doc = {
|
|
28
|
+
'@context': [{ '@vocab': 'https://example.com/' }, 'https://vocabulary.uncefact.org/untp/0.7.0/context/'],
|
|
29
|
+
};
|
|
30
|
+
expect(detectVersionFromContext(doc)).toBe('0.7.0');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('domain-scoped detection', () => {
|
|
34
|
+
it('finds the version under a caller-supplied domain (extension context)', () => {
|
|
35
|
+
const doc = {
|
|
36
|
+
'@context': [
|
|
37
|
+
'https://www.w3.org/ns/credentials/v2',
|
|
38
|
+
'https://vocabulary.uncefact.org/untp/0.7.0/context/',
|
|
39
|
+
'https://aatp.example.com/untp/0.5.0/context/',
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
expect(detectVersionFromContext(doc, { domain: 'aatp.example.com' })).toBe('0.5.0');
|
|
43
|
+
});
|
|
44
|
+
it('returns undefined when no context matches the supplied domain', () => {
|
|
45
|
+
const doc = {
|
|
46
|
+
'@context': ['https://vocabulary.uncefact.org/untp/0.7.0/context/'],
|
|
47
|
+
};
|
|
48
|
+
expect(detectVersionFromContext(doc, { domain: 'nope.example.com' })).toBeUndefined();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('input handling', () => {
|
|
52
|
+
it('returns undefined when @context is missing', () => {
|
|
53
|
+
expect(detectVersionFromContext({})).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
it('returns undefined for non-object input', () => {
|
|
56
|
+
expect(detectVersionFromContext(null)).toBeUndefined();
|
|
57
|
+
expect(detectVersionFromContext(undefined)).toBeUndefined();
|
|
58
|
+
expect(detectVersionFromContext('a string')).toBeUndefined();
|
|
59
|
+
expect(detectVersionFromContext(42)).toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('regex robustness', () => {
|
|
63
|
+
it('ignores version-like substrings outside a path segment', () => {
|
|
64
|
+
const doc = { '@context': 'https://vocabulary.uncefact.org/untp/context?v=1.2.3' };
|
|
65
|
+
expect(detectVersionFromContext(doc)).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=detect-version-from-context.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-version-from-context.test.js","sourceRoot":"","sources":["../../src/artefacts/detect-version-from-context.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;QAC3D,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;YAC3D,MAAM,GAAG,GAAG,EAAE,UAAU,EAAE,qDAAqD,EAAE,CAAC;YAClF,MAAM,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;YAClF,MAAM,GAAG,GAAG;gBACV,UAAU,EAAE,CAAC,sCAAsC,EAAE,qDAAqD,CAAC;aAC5G,CAAC;YACF,MAAM,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI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,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/artefacts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construction of UNTP artefact URLs (JSON Schema and JSON-LD context) for a
|
|
3
|
+
* given credential / artefact type and spec version.
|
|
4
|
+
*
|
|
5
|
+
* UNTP v0.7.0 relocated the artefacts. Schemas moved from the legacy
|
|
6
|
+
* per-credential-type layout on `test.uncefact.org` to the unece.org
|
|
7
|
+
* artefacts origin, and the JSON-LD context was unified into a single
|
|
8
|
+
* per-version context on `vocabulary.uncefact.org` (the same context URL for
|
|
9
|
+
* every type, including the Conformity Vocabulary Catalogue `ConformityScheme`
|
|
10
|
+
* artefact, which was introduced in v0.7.0). Earlier versions (v0.6.x)
|
|
11
|
+
* continue to be served from the legacy layout. This is the forward
|
|
12
|
+
* counterpart to {@link detectVersionFromContext}, which derives the version
|
|
13
|
+
* from a context URL.
|
|
14
|
+
*
|
|
15
|
+
* @see https://untp.unece.org/artefacts/schema/v0.7.0/dpp/DigitalProductPassport.json
|
|
16
|
+
* @see https://vocabulary.uncefact.org/untp/0.7.0/context/
|
|
17
|
+
*/
|
|
18
|
+
/** Short artefact codes used in UNTP artefact paths, keyed by credential / artefact type. */
|
|
19
|
+
export declare const UNTP_SHORT_CREDENTIAL_TYPES: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* v0.7.0+ core schema file names keyed by credential / artefact type. Most
|
|
22
|
+
* match the type verbatim; `DigitalConformityCredential` is published as
|
|
23
|
+
* `ConformityCredential`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const UNTP_CORE_SCHEMA_FILENAMES: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* UNTP specification page slugs keyed by credential / artefact type. Slugs are
|
|
28
|
+
* version-independent. Several differ from the credential type name:
|
|
29
|
+
* `DigitalConformityCredential` is documented at `ConformityCredential`,
|
|
30
|
+
* `DigitalTraceabilityEvent` at the plural `DigitalTraceabilityEvents`, and
|
|
31
|
+
* `ConformityScheme` at `ConformityVocabularyCatalog`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const UNTP_SPECIFICATION_PAGE_SLUGS: Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* The UNTP docs version currently served at the unversioned ("current") docs
|
|
36
|
+
* path. This version is linked at `/docs/specification/<slug>`; older versions
|
|
37
|
+
* are linked at `/docs/<version>/specification/<slug>`.
|
|
38
|
+
*
|
|
39
|
+
* Maintenance point: update this when UNTP promotes a newer docs version to
|
|
40
|
+
* current. The previously-current version then gains its own
|
|
41
|
+
* `/docs/<version>/` path, so this constant moving keeps existing links
|
|
42
|
+
* pointing at the right version.
|
|
43
|
+
*/
|
|
44
|
+
export declare const CURRENT_UNTP_DOCS_VERSION = "0.7.0";
|
|
45
|
+
/**
|
|
46
|
+
* Builds the human-readable UNTP specification page URL for a credential /
|
|
47
|
+
* artefact type at a given version.
|
|
48
|
+
*
|
|
49
|
+
* The current docs version ({@link CURRENT_UNTP_DOCS_VERSION}) is served at
|
|
50
|
+
* the unversioned `/docs/specification/<slug>` path; older versions resolve to
|
|
51
|
+
* `/docs/<version>/specification/<slug>`. Versions without their own docs fall
|
|
52
|
+
* back to the nearest published docs version (see `DOCS_VERSION_FALLBACKS`).
|
|
53
|
+
*
|
|
54
|
+
* @param type - UNTP credential / artefact type (e.g. `DigitalProductPassport`).
|
|
55
|
+
* @param version - Semantic version of the artefact (e.g. `0.7.0`).
|
|
56
|
+
* @returns The specification page URL.
|
|
57
|
+
* @throws {Error} When `type` is not a recognised UNTP artefact type.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildSpecificationPageUrl(type: string, version: string): string;
|
|
60
|
+
/** The schema and context URLs for a UNTP artefact. */
|
|
61
|
+
export interface UntpArtefactUrls {
|
|
62
|
+
/** URL of the JSON Schema the document validates against. */
|
|
63
|
+
schemaUrl: string;
|
|
64
|
+
/** URL of the JSON-LD context the document references in `@context`. */
|
|
65
|
+
contextUrl: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Builds the JSON Schema and JSON-LD context URLs for a UNTP artefact.
|
|
69
|
+
*
|
|
70
|
+
* `ConformityScheme` was introduced in v0.7.0 and has no legacy layout; only
|
|
71
|
+
* call it with a v0.7.0+ version.
|
|
72
|
+
*
|
|
73
|
+
* @param type - UNTP credential / artefact type (e.g. `DigitalProductPassport`,
|
|
74
|
+
* `ConformityScheme`). Must be a recognised type.
|
|
75
|
+
* @param version - Semantic version of the artefact (e.g. `0.7.0`).
|
|
76
|
+
* @returns The {@link UntpArtefactUrls} appropriate for the version.
|
|
77
|
+
* @throws {Error} When `type` is not a recognised UNTP artefact type.
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildUntpArtefactUrls(type: string, version: string): UntpArtefactUrls;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construction of UNTP artefact URLs (JSON Schema and JSON-LD context) for a
|
|
3
|
+
* given credential / artefact type and spec version.
|
|
4
|
+
*
|
|
5
|
+
* UNTP v0.7.0 relocated the artefacts. Schemas moved from the legacy
|
|
6
|
+
* per-credential-type layout on `test.uncefact.org` to the unece.org
|
|
7
|
+
* artefacts origin, and the JSON-LD context was unified into a single
|
|
8
|
+
* per-version context on `vocabulary.uncefact.org` (the same context URL for
|
|
9
|
+
* every type, including the Conformity Vocabulary Catalogue `ConformityScheme`
|
|
10
|
+
* artefact, which was introduced in v0.7.0). Earlier versions (v0.6.x)
|
|
11
|
+
* continue to be served from the legacy layout. This is the forward
|
|
12
|
+
* counterpart to {@link detectVersionFromContext}, which derives the version
|
|
13
|
+
* from a context URL.
|
|
14
|
+
*
|
|
15
|
+
* @see https://untp.unece.org/artefacts/schema/v0.7.0/dpp/DigitalProductPassport.json
|
|
16
|
+
* @see https://vocabulary.uncefact.org/untp/0.7.0/context/
|
|
17
|
+
*/
|
|
18
|
+
import { isV070OrAbove } from './version.js';
|
|
19
|
+
const LEGACY_BASE = 'https://test.uncefact.org/vocabulary/untp';
|
|
20
|
+
const ARTEFACTS_SCHEMA_BASE = 'https://untp.unece.org/artefacts/schema';
|
|
21
|
+
const UNIFIED_CONTEXT_BASE = 'https://vocabulary.uncefact.org/untp';
|
|
22
|
+
/** Short artefact codes used in UNTP artefact paths, keyed by credential / artefact type. */
|
|
23
|
+
export const UNTP_SHORT_CREDENTIAL_TYPES = {
|
|
24
|
+
DigitalProductPassport: 'dpp',
|
|
25
|
+
DigitalConformityCredential: 'dcc',
|
|
26
|
+
DigitalTraceabilityEvent: 'dte',
|
|
27
|
+
DigitalFacilityRecord: 'dfr',
|
|
28
|
+
DigitalIdentityAnchor: 'dia',
|
|
29
|
+
ConformityScheme: 'cvc',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* v0.7.0+ core schema file names keyed by credential / artefact type. Most
|
|
33
|
+
* match the type verbatim; `DigitalConformityCredential` is published as
|
|
34
|
+
* `ConformityCredential`.
|
|
35
|
+
*/
|
|
36
|
+
export const UNTP_CORE_SCHEMA_FILENAMES = {
|
|
37
|
+
DigitalProductPassport: 'DigitalProductPassport',
|
|
38
|
+
DigitalConformityCredential: 'ConformityCredential',
|
|
39
|
+
DigitalTraceabilityEvent: 'DigitalTraceabilityEvent',
|
|
40
|
+
DigitalFacilityRecord: 'DigitalFacilityRecord',
|
|
41
|
+
DigitalIdentityAnchor: 'DigitalIdentityAnchor',
|
|
42
|
+
ConformityScheme: 'ConformityScheme',
|
|
43
|
+
};
|
|
44
|
+
const DOCS_BASE = 'https://untp.unece.org/docs';
|
|
45
|
+
/**
|
|
46
|
+
* UNTP specification page slugs keyed by credential / artefact type. Slugs are
|
|
47
|
+
* version-independent. Several differ from the credential type name:
|
|
48
|
+
* `DigitalConformityCredential` is documented at `ConformityCredential`,
|
|
49
|
+
* `DigitalTraceabilityEvent` at the plural `DigitalTraceabilityEvents`, and
|
|
50
|
+
* `ConformityScheme` at `ConformityVocabularyCatalog`.
|
|
51
|
+
*/
|
|
52
|
+
export const UNTP_SPECIFICATION_PAGE_SLUGS = {
|
|
53
|
+
DigitalProductPassport: 'DigitalProductPassport',
|
|
54
|
+
DigitalConformityCredential: 'ConformityCredential',
|
|
55
|
+
DigitalTraceabilityEvent: 'DigitalTraceabilityEvents',
|
|
56
|
+
DigitalFacilityRecord: 'DigitalFacilityRecord',
|
|
57
|
+
DigitalIdentityAnchor: 'DigitalIdentityAnchor',
|
|
58
|
+
ConformityScheme: 'ConformityVocabularyCatalog',
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The UNTP docs version currently served at the unversioned ("current") docs
|
|
62
|
+
* path. This version is linked at `/docs/specification/<slug>`; older versions
|
|
63
|
+
* are linked at `/docs/<version>/specification/<slug>`.
|
|
64
|
+
*
|
|
65
|
+
* Maintenance point: update this when UNTP promotes a newer docs version to
|
|
66
|
+
* current. The previously-current version then gains its own
|
|
67
|
+
* `/docs/<version>/` path, so this constant moving keeps existing links
|
|
68
|
+
* pointing at the right version.
|
|
69
|
+
*/
|
|
70
|
+
export const CURRENT_UNTP_DOCS_VERSION = '0.7.0';
|
|
71
|
+
/**
|
|
72
|
+
* Versions that ship no docs of their own, mapped to the published docs
|
|
73
|
+
* version that covers them. UNTP released 0.6.1 schemas without separate
|
|
74
|
+
* 0.6.1 docs; the 0.6.0 docs document the whole 0.6.x line.
|
|
75
|
+
*/
|
|
76
|
+
const DOCS_VERSION_FALLBACKS = {
|
|
77
|
+
'0.6.1': '0.6.0',
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Builds the human-readable UNTP specification page URL for a credential /
|
|
81
|
+
* artefact type at a given version.
|
|
82
|
+
*
|
|
83
|
+
* The current docs version ({@link CURRENT_UNTP_DOCS_VERSION}) is served at
|
|
84
|
+
* the unversioned `/docs/specification/<slug>` path; older versions resolve to
|
|
85
|
+
* `/docs/<version>/specification/<slug>`. Versions without their own docs fall
|
|
86
|
+
* back to the nearest published docs version (see `DOCS_VERSION_FALLBACKS`).
|
|
87
|
+
*
|
|
88
|
+
* @param type - UNTP credential / artefact type (e.g. `DigitalProductPassport`).
|
|
89
|
+
* @param version - Semantic version of the artefact (e.g. `0.7.0`).
|
|
90
|
+
* @returns The specification page URL.
|
|
91
|
+
* @throws {Error} When `type` is not a recognised UNTP artefact type.
|
|
92
|
+
*/
|
|
93
|
+
export function buildSpecificationPageUrl(type, version) {
|
|
94
|
+
const slug = UNTP_SPECIFICATION_PAGE_SLUGS[type];
|
|
95
|
+
if (!slug) {
|
|
96
|
+
throw new Error(`Unknown UNTP artefact type "${type}". Expected one of: ${Object.keys(UNTP_SPECIFICATION_PAGE_SLUGS).join(', ')}.`);
|
|
97
|
+
}
|
|
98
|
+
const docsVersion = DOCS_VERSION_FALLBACKS[version] ?? version;
|
|
99
|
+
if (docsVersion === CURRENT_UNTP_DOCS_VERSION) {
|
|
100
|
+
return `${DOCS_BASE}/specification/${slug}`;
|
|
101
|
+
}
|
|
102
|
+
return `${DOCS_BASE}/${docsVersion}/specification/${slug}`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Builds the JSON Schema and JSON-LD context URLs for a UNTP artefact.
|
|
106
|
+
*
|
|
107
|
+
* `ConformityScheme` was introduced in v0.7.0 and has no legacy layout; only
|
|
108
|
+
* call it with a v0.7.0+ version.
|
|
109
|
+
*
|
|
110
|
+
* @param type - UNTP credential / artefact type (e.g. `DigitalProductPassport`,
|
|
111
|
+
* `ConformityScheme`). Must be a recognised type.
|
|
112
|
+
* @param version - Semantic version of the artefact (e.g. `0.7.0`).
|
|
113
|
+
* @returns The {@link UntpArtefactUrls} appropriate for the version.
|
|
114
|
+
* @throws {Error} When `type` is not a recognised UNTP artefact type.
|
|
115
|
+
*/
|
|
116
|
+
export function buildUntpArtefactUrls(type, version) {
|
|
117
|
+
const shortCode = UNTP_SHORT_CREDENTIAL_TYPES[type];
|
|
118
|
+
if (!shortCode) {
|
|
119
|
+
throw new Error(`Unknown UNTP artefact type "${type}". Expected one of: ${Object.keys(UNTP_SHORT_CREDENTIAL_TYPES).join(', ')}.`);
|
|
120
|
+
}
|
|
121
|
+
if (isV070OrAbove(version)) {
|
|
122
|
+
const fileName = UNTP_CORE_SCHEMA_FILENAMES[type];
|
|
123
|
+
return {
|
|
124
|
+
schemaUrl: `${ARTEFACTS_SCHEMA_BASE}/v${version}/${shortCode}/${fileName}.json`,
|
|
125
|
+
contextUrl: `${UNIFIED_CONTEXT_BASE}/${version}/context/`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
schemaUrl: `${LEGACY_BASE}/${shortCode}/untp-${shortCode}-schema-${version}.json`,
|
|
130
|
+
contextUrl: `${LEGACY_BASE}/${shortCode}/${version}/context/`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/artefacts/urls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAChE,MAAM,qBAAqB,GAAG,yCAAyC,CAAC;AACxE,MAAM,oBAAoB,GAAG,sCAAsC,CAAC;AAEpE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,2BAA2B,GAA2B;IACjE,sBAAsB,EAAE,KAAK;IAC7B,2BAA2B,EAAE,KAAK;IAClC,wBAAwB,EAAE,KAAK;IAC/B,qBAAqB,EAAE,KAAK;IAC5B,qBAAqB,EAAE,KAAK;IAC5B,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF;;;;G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AAUD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,OAAe;IACjE,MAAM,SAAS,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,uBAAuB,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjH,CAAC;IACJ,CAAC;IAED,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO;YACL,SAAS,EAAE,GAAG,qBAAqB,KAAK,OAAO,IAAI,SAAS,IAAI,QAAQ,OAAO;YAC/E,UAAU,EAAE,GAAG,oBAAoB,IAAI,OAAO,WAAW;SAC1D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,GAAG,WAAW,IAAI,SAAS,SAAS,SAAS,WAAW,OAAO,OAAO;QACjF,UAAU,EAAE,GAAG,WAAW,IAAI,SAAS,IAAI,OAAO,WAAW;KAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { buildUntpArtefactUrls, buildSpecificationPageUrl, UNTP_SHORT_CREDENTIAL_TYPES, UNTP_CORE_SCHEMA_FILENAMES, UNTP_SPECIFICATION_PAGE_SLUGS, } from './urls';
|
|
2
|
+
describe('buildUntpArtefactUrls', () => {
|
|
3
|
+
describe('v0.6.x (legacy layout)', () => {
|
|
4
|
+
it('builds the legacy per-credential-type schema and context URLs', () => {
|
|
5
|
+
expect(buildUntpArtefactUrls('DigitalProductPassport', '0.6.1')).toEqual({
|
|
6
|
+
schemaUrl: 'https://test.uncefact.org/vocabulary/untp/dpp/untp-dpp-schema-0.6.1.json',
|
|
7
|
+
contextUrl: 'https://test.uncefact.org/vocabulary/untp/dpp/0.6.1/context/',
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
it('uses the legacy layout for v0.6.0', () => {
|
|
11
|
+
expect(buildUntpArtefactUrls('DigitalConformityCredential', '0.6.0')).toEqual({
|
|
12
|
+
schemaUrl: 'https://test.uncefact.org/vocabulary/untp/dcc/untp-dcc-schema-0.6.0.json',
|
|
13
|
+
contextUrl: 'https://test.uncefact.org/vocabulary/untp/dcc/0.6.0/context/',
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('v0.7.0+ (artefacts layout)', () => {
|
|
18
|
+
it('builds the artefacts schema URL and unified context URL for DPP', () => {
|
|
19
|
+
expect(buildUntpArtefactUrls('DigitalProductPassport', '0.7.0')).toEqual({
|
|
20
|
+
schemaUrl: 'https://untp.unece.org/artefacts/schema/v0.7.0/dpp/DigitalProductPassport.json',
|
|
21
|
+
contextUrl: 'https://vocabulary.uncefact.org/untp/0.7.0/context/',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it('maps DigitalConformityCredential to the ConformityCredential schema file name', () => {
|
|
25
|
+
expect(buildUntpArtefactUrls('DigitalConformityCredential', '0.7.0').schemaUrl).toBe('https://untp.unece.org/artefacts/schema/v0.7.0/dcc/ConformityCredential.json');
|
|
26
|
+
});
|
|
27
|
+
it.each([
|
|
28
|
+
['DigitalFacilityRecord', 'dfr', 'DigitalFacilityRecord'],
|
|
29
|
+
['DigitalIdentityAnchor', 'dia', 'DigitalIdentityAnchor'],
|
|
30
|
+
['DigitalTraceabilityEvent', 'dte', 'DigitalTraceabilityEvent'],
|
|
31
|
+
])('builds the artefacts schema URL for %s', (type, shortCode, fileName) => {
|
|
32
|
+
expect(buildUntpArtefactUrls(type, '0.7.0').schemaUrl).toBe(`https://untp.unece.org/artefacts/schema/v0.7.0/${shortCode}/${fileName}.json`);
|
|
33
|
+
});
|
|
34
|
+
it('builds the artefacts schema and unified context URLs for ConformityScheme (introduced in v0.7.0)', () => {
|
|
35
|
+
expect(buildUntpArtefactUrls('ConformityScheme', '0.7.0')).toEqual({
|
|
36
|
+
schemaUrl: 'https://untp.unece.org/artefacts/schema/v0.7.0/cvc/ConformityScheme.json',
|
|
37
|
+
contextUrl: 'https://vocabulary.uncefact.org/untp/0.7.0/context/',
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
it('shares one unified context URL across credentials and the conformity scheme', () => {
|
|
41
|
+
const dpp = buildUntpArtefactUrls('DigitalProductPassport', '0.7.0').contextUrl;
|
|
42
|
+
const dte = buildUntpArtefactUrls('DigitalTraceabilityEvent', '0.7.0').contextUrl;
|
|
43
|
+
const cvc = buildUntpArtefactUrls('ConformityScheme', '0.7.0').contextUrl;
|
|
44
|
+
expect(new Set([dpp, dte, cvc]).size).toBe(1);
|
|
45
|
+
expect(dpp).toBe('https://vocabulary.uncefact.org/untp/0.7.0/context/');
|
|
46
|
+
});
|
|
47
|
+
it('treats a future minor (0.8.0) as the artefacts layout', () => {
|
|
48
|
+
expect(buildUntpArtefactUrls('DigitalProductPassport', '0.8.0').schemaUrl).toBe('https://untp.unece.org/artefacts/schema/v0.8.0/dpp/DigitalProductPassport.json');
|
|
49
|
+
});
|
|
50
|
+
it('treats a future major (1.0.0) as the artefacts layout', () => {
|
|
51
|
+
expect(buildUntpArtefactUrls('DigitalProductPassport', '1.0.0').contextUrl).toBe('https://vocabulary.uncefact.org/untp/1.0.0/context/');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('unknown artefact type', () => {
|
|
55
|
+
it('throws with a helpful message listing the supported types', () => {
|
|
56
|
+
expect(() => buildUntpArtefactUrls('DigitalLivestockPassport', '0.7.0')).toThrow(/Unknown UNTP artefact type/);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('exported maps', () => {
|
|
60
|
+
it('the short-code and schema-filename maps agree on the set of supported types', () => {
|
|
61
|
+
expect(Object.keys(UNTP_SHORT_CREDENTIAL_TYPES).sort()).toEqual(Object.keys(UNTP_CORE_SCHEMA_FILENAMES).sort());
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('buildSpecificationPageUrl', () => {
|
|
66
|
+
it('links the current docs version (0.7.0) at the unversioned path', () => {
|
|
67
|
+
expect(buildSpecificationPageUrl('DigitalProductPassport', '0.7.0')).toBe('https://untp.unece.org/docs/specification/DigitalProductPassport');
|
|
68
|
+
});
|
|
69
|
+
it('links an older version (0.6.0) at the versioned path', () => {
|
|
70
|
+
expect(buildSpecificationPageUrl('DigitalProductPassport', '0.6.0')).toBe('https://untp.unece.org/docs/0.6.0/specification/DigitalProductPassport');
|
|
71
|
+
});
|
|
72
|
+
it('falls back to the 0.6.0 docs for 0.6.1 (which has no docs of its own)', () => {
|
|
73
|
+
expect(buildSpecificationPageUrl('DigitalProductPassport', '0.6.1')).toBe('https://untp.unece.org/docs/0.6.0/specification/DigitalProductPassport');
|
|
74
|
+
});
|
|
75
|
+
it('uses the ConformityCredential slug for DigitalConformityCredential', () => {
|
|
76
|
+
expect(buildSpecificationPageUrl('DigitalConformityCredential', '0.7.0')).toBe('https://untp.unece.org/docs/specification/ConformityCredential');
|
|
77
|
+
});
|
|
78
|
+
it('uses the plural DigitalTraceabilityEvents slug for DigitalTraceabilityEvent', () => {
|
|
79
|
+
expect(buildSpecificationPageUrl('DigitalTraceabilityEvent', '0.6.0')).toBe('https://untp.unece.org/docs/0.6.0/specification/DigitalTraceabilityEvents');
|
|
80
|
+
});
|
|
81
|
+
it('uses the ConformityVocabularyCatalog slug for ConformityScheme', () => {
|
|
82
|
+
expect(buildSpecificationPageUrl('ConformityScheme', '0.7.0')).toBe('https://untp.unece.org/docs/specification/ConformityVocabularyCatalog');
|
|
83
|
+
});
|
|
84
|
+
it('throws for an unknown artefact type', () => {
|
|
85
|
+
expect(() => buildSpecificationPageUrl('DigitalLivestockPassport', '0.7.0')).toThrow(/Unknown UNTP artefact type/);
|
|
86
|
+
});
|
|
87
|
+
it('keeps the slug set aligned with the short-code map', () => {
|
|
88
|
+
expect(Object.keys(UNTP_SPECIFICATION_PAGE_SLUGS).sort()).toEqual(Object.keys(UNTP_SHORT_CREDENTIAL_TYPES).sort());
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=urls.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.test.js","sourceRoot":"","sources":["../../src/artefacts/urls.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,QAAQ,CAAC;AAEhB,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;YACvE,MAAM,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;gBACvE,SAAS,EAAE,0EAA0E;gBACrF,UAAU,EAAE,8DAA8D;aAC3E,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,CAAC,qBAAqB,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;gBAC5E,SAAS,EAAE,0EAA0E;gBACrF,UAAU,EAAE,8DAA8D;aAC3E,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;YACzE,MAAM,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;gBACvE,SAAS,EAAE,gFAAgF;gBAC3F,UAAU,EAAE,qDAAqD;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AAE,GAAG,EAAE;QAC5D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UNTP spec version predicates.
|
|
3
|
+
*
|
|
4
|
+
* The v0.7.0 boundary is significant because v0.7.0 relocated the published
|
|
5
|
+
* artefacts (see `./urls.ts`): schema origin, context unification, and the
|
|
6
|
+
* introduction of the Conformity Vocabulary Catalogue.
|
|
7
|
+
*/
|
|
8
|
+
/** Returns true when the given UNTP version string is v0.7.0 or newer. */
|
|
9
|
+
export declare function isV070OrAbove(version: string): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UNTP spec version predicates.
|
|
3
|
+
*
|
|
4
|
+
* The v0.7.0 boundary is significant because v0.7.0 relocated the published
|
|
5
|
+
* artefacts (see `./urls.ts`): schema origin, context unification, and the
|
|
6
|
+
* introduction of the Conformity Vocabulary Catalogue.
|
|
7
|
+
*/
|
|
8
|
+
/** Returns true when the given UNTP version string is v0.7.0 or newer. */
|
|
9
|
+
export function isV070OrAbove(version) {
|
|
10
|
+
const match = version.match(/^(\d+)\.(\d+)/);
|
|
11
|
+
if (!match)
|
|
12
|
+
return false;
|
|
13
|
+
const major = Number(match[1]);
|
|
14
|
+
const minor = Number(match[2]);
|
|
15
|
+
return major > 0 || (major === 0 && minor >= 7);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/artefacts/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|