@zhama/tego-plugin-sdk 0.0.0-stage → 1.36.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 (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,182 @@
1
+ /**
2
+ * The files a new plugin starts with (`pnpm plugin:new` in this repository,
3
+ * `tego-plugin create` anywhere else), as pure data.
4
+ *
5
+ * Kept apart from the interactive generator (`turbo/generators/config.ts`) so
6
+ * the same builder can be exercised without a TTY: a test — or a one-off
7
+ * script — calls `buildPluginFiles(answers)` and asserts on the tree, where the
8
+ * interactive generator can only be driven by a real terminal.
9
+ *
10
+ * Everything here is faithful to what the upload validator (`@tego/plugin-sdk`
11
+ * manifest schema + the server's `prepare-plugin-package`) accepts, because a
12
+ * scaffold that produces a package the platform then rejects is worse than no
13
+ * scaffold: the author learns the rules by hitting them one at a time.
14
+ */
15
+ type PluginPart = 'frontend' | 'backend' | 'claw';
16
+ interface PluginAnswers {
17
+ /** kebab-case id, e.g. `tego-notes`. */
18
+ id: string;
19
+ displayNameZh: string;
20
+ displayNameEn: string;
21
+ descriptionZh: string;
22
+ descriptionEn: string;
23
+ parts: PluginPart[];
24
+ /** With a `claw` part, `tenant` sends it to every avatar in the tenant. */
25
+ scope: 'avatar' | 'tenant';
26
+ /** Caret range for the current host, e.g. `^1.5.0`. */
27
+ hostApiRange: string;
28
+ }
29
+ /**
30
+ * Where the SDK packages come from.
31
+ *
32
+ * `workspace` — the plugin lives under `plugins/` in this repo and links the
33
+ * workspace packages. `npm` — a standalone repository installing the published
34
+ * packages under their workspace names through npm aliases, so its imports
35
+ * read exactly as they do here; its tsconfig presets and lint config are local
36
+ * files instead of the monorepo's `@tego/tsconfig` / `@tego/eslint-config`.
37
+ */
38
+ type DependencySource = 'workspace' | 'npm';
39
+ interface BuildPluginFilesOptions {
40
+ dependencies?: DependencySource;
41
+ }
42
+ /**
43
+ * Published names of the SDK packages. Mirrors
44
+ * `scripts/sdk-release/packages.mjs` (the release script's source of truth);
45
+ * `plugin-files.test.ts` fails if the two disagree.
46
+ */
47
+ declare const PUBLISHED_SDK_PACKAGES: Record<string, string>;
48
+ /**
49
+ * The TypeScript presets of `@tego/tsconfig` (packages/tsconfig), copied into a
50
+ * standalone plugin's root instead of published as a package: they only drive
51
+ * the editor and `tsgo --noEmit` — the build itself is the SDK's — so the
52
+ * plugin owns them and may change them. `files.test.ts` fails if these drift
53
+ * from packages/tsconfig.
54
+ */
55
+ declare const STANDALONE_TSCONFIG_FILES: {
56
+ 'tsconfig.base.json': {
57
+ $schema: string;
58
+ compilerOptions: {
59
+ strict: boolean;
60
+ useUnknownInCatchVariables: boolean;
61
+ allowJs: boolean;
62
+ skipLibCheck: boolean;
63
+ forceConsistentCasingInFileNames: boolean;
64
+ resolveJsonModule: boolean;
65
+ isolatedModules: boolean;
66
+ verbatimModuleSyntax: boolean;
67
+ declaration: boolean;
68
+ declarationMap: boolean;
69
+ esModuleInterop: boolean;
70
+ incremental: boolean;
71
+ noUncheckedIndexedAccess: boolean;
72
+ moduleDetection: string;
73
+ exactOptionalPropertyTypes: boolean;
74
+ target: string;
75
+ lib: string[];
76
+ module: string;
77
+ moduleResolution: string;
78
+ };
79
+ exclude: string[];
80
+ };
81
+ 'tsconfig.frontend.json': {
82
+ $schema: string;
83
+ extends: string;
84
+ compilerOptions: {
85
+ target: string;
86
+ lib: string[];
87
+ module: string;
88
+ moduleResolution: string;
89
+ jsx: string;
90
+ noEmit: boolean;
91
+ declaration: boolean;
92
+ declarationMap: boolean;
93
+ outDir: string;
94
+ };
95
+ };
96
+ 'tsconfig.backend.json': {
97
+ $schema: string;
98
+ extends: string;
99
+ compilerOptions: {
100
+ target: string;
101
+ lib: string[];
102
+ module: string;
103
+ moduleResolution: string;
104
+ types: string[];
105
+ noEmit: boolean;
106
+ declaration: boolean;
107
+ declarationMap: boolean;
108
+ outDir: string;
109
+ };
110
+ };
111
+ };
112
+ interface GeneratedFile {
113
+ /** Path relative to the plugin directory (`plugins/<id>/` in this repo). */
114
+ path: string;
115
+ contents: string;
116
+ }
117
+ /** `tego-notes` → `@tego/plugin-notes`; a non-`tego-` id keeps its whole self. */
118
+ declare function packageNameFor(id: string): string;
119
+ /**
120
+ * Every file a generated plugin ships, relative to the plugin's directory, for
121
+ * the chosen parts. Order is irrelevant to the writer; it is grouped for
122
+ * reading.
123
+ */
124
+ declare function buildPluginFiles(answers: PluginAnswers, { dependencies }?: BuildPluginFilesOptions): GeneratedFile[];
125
+
126
+ /**
127
+ * Turning answers into a plugin directory (`@tego/plugin-sdk/scaffold`).
128
+ *
129
+ * Shipped with the SDK so a plugin can be created without this repository:
130
+ * `tego-plugin create` (the SDK's bin, used by tools such as Tego Studio) writes
131
+ * a standalone plugin anywhere. Inside the repository the interactive generator
132
+ * (`turbo/generators/config.ts`, `pnpm plugin:new`) and the non-interactive one
133
+ * (`scaffold-cli.ts`, `pnpm plugin:scaffold`) call the same functions, so every
134
+ * entry validates the same way and writes the same files: a plugin never depends
135
+ * on how it was made.
136
+ */
137
+
138
+ /** Same id shape the manifest schema enforces, checked before any file lands. */
139
+ declare const PLUGIN_ID_PATTERN: RegExp;
140
+ declare const PLUGIN_PARTS: readonly PluginPart[];
141
+ declare const PLUGIN_SCOPES: readonly ["avatar", "tenant"];
142
+ declare const PLUGIN_ID_HINT = "lowercase letters and digits, may contain . _ -, starting with a letter or digit";
143
+ /**
144
+ * The answers a scaffold needs, checked like the interactive prompts check them.
145
+ * `hostApiRange` is never taken from the input: it follows the SDK's current version.
146
+ */
147
+ declare function validatePluginAnswers(input: unknown, hostApiRange: string): PluginAnswers;
148
+ /**
149
+ * Writes `plugins/<id>/` under the repository root, or refuses if the directory
150
+ * is already there rather than merging into an existing plugin.
151
+ */
152
+ declare function writePlugin(repoRoot: string, answers: PluginAnswers): {
153
+ directory: string;
154
+ files: string[];
155
+ };
156
+ /**
157
+ * Writes `<parentDirectory>/<id>/` as a standalone plugin repository: the SDK
158
+ * packages come from npm instead of this workspace. Same refusal rule as
159
+ * {@link writePlugin}.
160
+ */
161
+ declare function writeStandalonePlugin(parentDirectory: string, answers: PluginAnswers): {
162
+ directory: string;
163
+ files: string[];
164
+ };
165
+ /** What `tego-plugin create` prints on success. */
166
+ interface CreatePluginResult {
167
+ directory: string;
168
+ files: string[];
169
+ }
170
+ /**
171
+ * `tego-plugin create [--dir <parent>]`: reads the answers as JSON from
172
+ * `input`, writes `<parent>/<id>/` as a standalone plugin (the SDK packages
173
+ * from npm) and returns it. `parent` is resolved against `cwd`. The host API
174
+ * range follows this SDK's own version, so a plugin created with a newer SDK
175
+ * targets the newer host.
176
+ */
177
+ declare function createStandalonePlugin(input: string, options: {
178
+ parent: string;
179
+ cwd: string;
180
+ }): CreatePluginResult;
181
+
182
+ export { type BuildPluginFilesOptions, type CreatePluginResult, type DependencySource, type GeneratedFile, PLUGIN_ID_HINT, PLUGIN_ID_PATTERN, PLUGIN_PARTS, PLUGIN_SCOPES, PUBLISHED_SDK_PACKAGES, type PluginAnswers, type PluginPart, STANDALONE_TSCONFIG_FILES, buildPluginFiles, createStandalonePlugin, packageNameFor, validatePluginAnswers, writePlugin, writeStandalonePlugin };
@@ -0,0 +1,182 @@
1
+ /**
2
+ * The files a new plugin starts with (`pnpm plugin:new` in this repository,
3
+ * `tego-plugin create` anywhere else), as pure data.
4
+ *
5
+ * Kept apart from the interactive generator (`turbo/generators/config.ts`) so
6
+ * the same builder can be exercised without a TTY: a test — or a one-off
7
+ * script — calls `buildPluginFiles(answers)` and asserts on the tree, where the
8
+ * interactive generator can only be driven by a real terminal.
9
+ *
10
+ * Everything here is faithful to what the upload validator (`@tego/plugin-sdk`
11
+ * manifest schema + the server's `prepare-plugin-package`) accepts, because a
12
+ * scaffold that produces a package the platform then rejects is worse than no
13
+ * scaffold: the author learns the rules by hitting them one at a time.
14
+ */
15
+ type PluginPart = 'frontend' | 'backend' | 'claw';
16
+ interface PluginAnswers {
17
+ /** kebab-case id, e.g. `tego-notes`. */
18
+ id: string;
19
+ displayNameZh: string;
20
+ displayNameEn: string;
21
+ descriptionZh: string;
22
+ descriptionEn: string;
23
+ parts: PluginPart[];
24
+ /** With a `claw` part, `tenant` sends it to every avatar in the tenant. */
25
+ scope: 'avatar' | 'tenant';
26
+ /** Caret range for the current host, e.g. `^1.5.0`. */
27
+ hostApiRange: string;
28
+ }
29
+ /**
30
+ * Where the SDK packages come from.
31
+ *
32
+ * `workspace` — the plugin lives under `plugins/` in this repo and links the
33
+ * workspace packages. `npm` — a standalone repository installing the published
34
+ * packages under their workspace names through npm aliases, so its imports
35
+ * read exactly as they do here; its tsconfig presets and lint config are local
36
+ * files instead of the monorepo's `@tego/tsconfig` / `@tego/eslint-config`.
37
+ */
38
+ type DependencySource = 'workspace' | 'npm';
39
+ interface BuildPluginFilesOptions {
40
+ dependencies?: DependencySource;
41
+ }
42
+ /**
43
+ * Published names of the SDK packages. Mirrors
44
+ * `scripts/sdk-release/packages.mjs` (the release script's source of truth);
45
+ * `plugin-files.test.ts` fails if the two disagree.
46
+ */
47
+ declare const PUBLISHED_SDK_PACKAGES: Record<string, string>;
48
+ /**
49
+ * The TypeScript presets of `@tego/tsconfig` (packages/tsconfig), copied into a
50
+ * standalone plugin's root instead of published as a package: they only drive
51
+ * the editor and `tsgo --noEmit` — the build itself is the SDK's — so the
52
+ * plugin owns them and may change them. `files.test.ts` fails if these drift
53
+ * from packages/tsconfig.
54
+ */
55
+ declare const STANDALONE_TSCONFIG_FILES: {
56
+ 'tsconfig.base.json': {
57
+ $schema: string;
58
+ compilerOptions: {
59
+ strict: boolean;
60
+ useUnknownInCatchVariables: boolean;
61
+ allowJs: boolean;
62
+ skipLibCheck: boolean;
63
+ forceConsistentCasingInFileNames: boolean;
64
+ resolveJsonModule: boolean;
65
+ isolatedModules: boolean;
66
+ verbatimModuleSyntax: boolean;
67
+ declaration: boolean;
68
+ declarationMap: boolean;
69
+ esModuleInterop: boolean;
70
+ incremental: boolean;
71
+ noUncheckedIndexedAccess: boolean;
72
+ moduleDetection: string;
73
+ exactOptionalPropertyTypes: boolean;
74
+ target: string;
75
+ lib: string[];
76
+ module: string;
77
+ moduleResolution: string;
78
+ };
79
+ exclude: string[];
80
+ };
81
+ 'tsconfig.frontend.json': {
82
+ $schema: string;
83
+ extends: string;
84
+ compilerOptions: {
85
+ target: string;
86
+ lib: string[];
87
+ module: string;
88
+ moduleResolution: string;
89
+ jsx: string;
90
+ noEmit: boolean;
91
+ declaration: boolean;
92
+ declarationMap: boolean;
93
+ outDir: string;
94
+ };
95
+ };
96
+ 'tsconfig.backend.json': {
97
+ $schema: string;
98
+ extends: string;
99
+ compilerOptions: {
100
+ target: string;
101
+ lib: string[];
102
+ module: string;
103
+ moduleResolution: string;
104
+ types: string[];
105
+ noEmit: boolean;
106
+ declaration: boolean;
107
+ declarationMap: boolean;
108
+ outDir: string;
109
+ };
110
+ };
111
+ };
112
+ interface GeneratedFile {
113
+ /** Path relative to the plugin directory (`plugins/<id>/` in this repo). */
114
+ path: string;
115
+ contents: string;
116
+ }
117
+ /** `tego-notes` → `@tego/plugin-notes`; a non-`tego-` id keeps its whole self. */
118
+ declare function packageNameFor(id: string): string;
119
+ /**
120
+ * Every file a generated plugin ships, relative to the plugin's directory, for
121
+ * the chosen parts. Order is irrelevant to the writer; it is grouped for
122
+ * reading.
123
+ */
124
+ declare function buildPluginFiles(answers: PluginAnswers, { dependencies }?: BuildPluginFilesOptions): GeneratedFile[];
125
+
126
+ /**
127
+ * Turning answers into a plugin directory (`@tego/plugin-sdk/scaffold`).
128
+ *
129
+ * Shipped with the SDK so a plugin can be created without this repository:
130
+ * `tego-plugin create` (the SDK's bin, used by tools such as Tego Studio) writes
131
+ * a standalone plugin anywhere. Inside the repository the interactive generator
132
+ * (`turbo/generators/config.ts`, `pnpm plugin:new`) and the non-interactive one
133
+ * (`scaffold-cli.ts`, `pnpm plugin:scaffold`) call the same functions, so every
134
+ * entry validates the same way and writes the same files: a plugin never depends
135
+ * on how it was made.
136
+ */
137
+
138
+ /** Same id shape the manifest schema enforces, checked before any file lands. */
139
+ declare const PLUGIN_ID_PATTERN: RegExp;
140
+ declare const PLUGIN_PARTS: readonly PluginPart[];
141
+ declare const PLUGIN_SCOPES: readonly ["avatar", "tenant"];
142
+ declare const PLUGIN_ID_HINT = "lowercase letters and digits, may contain . _ -, starting with a letter or digit";
143
+ /**
144
+ * The answers a scaffold needs, checked like the interactive prompts check them.
145
+ * `hostApiRange` is never taken from the input: it follows the SDK's current version.
146
+ */
147
+ declare function validatePluginAnswers(input: unknown, hostApiRange: string): PluginAnswers;
148
+ /**
149
+ * Writes `plugins/<id>/` under the repository root, or refuses if the directory
150
+ * is already there rather than merging into an existing plugin.
151
+ */
152
+ declare function writePlugin(repoRoot: string, answers: PluginAnswers): {
153
+ directory: string;
154
+ files: string[];
155
+ };
156
+ /**
157
+ * Writes `<parentDirectory>/<id>/` as a standalone plugin repository: the SDK
158
+ * packages come from npm instead of this workspace. Same refusal rule as
159
+ * {@link writePlugin}.
160
+ */
161
+ declare function writeStandalonePlugin(parentDirectory: string, answers: PluginAnswers): {
162
+ directory: string;
163
+ files: string[];
164
+ };
165
+ /** What `tego-plugin create` prints on success. */
166
+ interface CreatePluginResult {
167
+ directory: string;
168
+ files: string[];
169
+ }
170
+ /**
171
+ * `tego-plugin create [--dir <parent>]`: reads the answers as JSON from
172
+ * `input`, writes `<parent>/<id>/` as a standalone plugin (the SDK packages
173
+ * from npm) and returns it. `parent` is resolved against `cwd`. The host API
174
+ * range follows this SDK's own version, so a plugin created with a newer SDK
175
+ * targets the newer host.
176
+ */
177
+ declare function createStandalonePlugin(input: string, options: {
178
+ parent: string;
179
+ cwd: string;
180
+ }): CreatePluginResult;
181
+
182
+ export { type BuildPluginFilesOptions, type CreatePluginResult, type DependencySource, type GeneratedFile, PLUGIN_ID_HINT, PLUGIN_ID_PATTERN, PLUGIN_PARTS, PLUGIN_SCOPES, PUBLISHED_SDK_PACKAGES, type PluginAnswers, type PluginPart, STANDALONE_TSCONFIG_FILES, buildPluginFiles, createStandalonePlugin, packageNameFor, validatePluginAnswers, writePlugin, writeStandalonePlugin };