@kumwe/studio-core 0.1.0-alpha.8 → 0.1.0-beta.2

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 (93) hide show
  1. package/README.md +84 -4
  2. package/THIRD_PARTY_NOTICES.md +9 -0
  3. package/dist/authentication-lifetime.d.ts +16 -0
  4. package/dist/authentication-lifetime.d.ts.map +1 -0
  5. package/dist/authentication-lifetime.js +1 -0
  6. package/dist/binding-projection.d.ts +47 -0
  7. package/dist/binding-projection.d.ts.map +1 -0
  8. package/dist/binding-projection.js +1 -0
  9. package/dist/canonical.js +1 -100
  10. package/dist/clone.js +1 -4
  11. package/dist/commands.d.ts +1 -1
  12. package/dist/commands.d.ts.map +1 -1
  13. package/dist/commands.js +1 -799
  14. package/dist/contextual-session.d.ts +112 -0
  15. package/dist/contextual-session.d.ts.map +1 -0
  16. package/dist/contextual-session.js +1 -0
  17. package/dist/contributions.d.ts +63 -2
  18. package/dist/contributions.d.ts.map +1 -1
  19. package/dist/contributions.js +1 -302
  20. package/dist/deployment-validation.d.ts +10 -0
  21. package/dist/deployment-validation.d.ts.map +1 -0
  22. package/dist/deployment-validation.js +1 -0
  23. package/dist/entry-commands.js +1 -36
  24. package/dist/extension-sdk.d.ts +12 -6
  25. package/dist/extension-sdk.d.ts.map +1 -1
  26. package/dist/extension-sdk.js +1 -188
  27. package/dist/history.d.ts +12 -2
  28. package/dist/history.d.ts.map +1 -1
  29. package/dist/history.js +1 -63
  30. package/dist/host-session.d.ts +93 -0
  31. package/dist/host-session.d.ts.map +1 -0
  32. package/dist/host-session.js +1 -0
  33. package/dist/http-authoring-contract.d.ts +29 -0
  34. package/dist/http-authoring-contract.d.ts.map +1 -0
  35. package/dist/http-authoring-contract.js +1 -0
  36. package/dist/http-host-adapter.d.ts +173 -0
  37. package/dist/http-host-adapter.d.ts.map +1 -0
  38. package/dist/http-host-adapter.js +1 -0
  39. package/dist/index.d.ts +13 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -18
  42. package/dist/layout.d.ts +66 -0
  43. package/dist/layout.d.ts.map +1 -0
  44. package/dist/layout.js +1 -0
  45. package/dist/migrations.js +1 -83
  46. package/dist/model-commands.js +1 -21
  47. package/dist/modes.js +1 -280
  48. package/dist/negotiation.js +1 -65
  49. package/dist/production-values.d.ts +12 -0
  50. package/dist/production-values.d.ts.map +1 -0
  51. package/dist/production-values.js +1 -0
  52. package/dist/production.d.ts +86 -0
  53. package/dist/production.d.ts.map +1 -0
  54. package/dist/production.js +1 -0
  55. package/dist/profile-validator.d.ts.map +1 -1
  56. package/dist/profile-validator.js +1 -887
  57. package/dist/recipes.js +1 -34
  58. package/dist/registry.js +1 -56
  59. package/dist/schema-profile.js +1 -1015
  60. package/dist/semver.js +1 -128
  61. package/dist/session-policy.d.ts +23 -0
  62. package/dist/session-policy.d.ts.map +1 -0
  63. package/dist/session-policy.js +1 -0
  64. package/dist/session.d.ts +14 -2
  65. package/dist/session.d.ts.map +1 -1
  66. package/dist/session.js +1 -178
  67. package/dist/strict-json.d.ts +7 -0
  68. package/dist/strict-json.d.ts.map +1 -0
  69. package/dist/strict-json.js +2 -0
  70. package/dist/url-policy.js +1 -248
  71. package/dist/validation.d.ts.map +1 -1
  72. package/dist/validation.js +1 -398
  73. package/package.json +5 -3
  74. package/dist/canonical.js.map +0 -1
  75. package/dist/clone.js.map +0 -1
  76. package/dist/commands.js.map +0 -1
  77. package/dist/contributions.js.map +0 -1
  78. package/dist/entry-commands.js.map +0 -1
  79. package/dist/extension-sdk.js.map +0 -1
  80. package/dist/history.js.map +0 -1
  81. package/dist/index.js.map +0 -1
  82. package/dist/migrations.js.map +0 -1
  83. package/dist/model-commands.js.map +0 -1
  84. package/dist/modes.js.map +0 -1
  85. package/dist/negotiation.js.map +0 -1
  86. package/dist/profile-validator.js.map +0 -1
  87. package/dist/recipes.js.map +0 -1
  88. package/dist/registry.js.map +0 -1
  89. package/dist/schema-profile.js.map +0 -1
  90. package/dist/semver.js.map +0 -1
  91. package/dist/session.js.map +0 -1
  92. package/dist/url-policy.js.map +0 -1
  93. package/dist/validation.js.map +0 -1
@@ -0,0 +1,173 @@
1
+ import { type HostAdapter, type StudioDeploymentOperationRoute } from '@kumwe/studio-protocol';
2
+ import { type HttpSchemaValidator } from './http-authoring-contract.js';
3
+ /**
4
+ * Minimal structural view of an HTTP response the adapter needs: media type,
5
+ * status code, and raw body text. Deliberately narrower than any platform
6
+ * response class so implementations from any runtime satisfy it. A missing
7
+ * `contentType` models a hostile/invalid response and is rejected.
8
+ */
9
+ export interface HttpResponseLike {
10
+ /** Parsed response Content-Type; omission is a fail-closed invalid response. */
11
+ contentType?: string;
12
+ status: number;
13
+ /**
14
+ * Read at most `maximumBytes` decoded transport bytes. Implementations MUST
15
+ * reject with a reason named `ResponseLimitError` before exceeding it.
16
+ */
17
+ text(maximumBytes: number): Promise<string>;
18
+ }
19
+ /** The request shape the adapter hands to the injected transport. */
20
+ export interface HttpRequestInit {
21
+ body: string;
22
+ /** Browser credential policy. `same-origin` is the secure default. */
23
+ credentials: 'include' | 'omit' | 'same-origin';
24
+ headers: Record<string, string>;
25
+ method: 'POST';
26
+ /** Opaque abort signal produced by the injected timeout factory, if any. */
27
+ signal?: unknown;
28
+ }
29
+ /**
30
+ * The injected fetch-like transport — the adapter's portability seam.
31
+ *
32
+ * Core source is deliberately free of host globals (no fetch, no DOM, no
33
+ * Node), so the embedder supplies the platform transport: a Node test injects
34
+ * a `node:http`-backed implementation while `@kumwe/studio` supplies the
35
+ * browser fetch convenience, and either stays outside this package. The function must
36
+ * resolve with the terminal HTTP response (any status) and reject only for
37
+ * transport-level failures: network refusal, connection loss, or an abort
38
+ * raised by the injected timeout signal.
39
+ */
40
+ export type HttpFetchLike = (url: string, init: HttpRequestInit) => Promise<HttpResponseLike>;
41
+ /**
42
+ * An abort signal handle minted per request by the injected timeout factory.
43
+ * `signal` is passed through to the transport untouched; `release` (when
44
+ * present) is invoked once the request settles so timer-backed factories can
45
+ * clean up.
46
+ */
47
+ export interface HttpTimeoutHandle {
48
+ /**
49
+ * Optional deadline rejection for work which happens before fetch receives
50
+ * the platform signal (notably an asynchronous authentication refresh).
51
+ */
52
+ deadline?: PromiseLike<never>;
53
+ release?(): void;
54
+ signal: unknown;
55
+ }
56
+ /**
57
+ * Exact operation endpoints supplied by the host. Missing entries are
58
+ * unavailable capabilities; the transport never invents a fallback URL.
59
+ */
60
+ export type HttpHostOperationEndpoints = Readonly<Partial<Record<HttpHostOperationRoute, string>>>;
61
+ export type HttpHostRoutingConfiguration = {
62
+ /** Each configured operation is posted to its exact host-owned URL. */
63
+ readonly endpoints: HttpHostOperationEndpoints;
64
+ readonly kind: 'operation-map';
65
+ } | {
66
+ /**
67
+ * Every operation uses one URL. Dispatch is carried only in the fixed
68
+ * `X-Studio-Operation` header; the canonical JSON body is unchanged.
69
+ */
70
+ readonly endpoint: string;
71
+ readonly kind: 'single-endpoint';
72
+ };
73
+ export interface HttpSameOriginSessionAuthentication {
74
+ readonly credentials: 'same-origin';
75
+ readonly csrf: {
76
+ readonly headerName: string;
77
+ readonly token: string;
78
+ };
79
+ readonly kind: 'same-origin-session';
80
+ }
81
+ export interface HttpBearerTokenAuthentication {
82
+ readonly credentials: 'omit';
83
+ /** Closed browser-use window; the server independently verifies the token. */
84
+ readonly expiresAt: string;
85
+ readonly issuedAt: string;
86
+ readonly kind: 'bearer-token';
87
+ readonly token: string;
88
+ }
89
+ export interface HttpHeaderTokenAuthentication {
90
+ readonly credentials: 'omit';
91
+ /** Closed browser-use window; the server independently verifies the token. */
92
+ readonly expiresAt: string;
93
+ readonly headerName: string;
94
+ readonly issuedAt: string;
95
+ readonly kind: 'header-token';
96
+ readonly token: string;
97
+ }
98
+ /** Authentication material has exactly one transport projection. */
99
+ export type HttpAuthenticationConfiguration = HttpBearerTokenAuthentication | HttpHeaderTokenAuthentication | HttpSameOriginSessionAuthentication;
100
+ /** Canonical browser/server deployment input for the HTTP HostAdapter. */
101
+ export interface HttpHostTransportConfiguration {
102
+ readonly authentication: HttpAuthenticationConfiguration;
103
+ readonly kind: 'http';
104
+ readonly maximumResponseBytes?: number;
105
+ readonly requestTimeoutMilliseconds?: number;
106
+ readonly routing: HttpHostRoutingConfiguration;
107
+ }
108
+ export interface HttpAuthenticationRequest {
109
+ /** Stable route only; authentication hooks never receive request content. */
110
+ readonly operation: HttpHostOperationRoute;
111
+ }
112
+ /**
113
+ * JS-only refresh seam. It runs for every call and may return fresh short-lived
114
+ * material. Returning `undefined` retains the static deployment value.
115
+ */
116
+ export type HttpAuthenticationResolver = (request: HttpAuthenticationRequest) => HttpAuthenticationConfiguration | Promise<HttpAuthenticationConfiguration | undefined> | undefined;
117
+ /** Closed route vocabulary implemented by the configured HTTP adapter. */
118
+ export type HttpHostOperationRoute = StudioDeploymentOperationRoute;
119
+ /** Closed route vocabulary accepted in a configured operation map. */
120
+ export declare const HTTP_HOST_OPERATION_ROUTES: readonly HttpHostOperationRoute[];
121
+ export interface HttpHostAdapterOptions {
122
+ /**
123
+ * Second half of the portability seam: mints the per-request timeout
124
+ * signal. When omitted, requests carry no deadline. A rejection whose
125
+ * reason is named `AbortError` or `TimeoutError` is mapped to the canonical
126
+ * deadline failure.
127
+ */
128
+ createTimeoutSignal?: (timeoutMilliseconds: number) => HttpTimeoutHandle;
129
+ /** Deterministic clock used only to refuse expired configured credentials. */
130
+ currentTimeMilliseconds: () => number;
131
+ fetchImplementation: HttpFetchLike;
132
+ /**
133
+ * Produces per-call authentication and CSRF/origin-integrity headers. It is
134
+ * invoked for every attempt so rotated credentials are not captured once.
135
+ * `accept` and `content-type` are transport-owned and cannot be overridden.
136
+ */
137
+ requestHeaders?: () => Readonly<Record<string, string>>;
138
+ /**
139
+ * Resolve or refresh configured authentication for every request. The value
140
+ * is projected only to the declared header and credential policy; Studio
141
+ * never treats it as permission or identity data.
142
+ */
143
+ resolveAuthentication?: HttpAuthenticationResolver;
144
+ /**
145
+ * Optional exact request/result validation. Standalone host integration
146
+ * conformance supplies this callback using the canonical protocol schemas.
147
+ */
148
+ validateSchema?: HttpSchemaValidator;
149
+ }
150
+ /** Explicit alias retained for consumers that emphasize configuration ownership. */
151
+ export type ConfiguredHttpHostAdapterOptions = HttpHostAdapterOptions;
152
+ /**
153
+ * A `HostAdapter` that speaks canonical JSON over an injected fetch-like
154
+ * transport. A deployment provides exact per-operation endpoints or one
155
+ * endpoint selected by the fixed `X-Studio-Operation` header. Production
156
+ * routing is never inferred from a base URL convention.
157
+ *
158
+ * Success responses (2xx) must carry a `HostPortResult` JSON body. Failure
159
+ * responses that carry a guard-conforming `HostPortError` body are re-thrown
160
+ * as that canonical error, so a host-authored category (with its safe
161
+ * revision on conflicts) crosses the transport intact. Everything else is
162
+ * mapped onto the canonical host error categories without disclosing
163
+ * transport details: network refusal and deadline expiry become
164
+ * `unavailable`, HTTP statuses map by class (401 `unauthenticated`, 403
165
+ * `forbidden`, 404 `not-found`, 409 `conflict`, 413 `limit-exceeded`, 422
166
+ * `validation-failed`, 429 `rate-limited`, 5xx `internal`/`unavailable`), and
167
+ * a malformed body — unparseable JSON, a result without `value`, or an error
168
+ * document the guard rejects — becomes `internal`. Every rejection is a
169
+ * canonical `HostPortFailure` whose `error` satisfies `isHostPortError`, and no
170
+ * message ever echoes response bodies, addresses, or underlying reasons.
171
+ */
172
+ export declare function createHttpHostAdapter(configuration: HttpHostTransportConfiguration, options: ConfiguredHttpHostAdapterOptions): HostAdapter;
173
+ //# sourceMappingURL=http-host-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-host-adapter.d.ts","sourceRoot":"","sources":["../src/http-host-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAkBL,KAAK,WAAW,EAmBhB,KAAK,8BAA8B,EAGpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAOnG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B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;CAC5C;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,OAAO,EAAE,yBAAyB,KAEhC,+BAA+B,GAC/B,OAAO,CAAC,+BAA+B,GAAG,SAAS,CAAC,GACpD,SAAS,CAAC;AAEd,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAEpE,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,EAAE,SAAS,sBAAsB,EAgCtE,CAAC;AAEH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,EAAE,MAAM,KAAK,iBAAiB,CAAC;IACzE,8EAA8E;IAC9E,uBAAuB,EAAE,MAAM,MAAM,CAAC;IACtC,mBAAmB,EAAE,aAAa,CAAC;IACnC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;IACnD;;;OAGG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED,oFAAoF;AACpF,MAAM,MAAM,gCAAgC,GAAG,sBAAsB,CAAC;AA4BtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,8BAA8B,EAC7C,OAAO,EAAE,gCAAgC,GACxC,WAAW,CAoZb"}
@@ -0,0 +1 @@
1
+ import{HostPortFailure as e,isHostPortError as t,STUDIO_CONTRACT_VERSION as n}from"@kumwe/studio-protocol";import{AUTHORING_HTTP_OPERATIONS as r}from"./http-authoring-contract.js";import{parseJsonRejectingDuplicateMembers as i}from"./strict-json.js";import{assertStudioTokenLifetime as a,isAuthenticationLifetimeFailure as o}from"./authentication-lifetime.js";export const HTTP_HOST_OPERATION_ROUTES=Object.freeze(`artifact/dependencies.artifact/load.artifact/publish.artifact/save.artifact/unpublish.authoring/list-types.authoring/plan-save.authoring/resolve-target.authoring/save-as-new-type.authoring/save-item.authoring/save-new-type-version.authoring/start.localization/messages.media/abort-upload.media/authorize-upload.media/complete-upload.media/get.media/import-external.media/list.media/upload-status.model/get.model/list.permission/explain.permission/refresh.preview/cancel.preview/render.recovery/discard.recovery/load.recovery/store.resource/search.telemetry/emit`.split(`.`));export function createHttpHostAdapter(i,a){let s=M(i,a),c=0;function v(t){c+=1;let r={category:t.category,contractVersion:n,correlationId:`http-transport-${c}`,kind:`host-error`,message:{defaultMessage:t.defaultMessage,key:t.key},retryable:t.retryable};return new e(r)}async function y(n,r,i,c,u=`https://schemas.kumwe.org/studio/v1/host-request.schema.json`,y=`https://schemas.kumwe.org/studio/v1/host-result.schema.json`){let M=`${n}/${r}`,N=s.resolveTarget(M);if(N===void 0)throw v(T());let P={arguments:i,context:c};if(a.validateSchema!==void 0){let e;try{e=a.validateSchema(u,P)}catch{throw v(E())}if(!e)throw v(S())}let F;try{F=JSON.stringify(P)}catch{throw v(S())}let I;try{I=a.createTimeoutSignal?.(s.timeoutMilliseconds)}catch{throw v(D())}try{let n;if(a.resolveAuthentication!==void 0)try{n=await _(Promise.resolve().then(()=>a.resolveAuthentication?.({operation:M})),I)}catch(e){throw v(h(e)?m(e):C())}let r,i;try{let e=n??s.authentication,t=e?.kind===`same-origin-session`?void 0:s.currentTimeMilliseconds?.();if(t!==void 0&&!Number.isFinite(t))throw TypeError(`The configured transport clock returned an invalid time.`);r=e===void 0?void 0:R(e,t),i=H(r?.headers,a.requestHeaders?.(),N.operationHeader)}catch(e){throw v(o(e)?w():S())}let c;try{c=await _(a.fetchImplementation(N.url,{body:F,credentials:r?.credentials??s.credentials,headers:i,method:`POST`,...I===void 0?{}:{signal:I.signal}}),I)}catch(e){throw v(g(e)?S():m(e))}if(c.contentType===void 0||!j(c.contentType))throw v(x());let u;try{u=await _(c.text(s.maximumResponseBytes),I)}catch(e){throw v(A(e)?O():h(e)?m(e):x())}if(K(u)>s.maximumResponseBytes)throw v(O());if(c.status>=200&&c.status<300){let e=d(u);if(!p(e)||a.validateSchema!==void 0&&!k(a.validateSchema,y,e))throw v(x());return{...e.revision===void 0?{}:{revision:e.revision},value:e.value}}let b=d(u);throw t(b)?f(b)?new e(b):v(x()):l(b)?v(x()):v(q(c.status))}finally{b(I)}}return{artifact:{dependencies(e,t){return y(`artifact`,`dependencies`,{reference:u(e)},t)},load(e,t){return y(`artifact`,`load`,{reference:u(e)},t)},publish(e,t){return y(`artifact`,`publish`,{reference:u(e)},t)},save(e,t){return y(`artifact`,`save`,{document:u(e)},t)},unpublish(e,t){return y(`artifact`,`unpublish`,{reference:u(e)},t)}},authoring:{listTypes(e,t){return y(`authoring`,`list-types`,{query:u(e)},t,r.listTypes.requestSchema,r.listTypes.responseSchema)},planSave(e,t){return y(`authoring`,`plan-save`,{intent:u(e)},t,r.planSave.requestSchema,r.planSave.responseSchema)},resolveTarget(e,t){return y(`authoring`,`resolve-target`,{request:u(e)},t,r.resolveTarget.requestSchema,r.resolveTarget.responseSchema)},saveAsNewType(e,t){return y(`authoring`,`save-as-new-type`,{request:u(e)},t,r.saveAsNewType.requestSchema,r.saveAsNewType.responseSchema)},saveItem(e,t){return y(`authoring`,`save-item`,{request:u(e)},t,r.saveItem.requestSchema,r.saveItem.responseSchema)},saveNewTypeVersion(e,t){return y(`authoring`,`save-new-type-version`,{request:u(e)},t,r.saveNewTypeVersion.requestSchema,r.saveNewTypeVersion.responseSchema)},start(e,t){return y(`authoring`,`start`,{request:u(e)},t,r.start.requestSchema,r.start.responseSchema)}},localization:{messages(e,t,n){return y(`localization`,`messages`,{locale:e,namespaces:t},n)}},media:{abortUpload(e,t){return y(`media`,`abort-upload`,{uploadId:e},t)},authorizeUpload(e,t){return y(`media`,`authorize-upload`,{request:u(e)},t)},completeUpload(e,t){return y(`media`,`complete-upload`,{uploadId:e},t)},get(e,t){return y(`media`,`get`,{assetId:e},t)},importExternal(e,t){return y(`media`,`import-external`,{url:e},t)},list(e,t){return y(`media`,`list`,{query:u(e)},t)},uploadStatus(e,t){return y(`media`,`upload-status`,{assetId:e},t)}},model:{get(e,t){return y(`model`,`get`,{reference:u(e)},t)},list(e){return y(`model`,`list`,{},e)}},permission:{explain(e,t){return y(`permission`,`explain`,{operation:e},t)},refresh(e){return y(`permission`,`refresh`,{},e)}},preview:{cancel(e,t){return y(`preview`,`cancel`,{draftDigest:e},t)},render(e,t){return y(`preview`,`render`,{payload:u(e)},t)}},recovery:{discard(e){return y(`recovery`,`discard`,{},e)},load(e){return y(`recovery`,`load`,{},e)},store(e,t){return y(`recovery`,`store`,{envelope:e},t)}},resource:{search(e,t){return y(`resource`,`search`,{query:u(e)},t)}},telemetry:{emit(e,t){return y(`telemetry`,`emit`,{event:u(e)},t)}}}}function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.kind===`host-error`}function u(e){return JSON.parse(JSON.stringify(e))}function d(e){try{return i(e,64)}catch{return}}function f(e){return e.revision!==void 0&&e.category!==`conflict`?!1:e.retryAfterMilliseconds===void 0||e.retryable&&(e.category===`rate-limited`||e.category===`unavailable`)}function p(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;if(!Object.hasOwn(t,`value`))return!1;let n=t.revision;return n!==void 0&&(typeof n!=`string`||n.length===0)?!1:Object.keys(t).every(e=>e===`value`||e===`revision`)}function m(e){return h(e)?{category:`unavailable`,defaultMessage:`The host did not respond within the transport deadline.`,key:`studio.transport/http-timeout`,retryable:!0}:{category:`unavailable`,defaultMessage:`The host could not be reached.`,key:`studio.transport/http-unreachable`,retryable:!0}}function h(e){let t=typeof e==`object`&&e&&`name`in e?e.name:void 0;return t===`AbortError`||t===`TimeoutError`}function g(e){return(typeof e==`object`&&e&&`name`in e?e.name:void 0)===`InvalidRequestError`}async function _(e,t){if(t?.deadline!==void 0)return Promise.race([Promise.resolve(e),Promise.resolve(t.deadline)]);let n=v(t?.signal);if(n===void 0)return e;if(n.aborted)throw y(n.reason);let r=()=>void 0,i=new Promise((e,t)=>{r=()=>t(y(n.reason)),n.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([Promise.resolve(e),i])}finally{n.removeEventListener(`abort`,r)}}function v(e){if(!(typeof e!=`object`||!e||!(`aborted`in e)||typeof e.aborted!=`boolean`||!(`addEventListener`in e)||typeof e.addEventListener!=`function`||!(`removeEventListener`in e)||typeof e.removeEventListener!=`function`))return e}function y(e){if(h(e))return e;let t=Error(`The Studio host request exceeded its deadline.`);return t.name=`TimeoutError`,t}function b(e){try{e?.release?.()}catch{}}function x(){return{category:`internal`,defaultMessage:`The host response could not be interpreted.`,key:`studio.transport/http-malformed-response`,retryable:!1}}function S(){return{category:`invalid-request`,defaultMessage:`The Studio request does not match the host transport contract.`,key:`studio.transport/http-invalid-request`,retryable:!1}}function C(){return{category:`unavailable`,defaultMessage:`The request authentication material could not be refreshed.`,key:`studio.transport/http-authentication-unavailable`,retryable:!0}}function w(){return{category:`unauthenticated`,defaultMessage:`The configured request authentication material is not currently valid.`,key:`studio.transport/http-authentication-invalid-lifetime`,retryable:!1}}function T(){return{category:`incompatible`,defaultMessage:`The requested host operation has no configured transport route.`,key:`studio.transport/http-route-unavailable`,retryable:!1}}function E(){return{category:`internal`,defaultMessage:`The Studio transport schema validator failed.`,key:`studio.transport/http-schema-validator-failed`,retryable:!1}}function D(){return{category:`internal`,defaultMessage:`The Studio transport deadline could not be initialized.`,key:`studio.transport/http-timeout-factory-failed`,retryable:!1}}function O(){return{category:`limit-exceeded`,defaultMessage:`The host response exceeds the configured transport limit.`,key:`studio.transport/http-response-too-large`,retryable:!1}}function k(e,t,n){try{return e(t,n)}catch{return!1}}function A(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`ResponseLimitError`}function j(e){return e.split(`;`,1)[0]?.trim().toLowerCase()===`application/json`}function M(e,t){if(e.kind!==`http`)throw TypeError(`A canonical HTTP transport configuration is required.`);F(e,[`authentication`,`kind`,`maximumResponseBytes`,`requestTimeoutMilliseconds`,`routing`],`HTTP transport configuration`);let n=e.requestTimeoutMilliseconds??1e4,r=e.maximumResponseBytes??67108864;if(P(n,100,12e4,`requestTimeoutMilliseconds`),P(r,1024,67108864,`maximumResponseBytes`),typeof t.currentTimeMilliseconds!=`function`)throw TypeError(`Configured HTTP transports require an injected deterministic clock.`);return{authentication:z(e.authentication),credentials:`omit`,currentTimeMilliseconds:t.currentTimeMilliseconds,maximumResponseBytes:r,resolveTarget:N(e.routing),timeoutMilliseconds:n}}function N(e){if(typeof e!=`object`||!e)throw TypeError(`A canonical HTTP routing configuration is required.`);if(e.kind===`single-endpoint`){F(e,[`endpoint`,`kind`],`single-endpoint routing`);let t=I(e.endpoint,`routing.endpoint`);return e=>({operationHeader:e,url:t})}if(e.kind!==`operation-map`)throw TypeError(`Unknown HTTP routing configuration.`);if(F(e,[`endpoints`,`kind`],`operation-map routing`),typeof e.endpoints!=`object`||e.endpoints===null)throw TypeError(`routing.endpoints must be an object.`);let t={},n=new Set(HTTP_HOST_OPERATION_ROUTES);for(let[r,i]of Object.entries(e.endpoints)){if(!n.has(r))throw TypeError(`routing.endpoints contains an unknown operation.`);t[r]=I(i,`routing.endpoints.${r}`)}return e=>{let n=t[e];return n===void 0?void 0:{url:n}}}function P(e,t,n,r){if(!Number.isSafeInteger(e)||e<t||e>n)throw TypeError(`${r} must be a safe integer from ${t} through ${n}.`)}function F(e,t,n){let r=new Set(t);if(Object.keys(e).some(e=>!r.has(e)))throw TypeError(`${n} contains an unknown member.`)}function I(e,t){if(typeof e!=`string`||e.length===0||e.length>2048||e.trim()!==e||/\s/u.test(e)||e.includes(`#`)||e.includes(`\\`))throw TypeError(`${t} must be an exact HTTP(S) URL reference without whitespace or a fragment.`);let n=e.indexOf(`?`),r=n===-1?e:e.slice(0,n);if(r.length===0)throw TypeError(`${t} must contain a non-empty HTTP endpoint path.`);let i;if(r.startsWith(`https://`)||r.startsWith(`http://`)){let e=r.indexOf(`://`)+3,n=r.indexOf(`/`,e);L(n===-1?r.slice(e):r.slice(e,n),t),i=n===-1?``:r.slice(n)}else{if(r.startsWith(`//`)||/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(r))throw TypeError(`${t} must be an HTTP(S) URL or a same-origin path.`);i=r}if(i.includes(`//`)||/%(?:2f|5c)/iu.test(i))throw TypeError(`${t} path must not contain ambiguous separators.`);for(let e of i.split(`/`)){let n=e.replaceAll(/%2e/giu,`.`);if(n===`.`||n===`..`)throw TypeError(`${t} path must not contain dot segments.`)}return e}function L(e,t){if(e.length===0||e!==e.toLowerCase()||e.includes(`@`)||e.includes(`%`)||e.endsWith(`.`))throw TypeError(`${t} must contain one canonical host without embedded credentials.`);let n=/^(\[[0-9a-f:.]+\])(?::([0-9]+))?$/u.exec(e),r=/^([a-z0-9](?:[a-z0-9.-]*[a-z0-9])?)(?::([0-9]+))?$/u.exec(e),i=n??r;if(i===null||r?.[1]?.includes(`..`)===!0)throw TypeError(`${t} must contain a canonical HTTP host.`);let a=i[2];if(a!==void 0&&(a!==String(Number(a))||Number(a)<1||Number(a)>65535))throw TypeError(`${t} must contain a canonical HTTP port.`)}function R(e,t){if(typeof e!=`object`||!e)throw TypeError(`A canonical HTTP authentication configuration is required.`);let n,r,i;switch(e.kind){case`same-origin-session`:if(F(e,[`credentials`,`csrf`,`kind`],`same-origin session authentication`),e.credentials!==`same-origin`||typeof e.csrf!=`object`||e.csrf===null)throw TypeError(`Invalid same-origin session authentication configuration.`);F(e.csrf,[`headerName`,`token`],`CSRF configuration`),n=`same-origin`,r=V(e.csrf.headerName,`csrf.headerName`),i=B(e.csrf.token,4096,`csrf.token`);break;case`bearer-token`:if(F(e,[`credentials`,`expiresAt`,`issuedAt`,`kind`,`token`],`bearer-token authentication`),e.credentials!==`omit`)throw TypeError(`Bearer authentication must omit ambient credentials.`);a(e,t),n=`omit`,r=`authorization`,i=`Bearer ${B(e.token,8192,`authentication.token`)}`;break;case`header-token`:if(F(e,[`credentials`,`expiresAt`,`headerName`,`issuedAt`,`kind`,`token`],`header-token authentication`),e.credentials!==`omit`)throw TypeError(`Header-token authentication must omit ambient credentials.`);a(e,t),n=`omit`,r=V(e.headerName,`authentication.headerName`),i=B(e.token,8192,`authentication.token`);break;default:throw TypeError(`Unknown HTTP authentication configuration.`)}let o={};return U(o,{[r]:i}),{credentials:n,headers:o}}function z(e){switch(R(e),e.kind){case`same-origin-session`:{let t=e.csrf.token;return{credentials:`same-origin`,csrf:{headerName:e.csrf.headerName,token:t},kind:`same-origin-session`}}case`bearer-token`:{let t=e.token;return{credentials:`omit`,expiresAt:e.expiresAt,issuedAt:e.issuedAt,kind:`bearer-token`,token:t}}case`header-token`:{let t=e.token;return{credentials:`omit`,expiresAt:e.expiresAt,headerName:e.headerName,issuedAt:e.issuedAt,kind:`header-token`,token:t}}}}function B(e,t,n){if(typeof e!=`string`||e.length===0||e.length>t||/\s/u.test(e)||W(e))throw TypeError(`${n} must be one bounded HTTP ByteString token.`);return e}function V(e,t){if(typeof e!=`string`)throw TypeError(`${t} must be a safe custom HTTP field name.`);let n=e.toLowerCase();if(e.length>100||!/^[!#$%&'*+.^_`|~0-9a-z-]+$/u.test(n)||n===`accept`||n===`authorization`||n===`content-type`||n===`x-studio-operation`||!G(n))throw TypeError(`${t} must be a safe custom HTTP field name.`);return e}function H(e,t,n){let r={};if(U(r,e),U(r,t),n!==void 0){if(Object.hasOwn(r,`x-studio-operation`))throw TypeError(`Transport-owned HTTP headers cannot be overridden.`);r[`x-studio-operation`]=n}return r.accept=`application/json`,r[`content-type`]=`application/json`,r}function U(e,t){let n=Object.entries(t??{});if(n.length>100)throw TypeError(`Too many HTTP request headers.`);for(let[t,r]of n){let n=t.toLowerCase();if(t.length>100||!/^[!#$%&'*+.^_`|~0-9a-z-]+$/u.test(n)||typeof r!=`string`||r.length>8192||r.trim()!==r||W(r)||!G(n))throw TypeError(`Invalid HTTP request header.`);if(n===`accept`||n===`content-type`||n===`x-studio-operation`)throw TypeError(`Transport-owned HTTP headers cannot be overridden.`);if(Object.hasOwn(e,n))throw TypeError(`Duplicate HTTP request header.`);e[n]=r}}function W(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n<=8||n>=10&&n<=31||n===127||n>255)return!0}return!1}function G(e){if(e.startsWith(`proxy-`)||e.startsWith(`sec-`)||e.startsWith(`access-control-`)||e===`forwarded`||e.startsWith(`x-forwarded-`))return!1;switch(e){case`connection`:case`content-length`:case`cookie`:case`date`:case`expect`:case`host`:case`keep-alive`:case`origin`:case`referer`:case`set-cookie`:case`te`:case`trailer`:case`transfer-encoding`:case`upgrade`:case`user-agent`:case`via`:return!1;default:return!0}}function K(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=e<=127?1:e<=2047?2:e<=65535?3:4}return t}function q(e){let t=J(e);return{category:t,defaultMessage:`The host rejected the request.`,key:`studio.transport/http-status-${t}`,retryable:t===`rate-limited`||t===`unavailable`}}function J(e){switch(e){case 401:return`unauthenticated`;case 403:return`forbidden`;case 404:return`not-found`;case 408:return`unavailable`;case 409:return`conflict`;case 413:return`limit-exceeded`;case 422:return`validation-failed`;case 429:return`rate-limited`;case 502:case 503:case 504:return`unavailable`;default:return e>=400&&e<500?`invalid-request`:`internal`}}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,19 @@
1
1
  export { canonicalStringify, canonicalUtf8Bytes, type CanonicalSerializationOptions, } from './canonical.js';
2
+ export { projectBlueprintFieldBindings, type BlueprintFieldBindingProjection, type FieldBindingCandidate, type FieldBindingPortProjection, type FieldBindingProjectionStatus, type NodeFieldBindingProjection, } from './binding-projection.js';
3
+ export { isAuthoringSaveIntent, isAuthoringSessionSnapshot, openContextualStudioSession, preflightContextualStudioSession, type OpenContextualStudioSessionOptions, type PreflightContextualStudioSessionOptions, type StudioContextualArtifactStateVersions, type StudioContextualDirtyArtifacts, type StudioContextualHostSessionHandle, type StudioContextualPreflightHandle, type StudioContextualSaveIntentOptions, type StudioContextualSession, type StudioContextualTypeCatalog, } from './contextual-session.js';
4
+ export { assertStudioDeploymentConfiguration, validateStudioDeploymentConfiguration, } from './deployment-validation.js';
5
+ export { assertStudioTokenLifetime, isAuthenticationLifetimeFailure, isStudioTokenLifetimeValid, STUDIO_TOKEN_MAXIMUM_LIFETIME_MILLISECONDS, type StudioTokenLifetime, } from './authentication-lifetime.js';
2
6
  export { applyCommand, invertCommand, StudioCommandError, type InverseCommandOptions, type StudioCommandErrorCode, } from './commands.js';
3
- export { ContributionRuntime, RegistryGeneration, StudioContributionError, type ExtensionContributions, type ExtensionInventory, type GenerationOptions, type UnresolvedNodeReport, } from './contributions.js';
7
+ export { ContributionRuntime, RegistryGeneration, StudioContributionError, type ExtensionContributions, type ExtensionInventory, type GenerationOptions, type AuthoringTargetRuntimeOptions, type ResolvedAuthoringTarget, type StudioCompositionContribution, type StudioCompositionContributionKind, type StudioLifecycleContribution, type StudioLifecycleContributionKind, type UnresolvedNodeReport, } from './contributions.js';
4
8
  export { activateStudioPlugin, defineStudioPlugin, unresolvedDeclaredContributions, type StudioPluginDefinition, } from './extension-sdk.js';
5
9
  export { applyEntryCommand } from './entry-commands.js';
6
10
  export { StudioHistory } from './history.js';
11
+ export { CORE_LAYOUT_BLOCK_TYPES, CORE_LAYOUT_THEME_CONTROLS, CoreLayoutError, coreLayoutInitialProperties, createCoreLayoutBlockDefinitions, isCoreLayoutBlockType, resolveCoreLayoutIntent, type CoreLayoutAlignment, type CoreLayoutBlockDefinitionOptions, type CoreLayoutBlockType, type CoreLayoutCollapse, type CoreLayoutDirection, type CoreLayoutErrorCode, type CoreLayoutIntent, type CoreLayoutPropertyResolution, type CoreLayoutSpacing, type CoreLayoutVisibility, } from './layout.js';
12
+ export { CORE_PRODUCTION_BLOCK_TYPES, CORE_PRODUCTION_CONTROL_IDS, CORE_PRODUCTION_PATTERN_IDS, coreProductionInitialProperties, createCoreProductionBlockDefinitions, createCoreProductionPatterns, isCoreProductionBlockType, type CoreProductionBlockTypeMap, type CoreProductionControlIdMap, type CoreProductionBlockType, } from './production.js';
13
+ export { parseStudioChartSpec, parseStudioDrawingDocument, parseStudioMoneyValue, parseStudioPresentationIntent, parseStudioTableDocument, } from './production-values.js';
14
+ export { openStudioSession, STUDIO_RESOURCE_SEARCH_LIMITS, StudioHostSessionError, type OpenStudioSessionOptions, type StudioHostSessionErrorCode, type StudioHostSessionHandle, type StudioHostSessionIdentifierFactories, type StudioHostSessionModels, type StudioHostSessionRecovery, type StudioHostSessionResources, } from './host-session.js';
15
+ export { AUTHORING_HTTP_OPERATIONS, AUTHORING_HTTP_OPERATIONS_BY_ROUTE, AUTHORING_HTTP_SCHEMA_ID, type AuthoringHttpOperationContract, type AuthoringHttpOperationRegistry, type AuthoringHttpRoute, type HttpSchemaValidator, } from './http-authoring-contract.js';
16
+ export { createHttpHostAdapter, HTTP_HOST_OPERATION_ROUTES, type ConfiguredHttpHostAdapterOptions, type HttpAuthenticationConfiguration, type HttpAuthenticationRequest, type HttpAuthenticationResolver, type HttpBearerTokenAuthentication, type HttpFetchLike, type HttpHeaderTokenAuthentication, type HttpHostAdapterOptions, type HttpHostOperationEndpoints, type HttpHostOperationRoute, type HttpHostRoutingConfiguration, type HttpHostTransportConfiguration, type HttpRequestInit, type HttpResponseLike, type HttpSameOriginSessionAuthentication, type HttpTimeoutHandle, } from './http-host-adapter.js';
7
17
  export { applyModelCommand } from './model-commands.js';
8
18
  export { permittedCommandTypes, resolveSessionMode, STUDIO_SESSION_MODES, type StudioCommandType, } from './modes.js';
9
19
  export { RECIPE_MARKER_PROPERTY, recipeSelectionOperations } from './recipes.js';
@@ -11,6 +21,8 @@ export { MigrationRunner, StudioMigrationError, type MigratableArtifactKind, typ
11
21
  export { negotiateCapabilities, type CapabilityNegotiationOptions, type CapabilityNegotiationResult, } from './negotiation.js';
12
22
  export { compareSemanticVersions, normalizeVersionRange, parseSemanticVersion, satisfiesVersionRange, type ParsedSemanticVersion, } from './semver.js';
13
23
  export { StudioSession, type StudioSessionOptions } from './session.js';
24
+ export { assertBlueprintWithinSessionPolicy, assertEntryWithinSessionPolicy, assertModelWithinSessionPolicy, STUDIO_PROTOCOL_MAXIMUM_COMMAND_POLICY_LIMITS, type StudioCommandPolicyLimits, type StudioSessionPolicyOptions, } from './session-policy.js';
25
+ export { parseJsonRejectingDuplicateMembers } from './strict-json.js';
14
26
  export { BlockRegistry, type BlockRegistrationOptions, type ResolvedBlockRegistration, } from './registry.js';
15
27
  export { assertStudioPropertySchema, compileStudioPropertySchema, STUDIO_SCHEMA_PROFILE_ERROR_CODES, STUDIO_SCHEMA_PROFILE_LIMITS, StudioSchemaProfileError, type StudioPropertySchemaValidator, type StudioSchemaProfileErrorCode, } from './schema-profile.js';
16
28
  export { STUDIO_DEFAULT_URL_POLICY, validateExternalUrl, type ExternalUrlPolicy, type ExternalUrlRejectionReason, type ExternalUrlValidationResult, } from './url-policy.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,6BAA6B,GACnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,+BAA+B,EAC/B,KAAK,sBAAsB,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,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KAAK,6BAA6B,EAClC,KAAK,4BAA4B,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,GACjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,GAC/B,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,18 +1 @@
1
- export { canonicalStringify, canonicalUtf8Bytes, } from './canonical.js';
2
- export { applyCommand, invertCommand, StudioCommandError, } from './commands.js';
3
- export { ContributionRuntime, RegistryGeneration, StudioContributionError, } from './contributions.js';
4
- export { activateStudioPlugin, defineStudioPlugin, unresolvedDeclaredContributions, } from './extension-sdk.js';
5
- export { applyEntryCommand } from './entry-commands.js';
6
- export { StudioHistory } from './history.js';
7
- export { applyModelCommand } from './model-commands.js';
8
- export { permittedCommandTypes, resolveSessionMode, STUDIO_SESSION_MODES, } from './modes.js';
9
- export { RECIPE_MARKER_PROPERTY, recipeSelectionOperations } from './recipes.js';
10
- export { MigrationRunner, StudioMigrationError, } from './migrations.js';
11
- export { negotiateCapabilities, } from './negotiation.js';
12
- export { compareSemanticVersions, normalizeVersionRange, parseSemanticVersion, satisfiesVersionRange, } from './semver.js';
13
- export { StudioSession } from './session.js';
14
- export { BlockRegistry, } from './registry.js';
15
- export { assertStudioPropertySchema, compileStudioPropertySchema, STUDIO_SCHEMA_PROFILE_ERROR_CODES, STUDIO_SCHEMA_PROFILE_LIMITS, StudioSchemaProfileError, } from './schema-profile.js';
16
- export { STUDIO_DEFAULT_URL_POLICY, validateExternalUrl, } from './url-policy.js';
17
- export { validateBlueprint, } from './validation.js';
18
- //# sourceMappingURL=index.js.map
1
+ export{canonicalStringify,canonicalUtf8Bytes}from"./canonical.js";export{projectBlueprintFieldBindings}from"./binding-projection.js";export{isAuthoringSaveIntent,isAuthoringSessionSnapshot,openContextualStudioSession,preflightContextualStudioSession}from"./contextual-session.js";export{assertStudioDeploymentConfiguration,validateStudioDeploymentConfiguration}from"./deployment-validation.js";export{assertStudioTokenLifetime,isAuthenticationLifetimeFailure,isStudioTokenLifetimeValid,STUDIO_TOKEN_MAXIMUM_LIFETIME_MILLISECONDS}from"./authentication-lifetime.js";export{applyCommand,invertCommand,StudioCommandError}from"./commands.js";export{ContributionRuntime,RegistryGeneration,StudioContributionError}from"./contributions.js";export{activateStudioPlugin,defineStudioPlugin,unresolvedDeclaredContributions}from"./extension-sdk.js";export{applyEntryCommand}from"./entry-commands.js";export{StudioHistory}from"./history.js";export{CORE_LAYOUT_BLOCK_TYPES,CORE_LAYOUT_THEME_CONTROLS,CoreLayoutError,coreLayoutInitialProperties,createCoreLayoutBlockDefinitions,isCoreLayoutBlockType,resolveCoreLayoutIntent}from"./layout.js";export{CORE_PRODUCTION_BLOCK_TYPES,CORE_PRODUCTION_CONTROL_IDS,CORE_PRODUCTION_PATTERN_IDS,coreProductionInitialProperties,createCoreProductionBlockDefinitions,createCoreProductionPatterns,isCoreProductionBlockType}from"./production.js";export{parseStudioChartSpec,parseStudioDrawingDocument,parseStudioMoneyValue,parseStudioPresentationIntent,parseStudioTableDocument}from"./production-values.js";export{openStudioSession,STUDIO_RESOURCE_SEARCH_LIMITS,StudioHostSessionError}from"./host-session.js";export{AUTHORING_HTTP_OPERATIONS,AUTHORING_HTTP_OPERATIONS_BY_ROUTE,AUTHORING_HTTP_SCHEMA_ID}from"./http-authoring-contract.js";export{createHttpHostAdapter,HTTP_HOST_OPERATION_ROUTES}from"./http-host-adapter.js";export{applyModelCommand}from"./model-commands.js";export{permittedCommandTypes,resolveSessionMode,STUDIO_SESSION_MODES}from"./modes.js";export{RECIPE_MARKER_PROPERTY,recipeSelectionOperations}from"./recipes.js";export{MigrationRunner,StudioMigrationError}from"./migrations.js";export{negotiateCapabilities}from"./negotiation.js";export{compareSemanticVersions,normalizeVersionRange,parseSemanticVersion,satisfiesVersionRange}from"./semver.js";export{StudioSession}from"./session.js";export{assertBlueprintWithinSessionPolicy,assertEntryWithinSessionPolicy,assertModelWithinSessionPolicy,STUDIO_PROTOCOL_MAXIMUM_COMMAND_POLICY_LIMITS}from"./session-policy.js";export{parseJsonRejectingDuplicateMembers}from"./strict-json.js";export{BlockRegistry}from"./registry.js";export{assertStudioPropertySchema,compileStudioPropertySchema,STUDIO_SCHEMA_PROFILE_ERROR_CODES,STUDIO_SCHEMA_PROFILE_LIMITS,StudioSchemaProfileError}from"./schema-profile.js";export{STUDIO_DEFAULT_URL_POLICY,validateExternalUrl}from"./url-policy.js";export{validateBlueprint}from"./validation.js";
@@ -0,0 +1,66 @@
1
+ import { type BlockDefinition, type BlockType, type BlueprintNode, type JsonObject, type LocalName, type RendererRequirement, type ThemeDocument, type ThemeViewport } from '@kumwe/studio-protocol';
2
+ /** The portable layout block family shipped by Studio. */
3
+ export declare const CORE_LAYOUT_BLOCK_TYPES: Readonly<{
4
+ columns: 'studio.core/columns';
5
+ grid: 'studio.core/grid';
6
+ section: 'studio.core/section';
7
+ stack: 'studio.core/stack';
8
+ }>;
9
+ export type CoreLayoutBlockType = (typeof CORE_LAYOUT_BLOCK_TYPES)[keyof typeof CORE_LAYOUT_BLOCK_TYPES];
10
+ /** Canonical theme-control identifiers understood by every core layout block. */
11
+ export declare const CORE_LAYOUT_THEME_CONTROLS: Readonly<{
12
+ alignment: 'layout-alignment';
13
+ collapse: 'layout-collapse';
14
+ direction: 'layout-direction';
15
+ spacing: 'layout-spacing';
16
+ visibility: 'layout-visibility';
17
+ }>;
18
+ export type CoreLayoutAlignment = 'center' | 'end' | 'start' | 'stretch';
19
+ export type CoreLayoutCollapse = 'preserve' | 'stack' | 'wrap';
20
+ export type CoreLayoutDirection = 'block' | 'inline';
21
+ export type CoreLayoutSpacing = 'comfortable' | 'compact' | 'none' | 'spacious';
22
+ export type CoreLayoutVisibility = 'hidden' | 'visible';
23
+ export interface CoreLayoutBlockDefinitionOptions {
24
+ /** Additional host block types admitted into every composable layout slot. */
25
+ acceptedChildTypes?: readonly BlockType[];
26
+ /** Trusted renderer capabilities required for this definition family. */
27
+ rendererRequirements?: readonly RendererRequirement[];
28
+ }
29
+ export interface CoreLayoutPropertyResolution<T> {
30
+ source: 'base' | 'default' | 'viewport';
31
+ value: T;
32
+ viewport?: LocalName;
33
+ }
34
+ export interface CoreLayoutIntent {
35
+ alignment: CoreLayoutPropertyResolution<CoreLayoutAlignment>;
36
+ collapse?: CoreLayoutPropertyResolution<CoreLayoutCollapse>;
37
+ columns?: CoreLayoutPropertyResolution<number>;
38
+ direction?: CoreLayoutPropertyResolution<CoreLayoutDirection>;
39
+ spacing: CoreLayoutPropertyResolution<CoreLayoutSpacing>;
40
+ visibility: CoreLayoutPropertyResolution<CoreLayoutVisibility>;
41
+ }
42
+ export type CoreLayoutErrorCode = 'invalid-layout-property' | 'theme-choice-missing' | 'theme-control-missing' | 'unsupported-layout-block' | 'viewport-missing';
43
+ /** Stable fail-closed error for renderer and authoring layout resolution. */
44
+ export declare class CoreLayoutError extends Error {
45
+ readonly code: CoreLayoutErrorCode;
46
+ constructor(code: CoreLayoutErrorCode, message: string);
47
+ }
48
+ /** True only for the four canonical Studio layout block types. */
49
+ export declare function isCoreLayoutBlockType(type: BlockType): type is CoreLayoutBlockType;
50
+ /**
51
+ * Creates the canonical section, stack, grid, and columns definitions. The
52
+ * family owns its bounded semantic properties while the host explicitly adds
53
+ * content block types and trusted renderer capabilities; no wildcard slot or
54
+ * renderer authority is invented.
55
+ */
56
+ export declare function createCoreLayoutBlockDefinitions(options?: Readonly<CoreLayoutBlockDefinitionOptions>): BlockDefinition[];
57
+ /** Minimal persisted properties for a newly inserted core layout node. */
58
+ export declare function coreLayoutInitialProperties(type: CoreLayoutBlockType): JsonObject;
59
+ /**
60
+ * Resolves one layout node for a named theme viewport. Responsive values use
61
+ * the active viewport override when present and otherwise inherit the base
62
+ * value, with defaults remaining runtime semantics rather than stored noise.
63
+ * Every token reference must be declared by the active theme.
64
+ */
65
+ export declare function resolveCoreLayoutIntent(node: Readonly<BlueprintNode>, viewport: Readonly<ThemeViewport>, theme: Readonly<ThemeDocument>): CoreLayoutIntent;
66
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAGhC,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC;IAC7C,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAKC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAEzE,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC;IAChD,SAAS,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,mBAAmB,CAAC;CACjC,CAMC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AACzE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAC/D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,CAAC;AACrD,MAAM,MAAM,iBAAiB,GAAG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gCAAgC,CAAM,GACvD,eAAe,EAAE,CAkBnB;AAED,0EAA0E;AAC1E,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,mBAAmB,GAAG,UAAU,CAUjF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC7B,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,EACjC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,gBAAgB,CAmElB"}
package/dist/layout.js ADDED
@@ -0,0 +1 @@
1
+ import{STUDIO_CONTRACT_VERSION as e}from"@kumwe/studio-protocol";import{cloneContractValue as t}from"./clone.js";export const CORE_LAYOUT_BLOCK_TYPES=Object.freeze({columns:`studio.core/columns`,grid:`studio.core/grid`,section:`studio.core/section`,stack:`studio.core/stack`});export const CORE_LAYOUT_THEME_CONTROLS=Object.freeze({alignment:`layout-alignment`,collapse:`layout-collapse`,direction:`layout-direction`,spacing:`layout-spacing`,visibility:`layout-visibility`});export class CoreLayoutError extends Error{code;constructor(e,t){super(t),this.name=`CoreLayoutError`,this.code=e}}const a=Object.freeze([{capability:`studio.renderer/layout`,surface:`preview`,versions:`^1.0.0`},{capability:`studio.renderer/layout`,surface:`web`,versions:`^1.0.0`}]),o=[`center`,`end`,`start`,`stretch`],s=[`preserve`,`stack`,`wrap`],c=[`block`,`inline`],l=[`comfortable`,`compact`,`none`,`spacious`],u=[`hidden`,`visible`];export function isCoreLayoutBlockType(e){return Object.values(CORE_LAYOUT_BLOCK_TYPES).includes(e)}export function createCoreLayoutBlockDefinitions(e={}){let r=g([...Object.values(CORE_LAYOUT_BLOCK_TYPES),...e.acceptedChildTypes??[]]),i=t(e.rendererRequirements??a);if(i.length===0)throw RangeError(`Core layout blocks require at least one trusted renderer capability.`);return[f(`section`,r,i),f(`stack`,r,i),f(`grid`,r,i),f(`columns`,r,i)]}export function coreLayoutInitialProperties(e){switch(e){case CORE_LAYOUT_BLOCK_TYPES.section:return{};case CORE_LAYOUT_BLOCK_TYPES.stack:return{direction:`block`};case CORE_LAYOUT_BLOCK_TYPES.grid:case CORE_LAYOUT_BLOCK_TYPES.columns:return{collapse:`stack`,columns:1}}}export function resolveCoreLayoutIntent(e,t,a){if(!isCoreLayoutBlockType(e.type))throw new CoreLayoutError(`unsupported-layout-block`,`Block ${e.type} is not a canonical Studio layout block.`);if(!a.viewports.some(e=>e.id===t.id))throw new CoreLayoutError(`viewport-missing`,`Theme ${a.id} does not declare viewport ${t.id}.`);let d={alignment:v(e,t,a,`alignment`,CORE_LAYOUT_THEME_CONTROLS.alignment,o,`stretch`),spacing:v(e,t,a,`spacing`,CORE_LAYOUT_THEME_CONTROLS.spacing,l,`comfortable`),visibility:v(e,t,a,`visibility`,CORE_LAYOUT_THEME_CONTROLS.visibility,u,`visible`)};return e.type===CORE_LAYOUT_BLOCK_TYPES.stack&&(d.direction=v(e,t,a,`direction`,CORE_LAYOUT_THEME_CONTROLS.direction,c,`block`)),(e.type===CORE_LAYOUT_BLOCK_TYPES.grid||e.type===CORE_LAYOUT_BLOCK_TYPES.columns)&&(d.collapse=v(e,t,a,`collapse`,CORE_LAYOUT_THEME_CONTROLS.collapse,s,`stack`),d.columns=y(e,t,`columns`,1,12,1)),d}function f(i,a,o){let s=CORE_LAYOUT_BLOCK_TYPES[i],c=`${i.charAt(0).toUpperCase()}${i.slice(1)}`,l=[CORE_LAYOUT_THEME_CONTROLS.alignment,CORE_LAYOUT_THEME_CONTROLS.spacing,CORE_LAYOUT_THEME_CONTROLS.visibility];return i===`stack`&&l.push(CORE_LAYOUT_THEME_CONTROLS.direction),(i===`grid`||i===`columns`)&&l.push(CORE_LAYOUT_THEME_CONTROLS.collapse),{accessibility:{accessibleName:i===`section`?`derived`:`not-applicable`,category:i===`section`?`landmark`:`structural`,keyboard:{defaultMessage:`Use the outline commands to insert, move, and reorder layout children.`,key:`studio.blocks/layout-keyboard`},outputChecks:[`studio.check/reading-order`,`studio.check/reflow`],reducedMotion:`not-applicable`},category:`studio.category/layout`,contractVersion:e,editingModes:[`blueprint`,`content`],icon:{kind:`symbol`,value:i},kind:`block-definition`,label:{defaultMessage:c,key:`studio.blocks/${i}`},owner:{id:`studio.core/blocks`,version:`1.0.0`},ports:[],propertyControls:l.map(e=>({control:`studio.control/${e}`,property:h(e)})),propertySchema:m(i),rendererRequirements:t([...o]),revision:`layout-${i}-r1`,slots:[p(i,a)],themeControls:l,type:s,version:`1.0.0`}}function p(e,n){let r=e===`section`?`content`:`items`;return{accepts:{types:t(n)},id:r,label:{defaultMessage:e===`section`?`Content`:`Items`,key:e===`section`?`studio.blocks/section-content`:`studio.blocks/layout-items`},maximum:100,minimum:0,ordered:!0}}function m(e){let t={alignment:{enum:[...o]},spacing:{enum:[...l]},visibility:{enum:[...u]}};return e===`stack`&&(t.direction={enum:[...c]}),(e===`grid`||e===`columns`)&&(t.collapse={enum:[...s]},t.columns={maximum:12,minimum:1,type:`integer`}),{additionalProperties:!1,properties:t,type:`object`}}function h(e){switch(e){case CORE_LAYOUT_THEME_CONTROLS.alignment:return`alignment`;case CORE_LAYOUT_THEME_CONTROLS.collapse:return`collapse`;case CORE_LAYOUT_THEME_CONTROLS.direction:return`direction`;case CORE_LAYOUT_THEME_CONTROLS.spacing:return`spacing`;case CORE_LAYOUT_THEME_CONTROLS.visibility:return`visibility`;default:throw RangeError(`Unknown core layout control ${e}.`)}}function g(e){let t=[...new Set(e)];if(t.sort((e,t)=>e<t?-1:+(e>t)),t.length===0)throw RangeError(`A core layout slot requires at least one accepted block type.`);return t}function _(e,t,n){let r=e.responsive?.[n]?.[t.id];if(r!==void 0)return{source:`viewport`,value:r,viewport:t.id};let i=e.properties[n];return i===void 0?{source:`default`,value:void 0}:{source:`base`,value:i}}function v(e,t,n,r,a,o,s){let c=_(e,t,r),l=c.value??s;if(typeof l!=`string`||!o.includes(l))throw new CoreLayoutError(`invalid-layout-property`,`Property ${r} on node ${e.id} is not a supported layout token.`);let u=n.designControls.find(e=>e.id===a);if(u===void 0)throw new CoreLayoutError(`theme-control-missing`,`Theme ${n.id} does not declare required layout control ${a}.`);if(!u.choices.some(e=>e.id===l))throw new CoreLayoutError(`theme-choice-missing`,`Theme ${n.id} does not declare ${l} for layout control ${a}.`);return{source:c.source,value:l,...c.viewport===void 0?{}:{viewport:c.viewport}}}function y(e,t,n,r,a,o){let s=_(e,t,n),c=s.value??o;if(typeof c!=`number`||!Number.isInteger(c)||c<r||c>a)throw new CoreLayoutError(`invalid-layout-property`,`Property ${n} on node ${e.id} must be an integer from ${r} through ${a}.`);return{source:s.source,value:c,...s.viewport===void 0?{}:{viewport:s.viewport}}}
@@ -1,83 +1 @@
1
- import { cloneContractValue } from './clone.js';
2
- import { normalizeVersionRange, parseSemanticVersion, satisfiesVersionRange } from './semver.js';
3
- export class StudioMigrationError extends Error {
4
- code;
5
- diagnostics;
6
- constructor(code, message, diagnostics = []) {
7
- super(message);
8
- this.name = 'StudioMigrationError';
9
- this.code = code;
10
- this.diagnostics = diagnostics;
11
- }
12
- }
13
- /**
14
- * The deterministic migration runner the versioning contract defines.
15
- * Migration operates on a copy, validates the complete result before
16
- * acceptance, never mutates or replaces the original revision, refuses
17
- * lossy transformations without explicit confirmation, and rejects
18
- * reapplication once a document has left a migration's source range.
19
- */
20
- export class MigrationRunner {
21
- #migrations = new Map();
22
- register(migration) {
23
- if (this.#migrations.has(migration.id)) {
24
- throw new StudioMigrationError('duplicate-migration', `Migration ${migration.id} is already registered.`);
25
- }
26
- if (migration.artifactKinds.length === 0) {
27
- throw new StudioMigrationError('not-applicable', `Migration ${migration.id} declares no artifact kinds.`);
28
- }
29
- normalizeVersionRange(migration.sourceVersions);
30
- parseSemanticVersion(migration.targetVersion);
31
- if (satisfiesVersionRange(migration.targetVersion, migration.sourceVersions)) {
32
- throw new StudioMigrationError('invalid-result', `Migration ${migration.id} targets a version inside its own source range, so reapplication could never be rejected.`);
33
- }
34
- this.#migrations.set(migration.id, migration);
35
- }
36
- migrations() {
37
- return [...this.#migrations.values()];
38
- }
39
- /** Ordered migrations whose source range and artifact kind match the document. */
40
- plan(document) {
41
- return this.migrations()
42
- .filter((migration) => migration.artifactKinds.includes(document.kind) &&
43
- satisfiesVersionRange(document.version, migration.sourceVersions))
44
- .sort((left, right) => (left.id < right.id ? -1 : 1));
45
- }
46
- apply(document, migrationId, options = {}) {
47
- const migration = this.#migrations.get(migrationId);
48
- if (migration === undefined) {
49
- throw new StudioMigrationError('unknown-migration', `Migration ${migrationId} is not registered.`);
50
- }
51
- if (!migration.artifactKinds.includes(document.kind)) {
52
- throw new StudioMigrationError('not-applicable', `Migration ${migrationId} does not cover ${document.kind} artifacts.`);
53
- }
54
- if (!satisfiesVersionRange(document.version, migration.sourceVersions)) {
55
- const code = document.version === migration.targetVersion ? 'already-applied' : 'not-applicable';
56
- throw new StudioMigrationError(code, `Document version ${document.version} is outside the source range of ${migrationId}.`);
57
- }
58
- if (migration.lossClassification === 'lossy' && options.confirmLossy !== true) {
59
- throw new StudioMigrationError('confirmation-required', `Migration ${migrationId} is lossy and requires explicit confirmation.`);
60
- }
61
- const migrated = migration.migrate(cloneContractValue(document));
62
- const diagnostics = [];
63
- if (migrated.kind !== document.kind) {
64
- throw new StudioMigrationError('invalid-result', `Migration ${migrationId} changed the artifact kind from ${document.kind} to ${migrated.kind}.`);
65
- }
66
- if (migrated.version !== migration.targetVersion) {
67
- throw new StudioMigrationError('invalid-result', `Migration ${migrationId} produced version ${migrated.version}, not the declared target ${migration.targetVersion}.`);
68
- }
69
- if (options.validate !== undefined) {
70
- const validationDiagnostics = options.validate(migrated);
71
- diagnostics.push(...validationDiagnostics);
72
- if (validationDiagnostics.some((entry) => entry.severity === 'blocking' || entry.severity === 'error')) {
73
- throw new StudioMigrationError('invalid-result', `Migration ${migrationId} produced an invalid document.`, validationDiagnostics);
74
- }
75
- }
76
- return {
77
- diagnostics,
78
- document: migrated,
79
- migrationId,
80
- };
81
- }
82
- }
83
- //# sourceMappingURL=migrations.js.map
1
+ import{cloneContractValue as e}from"./clone.js";import{normalizeVersionRange as t,parseSemanticVersion as n,satisfiesVersionRange as r}from"./semver.js";export class StudioMigrationError extends Error{code;diagnostics;constructor(e,t,n=[]){super(t),this.name=`StudioMigrationError`,this.code=e,this.diagnostics=n}}export class MigrationRunner{#migrations=new Map;register(e){if(this.#migrations.has(e.id))throw new StudioMigrationError(`duplicate-migration`,`Migration ${e.id} is already registered.`);if(e.artifactKinds.length===0)throw new StudioMigrationError(`not-applicable`,`Migration ${e.id} declares no artifact kinds.`);if(t(e.sourceVersions),n(e.targetVersion),r(e.targetVersion,e.sourceVersions))throw new StudioMigrationError(`invalid-result`,`Migration ${e.id} targets a version inside its own source range, so reapplication could never be rejected.`);this.#migrations.set(e.id,e)}migrations(){return[...this.#migrations.values()]}plan(e){return this.migrations().filter(t=>t.artifactKinds.includes(e.kind)&&r(e.version,t.sourceVersions)).sort((e,t)=>e.id<t.id?-1:1)}apply(t,n,i={}){let a=this.#migrations.get(n);if(a===void 0)throw new StudioMigrationError(`unknown-migration`,`Migration ${n} is not registered.`);if(!a.artifactKinds.includes(t.kind))throw new StudioMigrationError(`not-applicable`,`Migration ${n} does not cover ${t.kind} artifacts.`);if(!r(t.version,a.sourceVersions)){let e=t.version===a.targetVersion?`already-applied`:`not-applicable`;throw new StudioMigrationError(e,`Document version ${t.version} is outside the source range of ${n}.`)}if(a.lossClassification===`lossy`&&i.confirmLossy!==!0)throw new StudioMigrationError(`confirmation-required`,`Migration ${n} is lossy and requires explicit confirmation.`);let o=a.migrate(e(t)),s=[];if(o.kind!==t.kind)throw new StudioMigrationError(`invalid-result`,`Migration ${n} changed the artifact kind from ${t.kind} to ${o.kind}.`);if(o.version!==a.targetVersion)throw new StudioMigrationError(`invalid-result`,`Migration ${n} produced version ${o.version}, not the declared target ${a.targetVersion}.`);if(i.validate!==void 0){let e=i.validate(o);if(s.push(...e),e.some(e=>e.severity===`blocking`||e.severity===`error`))throw new StudioMigrationError(`invalid-result`,`Migration ${n} produced an invalid document.`,e)}return{diagnostics:s,document:o,migrationId:n}}}
@@ -1,21 +1 @@
1
- import { cloneContractValue } from './clone.js';
2
- import { StudioCommandError } from './commands.js';
3
- export function applyModelCommand(model, command) {
4
- if (command.artifactId !== model.id) {
5
- throw new StudioCommandError('node-not-found', `Command targets ${command.artifactId}, not content model ${model.id}.`);
6
- }
7
- if (model.status !== 'draft') {
8
- throw new StudioCommandError('artifact-not-draft', `Content model ${model.id} is ${model.status}; fields are added through a new draft.`);
9
- }
10
- if (model.fields.some((field) => field.id === command.payload.field.id)) {
11
- throw new StudioCommandError('duplicate-field', `Field ${command.payload.field.id} already exists on ${model.id}.`);
12
- }
13
- const position = command.payload.position ?? model.fields.length;
14
- if (!Number.isInteger(position) || position < 0 || position > model.fields.length) {
15
- throw new StudioCommandError('invalid-index', `Field position ${position} is outside the model's field list.`);
16
- }
17
- const next = cloneContractValue(model);
18
- next.fields.splice(position, 0, cloneContractValue(command.payload.field));
19
- return next;
20
- }
21
- //# sourceMappingURL=model-commands.js.map
1
+ import{cloneContractValue as e}from"./clone.js";import{StudioCommandError as t}from"./commands.js";export function applyModelCommand(n,r){if(r.artifactId!==n.id)throw new t(`node-not-found`,`Command targets ${r.artifactId}, not content model ${n.id}.`);if(n.status!==`draft`)throw new t(`artifact-not-draft`,`Content model ${n.id} is ${n.status}; fields are added through a new draft.`);if(n.fields.some(e=>e.id===r.payload.field.id))throw new t(`duplicate-field`,`Field ${r.payload.field.id} already exists on ${n.id}.`);let i=r.payload.position??n.fields.length;if(!Number.isInteger(i)||i<0||i>n.fields.length)throw new t(`invalid-index`,`Field position ${i} is outside the model's field list.`);let a=e(n);return a.fields.splice(i,0,e(r.payload.field)),a}