@zhama/tego-plugin-sdk 0.0.0-stage → 1.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +172 -0
  2. package/README.md +846 -2
  3. package/access-catalog.schema.json +304 -0
  4. package/access-fixtures/resolve.json +1359 -0
  5. package/bin/tego-plugin-pack.mjs +2 -0
  6. package/bin/tego-plugin.mjs +3 -0
  7. package/dist/access-drizzle.cjs +1 -0
  8. package/dist/access-drizzle.d.cts +726 -0
  9. package/dist/access-drizzle.d.ts +726 -0
  10. package/dist/access-drizzle.js +1 -0
  11. package/dist/access-hono.cjs +3 -0
  12. package/dist/access-hono.d.cts +108 -0
  13. package/dist/access-hono.d.ts +108 -0
  14. package/dist/access-hono.js +3 -0
  15. package/dist/access-implications.cjs +1 -0
  16. package/dist/access-implications.d.cts +25 -0
  17. package/dist/access-implications.d.ts +25 -0
  18. package/dist/access-implications.js +1 -0
  19. package/dist/access.cjs +26 -0
  20. package/dist/access.d.cts +884 -0
  21. package/dist/access.d.ts +884 -0
  22. package/dist/access.js +26 -0
  23. package/dist/catalog-CSSbrfEf.d.cts +361 -0
  24. package/dist/catalog-CSSbrfEf.d.ts +361 -0
  25. package/dist/chunk-3KUOBGJN.js +19 -0
  26. package/dist/chunk-3WA3M347.cjs +1 -0
  27. package/dist/chunk-5CU33JVY.js +1 -0
  28. package/dist/chunk-7K37PVGV.js +5 -0
  29. package/dist/chunk-7XHF3YSK.js +1 -0
  30. package/dist/chunk-AJY7ZHXK.cjs +3 -0
  31. package/dist/chunk-BN6TGHSB.cjs +1 -0
  32. package/dist/chunk-BTHXQWHT.js +1 -0
  33. package/dist/chunk-C2OCOPZQ.cjs +1 -0
  34. package/dist/chunk-IMAVYQ4U.cjs +4 -0
  35. package/dist/chunk-OP64Y4IN.cjs +1 -0
  36. package/dist/chunk-QKSPPMVN.js +1 -0
  37. package/dist/chunk-ROFUQLOZ.cjs +1 -0
  38. package/dist/chunk-SNUCO2MK.js +1 -0
  39. package/dist/chunk-THMWRUAT.cjs +19 -0
  40. package/dist/chunk-VMCGDDGP.js +3 -0
  41. package/dist/chunk-W7C357A6.cjs +5 -0
  42. package/dist/chunk-WLTASJF6.js +4 -0
  43. package/dist/egress.cjs +7 -0
  44. package/dist/egress.d.cts +9 -0
  45. package/dist/egress.d.ts +9 -0
  46. package/dist/egress.js +7 -0
  47. package/dist/frontend.cjs +2 -0
  48. package/dist/frontend.d.cts +353 -0
  49. package/dist/frontend.d.ts +353 -0
  50. package/dist/frontend.js +2 -0
  51. package/dist/gateway-signature.cjs +1 -0
  52. package/dist/gateway-signature.d.cts +112 -0
  53. package/dist/gateway-signature.d.ts +112 -0
  54. package/dist/gateway-signature.js +1 -0
  55. package/dist/index.cjs +1 -0
  56. package/dist/index.d.cts +528 -0
  57. package/dist/index.d.ts +528 -0
  58. package/dist/index.js +1 -0
  59. package/dist/manifest-types-DQARCQJt.d.cts +627 -0
  60. package/dist/manifest-types-DQARCQJt.d.ts +627 -0
  61. package/dist/manifest.cjs +1 -0
  62. package/dist/manifest.d.cts +2824 -0
  63. package/dist/manifest.d.ts +2824 -0
  64. package/dist/manifest.js +1 -0
  65. package/dist/mcp-identity.cjs +2 -0
  66. package/dist/mcp-identity.d.cts +106 -0
  67. package/dist/mcp-identity.d.ts +106 -0
  68. package/dist/mcp-identity.js +2 -0
  69. package/dist/pack.cjs +1 -0
  70. package/dist/pack.d.cts +169 -0
  71. package/dist/pack.d.ts +169 -0
  72. package/dist/pack.js +1 -0
  73. package/dist/publish.cjs +1 -0
  74. package/dist/publish.d.cts +96 -0
  75. package/dist/publish.d.ts +96 -0
  76. package/dist/publish.js +1 -0
  77. package/dist/scaffold.cjs +523 -0
  78. package/dist/scaffold.d.cts +182 -0
  79. package/dist/scaffold.d.ts +182 -0
  80. package/dist/scaffold.js +523 -0
  81. package/dist/server-runtime.cjs +1 -0
  82. package/dist/server-runtime.d.cts +63 -0
  83. package/dist/server-runtime.d.ts +63 -0
  84. package/dist/server-runtime.js +1 -0
  85. package/dist/server.cjs +1 -0
  86. package/dist/server.d.cts +1808 -0
  87. package/dist/server.d.ts +1808 -0
  88. package/dist/server.js +1 -0
  89. package/dist/testing.cjs +2 -0
  90. package/dist/testing.d.cts +92 -0
  91. package/dist/testing.d.ts +92 -0
  92. package/dist/testing.js +2 -0
  93. package/dist/vite.cjs +1 -0
  94. package/dist/vite.d.cts +133 -0
  95. package/dist/vite.d.ts +133 -0
  96. package/dist/vite.js +1 -0
  97. package/package.json +160 -4
  98. package/sql/access.sql +73 -0
@@ -0,0 +1,96 @@
1
+ import { PackedPlugin } from './pack.cjs';
2
+ import './manifest-types-DQARCQJt.cjs';
3
+
4
+ interface PublishPluginOptions {
5
+ /** Package root: the directory holding `tego.plugin.json`. */
6
+ root: string;
7
+ /** Server origin, e.g. `http://localhost:3100`. Trailing slashes are trimmed. */
8
+ server: string;
9
+ /** Admin bearer token. The publish endpoints all sit behind `adminMiddleware`. */
10
+ token: string;
11
+ /**
12
+ * Avatars to install onto, for an avatar-scoped plugin. An empty array
13
+ * installs it for nobody, which is the server's own contract, not a no-op —
14
+ * it still creates the tenant install. Ignored for a tenant-scoped plugin.
15
+ */
16
+ avatarIds?: string[];
17
+ /** Catalog metadata to stamp on the release. */
18
+ meta?: {
19
+ category?: string;
20
+ homepage?: string;
21
+ icon?: string;
22
+ };
23
+ /** Approve the release after finalizing it. Defaults to true. */
24
+ approve?: boolean;
25
+ /** Install onto the tenant after approving. Defaults to true. */
26
+ install?: boolean;
27
+ /** Where to report progress. Defaults to `console.log`. Pass `null` to mute. */
28
+ log?: ((message: string) => void) | null;
29
+ /** Injectable for tests; defaults to Node's global `fetch`. */
30
+ fetchImpl?: typeof fetch;
31
+ }
32
+ interface PackagePreview {
33
+ pluginId: string;
34
+ semanticVersion: string;
35
+ displayName: string;
36
+ isUpgrade: boolean;
37
+ requiresConfig: boolean;
38
+ parts: {
39
+ frontend?: {
40
+ entryPath: string;
41
+ locales: string[];
42
+ navCount: number;
43
+ };
44
+ backend?: {
45
+ entryPath: string;
46
+ migrationCount: number;
47
+ };
48
+ claw?: {
49
+ entryPath: string;
50
+ };
51
+ };
52
+ }
53
+ interface CatalogItem {
54
+ id: string;
55
+ pluginId: string;
56
+ displayName: string;
57
+ }
58
+ interface Release {
59
+ id: string;
60
+ pluginId: string;
61
+ semanticVersion: string;
62
+ packageSha256: string;
63
+ status: 'draft' | 'approved' | 'retired' | 'revoked';
64
+ }
65
+ interface TenantInstall {
66
+ pluginId: string;
67
+ releaseId: string;
68
+ version: string;
69
+ scope: 'avatar' | 'tenant';
70
+ enabled: boolean;
71
+ avatarIds: string[];
72
+ avatars?: {
73
+ attempted: number;
74
+ failures: {
75
+ avatarId: string;
76
+ message: string;
77
+ }[];
78
+ };
79
+ }
80
+ interface PublishResult {
81
+ packed: PackedPlugin;
82
+ preview: PackagePreview;
83
+ catalog: CatalogItem;
84
+ release: Release;
85
+ /** Present unless install was disabled. */
86
+ install: TenantInstall | null;
87
+ }
88
+ declare function publishPlugin(options: PublishPluginOptions): Promise<PublishResult>;
89
+ /**
90
+ * The network half of `publishPlugin`, split out so the sequence can be
91
+ * exercised without a real `vite`/`esbuild` pack: presign → upload → inspect →
92
+ * finalize → approve → install, against an already-built archive on disk.
93
+ */
94
+ declare function publishPackedPlugin(packed: PackedPlugin, options: Omit<PublishPluginOptions, 'root'>): Promise<PublishResult>;
95
+
96
+ export { type PublishPluginOptions, type PublishResult, publishPackedPlugin, publishPlugin };
@@ -0,0 +1,96 @@
1
+ import { PackedPlugin } from './pack.js';
2
+ import './manifest-types-DQARCQJt.js';
3
+
4
+ interface PublishPluginOptions {
5
+ /** Package root: the directory holding `tego.plugin.json`. */
6
+ root: string;
7
+ /** Server origin, e.g. `http://localhost:3100`. Trailing slashes are trimmed. */
8
+ server: string;
9
+ /** Admin bearer token. The publish endpoints all sit behind `adminMiddleware`. */
10
+ token: string;
11
+ /**
12
+ * Avatars to install onto, for an avatar-scoped plugin. An empty array
13
+ * installs it for nobody, which is the server's own contract, not a no-op —
14
+ * it still creates the tenant install. Ignored for a tenant-scoped plugin.
15
+ */
16
+ avatarIds?: string[];
17
+ /** Catalog metadata to stamp on the release. */
18
+ meta?: {
19
+ category?: string;
20
+ homepage?: string;
21
+ icon?: string;
22
+ };
23
+ /** Approve the release after finalizing it. Defaults to true. */
24
+ approve?: boolean;
25
+ /** Install onto the tenant after approving. Defaults to true. */
26
+ install?: boolean;
27
+ /** Where to report progress. Defaults to `console.log`. Pass `null` to mute. */
28
+ log?: ((message: string) => void) | null;
29
+ /** Injectable for tests; defaults to Node's global `fetch`. */
30
+ fetchImpl?: typeof fetch;
31
+ }
32
+ interface PackagePreview {
33
+ pluginId: string;
34
+ semanticVersion: string;
35
+ displayName: string;
36
+ isUpgrade: boolean;
37
+ requiresConfig: boolean;
38
+ parts: {
39
+ frontend?: {
40
+ entryPath: string;
41
+ locales: string[];
42
+ navCount: number;
43
+ };
44
+ backend?: {
45
+ entryPath: string;
46
+ migrationCount: number;
47
+ };
48
+ claw?: {
49
+ entryPath: string;
50
+ };
51
+ };
52
+ }
53
+ interface CatalogItem {
54
+ id: string;
55
+ pluginId: string;
56
+ displayName: string;
57
+ }
58
+ interface Release {
59
+ id: string;
60
+ pluginId: string;
61
+ semanticVersion: string;
62
+ packageSha256: string;
63
+ status: 'draft' | 'approved' | 'retired' | 'revoked';
64
+ }
65
+ interface TenantInstall {
66
+ pluginId: string;
67
+ releaseId: string;
68
+ version: string;
69
+ scope: 'avatar' | 'tenant';
70
+ enabled: boolean;
71
+ avatarIds: string[];
72
+ avatars?: {
73
+ attempted: number;
74
+ failures: {
75
+ avatarId: string;
76
+ message: string;
77
+ }[];
78
+ };
79
+ }
80
+ interface PublishResult {
81
+ packed: PackedPlugin;
82
+ preview: PackagePreview;
83
+ catalog: CatalogItem;
84
+ release: Release;
85
+ /** Present unless install was disabled. */
86
+ install: TenantInstall | null;
87
+ }
88
+ declare function publishPlugin(options: PublishPluginOptions): Promise<PublishResult>;
89
+ /**
90
+ * The network half of `publishPlugin`, split out so the sequence can be
91
+ * exercised without a real `vite`/`esbuild` pack: presign → upload → inspect →
92
+ * finalize → approve → install, against an already-built archive on disk.
93
+ */
94
+ declare function publishPackedPlugin(packed: PackedPlugin, options: Omit<PublishPluginOptions, 'root'>): Promise<PublishResult>;
95
+
96
+ export { type PublishPluginOptions, type PublishResult, publishPackedPlugin, publishPlugin };
@@ -0,0 +1 @@
1
+ var h=Object.defineProperty;var o=(e,a)=>h(e,"name",{value:a,configurable:!0});import{packPlugin as v}from"./chunk-3KUOBGJN.js";import"./chunk-7K37PVGV.js";import"./chunk-5CU33JVY.js";import{resolvePluginScope as P}from"./chunk-BTHXQWHT.js";import"./chunk-7XHF3YSK.js";import"./chunk-VMCGDDGP.js";import"./chunk-SNUCO2MK.js";import{readFile as w}from"fs/promises";import{basename as y}from"path";var I="/api/v1/tego-os";async function T(e){const a=e.log===null?()=>{}:e.log??(n=>console.log(n)),t=await v({root:e.root,log:a});return f(t,e)}o(T,"publishPlugin");async function f(e,a){const t=a.log===null?()=>{}:a.log??(p=>console.log(p)),n=a.fetchImpl??fetch,r=A(a.server,a.token,n),s=await w(e.file),c=y(e.file);t("\u203A presigning upload");const u=await r("POST","/admin/runtime-plugins/presign-stream",{filename:c,mimeType:"application/zip",size:s.byteLength});t(`\u203A uploading ${c} (${s.byteLength} bytes)`),await S(a.server,u.uploadUrl,s,n),t("\u203A inspecting package");const l=await r("POST","/admin/runtime-plugins/inspect",{uploadToken:u.uploadToken});t(` ${l.pluginId}@${l.semanticVersion} \u2014 ${b(l)}${l.isUpgrade?" (upgrade)":""}${l.requiresConfig?", needs config":""}`),t("\u203A finalizing release");const g=await r("POST","/admin/runtime-plugins/upload",{uploadToken:u.uploadToken,...a.meta});let i=g.release;t(` release ${i.id} (${i.status})`),(a.approve??!0)&&(t("\u203A approving release"),i=await r("POST",`/admin/runtime-plugins/releases/${encodeURIComponent(i.id)}/approve`,{}),t(` release ${i.id} (${i.status})`));let d=null;if(a.install??!0){const p=P(e.manifest),$=p==="avatar"?{releaseId:i.id,avatarIds:a.avatarIds??[]}:{releaseId:i.id};t(`\u203A installing for tenant (${p}-scoped)`),d=await r("POST","/admin/runtime-plugins/installs",$),k(d,t)}return{packed:e,preview:l,catalog:g.catalog,release:i,install:d}}o(f,"publishPackedPlugin");function b(e){const a=[];return e.parts.frontend&&a.push(`frontend (${e.parts.frontend.locales.length} locales)`),e.parts.backend&&a.push(`backend (${e.parts.backend.migrationCount} migrations)`),e.parts.claw&&a.push("claw"),a.join(", ")||"no parts"}o(b,"describeParts");function k(e,a){const t=e.avatars;if(!t||t.attempted===0){a(` installed ${e.pluginId}@${e.version}`);return}const n=t.attempted-t.failures.length;a(` installed ${e.pluginId}@${e.version} \u2014 ${n}/${t.attempted} avatars`);for(const r of t.failures)a(` \u2717 ${r.avatarId}: ${r.message}`)}o(k,"reportInstall");function A(e,a,t){const n=e.replace(/\/+$/,"");return o(async function(s,c,u){const l=await t(`${n}${I}${c}`,{method:s,headers:{authorization:`Bearer ${a}`,...u===void 0?{}:{"content-type":"application/json"}},...u===void 0?{}:{body:JSON.stringify(u)}});return m(l,`${s} ${c}`)},"call")}o(A,"createCaller");async function S(e,a,t,n){const r=e.replace(/\/+$/,""),s=await n(`${r}${a}`,{method:"PUT",headers:{"content-type":"application/zip"},body:t});await m(s,"PUT upload")}o(S,"putArchive");async function m(e,a){let t;try{t=await e.json()}catch{t=null}if(!e.ok||!t?.success){const n=t?.error?.message??`HTTP ${e.status}`;throw new Error(`${a} failed: ${n}`)}return t.data}o(m,"unwrap");export{f as publishPackedPlugin,T as publishPlugin};