@xtrable-ltd/nanoesis 0.1.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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/adapter-azure-blob.d.ts +97 -0
  4. package/dist/adapter-azure-blob.js +127 -0
  5. package/dist/adapter-cloudflare.d.ts +28 -0
  6. package/dist/adapter-cloudflare.js +32 -0
  7. package/dist/adapter-fs.d.ts +38 -0
  8. package/dist/adapter-fs.js +54 -0
  9. package/dist/adapter-local-jwt.d.ts +205 -0
  10. package/dist/adapter-local-jwt.js +550 -0
  11. package/dist/adapter-sharp.d.ts +11 -0
  12. package/dist/adapter-sharp.js +39 -0
  13. package/dist/adapter-shell.d.ts +48 -0
  14. package/dist/adapter-shell.js +56 -0
  15. package/dist/adapter-trusted-header.d.ts +43 -0
  16. package/dist/adapter-trusted-header.js +21 -0
  17. package/dist/chunk-G2UEZTYC.js +2541 -0
  18. package/dist/editor-api.d.ts +198 -0
  19. package/dist/editor-api.js +592 -0
  20. package/dist/editor.d.ts +13 -0
  21. package/dist/editor.js +6 -0
  22. package/dist/index.d.ts +1238 -0
  23. package/dist/index.js +124 -0
  24. package/editor/assets/TemplatesPane-5qsDAK_B.js +792 -0
  25. package/editor/assets/TemplatesPane-B4_sg2u5.css +1 -0
  26. package/editor/assets/abap-BrgZPUOV.js +6 -0
  27. package/editor/assets/apex-DyP6w7ZV.js +6 -0
  28. package/editor/assets/azcli-BaLxmfj-.js +6 -0
  29. package/editor/assets/bat-CFOPXBzS.js +6 -0
  30. package/editor/assets/bicep-BfEKNvv3.js +7 -0
  31. package/editor/assets/cameligo-BFG1Mk7z.js +6 -0
  32. package/editor/assets/clojure-DTECt2xU.js +6 -0
  33. package/editor/assets/codicon-DCmgc-ay.ttf +0 -0
  34. package/editor/assets/coffee-CDGzqUPQ.js +6 -0
  35. package/editor/assets/cpp-CLLBncYj.js +6 -0
  36. package/editor/assets/csharp-dUCx_-0o.js +6 -0
  37. package/editor/assets/csp-5Rap-vPy.js +6 -0
  38. package/editor/assets/css-D3h14YRZ.js +8 -0
  39. package/editor/assets/css.worker-DaIe3gwK.js +84 -0
  40. package/editor/assets/cssMode-CGp4MIjR.js +9 -0
  41. package/editor/assets/cypher-DrQuvNYM.js +6 -0
  42. package/editor/assets/dart-CFKIUWau.js +6 -0
  43. package/editor/assets/dockerfile-Zznr-cwX.js +6 -0
  44. package/editor/assets/ecl-Ce3n6wWz.js +6 -0
  45. package/editor/assets/editor.worker-BCzxt1at.js +12 -0
  46. package/editor/assets/elixir-deUWdS0T.js +6 -0
  47. package/editor/assets/flow9-i9-g7ZhI.js +6 -0
  48. package/editor/assets/freemarker2-CJkwxmPv.js +8 -0
  49. package/editor/assets/fsharp-CzKuDChf.js +6 -0
  50. package/editor/assets/go-Cphgjts3.js +6 -0
  51. package/editor/assets/graphql-Cg7bfA9N.js +6 -0
  52. package/editor/assets/handlebars-CKb5i2nM.js +6 -0
  53. package/editor/assets/hcl-0cvrggvQ.js +6 -0
  54. package/editor/assets/html-DyMbQx0w.js +6 -0
  55. package/editor/assets/html.worker-CKrFyw_2.js +461 -0
  56. package/editor/assets/htmlMode-DVPeqtn-.js +9 -0
  57. package/editor/assets/index-CbuWEnUB.css +7 -0
  58. package/editor/assets/index-DJmSgobK.js +129 -0
  59. package/editor/assets/ini-Drc7WvVn.js +6 -0
  60. package/editor/assets/java-B_fMsGYe.js +6 -0
  61. package/editor/assets/javascript-Bp1Qh9wR.js +6 -0
  62. package/editor/assets/json.worker-B7c_PmGb.js +49 -0
  63. package/editor/assets/jsonMode-FLEeVtx7.js +15 -0
  64. package/editor/assets/julia-Bqgm2twL.js +6 -0
  65. package/editor/assets/kotlin-BSkB5QuD.js +6 -0
  66. package/editor/assets/less-BsTHnhdd.js +7 -0
  67. package/editor/assets/lexon-YWi4-JPR.js +6 -0
  68. package/editor/assets/liquid-Bh8c534t.js +6 -0
  69. package/editor/assets/lua-nf6ki56Z.js +6 -0
  70. package/editor/assets/m3-Cpb6xl2v.js +6 -0
  71. package/editor/assets/markdown-DSZPf7rp.js +6 -0
  72. package/editor/assets/mdx-BUbo8M9l.js +6 -0
  73. package/editor/assets/mips-B_c3zf-v.js +6 -0
  74. package/editor/assets/msdax-rUNN04Wq.js +6 -0
  75. package/editor/assets/mysql-DDwshQtU.js +6 -0
  76. package/editor/assets/nanoesis-logo-CgieIWPg.png +0 -0
  77. package/editor/assets/objective-c-B5zXfXm9.js +6 -0
  78. package/editor/assets/pascal-CXOwvkN_.js +6 -0
  79. package/editor/assets/pascaligo-Bc-ZgV77.js +6 -0
  80. package/editor/assets/perl-CwNk8-XU.js +6 -0
  81. package/editor/assets/pgsql-tGk8EFnU.js +6 -0
  82. package/editor/assets/php-CpIb_Oan.js +6 -0
  83. package/editor/assets/pla-B03wrqEc.js +6 -0
  84. package/editor/assets/postiats-BKlk5iyT.js +6 -0
  85. package/editor/assets/powerquery-Bhzvs7bI.js +6 -0
  86. package/editor/assets/powershell-Dd3NCNK9.js +6 -0
  87. package/editor/assets/protobuf-COyEY5Pt.js +7 -0
  88. package/editor/assets/pug-BaJupSGV.js +6 -0
  89. package/editor/assets/python-CuJlk8g3.js +6 -0
  90. package/editor/assets/qsharp-DXyYeYxl.js +6 -0
  91. package/editor/assets/r-CdQndTaG.js +6 -0
  92. package/editor/assets/razor-CuQT_1Ku.js +6 -0
  93. package/editor/assets/redis-CVwtpugi.js +6 -0
  94. package/editor/assets/redshift-25W9uPmb.js +6 -0
  95. package/editor/assets/restructuredtext-DfzH4Xui.js +6 -0
  96. package/editor/assets/ruby-Cp1zYvxS.js +6 -0
  97. package/editor/assets/rust-D5C2fndG.js +6 -0
  98. package/editor/assets/sb-CDntyWJ8.js +6 -0
  99. package/editor/assets/scala-BoFRg7Ot.js +6 -0
  100. package/editor/assets/scheme-Bio4gycK.js +6 -0
  101. package/editor/assets/scss-4Ik7cdeQ.js +8 -0
  102. package/editor/assets/shell-CX-rkNHf.js +6 -0
  103. package/editor/assets/solidity-Tw7wswEv.js +6 -0
  104. package/editor/assets/sophia-C5WLch3f.js +6 -0
  105. package/editor/assets/sparql-DHaeiCBh.js +6 -0
  106. package/editor/assets/sql-CCSDG5nI.js +6 -0
  107. package/editor/assets/st-pnP8ivHi.js +6 -0
  108. package/editor/assets/swift-DwJ7jVG9.js +8 -0
  109. package/editor/assets/systemverilog-B9Xyijhd.js +6 -0
  110. package/editor/assets/tcl-DnHyzjbg.js +6 -0
  111. package/editor/assets/ts.worker-BhkL8olL.js +51334 -0
  112. package/editor/assets/tsMode-CT2HUNtN.js +16 -0
  113. package/editor/assets/twig-CPajHgWi.js +6 -0
  114. package/editor/assets/typescript-CtMx97cn.js +6 -0
  115. package/editor/assets/typespec-D-MeaMDU.js +6 -0
  116. package/editor/assets/vb-DgyLZaXg.js +6 -0
  117. package/editor/assets/wgsl-BIv9DU6q.js +303 -0
  118. package/editor/assets/xml-CyfpINj_.js +6 -0
  119. package/editor/assets/yaml-BBWmgfMA.js +6 -0
  120. package/editor/config.json +3 -0
  121. package/editor/index.html +28 -0
  122. package/package.json +85 -0
@@ -0,0 +1,198 @@
1
+ import { WorkingStore, IdentityProvider, PublishResult, AuthEndpoints, UserAdminEndpoints, AuthorOption, UserSummary, AuthorDirectory } from '@nanoesis/engine';
2
+
3
+ /**
4
+ * Editor white-labelling storage (DESIGN §11, Phase B). This is the *editor app's*
5
+ * own chrome, a custom top-left logo + name an operator sets, deliberately kept out
6
+ * of the engine (which only compiles a site's data to data) and out of the site's
7
+ * `ContentSource` (so it can never leak into the published output). It lives here, in
8
+ * the host, behind a narrow port so a deploy can swap the file-backed store for a
9
+ * blob/table one without touching the routes.
10
+ *
11
+ * The logo bytes and the name are stored separately so reading the cheap metadata
12
+ * (for the `GET /api/branding` poll the login screen and top bar make) doesn't pull
13
+ * the image down every time; the image is fetched once via `GET /api/branding/logo`.
14
+ */
15
+ interface BrandingLogoMeta {
16
+ readonly contentType: string;
17
+ /** Epoch ms of the last logo write, used to cache-bust the logo URL. */
18
+ readonly updatedAt: number;
19
+ }
20
+ interface BrandingState {
21
+ /** Operator-set display name, or null to fall back to the built-in brand. */
22
+ readonly name: string | null;
23
+ /** Logo metadata, or null when no logo is set. */
24
+ readonly logo: BrandingLogoMeta | null;
25
+ }
26
+ interface BrandingLogo {
27
+ readonly bytes: Uint8Array;
28
+ readonly contentType: string;
29
+ }
30
+ interface BrandingStore {
31
+ /** Cheap metadata read (name + whether/when a logo exists); never the image bytes. */
32
+ get(): Promise<BrandingState>;
33
+ /** The logo image, or null when none is set. */
34
+ getLogo(): Promise<BrandingLogo | null>;
35
+ /** Set (or clear, with null) the display name. */
36
+ setName(name: string | null): Promise<void>;
37
+ /** Replace the logo image. */
38
+ setLogo(bytes: Uint8Array, contentType: string): Promise<void>;
39
+ /** Remove the logo image (revert to the built-in mark). */
40
+ clearLogo(): Promise<void>;
41
+ }
42
+ /** An ephemeral in-process {@link BrandingStore}, for tests and ephemeral examples. */
43
+ declare class InMemoryBrandingStore implements BrandingStore {
44
+ private readonly now;
45
+ private name;
46
+ private logo;
47
+ private logoUpdatedAt;
48
+ constructor(now?: () => number);
49
+ get(): Promise<BrandingState>;
50
+ getLogo(): Promise<BrandingLogo | null>;
51
+ setName(name: string | null): Promise<void>;
52
+ setLogo(bytes: Uint8Array, contentType: string): Promise<void>;
53
+ clearLogo(): Promise<void>;
54
+ }
55
+ /**
56
+ * A file-backed {@link BrandingStore} for the local example and small self-hosted
57
+ * deploys. Metadata is a small JSON file (`{ name, logo: { contentType, updatedAt } }`)
58
+ * written atomically (tmp + rename); the image is a sibling file. BOM-tolerant on read
59
+ * (Windows / PowerShell-5 default). Bring your own store for blob/table persistence.
60
+ */
61
+ declare class FileBrandingStore implements BrandingStore {
62
+ private readonly metaPath;
63
+ private readonly now;
64
+ private readonly logoPath;
65
+ constructor(metaPath: string, now?: () => number);
66
+ private loadMeta;
67
+ private saveMeta;
68
+ get(): Promise<BrandingState>;
69
+ getLogo(): Promise<BrandingLogo | null>;
70
+ setName(name: string | null): Promise<void>;
71
+ setLogo(bytes: Uint8Array, contentType: string): Promise<void>;
72
+ clearLogo(): Promise<void>;
73
+ }
74
+
75
+ /**
76
+ * The host's content API as a pure, framework-agnostic router. It reproduces the dev
77
+ * server's contract (`packages/editor/dev/content-api.ts`) exactly, `/api/list`,
78
+ * `/read`, `/exists`, `/write`, `/delete`, `/rename`, plus `/publish`, so the editor
79
+ * client talks to it unchanged. Keeping it free of `@azure/functions` means it is
80
+ * unit-tested in memory; the Functions glue (`functions.ts`) just maps the runtime's
81
+ * request/response onto these types.
82
+ */
83
+ interface ApiRequest {
84
+ readonly method: string;
85
+ /** URL pathname, e.g. "/api/list". */
86
+ readonly path: string;
87
+ readonly query: URLSearchParams;
88
+ readonly getHeader: (name: string) => string | undefined;
89
+ readonly body: () => Promise<Uint8Array>;
90
+ }
91
+ interface ApiResponse {
92
+ readonly status: number;
93
+ readonly headers?: Record<string, string>;
94
+ readonly body?: string | Uint8Array;
95
+ }
96
+ interface ApiDeps {
97
+ /** The editor working store (read + write/delete/rename), any {@link WorkingStore}. */
98
+ readonly store: WorkingStore;
99
+ /** Who is calling, gates every editing route (DESIGN §11). */
100
+ readonly identity: IdentityProvider;
101
+ /** Run the publish pipeline (host binds source/sink/purge). */
102
+ readonly publish: () => Promise<PublishResult>;
103
+ /**
104
+ * Optional credential-management surface (DESIGN §11). When present, the router
105
+ * mounts `/api/login`, `/api/refresh`, `/api/logout`, and `/api/auth/state`,
106
+ * unauthenticated routes that bypass the editor-role check. Trusted-header /
107
+ * gateway-style deployments leave this unset.
108
+ */
109
+ readonly authEndpoints?: AuthEndpoints;
110
+ /**
111
+ * Optional admin-only user-management surface (DESIGN §11, Phase B). When present,
112
+ * the router mounts `/api/users` (list/create) and `/api/users/:id` (update/delete)
113
+ * plus `/api/users/:id/password` (reset), all gated on the `admin` role. Omitted by
114
+ * trusted-header / external-IdP providers, where users are managed upstream.
115
+ */
116
+ readonly userAdmin?: UserAdminEndpoints;
117
+ /**
118
+ * Optional editor white-labelling store (DESIGN §11, Phase B). When present, the
119
+ * router mounts the *anonymous* reads `GET /api/branding` (`{ name, logoUrl }`) and
120
+ * `GET /api/branding/logo` (the image, anonymous so the login screen is branded too),
121
+ * plus the admin-gated writes `PUT /api/branding`, `POST`/`DELETE /api/branding/logo`.
122
+ * When absent, the reads return the built-in defaults and writes 404.
123
+ */
124
+ readonly branding?: BrandingStore;
125
+ /**
126
+ * Optional author directory (DESIGN §6.11). When present, the router mounts
127
+ * `GET /api/authors` (any editing role, bylines are public) returning the users a
128
+ * byline can name as `{ name, user }`, for the editor's authors picker. Absent → the
129
+ * route returns `[]` and the picker is guest-only. The host builds this from its user
130
+ * store and feeds the *same* users to the compiler's `authorDirectory` at publish.
131
+ */
132
+ readonly authors?: () => Promise<readonly AuthorOption[]>;
133
+ }
134
+ /** Dispatch one API request. The editor is private, so every route requires an editing
135
+ * role (author/developer/admin); writes are further partitioned by path (DESIGN §11). */
136
+ declare function handleApi(deps: ApiDeps, req: ApiRequest): Promise<ApiResponse>;
137
+
138
+ /** The byline picker's options, display name + stable handle, sorted by display name. */
139
+ declare function authorOptions(users: readonly UserSummary[]): AuthorOption[];
140
+ /**
141
+ * A sync directory resolving a stored `user` handle to its current display name, for the
142
+ * compiler's `authorDirectory`. The compiler resolves synchronously, so snapshot a fresh
143
+ * user list (an async `listUsers()`) into this map *before* each compile/publish.
144
+ */
145
+ declare function authorDirectory(users: readonly UserSummary[]): AuthorDirectory;
146
+
147
+ /** A JSON Schema (2020-12 subset) for a tool's arguments. Plain data, no SDK types. */
148
+ interface JsonSchemaProperty {
149
+ readonly type: 'string';
150
+ readonly description?: string;
151
+ }
152
+ interface JsonSchemaObject {
153
+ readonly type: 'object';
154
+ readonly properties: Readonly<Record<string, JsonSchemaProperty>>;
155
+ readonly required?: readonly string[];
156
+ readonly additionalProperties: false;
157
+ }
158
+ /** A transport-neutral MCP tool definition the host registers with the SDK. */
159
+ interface McpToolDef {
160
+ readonly name: string;
161
+ readonly description: string;
162
+ readonly inputSchema: JsonSchemaObject;
163
+ }
164
+ /** The outcome of a tool call, ready for the host to wrap in the SDK's result type. */
165
+ interface McpToolResult {
166
+ readonly text: string;
167
+ readonly isError: boolean;
168
+ }
169
+ /** Per-call options. The token threads the caller's identity for HTTP transports; a
170
+ * local stdio host with a pass-through identity omits it. */
171
+ interface McpCallOptions {
172
+ readonly token?: string;
173
+ }
174
+ /** A read-only MCP resource definition (context the client can pull). */
175
+ interface McpResourceDef {
176
+ readonly uri: string;
177
+ readonly name: string;
178
+ readonly description: string;
179
+ readonly mimeType: string;
180
+ }
181
+ /** The catalog of MCP tools a host registers (the executable mapping is kept internal). */
182
+ declare const MCP_TOOLS: readonly McpToolDef[];
183
+ /**
184
+ * Execute an MCP tool call by routing it through {@link handleApi}, so it is authenticated
185
+ * and role-gated identically to the HTTP transport. An unknown tool name is a tool error,
186
+ * not a thrown exception (the client surfaces it to the model).
187
+ */
188
+ declare function callMcpTool(deps: ApiDeps, name: string, args?: Readonly<Record<string, unknown>>, options?: McpCallOptions): Promise<McpToolResult>;
189
+ /** The read-only resources a host exposes. The authoring reference is the keystone: the
190
+ * engine-generated, never-drifting syntax guide the model reads before authoring. */
191
+ declare const MCP_RESOURCES: readonly McpResourceDef[];
192
+ /** Resolve a resource URI to its contents, or `undefined` if the URI is unknown. */
193
+ declare function readMcpResource(uri: string): {
194
+ readonly text: string;
195
+ readonly mimeType: string;
196
+ } | undefined;
197
+
198
+ export { type ApiDeps, type ApiRequest, type ApiResponse, type BrandingLogo, type BrandingLogoMeta, type BrandingState, type BrandingStore, FileBrandingStore, InMemoryBrandingStore, MCP_RESOURCES, MCP_TOOLS, type McpCallOptions, type McpResourceDef, type McpToolDef, type McpToolResult, authorDirectory, authorOptions, callMcpTool, handleApi, readMcpResource };