@asturiu/v0-sdk 0.0.0-stage → 1.0.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.
Files changed (239) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +82 -2
  5. package/contract/assertion-vectors.json +90 -0
  6. package/contract/schemas/branding.schema.json +46 -0
  7. package/contract/schemas/definitions.schema.json +376 -0
  8. package/contract/schemas/portal.schema.json +56 -0
  9. package/contract/tenant-api-routes.json +165 -0
  10. package/dist/branding.d.ts +131 -0
  11. package/dist/branding.d.ts.map +1 -0
  12. package/dist/branding.js +206 -0
  13. package/dist/branding.js.map +1 -0
  14. package/dist/changesets.d.ts +58 -0
  15. package/dist/changesets.d.ts.map +1 -0
  16. package/dist/changesets.js +18 -0
  17. package/dist/changesets.js.map +1 -0
  18. package/dist/cli/bin.d.ts +3 -0
  19. package/dist/cli/bin.d.ts.map +1 -0
  20. package/dist/cli/bin.js +12 -0
  21. package/dist/cli/bin.js.map +1 -0
  22. package/dist/cli/changesets.d.ts +14 -0
  23. package/dist/cli/changesets.d.ts.map +1 -0
  24. package/dist/cli/changesets.js +252 -0
  25. package/dist/cli/changesets.js.map +1 -0
  26. package/dist/cli/cli.d.ts +37 -0
  27. package/dist/cli/cli.d.ts.map +1 -0
  28. package/dist/cli/cli.js +415 -0
  29. package/dist/cli/cli.js.map +1 -0
  30. package/dist/cli/context.d.ts +147 -0
  31. package/dist/cli/context.d.ts.map +1 -0
  32. package/dist/cli/context.js +258 -0
  33. package/dist/cli/context.js.map +1 -0
  34. package/dist/cli/engine.d.ts +59 -0
  35. package/dist/cli/engine.d.ts.map +1 -0
  36. package/dist/cli/engine.js +85 -0
  37. package/dist/cli/engine.js.map +1 -0
  38. package/dist/cli/feedback.d.ts +40 -0
  39. package/dist/cli/feedback.d.ts.map +1 -0
  40. package/dist/cli/feedback.js +420 -0
  41. package/dist/cli/feedback.js.map +1 -0
  42. package/dist/cli/files.d.ts +83 -0
  43. package/dist/cli/files.d.ts.map +1 -0
  44. package/dist/cli/files.js +389 -0
  45. package/dist/cli/files.js.map +1 -0
  46. package/dist/cli/index.d.ts +8 -0
  47. package/dist/cli/index.d.ts.map +1 -0
  48. package/dist/cli/index.js +8 -0
  49. package/dist/cli/index.js.map +1 -0
  50. package/dist/cli/overview.d.ts +6 -0
  51. package/dist/cli/overview.d.ts.map +1 -0
  52. package/dist/cli/overview.js +379 -0
  53. package/dist/cli/overview.js.map +1 -0
  54. package/dist/cli/parts.d.ts +5 -0
  55. package/dist/cli/parts.d.ts.map +1 -0
  56. package/dist/cli/parts.js +414 -0
  57. package/dist/cli/parts.js.map +1 -0
  58. package/dist/cli/sources.d.ts +37 -0
  59. package/dist/cli/sources.d.ts.map +1 -0
  60. package/dist/cli/sources.js +91 -0
  61. package/dist/cli/sources.js.map +1 -0
  62. package/dist/cli/terminal.d.ts +135 -0
  63. package/dist/cli/terminal.d.ts.map +1 -0
  64. package/dist/cli/terminal.js +353 -0
  65. package/dist/cli/terminal.js.map +1 -0
  66. package/dist/cli/ui-page.d.ts +8 -0
  67. package/dist/cli/ui-page.d.ts.map +1 -0
  68. package/dist/cli/ui-page.js +216 -0
  69. package/dist/cli/ui-page.js.map +1 -0
  70. package/dist/cli/ui.d.ts +54 -0
  71. package/dist/cli/ui.d.ts.map +1 -0
  72. package/dist/cli/ui.js +251 -0
  73. package/dist/cli/ui.js.map +1 -0
  74. package/dist/client.d.ts +88 -0
  75. package/dist/client.d.ts.map +1 -0
  76. package/dist/client.js +165 -0
  77. package/dist/client.js.map +1 -0
  78. package/dist/contacts.d.ts +43 -0
  79. package/dist/contacts.d.ts.map +1 -0
  80. package/dist/contacts.js +46 -0
  81. package/dist/contacts.js.map +1 -0
  82. package/dist/definition-set.d.ts +731 -0
  83. package/dist/definition-set.d.ts.map +1 -0
  84. package/dist/definition-set.js +659 -0
  85. package/dist/definition-set.js.map +1 -0
  86. package/dist/definitions.d.ts +42 -0
  87. package/dist/definitions.d.ts.map +1 -0
  88. package/dist/definitions.js +154 -0
  89. package/dist/definitions.js.map +1 -0
  90. package/dist/enrolment.d.ts +9 -0
  91. package/dist/enrolment.d.ts.map +1 -0
  92. package/dist/enrolment.js +8 -0
  93. package/dist/enrolment.js.map +1 -0
  94. package/dist/fill.d.ts +73 -0
  95. package/dist/fill.d.ts.map +1 -0
  96. package/dist/fill.js +46 -0
  97. package/dist/fill.js.map +1 -0
  98. package/dist/index.d.ts +39 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +39 -0
  101. package/dist/index.js.map +1 -0
  102. package/dist/notifications.d.ts +33 -0
  103. package/dist/notifications.d.ts.map +1 -0
  104. package/dist/notifications.js +36 -0
  105. package/dist/notifications.js.map +1 -0
  106. package/dist/oidc.d.ts +122 -0
  107. package/dist/oidc.d.ts.map +1 -0
  108. package/dist/oidc.js +150 -0
  109. package/dist/oidc.js.map +1 -0
  110. package/dist/overlay.d.ts +109 -0
  111. package/dist/overlay.d.ts.map +1 -0
  112. package/dist/overlay.js +58 -0
  113. package/dist/overlay.js.map +1 -0
  114. package/dist/passes.d.ts +95 -0
  115. package/dist/passes.d.ts.map +1 -0
  116. package/dist/passes.js +140 -0
  117. package/dist/passes.js.map +1 -0
  118. package/dist/portal-options.d.ts +65 -0
  119. package/dist/portal-options.d.ts.map +1 -0
  120. package/dist/portal-options.js +120 -0
  121. package/dist/portal-options.js.map +1 -0
  122. package/dist/reads.d.ts +41 -0
  123. package/dist/reads.d.ts.map +1 -0
  124. package/dist/reads.js +44 -0
  125. package/dist/reads.js.map +1 -0
  126. package/dist/recovery-words.d.ts +8 -0
  127. package/dist/recovery-words.d.ts.map +1 -0
  128. package/dist/recovery-words.js +136 -0
  129. package/dist/recovery-words.js.map +1 -0
  130. package/dist/recovery.d.ts +198 -0
  131. package/dist/recovery.d.ts.map +1 -0
  132. package/dist/recovery.js +112 -0
  133. package/dist/recovery.js.map +1 -0
  134. package/dist/reveal.d.ts +35 -0
  135. package/dist/reveal.d.ts.map +1 -0
  136. package/dist/reveal.js +66 -0
  137. package/dist/reveal.js.map +1 -0
  138. package/dist/seal.d.ts +15 -0
  139. package/dist/seal.d.ts.map +1 -0
  140. package/dist/seal.js +0 -0
  141. package/dist/seal.js.map +1 -0
  142. package/dist/session.d.ts +66 -0
  143. package/dist/session.d.ts.map +1 -0
  144. package/dist/session.js +61 -0
  145. package/dist/session.js.map +1 -0
  146. package/dist/signing-in-mark.d.ts +14 -0
  147. package/dist/signing-in-mark.d.ts.map +1 -0
  148. package/dist/signing-in-mark.js +24 -0
  149. package/dist/signing-in-mark.js.map +1 -0
  150. package/dist/signing-in.d.ts +22 -0
  151. package/dist/signing-in.d.ts.map +1 -0
  152. package/dist/signing-in.js +203 -0
  153. package/dist/signing-in.js.map +1 -0
  154. package/dist/tags.d.ts +96 -0
  155. package/dist/tags.d.ts.map +1 -0
  156. package/dist/tags.js +88 -0
  157. package/dist/tags.js.map +1 -0
  158. package/dist/tenant-subscription.d.ts +47 -0
  159. package/dist/tenant-subscription.d.ts.map +1 -0
  160. package/dist/tenant-subscription.js +7 -0
  161. package/dist/tenant-subscription.js.map +1 -0
  162. package/dist/testing/index.d.ts +125 -0
  163. package/dist/testing/index.d.ts.map +1 -0
  164. package/dist/testing/index.js +320 -0
  165. package/dist/testing/index.js.map +1 -0
  166. package/dist/theme.d.ts +237 -0
  167. package/dist/theme.d.ts.map +1 -0
  168. package/dist/theme.js +504 -0
  169. package/dist/theme.js.map +1 -0
  170. package/dist/tickets.d.ts +152 -0
  171. package/dist/tickets.d.ts.map +1 -0
  172. package/dist/tickets.js +65 -0
  173. package/dist/tickets.js.map +1 -0
  174. package/dist/tiers.d.ts +168 -0
  175. package/dist/tiers.d.ts.map +1 -0
  176. package/dist/tiers.js +341 -0
  177. package/dist/tiers.js.map +1 -0
  178. package/dist/types.d.ts +885 -0
  179. package/dist/types.d.ts.map +1 -0
  180. package/dist/types.js +12 -0
  181. package/dist/types.js.map +1 -0
  182. package/dist/urlid.d.ts +50 -0
  183. package/dist/urlid.d.ts.map +1 -0
  184. package/dist/urlid.js +78 -0
  185. package/dist/urlid.js.map +1 -0
  186. package/dist/version.d.ts +15 -0
  187. package/dist/version.d.ts.map +1 -0
  188. package/dist/version.js +15 -0
  189. package/dist/version.js.map +1 -0
  190. package/make/asturiu.mk +43 -0
  191. package/package.json +63 -4
  192. package/src/branding.ts +221 -0
  193. package/src/changesets.ts +61 -0
  194. package/src/cli/bin.ts +12 -0
  195. package/src/cli/changesets.ts +233 -0
  196. package/src/cli/cli.ts +425 -0
  197. package/src/cli/context.ts +299 -0
  198. package/src/cli/engine.ts +112 -0
  199. package/src/cli/feedback.ts +406 -0
  200. package/src/cli/files.ts +371 -0
  201. package/src/cli/index.ts +7 -0
  202. package/src/cli/overview.ts +343 -0
  203. package/src/cli/parts.ts +371 -0
  204. package/src/cli/sources.ts +111 -0
  205. package/src/cli/terminal.ts +384 -0
  206. package/src/cli/ui-page.ts +215 -0
  207. package/src/cli/ui.ts +266 -0
  208. package/src/client.ts +202 -0
  209. package/src/contacts.ts +61 -0
  210. package/src/definition-set.ts +965 -0
  211. package/src/definitions.ts +156 -0
  212. package/src/enrolment.ts +10 -0
  213. package/src/fill.ts +83 -0
  214. package/src/index.ts +38 -0
  215. package/src/notifications.ts +55 -0
  216. package/src/oidc.ts +199 -0
  217. package/src/overlay.ts +137 -0
  218. package/src/passes.ts +168 -0
  219. package/src/portal-options.ts +125 -0
  220. package/src/reads.ts +71 -0
  221. package/src/recovery-words.ts +137 -0
  222. package/src/recovery.ts +269 -0
  223. package/src/reveal.ts +72 -0
  224. package/src/seal.ts +0 -0
  225. package/src/session.ts +93 -0
  226. package/src/signing-in-mark.ts +23 -0
  227. package/src/signing-in.ts +213 -0
  228. package/src/tags.ts +146 -0
  229. package/src/tenant-subscription.ts +44 -0
  230. package/src/testing/index.ts +337 -0
  231. package/src/theme.ts +628 -0
  232. package/src/tickets.ts +195 -0
  233. package/src/tiers.ts +397 -0
  234. package/src/types.ts +847 -0
  235. package/src/urlid.ts +77 -0
  236. package/src/version.ts +15 -0
  237. package/templates/asturiu/branding.json +4 -0
  238. package/templates/asturiu/definitions.json +23 -0
  239. package/templates/asturiu/portal.json +16 -0
package/src/urlid.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The ARID type tokens (ADR-008). The Engine's `arid` module keeps the same
3
+ * list; a test there fails when they differ.
4
+ */
5
+ export const ARID_TYPE_TOKENS = ["tnt", "usr", "cst", "vlt", "prn", "grp", "pfl", "wlt", "ent", "fld", "att", "wdf", "edf", "fdf", "grt", "trg", "evt", "ntf", "rcv", "trf", "cnt", "msg", "ovl", "pss", "tkt", "sbs"] as const;
6
+ /** The type token a route fixes (ADR-008). */
7
+ export type ResourceType = (typeof ARID_TYPE_TOKENS)[number];
8
+
9
+ /**
10
+ * The URL spelling of an ARID (components/02 §Resource URLs).
11
+ *
12
+ * A browser URL names a resource by its `ResourceID` alone when the Issuer is
13
+ * `global`, and by `<issuer>~<ResourceID>` otherwise:
14
+ *
15
+ * /wallets/01M25QTXZNCXBE3DCYZQWAMB72 ARID:0:global:wlt:01M25Q…
16
+ * /wallets/device-a~01M25QTXZNCXBE3DCYZQWAMB72 ARID:0:device-a:wlt:01M25Q…
17
+ *
18
+ * This is a *rendering* of the ARID, never an identifier of its own: the route
19
+ * fixes the type, the form fixes the ARID version, and the page rebuilds the
20
+ * full ARID before anything else sees it. Four rules keep that safe:
21
+ *
22
+ * 1. One route family per resource type. A route that could show two types
23
+ * cannot rebuild the ARID.
24
+ * 2. URL forms are added, never retired. A later ARID version gets its own
25
+ * form; every form ever linked keeps resolving.
26
+ * 3. Only a browser URL ever carries this form. Nothing stores, logs, HMACs or
27
+ * emits it — those carry the ARID. No Engine component imports this file,
28
+ * with one exception (ADR-048): a link to a frontend page that the Engine
29
+ * sends to a person — today only the Operations API's approval link of a
30
+ * waiting Definition plan. A new case needs an ADR.
31
+ * 4. A route that moves keeps a redirect from the old path.
32
+ *
33
+ * `~` is an RFC 3986 unreserved character that neither the Issuer grammar
34
+ * (`[a-z0-9-]`) nor a ULID (uppercase Crockford base32) contains, so the form
35
+ * needs no percent-encoding and parses without lookahead. The grammar is
36
+ * repeated here rather than imported: the Frontend kit must stay free of
37
+ * `node:` imports (ADR-013), and `../arid.js` pulls in `node:crypto`.
38
+ */
39
+
40
+ /** The Issuer a bare `ResourceID` stands for. Fixed, not per deployment: a link must mean the same thing everywhere. */
41
+ export const URL_DEFAULT_ISSUER = "global";
42
+ const URL_ISSUER_SEPARATOR = "~";
43
+ const ARID_VERSION = "0";
44
+ const ISSUER_REGEX = /^[a-z0-9][a-z0-9-]{0,62}$/;
45
+ const ULID_REGEX = /^[0-9A-HJKMNP-TV-Z]{26}$/;
46
+ const TYPE_REGEX = /^[a-z]{3}$/;
47
+
48
+ /** The URL segment for an ARID. Throws on a malformed ARID: only a value the Engine issued belongs in a link. */
49
+ export function aridToUrlId(arid: string): string {
50
+ const parts = arid.split(":");
51
+ if (parts.length !== 5 || parts[0] !== "ARID" || parts[1] !== ARID_VERSION) throw new Error("malformed ARID");
52
+ const [, , issuer, , id] = parts;
53
+ if (!ISSUER_REGEX.test(issuer) || !ULID_REGEX.test(id)) throw new Error("malformed ARID");
54
+ return issuer === URL_DEFAULT_ISSUER ? id : `${issuer}${URL_ISSUER_SEPARATOR}${id}`;
55
+ }
56
+
57
+ /**
58
+ * The ARID a route segment names, for the type the route fixes. Accepts the
59
+ * canonical form, a lower-cased `ResourceID` (Crockford base32 is
60
+ * case-insensitive) and a full ARID of the same type; `null` for anything
61
+ * else. Compare the segment with `aridToUrlId(result)` to decide whether to
62
+ * redirect to the canonical spelling.
63
+ */
64
+ export function aridFromUrlId(type: ResourceType, segment: string): string | null {
65
+ if (!TYPE_REGEX.test(type)) return null;
66
+ if (segment.startsWith("ARID:")) {
67
+ const parts = segment.split(":");
68
+ if (parts.length !== 5 || parts[1] !== ARID_VERSION || parts[3] !== type) return null;
69
+ if (!ISSUER_REGEX.test(parts[2]) || !ULID_REGEX.test(parts[4])) return null;
70
+ return segment;
71
+ }
72
+ const at = segment.indexOf(URL_ISSUER_SEPARATOR);
73
+ const issuer = at < 0 ? URL_DEFAULT_ISSUER : segment.slice(0, at);
74
+ const id = (at < 0 ? segment : segment.slice(at + 1)).toUpperCase();
75
+ if (!ISSUER_REGEX.test(issuer) || !ULID_REGEX.test(id)) return null;
76
+ return `ARID:${ARID_VERSION}:${issuer}:${type}:${id}`;
77
+ }
package/src/version.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The SDK's own version (ADR-074 §4): a semantic version of its own, separate
3
+ * from the Engine's. A test checks it against `package.json`. The Asturiu
4
+ * generation is in the name, never in the number.
5
+ */
6
+ export const SDK_NAME = "@asturiu/v0-sdk";
7
+ export const SDK_VERSION = "1.0.0";
8
+
9
+ /**
10
+ * What every Tenant API call sends as its `User-Agent`. The Tenant API
11
+ * forwards the version as `X-Asturiu-Sdk-Version`, and the Engine records it
12
+ * on the key as `last_sdk_version`: how an administrator sees what a
13
+ * Tenant's server runs.
14
+ */
15
+ export const SDK_USER_AGENT = `asturiu-v0-sdk/${SDK_VERSION}`;
@@ -0,0 +1,4 @@
1
+ {
2
+ "$comment": "The look of your Customer Portal (ADR-033, ADR-038). Sent whole: a key left out is cleared. An image may be named file:<path>, relative to this file. Take the stored state in first with `asturiu-v0-tenant pull`.",
3
+ "theme": { "preset": "porcelain" }
4
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$comment": "The Definition set: what your Customers keep, as Wallet types with the Entry types they own, and Entry types with their fields (ADR-029, ADR-031). Keys are permanent; labels are what people see. Make it your own, then check it with `asturiu-v0-tenant definitions`.",
3
+ "shared_fields": {
4
+ "title": { "label": "Title", "value_type": "text", "searchable": true },
5
+ "notes": { "label": "Notes", "value_type": "text" }
6
+ },
7
+ "wallets": {
8
+ "documents": {
9
+ "label": "Documents",
10
+ "entries": {
11
+ "document": {
12
+ "label": "Document",
13
+ "fields": {
14
+ "title": { "use": "title", "required": true, "order": 0 },
15
+ "issued_on": { "label": "Issued on", "value_type": "date", "order": 1 },
16
+ "file": { "label": "File", "value_type": "attachment", "order": 2 },
17
+ "notes": { "use": "notes", "order": 3 }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$comment": "What your Customer Portal shows (ADR-037, ADR-039). A switch left out is on; a page left out is back to its default. Redirects stay with an administrator.",
3
+ "account_link": true,
4
+ "open_app": true,
5
+ "back_link": true,
6
+ "language_menu": true,
7
+ "appearance": true,
8
+ "pages": {
9
+ "profile": { "mode": "portal" },
10
+ "security": { "mode": "portal" },
11
+ "plan": { "mode": "portal" },
12
+ "privacy": { "mode": "portal" },
13
+ "recovery": { "mode": "portal" },
14
+ "support": { "mode": "portal" }
15
+ }
16
+ }