@tpluscode/rdf-ns-builders 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ff6f87c: Add a way to extend namespace factory
8
+
3
9
  ## 4.2.0
4
10
 
5
11
  ### Minor Changes
package/Factory.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as StrictBuilders from './index.js';
2
+ import type { CustomNamespaces } from './index.js';
2
3
  export interface NsBuildersFactory {
3
- ns: typeof StrictBuilders;
4
+ ns: typeof StrictBuilders & CustomNamespaces;
4
5
  }
5
6
  export declare class NsBuildersFactory {
6
7
  init(): void;
package/Factory.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Factory.d.ts","sourceRoot":"","sources":["Factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,cAAc,CAAA;CAC1B;AAED,qBAAa,iBAAiB;IAC5B,IAAI;CAGL"}
1
+ {"version":3,"file":"Factory.d.ts","sourceRoot":"","sources":["Factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,cAAc,GAAG,gBAAgB,CAAA;CAC7C;AAED,qBAAa,iBAAiB;IAC5B,IAAI;CAGL"}
package/README.md CHANGED
@@ -74,3 +74,41 @@ This will create a directory `source`, containing typescript modules for all voc
74
74
 
75
75
  [rdfv]: https://github.com/zazuko/rdf-vocabularies
76
76
  [ns]: http://npm.im/@rdfjs/namespace
77
+
78
+ ## Adding your own vocabularies
79
+
80
+ To extend the interface of `env.ns` you need to add you own factory which will add additional
81
+ namespace builders to the environment. TypeScript users will also need to extend the `CustomPrefixes`
82
+ interface.
83
+
84
+ ```ts
85
+ // ./ns.ts
86
+ import { NamespaceBuilder } from '@rdfjs/namespace'
87
+
88
+ type ExampleTerms = 'foo' | 'bar
89
+
90
+ declare module '@tpluscode/rdf-ns-builders' {
91
+ interface CustomNamespaces {
92
+ ex: NamespaceBuilder<ExampleTerms>
93
+ }
94
+ }
95
+
96
+ export class ExampleNsFactory {
97
+ init(this: Environment<NsBuildersFactory | NamespaceFactory>) {
98
+ this.ns = {
99
+ ...this.ns,
100
+ ex: this.namespace<ExampleTerms>('https://example.com/'),
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ Then, use it to create an extended environment.
107
+
108
+ ```ts
109
+ // ./env.ts
110
+ import { create } from '@zazuko/env'
111
+ import { ExampleNsFactory } from './ns.js'
112
+
113
+ export default create(TalosNsFactory)
114
+ ```
package/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { NsBuildersFactory } from './Factory.js';
2
+ export interface CustomNamespaces {
3
+ }
2
4
  export default NsBuildersFactory;
3
5
  export * from './strict.js';
4
6
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,eAAe,iBAAiB,CAAA;AAChC,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,MAAM,WAAW,gBAAgB;CAAG;AAEpC,eAAe,iBAAiB,CAAA;AAChC,cAAc,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpluscode/rdf-ns-builders",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Generated RDF/JS namespace builders for common vocabularies",
5
5
  "type": "module",
6
6
  "main": "index.js",