kubun 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/LICENSE.md ADDED
@@ -0,0 +1,57 @@
1
+ # The Prosperity Public License 3.0.0
2
+
3
+ Contributor: Paul Le Cam
4
+
5
+ Source Code: https://github.com/PaulLeCam/kubun
6
+
7
+ ## Purpose
8
+
9
+ This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.
10
+
11
+ ## Agreement
12
+
13
+ In order to receive this license, you have to agree to its rules. Those rules are both obligations under that agreement and conditions to your license. Don't do anything with this software that triggers a rule you can't or won't follow.
14
+
15
+ ## Notices
16
+
17
+ Make sure everyone who gets a copy of any part of this software from you, with or without changes, also gets the text of this license and the contributor and source code lines above.
18
+
19
+ ## Commercial Trial
20
+
21
+ Limit your use of this software for commercial purposes to a thirty-day trial period. If you use this software for work, your company gets one trial period for all personnel, not one trial per person.
22
+
23
+ ## Contributions Back
24
+
25
+ Developing feedback, changes, or additions that you contribute back to the contributor on the terms of a standardized public software license such as [the Blue Oak Model License 1.0.0](https://blueoakcouncil.org/license/1.0.0), [the Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html), [the MIT license](https://spdx.org/licenses/MIT.html), or [the two-clause BSD license](https://spdx.org/licenses/BSD-2-Clause.html) doesn't count as use for a commercial purpose.
26
+
27
+ ## Personal Uses
28
+
29
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn't count as use for a commercial purpose.
30
+
31
+ ## Noncommercial Organizations
32
+
33
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution doesn't count as use for a commercial purpose regardless of the source of funding or obligations resulting from the funding.
34
+
35
+ ## Defense
36
+
37
+ Don't make any legal claim against anyone accusing this software, with or without changes, alone or with other technology, of infringing any patent.
38
+
39
+ ## Copyright
40
+
41
+ The contributor licenses you to do everything with this software that would otherwise infringe their copyright in it.
42
+
43
+ ## Patent
44
+
45
+ The contributor licenses you to do everything with this software that would otherwise infringe any patents they can license or become able to license.
46
+
47
+ ## Reliability
48
+
49
+ The contributor can't revoke this license.
50
+
51
+ ## Excuse
52
+
53
+ You're excused for unknowingly breaking [Notices](#notices) if you take all practical steps to comply within thirty days of learning you broke the rule.
54
+
55
+ ## No Liability
56
+
57
+ ***As far as the law allows, this software comes as is, without any warranty or condition, and the contributor won't be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
package/README.md ADDED
@@ -0,0 +1,563 @@
1
+ kubun
2
+ =================
3
+
4
+ Kubun CLI
5
+
6
+
7
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
8
+ [![Version](https://img.shields.io/npm/v/kubun.svg)](https://npmjs.org/package/kubun)
9
+ [![Downloads/week](https://img.shields.io/npm/dw/kubun.svg)](https://npmjs.org/package/kubun)
10
+
11
+
12
+ <!-- toc -->
13
+ * [Usage](#usage)
14
+ * [Commands](#commands)
15
+ <!-- tocstop -->
16
+ # Usage
17
+ <!-- usage -->
18
+ ```sh-session
19
+ $ npm install -g kubun
20
+ $ kubun COMMAND
21
+ running command...
22
+ $ kubun (--version)
23
+ kubun/0.2.0 darwin-arm64 node-v23.7.0
24
+ $ kubun --help [COMMAND]
25
+ USAGE
26
+ $ kubun COMMAND
27
+ ...
28
+ ```
29
+ <!-- usagestop -->
30
+ # Commands
31
+ <!-- commands -->
32
+ * [`kubun account generate`](#kubun-account-generate)
33
+ * [`kubun account id`](#kubun-account-id)
34
+ * [`kubun graph deploy`](#kubun-graph-deploy)
35
+ * [`kubun graph mutate ID TEXT`](#kubun-graph-mutate-id-text)
36
+ * [`kubun graph query ID TEXT`](#kubun-graph-query-id-text)
37
+ * [`kubun graphql schema`](#kubun-graphql-schema)
38
+ * [`kubun hello PERSON`](#kubun-hello-person)
39
+ * [`kubun hello world`](#kubun-hello-world)
40
+ * [`kubun help [COMMAND]`](#kubun-help-command)
41
+ * [`kubun model cluster`](#kubun-model-cluster)
42
+ * [`kubun model create NAME SCHEMA`](#kubun-model-create-name-schema)
43
+ * [`kubun plugins`](#kubun-plugins)
44
+ * [`kubun plugins add PLUGIN`](#kubun-plugins-add-plugin)
45
+ * [`kubun plugins:inspect PLUGIN...`](#kubun-pluginsinspect-plugin)
46
+ * [`kubun plugins install PLUGIN`](#kubun-plugins-install-plugin)
47
+ * [`kubun plugins link PATH`](#kubun-plugins-link-path)
48
+ * [`kubun plugins remove [PLUGIN]`](#kubun-plugins-remove-plugin)
49
+ * [`kubun plugins reset`](#kubun-plugins-reset)
50
+ * [`kubun plugins uninstall [PLUGIN]`](#kubun-plugins-uninstall-plugin)
51
+ * [`kubun plugins unlink [PLUGIN]`](#kubun-plugins-unlink-plugin)
52
+ * [`kubun plugins update`](#kubun-plugins-update)
53
+ * [`kubun serve`](#kubun-serve)
54
+
55
+ ## `kubun account generate`
56
+
57
+ Generate a random private key to use as account signer
58
+
59
+ ```
60
+ USAGE
61
+ $ kubun account generate
62
+
63
+ DESCRIPTION
64
+ Generate a random private key to use as account signer
65
+ ```
66
+
67
+ ## `kubun account id`
68
+
69
+ Display the DID of an account given its private key
70
+
71
+ ```
72
+ USAGE
73
+ $ kubun account id -k <value>
74
+
75
+ FLAGS
76
+ -k, --privateKey=<value> (required) base64-encoded private key
77
+
78
+ DESCRIPTION
79
+ Display the DID of an account given its private key
80
+ ```
81
+
82
+ ## `kubun graph deploy`
83
+
84
+ Deploy a documents model graph
85
+
86
+ ```
87
+ USAGE
88
+ $ kubun graph deploy -c <value>... -k <value> [--id <value>] [-n <value>] [--url <value>]
89
+
90
+ FLAGS
91
+ -c, --cluster=<value>... (required) path of the JSON file of the cluster
92
+ -k, --privateKey=<value> (required) base64-encoded private key
93
+ -n, --name=<value> graph name
94
+ --id=<value> graph ID
95
+ --url=<value> Kubun server URL
96
+
97
+ DESCRIPTION
98
+ Deploy a documents model graph
99
+ ```
100
+
101
+ ## `kubun graph mutate ID TEXT`
102
+
103
+ Execute a GraphQL mutation on a graph
104
+
105
+ ```
106
+ USAGE
107
+ $ kubun graph mutate ID TEXT -k <value> [--url <value>] [--variables <value>]
108
+
109
+ ARGUMENTS
110
+ ID graph ID
111
+ TEXT mutation text
112
+
113
+ FLAGS
114
+ -k, --privateKey=<value> (required) base64-encoded private key
115
+ --url=<value> Kubun server URL
116
+ --variables=<value> query variables as JSON string
117
+
118
+ DESCRIPTION
119
+ Execute a GraphQL mutation on a graph
120
+ ```
121
+
122
+ ## `kubun graph query ID TEXT`
123
+
124
+ Execute a GraphQL query on a graph
125
+
126
+ ```
127
+ USAGE
128
+ $ kubun graph query ID TEXT -k <value> [--url <value>] [--variables <value>]
129
+
130
+ ARGUMENTS
131
+ ID graph ID
132
+ TEXT query text
133
+
134
+ FLAGS
135
+ -k, --privateKey=<value> (required) base64-encoded private key
136
+ --url=<value> Kubun server URL
137
+ --variables=<value> query variables as JSON string
138
+
139
+ DESCRIPTION
140
+ Execute a GraphQL query on a graph
141
+ ```
142
+
143
+ ## `kubun graphql schema`
144
+
145
+ Create a GraphQL schema from clusters of document models
146
+
147
+ ```
148
+ USAGE
149
+ $ kubun graphql schema -c <value>... [-o <value>]
150
+
151
+ FLAGS
152
+ -c, --cluster=<value>... (required) path of the JSON file of the cluster
153
+ -o, --output=<value> output file for the GraphQL schema
154
+
155
+ DESCRIPTION
156
+ Create a GraphQL schema from clusters of document models
157
+ ```
158
+
159
+ ## `kubun hello PERSON`
160
+
161
+ Say hello
162
+
163
+ ```
164
+ USAGE
165
+ $ kubun hello PERSON -f <value>
166
+
167
+ ARGUMENTS
168
+ PERSON Person to say hello to
169
+
170
+ FLAGS
171
+ -f, --from=<value> (required) Who is saying hello
172
+
173
+ DESCRIPTION
174
+ Say hello
175
+
176
+ EXAMPLES
177
+ $ kubun hello friend --from oclif
178
+ hello friend from oclif! (./src/commands/hello/index.ts)
179
+ ```
180
+
181
+ ## `kubun hello world`
182
+
183
+ Say hello world
184
+
185
+ ```
186
+ USAGE
187
+ $ kubun hello world
188
+
189
+ DESCRIPTION
190
+ Say hello world
191
+
192
+ EXAMPLES
193
+ $ kubun hello world
194
+ hello world! (./src/commands/hello/world.ts)
195
+ ```
196
+
197
+ ## `kubun help [COMMAND]`
198
+
199
+ Display help for kubun.
200
+
201
+ ```
202
+ USAGE
203
+ $ kubun help [COMMAND...] [-n]
204
+
205
+ ARGUMENTS
206
+ COMMAND... Command to show help for.
207
+
208
+ FLAGS
209
+ -n, --nested-commands Include all nested commands in the output.
210
+
211
+ DESCRIPTION
212
+ Display help for kubun.
213
+ ```
214
+
215
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.24/src/commands/help.ts)_
216
+
217
+ ## `kubun model cluster`
218
+
219
+ Create a documents cluster model
220
+
221
+ ```
222
+ USAGE
223
+ $ kubun model cluster -m <value>... [-o <value>]
224
+
225
+ FLAGS
226
+ -m, --model=<value>... (required) document model as JSON string
227
+ -o, --output=<value> output file for the cluster
228
+
229
+ DESCRIPTION
230
+ Create a documents cluster model
231
+ ```
232
+
233
+ ## `kubun model create NAME SCHEMA`
234
+
235
+ Create a document model
236
+
237
+ ```
238
+ USAGE
239
+ $ kubun model create NAME SCHEMA [-b default|interface|unique] [-c] [-o <value>] [-u <value>...]
240
+
241
+ ARGUMENTS
242
+ NAME document model name
243
+ SCHEMA document schema as JSON string
244
+
245
+ FLAGS
246
+ -b, --behavior=<option> [default: default] behavior of the document
247
+ <options: default|interface|unique>
248
+ -c, --cluster create a cluster model instead of a document model
249
+ -o, --output=<value> output file
250
+ -u, --uniqueField=<value>... unique field of the document when behavior is set to "unique"
251
+
252
+ DESCRIPTION
253
+ Create a document model
254
+ ```
255
+
256
+ ## `kubun plugins`
257
+
258
+ List installed plugins.
259
+
260
+ ```
261
+ USAGE
262
+ $ kubun plugins [--json] [--core]
263
+
264
+ FLAGS
265
+ --core Show core plugins.
266
+
267
+ GLOBAL FLAGS
268
+ --json Format output as json.
269
+
270
+ DESCRIPTION
271
+ List installed plugins.
272
+
273
+ EXAMPLES
274
+ $ kubun plugins
275
+ ```
276
+
277
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/index.ts)_
278
+
279
+ ## `kubun plugins add PLUGIN`
280
+
281
+ Installs a plugin into kubun.
282
+
283
+ ```
284
+ USAGE
285
+ $ kubun plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
286
+
287
+ ARGUMENTS
288
+ PLUGIN... Plugin to install.
289
+
290
+ FLAGS
291
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
292
+ -h, --help Show CLI help.
293
+ -s, --silent Silences npm output.
294
+ -v, --verbose Show verbose npm output.
295
+
296
+ GLOBAL FLAGS
297
+ --json Format output as json.
298
+
299
+ DESCRIPTION
300
+ Installs a plugin into kubun.
301
+
302
+ Uses npm to install plugins.
303
+
304
+ Installation of a user-installed plugin will override a core plugin.
305
+
306
+ Use the KUBUN_NPM_LOG_LEVEL environment variable to set the npm loglevel.
307
+ Use the KUBUN_NPM_REGISTRY environment variable to set the npm registry.
308
+
309
+ ALIASES
310
+ $ kubun plugins add
311
+
312
+ EXAMPLES
313
+ Install a plugin from npm registry.
314
+
315
+ $ kubun plugins add myplugin
316
+
317
+ Install a plugin from a github url.
318
+
319
+ $ kubun plugins add https://github.com/someuser/someplugin
320
+
321
+ Install a plugin from a github slug.
322
+
323
+ $ kubun plugins add someuser/someplugin
324
+ ```
325
+
326
+ ## `kubun plugins:inspect PLUGIN...`
327
+
328
+ Displays installation properties of a plugin.
329
+
330
+ ```
331
+ USAGE
332
+ $ kubun plugins inspect PLUGIN...
333
+
334
+ ARGUMENTS
335
+ PLUGIN... [default: .] Plugin to inspect.
336
+
337
+ FLAGS
338
+ -h, --help Show CLI help.
339
+ -v, --verbose
340
+
341
+ GLOBAL FLAGS
342
+ --json Format output as json.
343
+
344
+ DESCRIPTION
345
+ Displays installation properties of a plugin.
346
+
347
+ EXAMPLES
348
+ $ kubun plugins inspect myplugin
349
+ ```
350
+
351
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/inspect.ts)_
352
+
353
+ ## `kubun plugins install PLUGIN`
354
+
355
+ Installs a plugin into kubun.
356
+
357
+ ```
358
+ USAGE
359
+ $ kubun plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
360
+
361
+ ARGUMENTS
362
+ PLUGIN... Plugin to install.
363
+
364
+ FLAGS
365
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
366
+ -h, --help Show CLI help.
367
+ -s, --silent Silences npm output.
368
+ -v, --verbose Show verbose npm output.
369
+
370
+ GLOBAL FLAGS
371
+ --json Format output as json.
372
+
373
+ DESCRIPTION
374
+ Installs a plugin into kubun.
375
+
376
+ Uses npm to install plugins.
377
+
378
+ Installation of a user-installed plugin will override a core plugin.
379
+
380
+ Use the KUBUN_NPM_LOG_LEVEL environment variable to set the npm loglevel.
381
+ Use the KUBUN_NPM_REGISTRY environment variable to set the npm registry.
382
+
383
+ ALIASES
384
+ $ kubun plugins add
385
+
386
+ EXAMPLES
387
+ Install a plugin from npm registry.
388
+
389
+ $ kubun plugins install myplugin
390
+
391
+ Install a plugin from a github url.
392
+
393
+ $ kubun plugins install https://github.com/someuser/someplugin
394
+
395
+ Install a plugin from a github slug.
396
+
397
+ $ kubun plugins install someuser/someplugin
398
+ ```
399
+
400
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/install.ts)_
401
+
402
+ ## `kubun plugins link PATH`
403
+
404
+ Links a plugin into the CLI for development.
405
+
406
+ ```
407
+ USAGE
408
+ $ kubun plugins link PATH [-h] [--install] [-v]
409
+
410
+ ARGUMENTS
411
+ PATH [default: .] path to plugin
412
+
413
+ FLAGS
414
+ -h, --help Show CLI help.
415
+ -v, --verbose
416
+ --[no-]install Install dependencies after linking the plugin.
417
+
418
+ DESCRIPTION
419
+ Links a plugin into the CLI for development.
420
+
421
+ Installation of a linked plugin will override a user-installed or core plugin.
422
+
423
+ e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
424
+ command will override the user-installed or core plugin implementation. This is useful for development work.
425
+
426
+
427
+ EXAMPLES
428
+ $ kubun plugins link myplugin
429
+ ```
430
+
431
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/link.ts)_
432
+
433
+ ## `kubun plugins remove [PLUGIN]`
434
+
435
+ Removes a plugin from the CLI.
436
+
437
+ ```
438
+ USAGE
439
+ $ kubun plugins remove [PLUGIN...] [-h] [-v]
440
+
441
+ ARGUMENTS
442
+ PLUGIN... plugin to uninstall
443
+
444
+ FLAGS
445
+ -h, --help Show CLI help.
446
+ -v, --verbose
447
+
448
+ DESCRIPTION
449
+ Removes a plugin from the CLI.
450
+
451
+ ALIASES
452
+ $ kubun plugins unlink
453
+ $ kubun plugins remove
454
+
455
+ EXAMPLES
456
+ $ kubun plugins remove myplugin
457
+ ```
458
+
459
+ ## `kubun plugins reset`
460
+
461
+ Remove all user-installed and linked plugins.
462
+
463
+ ```
464
+ USAGE
465
+ $ kubun plugins reset [--hard] [--reinstall]
466
+
467
+ FLAGS
468
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
469
+ --reinstall Reinstall all plugins after uninstalling.
470
+ ```
471
+
472
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/reset.ts)_
473
+
474
+ ## `kubun plugins uninstall [PLUGIN]`
475
+
476
+ Removes a plugin from the CLI.
477
+
478
+ ```
479
+ USAGE
480
+ $ kubun plugins uninstall [PLUGIN...] [-h] [-v]
481
+
482
+ ARGUMENTS
483
+ PLUGIN... plugin to uninstall
484
+
485
+ FLAGS
486
+ -h, --help Show CLI help.
487
+ -v, --verbose
488
+
489
+ DESCRIPTION
490
+ Removes a plugin from the CLI.
491
+
492
+ ALIASES
493
+ $ kubun plugins unlink
494
+ $ kubun plugins remove
495
+
496
+ EXAMPLES
497
+ $ kubun plugins uninstall myplugin
498
+ ```
499
+
500
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/uninstall.ts)_
501
+
502
+ ## `kubun plugins unlink [PLUGIN]`
503
+
504
+ Removes a plugin from the CLI.
505
+
506
+ ```
507
+ USAGE
508
+ $ kubun plugins unlink [PLUGIN...] [-h] [-v]
509
+
510
+ ARGUMENTS
511
+ PLUGIN... plugin to uninstall
512
+
513
+ FLAGS
514
+ -h, --help Show CLI help.
515
+ -v, --verbose
516
+
517
+ DESCRIPTION
518
+ Removes a plugin from the CLI.
519
+
520
+ ALIASES
521
+ $ kubun plugins unlink
522
+ $ kubun plugins remove
523
+
524
+ EXAMPLES
525
+ $ kubun plugins unlink myplugin
526
+ ```
527
+
528
+ ## `kubun plugins update`
529
+
530
+ Update installed plugins.
531
+
532
+ ```
533
+ USAGE
534
+ $ kubun plugins update [-h] [-v]
535
+
536
+ FLAGS
537
+ -h, --help Show CLI help.
538
+ -v, --verbose
539
+
540
+ DESCRIPTION
541
+ Update installed plugins.
542
+ ```
543
+
544
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/update.ts)_
545
+
546
+ ## `kubun serve`
547
+
548
+ Start a local Kubun server
549
+
550
+ ```
551
+ USAGE
552
+ $ kubun serve [--db <value>] [-p <value>] [-k <value> | --id <value>]
553
+
554
+ FLAGS
555
+ -k, --privateKey=<value> base64-encoded private key
556
+ -p, --port=<value> port to listen on
557
+ --db=<value> path to the local SQLite database
558
+ --id=<value> server ID
559
+
560
+ DESCRIPTION
561
+ Start a local Kubun server
562
+ ```
563
+ <!-- commandsstop -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ // eslint-disable-next-line n/shebang
4
+ import { execute } from '@oclif/core'
5
+
6
+ await execute({ development: true, dir: import.meta.url })
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from '@oclif/core'
4
+
5
+ await execute({ dir: import.meta.url })
@@ -0,0 +1,5 @@
1
+ import { fromB64 } from '@enkaku/codec';
2
+ import { getTokenSigner as signerFromKey } from '@enkaku/token';
3
+ export function getSigner(key) {
4
+ return signerFromKey(fromB64(key));
5
+ }
package/dist/client.js ADDED
@@ -0,0 +1,5 @@
1
+ import { HTTPClient } from '@kubun/http-client';
2
+ import { getSigner } from './account.js';
3
+ export function createClient(signerKey, url = 'http://localhost:4321') {
4
+ return new HTTPClient({ signer: getSigner(signerKey), url });
5
+ }
@@ -0,0 +1,10 @@
1
+ import { toB64 } from '@enkaku/codec';
2
+ import { randomPrivateKey } from '@enkaku/token';
3
+ import { Command } from '@oclif/core';
4
+ export default class GenerateAccount extends Command {
5
+ static description = 'Generate a random private key to use as account signer';
6
+ async run() {
7
+ const key = await randomPrivateKey();
8
+ this.log(toB64(key));
9
+ }
10
+ }
@@ -0,0 +1,18 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { getSigner } from '../../account.js';
3
+ export default class AccountID extends Command {
4
+ static description = 'Display the DID of an account given its private key';
5
+ static flags = {
6
+ privateKey: Flags.string({
7
+ description: 'base64-encoded private key',
8
+ char: 'k',
9
+ env: 'KUBUN_PRIVATE_KEY',
10
+ required: true,
11
+ }),
12
+ };
13
+ async run() {
14
+ const { flags } = await this.parse(AccountID);
15
+ const signer = getSigner(flags.privateKey);
16
+ this.log(signer.id);
17
+ }
18
+ }